-
Notifications
You must be signed in to change notification settings - Fork 4
/
Neighbor.h
57 lines (48 loc) · 1.37 KB
/
Neighbor.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
/**
* @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_NEIGHBOR_H
#define PUML_NEIGHBOR_H
#include <cassert>
#include "Downward.h"
#include "PUML.h"
#include "Topology.h"
#include "Upward.h"
namespace PUML
{
class Neighbor
{
public:
/**
* Returns all local neighor ids for a cell
*
* @param puml The PUML mesh
* @param clid The local id of the cell for which the neighbors should be returned
* @param flid The local ids of the neighbors or -1 if there is no local neighbor
*/
template<TopoType Topo>
static void face(const PUML<Topo> &puml, unsigned int clid, int* flid)
{
unsigned int faces[internal::Topology<Topo>::cellfaces()];
assert(clid < puml.cells().size());
Downward::faces(puml, puml.cells()[clid], faces);
for (unsigned int i = 0; i < internal::Topology<Topo>::cellfaces(); i++) {
int neighbors[2];
Upward::cells(puml, puml.faces()[faces[i]], neighbors);
if (static_cast<unsigned int>(neighbors[0]) == clid)
flid[i] = neighbors[1];
else
flid[i] = neighbors[0];
}
}
};
}
#endif // PUML_NEIGHBOR_H