-
Notifications
You must be signed in to change notification settings - Fork 4
/
Utils.h
66 lines (54 loc) · 1.43 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
62
63
64
65
66
/**
* @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
*
* @copyright 2017 Technische Universitaet Muenchen
* @author Sebastian Rettenberger <[email protected]>
*/
#ifndef PUML_UTILS_H
#define PUML_UTILS_H
#include <vector>
#include "PUML.h"
#include "Topology.h"
namespace PUML
{
namespace internal
{
template<TopoType Topo, typename E>
struct ElementVector
{
static const std::vector<E>& elements(const PUML<Topo> &puml);
};
template<TopoType Topo>
struct ElementVector<Topo, typename PUML<Topo>::cell_t>
{
static const std::vector<typename PUML<Topo>::cell_t>& elements(const PUML<Topo> &puml)
{ return puml.cells(); }
};
template<TopoType Topo>
struct ElementVector<Topo, typename PUML<Topo>::vertex_t>
{
static const std::vector<typename PUML<Topo>::vertex_t>& elements(const PUML<Topo> &puml)
{ 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;
}
};
}
}
#endif // PUML_UTILS_H