Block-Structured AMR Software Framework
AMReX_EB2_Graph.H
Go to the documentation of this file.
1 #ifndef AMREX_EB2_GRAPH_H_
2 #define AMREX_EB2_GRAPH_H_
3 #include <AMReX_Config.H>
4 
5 #include <AMReX_Array.H>
6 #include <AMReX_Vector.H>
7 #include <AMReX_IntVect.H>
8 
9 #include <unordered_map>
10 #include <utility>
11 #include <cstdint>
12 
13 namespace amrex::EB2 {
14 
15 struct Cell
16 {
18  // and more such as boundary centroid and normal
19 };
20 
21 struct Face
22 {
24  Real m_areafrac;
25 };
26 
27 using VertexID = std::pair<IntVect,int>;
28 
29 struct Edge
30 {
33 };
34 
35 using Type_t = uint32_t;
36 
37 namespace Type {
38  static constexpr Type_t regular=0x0;
39  static constexpr Type_t covered=0x1;
40  static constexpr Type_t irregular=0x2;
41  static constexpr Type_t unknown=0x3;
42 }
43 
44 struct Neighbor
45 {
46  void setXLo (Type_t t) { flag &= zero_xlo_mask; flag |= t; }
47  void setXHi (Type_t t) { flag &= zero_xhi_mask; flag |= (t << 2); }
48  void setYLo (Type_t t) { flag &= zero_ylo_mask; flag |= (t << 4); }
49  void setYHi (Type_t t) { flag &= zero_yhi_mask; flag |= (t << 6); }
50  void setZLo (Type_t t) { flag &= zero_zlo_mask; flag |= (t << 8); }
51  void setZHi (Type_t t) { flag &= zero_zhi_mask; flag |= (t << 10); }
52 
53  [[nodiscard]] Type_t getXLo () const { return (flag & one_xlo_mask); }
54  [[nodiscard]] Type_t getXHi () const { return (flag & one_xhi_mask) >> 2; }
55  [[nodiscard]] Type_t getYLo () const { return (flag & one_ylo_mask) >> 4; }
56  [[nodiscard]] Type_t getYHi () const { return (flag & one_yhi_mask) >> 6; }
57  [[nodiscard]] Type_t getZLo () const { return (flag & one_zlo_mask) >> 8; }
58  [[nodiscard]] Type_t getZHi () const { return (flag & one_zhi_mask) >> 10; }
59 
60 private:
61 
62  Type_t flag = 0;
63 
64  static constexpr Type_t one_xlo_mask = 0x3;
65  static constexpr Type_t zero_xlo_mask = ~0x3;
66  static constexpr Type_t one_xhi_mask = 0xC;
67  static constexpr Type_t zero_xhi_mask = ~0xC;
68  static constexpr Type_t one_ylo_mask = 0x30;
69  static constexpr Type_t zero_ylo_mask = ~0x30;
70  static constexpr Type_t one_yhi_mask = 0xC0;
71  static constexpr Type_t zero_yhi_mask = ~0xC0;
72  static constexpr Type_t one_zlo_mask = 0x300;
73  static constexpr Type_t zero_zlo_mask = ~0x300;
74  static constexpr Type_t one_zhi_mask = 0xC00;
75  static constexpr Type_t zero_zhi_mask = ~0xC00;
76 };
77 
78 struct Vertex
79 {
83 };
84 
85 using Graph = std::unordered_map<IntVect, Vector<Vertex>, IntVect::hasher>;
86 
87 }
88 
89 #endif
shift_hasher hasher
Definition: AMReX_IntVect.H:85
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition: AMReX_Vector.H:27
static constexpr Type_t regular
Definition: AMReX_EB2_Graph.H:38
static constexpr Type_t unknown
Definition: AMReX_EB2_Graph.H:41
static constexpr Type_t covered
Definition: AMReX_EB2_Graph.H:39
static constexpr Type_t irregular
Definition: AMReX_EB2_Graph.H:40
Definition: AMReX_FabArrayBase.H:32
std::unordered_map< IntVect, Vector< Vertex >, IntVect::hasher > Graph
Definition: AMReX_EB2_Graph.H:85
std::pair< IntVect, int > VertexID
Definition: AMReX_EB2_Graph.H:27
uint32_t Type_t
Definition: AMReX_EB2_Graph.H:35
Array< Real, AMREX_SPACEDIM > RealArray
Definition: AMReX_Array.H:26
Definition: AMReX_EB2_Graph.H:16
RealArray m_volfrac
Definition: AMReX_EB2_Graph.H:17
Definition: AMReX_EB2_Graph.H:30
VertexID m_vid
Definition: AMReX_EB2_Graph.H:32
Face m_face
Definition: AMReX_EB2_Graph.H:31
Definition: AMReX_EB2_Graph.H:22
RealArray m_facecent
Definition: AMReX_EB2_Graph.H:23
Real m_areafrac
Definition: AMReX_EB2_Graph.H:24
Definition: AMReX_EB2_Graph.H:45
Type_t flag
Definition: AMReX_EB2_Graph.H:62
Type_t getYHi() const
Definition: AMReX_EB2_Graph.H:56
Type_t getYLo() const
Definition: AMReX_EB2_Graph.H:55
Type_t getXLo() const
Definition: AMReX_EB2_Graph.H:53
void setYHi(Type_t t)
Definition: AMReX_EB2_Graph.H:49
void setXHi(Type_t t)
Definition: AMReX_EB2_Graph.H:47
static constexpr Type_t zero_zhi_mask
Definition: AMReX_EB2_Graph.H:75
static constexpr Type_t one_xlo_mask
Definition: AMReX_EB2_Graph.H:64
static constexpr Type_t zero_xhi_mask
Definition: AMReX_EB2_Graph.H:67
static constexpr Type_t one_zlo_mask
Definition: AMReX_EB2_Graph.H:72
static constexpr Type_t zero_yhi_mask
Definition: AMReX_EB2_Graph.H:71
Type_t getXHi() const
Definition: AMReX_EB2_Graph.H:54
static constexpr Type_t zero_xlo_mask
Definition: AMReX_EB2_Graph.H:65
Type_t getZLo() const
Definition: AMReX_EB2_Graph.H:57
void setZHi(Type_t t)
Definition: AMReX_EB2_Graph.H:51
Type_t getZHi() const
Definition: AMReX_EB2_Graph.H:58
void setXLo(Type_t t)
Definition: AMReX_EB2_Graph.H:46
void setZLo(Type_t t)
Definition: AMReX_EB2_Graph.H:50
void setYLo(Type_t t)
Definition: AMReX_EB2_Graph.H:48
static constexpr Type_t zero_ylo_mask
Definition: AMReX_EB2_Graph.H:69
static constexpr Type_t one_yhi_mask
Definition: AMReX_EB2_Graph.H:70
static constexpr Type_t one_zhi_mask
Definition: AMReX_EB2_Graph.H:74
static constexpr Type_t one_ylo_mask
Definition: AMReX_EB2_Graph.H:68
static constexpr Type_t zero_zlo_mask
Definition: AMReX_EB2_Graph.H:73
static constexpr Type_t one_xhi_mask
Definition: AMReX_EB2_Graph.H:66
Definition: AMReX_EB2_Graph.H:79
Cell m_cell
Definition: AMReX_EB2_Graph.H:80
Neighbor m_nghb
Definition: AMReX_EB2_Graph.H:81
Vector< Edge > m_edges
Definition: AMReX_EB2_Graph.H:82