1#ifndef AMREX_EBCELLFLAG_H_
2#define AMREX_EBCELLFLAG_H_
3#include <AMReX_Config.H>
36 explicit constexpr
EBCellFlag (uint32_t i) noexcept : flag(i) {}
51 flag &= zero_lower_mask;
53 flag |= single_vof_bits;
65 flag &= zero_lower_mask;
66 flag |= single_valued_bits;
67 flag |= single_vof_bits;
73 flag &= zero_lower_mask;
74 flag |= multi_valued_bits;
76 flag |=
static_cast<uint32_t
>(n) << pos_numvofs;
83 return (flag == (a_input.flag));
90 return (flag != (a_input.flag));
97 return static_cast<int>((flag & one_numvofs_mask) >> pos_numvofs);
103 return (flag & one_type_mask) == regular_bits;
109 return (flag & one_type_mask) == single_valued_bits;
115 return (flag & one_type_mask) == multi_valued_bits;
121 return (flag & one_type_mask) == covered_bits;
129 const int n = w_lower_mask + 13 + i + 3*j + k*9;
130 return flag & (1 << n);
136 const int n = w_lower_mask + 13 + i + 3*j + k*9;
137 return flag & (1 << n);
145 const int n = w_lower_mask + 13 + i + 3*j + k*9;
146 return !(flag & (1 << n));
152 const int n = w_lower_mask + 13 + i + 3*j + k*9;
153 return !(flag & (1 << n));
159 flag &= one_lower_mask;
167 const int n = w_lower_mask + 13 + i + 3*j + k*9;
174 const int n = w_lower_mask + 13 + i + 3*j + k*9;
181 flag |= zero_lower_mask;
189 const int n = w_lower_mask + 13 + i + 3*j + k*9;
196 const int n = w_lower_mask + 13 + i + 3*j + k*9;
214#if (AMREX_SPACEDIM == 3)
263 static constexpr uint32_t one_lower_mask = 0x1f;
264 static constexpr uint32_t zero_lower_mask = ~0x1f;
267 static constexpr uint32_t one_type_mask = 0x3;
268 static constexpr uint32_t zero_type_mask = ~0x3;
271 static constexpr uint32_t one_numvofs_mask = 0x1c;
272 static constexpr uint32_t zero_numvofs_mask = ~0x1c;
276 static constexpr uint32_t regular_bits = 0x0;
277 static constexpr uint32_t single_valued_bits = 0x1;
278 static constexpr uint32_t multi_valued_bits = 0x2;
279 static constexpr uint32_t covered_bits = 0x3;
282 static constexpr uint32_t single_vof_bits = 0x4;
289 static constexpr int w_lower_mask = 5;
290 static constexpr int w_type = 2;
291 static constexpr int w_numvofs = 3;
292 static constexpr int pos_numvofs = 2;
294 static constexpr std::array<std::array<std::array<int,3>,3>,3> pos_ngbr
295 {{ std::array<std::array<int,3>,3>{{{ w_lower_mask , w_lower_mask+ 1, w_lower_mask+ 2 },
296 { w_lower_mask+ 3, w_lower_mask+ 4, w_lower_mask+ 5 },
297 { w_lower_mask+ 6, w_lower_mask+ 7, w_lower_mask+ 8 }}},
298 std::array<std::array<int,3>,3>{{{ w_lower_mask+ 9, w_lower_mask+10, w_lower_mask+11 },
299 { w_lower_mask+12, w_lower_mask+13, w_lower_mask+14 },
300 { w_lower_mask+15, w_lower_mask+16, w_lower_mask+17 }}},
301 std::array<std::array<int,3>,3>{{{ w_lower_mask+18, w_lower_mask+19, w_lower_mask+20 },
302 { w_lower_mask+21, w_lower_mask+22, w_lower_mask+23 },
303 { w_lower_mask+24, w_lower_mask+25, w_lower_mask+26 }}} }};
307#if AMREX_SPACEDIM == 3
308 static constexpr uint32_t default_value = zero_lower_mask | regular_bits | single_vof_bits;
310 static constexpr uint32_t default_value = 0x7fc004;
313 static constexpr uint32_t covered_value = 0x40003;
315 uint32_t flag = default_value;
338 Arena* ar =
nullptr);
382 mutable std::map<Box,NumCells> m_typemap;
#define AMREX_ASSERT(EX)
Definition AMReX_BLassert.H:38
#define AMREX_FORCE_INLINE
Definition AMReX_Extension.H:119
#define AMREX_GPU_HOST_DEVICE
Definition AMReX_GpuQualifiers.H:20
#define AMREX_D_TERM(a, b, c)
Definition AMReX_SPACE.H:172
A virtual base class for objects that manage their own dynamic memory allocation.
Definition AMReX_Arena.H:132
A FortranArrayBox(FAB)-like object.
Definition AMReX_BaseFab.H:190
FAB storing EBCellFlag data per cell.
Definition AMReX_EBCellFlag.H:324
int getNumRegularCells(const Box &bx) const noexcept
Count regular cells within bx.
Definition AMReX_EBCellFlag.cpp:147
~EBCellFlagFab() override=default
void setType(FabType t) noexcept
Manually override the cached FabType.
Definition AMReX_EBCellFlag.H:370
void resetType(int ng)
Recompute FabType using the given number of grow cells.
Definition AMReX_EBCellFlag.cpp:132
EBCellFlagFab & operator=(const EBCellFlagFab &)=delete
EBCellFlagFab(EBCellFlagFab &&rhs)=default
int getNumCutCells(const Box &bx) const noexcept
Count cut cells within bx.
Definition AMReX_EBCellFlag.cpp:188
int getNumCoveredCells(const Box &bx) const noexcept
Count covered cells within bx.
Definition AMReX_EBCellFlag.cpp:226
FabType getType() const noexcept
Returns FabType (regular, covered, etc.) for the entire FAB.
Definition AMReX_EBCellFlag.H:352
EBCellFlagFab(const EBCellFlagFab &)=delete
Bit-coded helper that classifies EB cells and neighbor connectivity.
Definition AMReX_EBCellFlag.H:24
__host__ __device__ bool isConnected(int i, int j, int k) const noexcept
Return whether the EB cut connects to neighbor at offset (i,j,k).
Definition AMReX_EBCellFlag.H:135
__host__ __device__ void setDisconnected(int i, int j, int k) noexcept
Clear connectivity to neighbor at offset (i,j,k).
Definition AMReX_EBCellFlag.H:173
__host__ __device__ int getNumVoFs() const noexcept
Number of volume-of-fluid entries for this cell (1 for regular or single-valued, 0 for covered).
Definition AMReX_EBCellFlag.H:95
__host__ __device__ void setMultiValued(int n) noexcept
Mark the cell as multi-valued and store the number of VoFs (n).
Definition AMReX_EBCellFlag.H:72
__host__ __device__ void setCovered() noexcept
Mark the cell as completely covered (solid).
Definition AMReX_EBCellFlag.H:58
__host__ __device__ void setConnected() noexcept
Mark all neighbors as connected.
Definition AMReX_EBCellFlag.H:180
__host__ __device__ void setSingleValued() noexcept
Mark the cell as single-valued (one cut)
Definition AMReX_EBCellFlag.H:64
__host__ __device__ EBCellFlag & operator+=(const EBCellFlag &)
Disabled on purpose—EBCellFlag values are not additive.
Definition AMReX_EBCellFlag.H:43
__host__ __device__ void setConnected(const IntVect &iv) noexcept
Mark connectivity to neighbor offset by iv.
Definition AMReX_EBCellFlag.H:186
__host__ __device__ int numNeighbors() const noexcept
Count how many neighbors are connected (including itself).
Definition AMReX_EBCellFlag.H:202
__host__ __device__ void setDisconnected(const IntVect &iv) noexcept
Clear connectivity to neighbor at offset iv.
Definition AMReX_EBCellFlag.H:164
__host__ __device__ void setDisconnected() noexcept
Clear all neighbor-connection bits.
Definition AMReX_EBCellFlag.H:158
__host__ __device__ void setRegular() noexcept
Mark this cell as purely regular (single volume fraction, no cuts).
Definition AMReX_EBCellFlag.H:50
constexpr EBCellFlag() noexcept=default
Default-construct a flag with all bits cleared (treated as regular).
__host__ __device__ bool isSingleValued() const noexcept
True if the cell stores a single cut (one VoF).
Definition AMReX_EBCellFlag.H:108
__host__ __device__ bool isDisconnected(int i, int j, int k) const noexcept
Inverse of isConnected(i,j,k).
Definition AMReX_EBCellFlag.H:151
__host__ __device__ bool operator!=(const EBCellFlag &a_input) const noexcept
Compare two flags for inequality.
Definition AMReX_EBCellFlag.H:88
__host__ __device__ bool isCovered() const noexcept
True if the cell is fully covered (solid).
Definition AMReX_EBCellFlag.H:120
__host__ __device__ bool isDisconnected(const IntVect &iv) const noexcept
Inverse of isConnected(IntVect).
Definition AMReX_EBCellFlag.H:142
__host__ __device__ bool operator==(const EBCellFlag &a_input) const noexcept
Compare two flags for bitwise equality.
Definition AMReX_EBCellFlag.H:81
__host__ __device__ bool isConnected(const IntVect &iv) const noexcept
Return whether the EB cut is connected to the neighbor offset by iv.
Definition AMReX_EBCellFlag.H:126
__host__ static __device__ constexpr EBCellFlag TheDefaultCell()
Convenience flag representing a completely regular cell.
Definition AMReX_EBCellFlag.H:251
__host__ __device__ bool isMultiValued() const noexcept
True if the cell has multiple VoFs.
Definition AMReX_EBCellFlag.H:114
__host__ __device__ void setConnected(int i, int j, int k) noexcept
Mark connectivity to neighbor at offset (i,j,k).
Definition AMReX_EBCellFlag.H:195
__host__ static __device__ constexpr EBCellFlag TheCoveredCell()
Convenience flag representing a fully covered cell.
Definition AMReX_EBCellFlag.H:258
__host__ __device__ bool isRegular() const noexcept
True if the stored type bits correspond to a regular cell.
Definition AMReX_EBCellFlag.H:102
constexpr EBCellFlag & operator=(const EBCellFlag &rhs) noexcept=default
__host__ __device__ uint32_t getValue() const noexcept
Raw 32-bit encoding stored in this flag.
Definition AMReX_EBCellFlag.H:244
Definition AMReX_Amr.cpp:49
std::ostream & operator<<(std::ostream &os, AmrMesh const &amr_mesh)
Stream helper; forwards to the friend declared inside AmrMesh.
Definition AMReX_AmrMesh.cpp:1306
MakeType
Definition AMReX_MakeType.H:7
FabType
Definition AMReX_FabFactory.H:18
void Abort(const std::string &msg)
Print out message to cerr and exit via abort().
Definition AMReX.cpp:240
void * alloc(std::size_t sz) const noexcept
Definition AMReX_DataAllocator.H:16
Definition AMReX_EBCellFlag.H:372
FabType type
Definition AMReX_EBCellFlag.H:377
int nmulti
Definition AMReX_EBCellFlag.H:375
int nsingle
Definition AMReX_EBCellFlag.H:374
int ncovered
Definition AMReX_EBCellFlag.H:376
int nregular
Definition AMReX_EBCellFlag.H:373
Definition AMReX_TypeTraits.H:282