-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathUtils.h
61 lines (51 loc) · 1.57 KB
/
Utils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// SPDX-FileCopyrightText: 2017 Technical University of Munich
//
// SPDX-License-Identifier: BSD-3-Clause
/**
* @file
* This file is part of PUML
*
* For conditions of distribution and use, please see the copyright
* notice in the file 'COPYING' at the root directory of this package
* and the copyright notice at https://github.com/TUM-I5/PUMGen
*
* @author Sebastian Rettenberger <[email protected]>
*/
#ifndef PUML_UTILS_H
#define PUML_UTILS_H
#include <vector>
#include "PUML.h"
#include "Topology.h"
namespace PUML::internal {
template <TopoType Topo, typename E>
struct ElementVector {
static auto elements(const PUML<Topo>& puml) -> const std::vector<E>&;
};
template <TopoType Topo>
struct ElementVector<Topo, typename PUML<Topo>::cell_t> {
static auto elements(const PUML<Topo>& puml) -> const std::vector<typename PUML<Topo>::cell_t>& {
return puml.cells();
}
};
template <TopoType Topo>
struct ElementVector<Topo, typename PUML<Topo>::vertex_t> {
static auto elements(const PUML<Topo>& puml)
-> const std::vector<typename PUML<Topo>::vertex_t>& {
return puml.vertices();
}
};
class Utils {
public:
/**
* Get the global ids for a set of local ids
*/
template <TopoType Topo, typename E, unsigned int N>
static void l2g(const PUML<Topo>& puml, const unsigned int lid[N], unsigned long gid[N]) {
const std::vector<E>& elements = ElementVector<Topo, E>::elements(puml);
for (unsigned int i = 0; i < N; i++) {
gid[i] = elements[lid[i]].m_gid;
}
}
};
} // namespace PUML::internal
#endif // PUML_UTILS_H