Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
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#include <limits>
13
21namespace amrex::EB2 {
22
24struct Cell
25{
27 // and more such as boundary centroid and normal
28};
29
36
37using VertexID = std::pair<IntVect,int>;
38
45
46using Type_t = uint32_t;
47
49namespace Type {
50 static constexpr Type_t regular=0x0;
51 static constexpr Type_t covered=0x1;
52 static constexpr Type_t irregular=0x2;
53 static constexpr Type_t unknown=0x3;
54}
55
57static constexpr Real no_intercept = std::numeric_limits<Real>::max();
58
61{
63 void setXLo (Type_t t) { flag &= zero_xlo_mask; flag |= t; }
65 void setXHi (Type_t t) { flag &= zero_xhi_mask; flag |= (t << 2); }
67 void setYLo (Type_t t) { flag &= zero_ylo_mask; flag |= (t << 4); }
69 void setYHi (Type_t t) { flag &= zero_yhi_mask; flag |= (t << 6); }
71 void setZLo (Type_t t) { flag &= zero_zlo_mask; flag |= (t << 8); }
73 void setZHi (Type_t t) { flag &= zero_zhi_mask; flag |= (t << 10); }
74
75 [[nodiscard]] Type_t getXLo () const { return (flag & one_xlo_mask); }
76 [[nodiscard]] Type_t getXHi () const { return (flag & one_xhi_mask) >> 2; }
77 [[nodiscard]] Type_t getYLo () const { return (flag & one_ylo_mask) >> 4; }
78 [[nodiscard]] Type_t getYHi () const { return (flag & one_yhi_mask) >> 6; }
79 [[nodiscard]] Type_t getZLo () const { return (flag & one_zlo_mask) >> 8; }
80 [[nodiscard]] Type_t getZHi () const { return (flag & one_zhi_mask) >> 10; }
81
82private:
83
84 Type_t flag = 0;
85
86 static constexpr Type_t one_xlo_mask = 0x3;
87 static constexpr Type_t zero_xlo_mask = ~0x3;
88 static constexpr Type_t one_xhi_mask = 0xC;
89 static constexpr Type_t zero_xhi_mask = ~0xC;
90 static constexpr Type_t one_ylo_mask = 0x30;
91 static constexpr Type_t zero_ylo_mask = ~0x30;
92 static constexpr Type_t one_yhi_mask = 0xC0;
93 static constexpr Type_t zero_yhi_mask = ~0xC0;
94 static constexpr Type_t one_zlo_mask = 0x300;
95 static constexpr Type_t zero_zlo_mask = ~0x300;
96 static constexpr Type_t one_zhi_mask = 0xC00;
97 static constexpr Type_t zero_zhi_mask = ~0xC00;
98};
99
107
109using Graph = std::unordered_map<IntVect, Vector<Vertex>, IntVect::hasher>;
110
111}
112
113#endif
Fixed-size array types for use on GPU and CPU.
shift_hasher hasher
Definition AMReX_IntVect.H:187
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition AMReX_Vector.H:29
amrex_real Real
Floating Point Type for Fields.
Definition AMReX_REAL.H:80
Array< Real, 3 > RealArray
Definition AMReX_Array.H:35
static constexpr Type_t regular
Definition AMReX_EB2_Graph.H:50
static constexpr Type_t unknown
Definition AMReX_EB2_Graph.H:53
static constexpr Type_t covered
Definition AMReX_EB2_Graph.H:51
static constexpr Type_t irregular
Definition AMReX_EB2_Graph.H:52
Definition AMReX_FabArrayBase.H:38
std::unordered_map< IntVect, Vector< Vertex >, IntVect::hasher > Graph
EB graph type: map from cell index to all EB vertices stored there.
Definition AMReX_EB2_Graph.H:109
std::pair< IntVect, int > VertexID
Definition AMReX_EB2_Graph.H:37
uint32_t Type_t
Definition AMReX_EB2_Graph.H:46
static constexpr Real no_intercept
Marker stored in an edge intercept array when the edge has no intercept.
Definition AMReX_EB2_Graph.H:57
Per-cell geometric information stored in EB graphs.
Definition AMReX_EB2_Graph.H:25
RealArray m_volfrac
Definition AMReX_EB2_Graph.H:26
Edge connecting a graph vertex to a face and downstream vertex id.
Definition AMReX_EB2_Graph.H:41
VertexID m_vid
Definition AMReX_EB2_Graph.H:43
Face m_face
Definition AMReX_EB2_Graph.H:42
Metadata associated with an EB face.
Definition AMReX_EB2_Graph.H:32
RealArray m_facecent
Definition AMReX_EB2_Graph.H:33
Real m_areafrac
Definition AMReX_EB2_Graph.H:34
Packed neighbor structure that tracks the neighbor type in every direction.
Definition AMReX_EB2_Graph.H:61
Type_t getYHi() const
Definition AMReX_EB2_Graph.H:78
Type_t getYLo() const
Definition AMReX_EB2_Graph.H:77
Type_t getXLo() const
Definition AMReX_EB2_Graph.H:75
void setYHi(Type_t t)
Mark the high-y neighbor type.
Definition AMReX_EB2_Graph.H:69
void setXHi(Type_t t)
Mark the high-x neighbor type.
Definition AMReX_EB2_Graph.H:65
Type_t getXHi() const
Definition AMReX_EB2_Graph.H:76
Type_t getZLo() const
Definition AMReX_EB2_Graph.H:79
void setZHi(Type_t t)
Mark the high-z neighbor type.
Definition AMReX_EB2_Graph.H:73
Type_t getZHi() const
Definition AMReX_EB2_Graph.H:80
void setXLo(Type_t t)
Mark the low-x neighbor type.
Definition AMReX_EB2_Graph.H:63
void setZLo(Type_t t)
Mark the low-z neighbor type.
Definition AMReX_EB2_Graph.H:71
void setYLo(Type_t t)
Mark the low-y neighbor type.
Definition AMReX_EB2_Graph.H:67
Vertex capturing one irregular cell plus its neighbor connectivity.
Definition AMReX_EB2_Graph.H:102
Cell m_cell
Definition AMReX_EB2_Graph.H:103
Neighbor m_nghb
Definition AMReX_EB2_Graph.H:104
Vector< Edge > m_edges
Definition AMReX_EB2_Graph.H:105