forked from AMReX-Codes/amrex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAMReX_EB2_Graph.H
89 lines (71 loc) · 2.33 KB
/
AMReX_EB2_Graph.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#ifndef AMREX_EB2_GRAPH_H_
#define AMREX_EB2_GRAPH_H_
#include <AMReX_Config.H>
#include <AMReX_Array.H>
#include <AMReX_Vector.H>
#include <AMReX_IntVect.H>
#include <unordered_map>
#include <utility>
#include <cstdint>
namespace amrex { namespace EB2 {
struct Cell
{
RealArray m_volfrac;
// and more such as boundary centroid and normal
};
struct Face
{
RealArray m_facecent;
Real m_areafrac;
};
using VertexID = std::pair<IntVect,int>;
struct Edge
{
Face m_face;
VertexID m_vid;
};
using Type_t = uint32_t;
namespace Type {
static constexpr Type_t regular=0x0;
static constexpr Type_t covered=0x1;
static constexpr Type_t irregular=0x2;
static constexpr Type_t unknown=0x3;
}
struct Neighbor
{
void setXLo (Type_t t) { flag &= zero_xlo_mask; flag |= t; }
void setXHi (Type_t t) { flag &= zero_xhi_mask; flag |= (t << 2); }
void setYLo (Type_t t) { flag &= zero_ylo_mask; flag |= (t << 4); }
void setYHi (Type_t t) { flag &= zero_yhi_mask; flag |= (t << 6); }
void setZLo (Type_t t) { flag &= zero_zlo_mask; flag |= (t << 8); }
void setZHi (Type_t t) { flag &= zero_zhi_mask; flag |= (t << 10); }
Type_t getXLo () const { return (flag & one_xlo_mask); }
Type_t getXHi () const { return (flag & one_xhi_mask) >> 2; }
Type_t getYLo () const { return (flag & one_ylo_mask) >> 4; }
Type_t getYHi () const { return (flag & one_yhi_mask) >> 6; }
Type_t getZLo () const { return (flag & one_zlo_mask) >> 8; }
Type_t getZHi () const { return (flag & one_zhi_mask) >> 10; }
private:
Type_t flag = 0;
static constexpr Type_t one_xlo_mask = 0x3;
static constexpr Type_t zero_xlo_mask = ~0x3;
static constexpr Type_t one_xhi_mask = 0xC;
static constexpr Type_t zero_xhi_mask = ~0xC;
static constexpr Type_t one_ylo_mask = 0x30;
static constexpr Type_t zero_ylo_mask = ~0x30;
static constexpr Type_t one_yhi_mask = 0xC0;
static constexpr Type_t zero_yhi_mask = ~0xC0;
static constexpr Type_t one_zlo_mask = 0x300;
static constexpr Type_t zero_zlo_mask = ~0x300;
static constexpr Type_t one_zhi_mask = 0xC00;
static constexpr Type_t zero_zhi_mask = ~0xC00;
};
struct Vertex
{
Cell m_cell;
Neighbor m_nghb;
Vector<Edge> m_edges;
};
using Graph = std::unordered_map<IntVect, Vector<Vertex>, IntVect::hasher>;
}}
#endif