4 #include <AMReX_Config.H>
15 #include <unordered_map>
73 bool no_overlap =
false);
82 explicit BARef (std::istream& is);
93 void define (std::istream& is,
int& ndims);
96 #ifdef AMREX_MEM_PROFILING
97 void updateMemoryUsage_box (
int s);
98 void updateMemoryUsage_hash (
int s);
104 #pragma omp atomic read
119 using HashType = std::unordered_map< IntVect, std::vector<int>, IntVect::shift_hasher > ;
141 [[nodiscard]]
static constexpr
Box coarsen (
Box const& a_box) {
return a_box; }
152 [[nodiscard]]
static Box coarsen (
Box const& a_box) noexcept {
return a_box; }
196 int a_in_rad,
int a_out_rad,
int a_extent_rad)
219 m_hishft[d] = nodal[d] + a_in_rad - 1;
260 return a.m_face ==
b.m_face && a.m_typ ==
b.m_typ && a.m_crse_ratio ==
b.m_crse_ratio
261 && a.m_loshft ==
b.m_loshft && a.m_hishft ==
b.m_hishft
262 && a.m_doilo ==
b.m_doilo && a.m_doihi ==
b.m_doihi;
304 m_op(
f,t,in_rad,out_rad,extent_rad) {}
402 [[nodiscard]]
bool is_null () const noexcept {
470 if (typ.cellCentered()) {
480 if (typ.cellCentered()) {
490 if (typ.cellCentered()) {
502 if (typ.cellCentered()) {
522 return a.index_type() ==
b.index_type()
523 && a.coarsen_ratio() ==
b.coarsen_ratio();
525 return a.m_op.m_bndryReg ==
b.m_op.m_bndryReg;
596 [[nodiscard]] Long
size () const noexcept {
return m_ref->m_abox.size(); }
599 [[nodiscard]] Long
capacity () const noexcept {
return static_cast<Long
>(
m_ref->m_abox.capacity()); }
602 [[nodiscard]]
bool empty () const noexcept {
return m_ref->m_abox.empty(); }
605 [[nodiscard]] Long
numPts() const noexcept;
621 [[nodiscard]]
bool operator== (const
BoxArray& rhs) const noexcept;
624 [[nodiscard]]
bool operator!= (const
BoxArray& rhs) const noexcept;
626 [[nodiscard]]
bool operator== (const
Vector<
Box>& bv) const noexcept;
627 [[nodiscard]]
bool operator!= (const
Vector<
Box>& bv) const noexcept;
652 [[nodiscard]]
bool coarsenable (
int refinement_ratio,
int min_width=1) const;
718 [[nodiscard]]
Box operator[] (
int index) const noexcept {
737 [[nodiscard]]
bool ok ()
const;
793 std::vector< std::pair<int,Box> >
intersections (
const Box& bx,
bool first_only,
int ng)
const;
803 bool first_only,
int ng)
const;
806 bool first_only,
const IntVect& ng)
const;
872 std::ostream& operator<< (std::ostream& os, const
BoxArray& ba);
874 std::ostream& operator<< (std::ostream& os, const
BoxArray::RefID&
id);
int idir
Definition: AMReX_HypreMLABecLap.cpp:1093
#define AMREX_D_DECL(a, b, c)
Definition: AMReX_SPACE.H:104
Definition: AMReX_AmrMesh.H:62
A collection of Boxes stored in an Array.
Definition: AMReX_BoxArray.H:549
IndexType ixType() const noexcept
Return index type of this BoxArray.
Definition: AMReX_BoxArray.H:836
Box operator[](int index) const noexcept
Return element index of this BoxArray.
Definition: AMReX_BoxArray.H:718
BoxArray & minmaxSize(const IntVect &min_size, const IntVect &max_size)
Long capacity() const noexcept
Return the number of boxes that can be held in the current allocated storage.
Definition: AMReX_BoxArray.H:599
BoxArray & growcoarsen(int n, const IntVect &iv)
Grow and then coarsen each Box in the BoxArray.
RefID getRefID() const noexcept
Return a unique ID of the reference.
Definition: AMReX_BoxArray.H:833
bool intersects(const Box &b, int ng=0) const
True if the Box intersects with this BoxArray(+ghostcells). The Box must have the same IndexType as t...
bool intersects(const Box &b, const IntVect &ng) const
BoxArray & coarsen(int refinement_ratio)
Coarsen each Box in the BoxArray to the specified ratio.
bool contains(const Box &b, bool assume_disjoint_ba=false, const IntVect &ng=IntVect(0)) const
True if the Box is contained in this BoxArray(+ng). The Box must also have the same IndexType as thos...
std::vector< std::pair< int, Box > > intersections(const Box &bx) const
Return intersections of Box and BoxArray.
bool contains(const IntVect &v) const
True if the IntVect is within any of the Boxes in this BoxArray.
bool contains(const BoxArray &ba, bool assume_disjoint_ba=false, const IntVect &ng=IntVect(0)) const
True if all Boxes in ba are contained in this BoxArray(+ng).
BATransformer m_bat
Definition: AMReX_BoxArray.H:865
BoxList boxList() const
Create a BoxList from this BoxArray.
std::vector< std::pair< int, Box > > intersections(const Box &bx, bool first_only, const IntVect &ng) const
BoxArray simplified() const
IntVect crseRatio() const noexcept
Return crse ratio of this BoxArray.
Definition: AMReX_BoxArray.H:839
int readFrom(std::istream &is)
Initialize the BoxArray from the supplied istream. It is an error if the BoxArray has already been in...
IntVect getDoiLo() const noexcept
bool contains(const BoxArray &ba, Periodicity const &period) const
True if all cells in ba are periodically contained in this BoxArray.
void define(const Box &bx)
Initialize the BoxArray from a single box. It is an error if the BoxArray has already been initialize...
BoxArray & growLo(int idir, int n_cell)
Grow each Box in the BoxArray on the low end by n_cell cells in the idir direction.
Long numPts() const noexcept
Returns the total number of cells contained in all boxes in the BoxArray.
std::shared_ptr< BoxList > m_simplified_list
Definition: AMReX_BoxArray.H:868
IntVect getDoiHi() const noexcept
BoxList const & simplified_list() const
void clear_hash_bin() const
Clear out the internal hash table used by intersections.
Box minimalBox() const
Return smallest Box that contains all Boxes in this BoxArray.
BoxArray & enclosedCells()
Apply Box::enclosedCells() to each Box in the BoxArray.
bool coarsenable(int refinement_ratio, int min_width=1) const
Coarsen each Box in the BoxArray to the specified ratio.
BoxArray & refine(int refinement_ratio)
Refine each Box in the BoxArray to the specified ratio.
void intersections(const Box &bx, std::vector< std::pair< int, Box > > &isects, bool first_only, int ng) const
intersect Box and BoxArray(+ghostcells), then store the result in isects
void resize(Long len)
Resize the BoxArray. See Vector<T>::resize() for the gory details.
void intersections(const Box &bx, std::vector< std::pair< int, Box > > &isects) const
intersect Box and BoxArray, then store the result in isects
Box getCellCenteredBox(int index) const noexcept
Return cell-centered box at element index of this BoxArray.
Definition: AMReX_BoxArray.H:729
double d_numPts() const noexcept
Returns the total number of cells (in double type) contained in all boxes in the BoxArray.
static bool initialized
Definition: AMReX_BoxArray.H:843
BoxArray & maxSize(int block_size)
Forces each Box in BoxArray to have sides <= block_size.
static bool SameRefs(const BoxArray &lhs, const BoxArray &rhs)
whether two BoxArrays share the same data
Definition: AMReX_BoxArray.H:819
BoxArray & surroundingNodes()
Apply surroundingNodes(Box) to each Box in BoxArray. See the documentation of Box for details.
BoxList complementIn(const Box &b) const
Return box - boxarray.
BATransformer const & transformer() const
void type_update()
Update BoxArray index type according the box type, and then convert boxes to cell-centered.
BoxArray & convert(IndexType typ)
Apply Box::convert(IndexType) to each Box in the BoxArray.
void complementIn(BoxList &bl, const Box &b) const
std::shared_ptr< BARef > m_ref
The data – a reference-counted pointer to a Ref.
Definition: AMReX_BoxArray.H:867
void removeOverlap(bool simplify=true)
Change the BoxArray to one with no overlap and then simplify it (see the simplify function in BoxList...
BARef::HashType & getHashMap() const
std::ostream & writeOn(std::ostream &) const
Output this BoxArray to a checkpoint file.
void intersections(const Box &bx, std::vector< std::pair< int, Box > > &isects, bool first_only, const IntVect &ng) const
Long size() const noexcept
Return the number of boxes in the BoxArray.
Definition: AMReX_BoxArray.H:596
Box get(int index) const noexcept
Return element index of this BoxArray.
Definition: AMReX_BoxArray.H:726
bool CellEqual(const BoxArray &rhs) const noexcept
Are the BoxArrays equal after conversion to cell-centered.
void set(int i, const Box &ibox)
Set element i in this BoxArray to Box ibox.
BoxArray & growHi(int idir, int n_cell)
Grow each Box in the BoxArray on the high end by n_cell cells in the idir direction.
bool ok() const
Return true if Box is valid and they all have the same IndexType. Is true by default if the BoxArray ...
Box minimalBox(Long &npts_avg_box) const
void uniqify()
Make ourselves unique.
bool empty() const noexcept
Return whether the BoxArray is empty.
Definition: AMReX_BoxArray.H:602
bool isDisjoint() const
Return true if set of intersecting Boxes in BoxArray is null.
BoxArray & grow(int n)
Grow each Box in the BoxArray by the specified amount.
std::vector< std::pair< int, Box > > intersections(const Box &bx, bool first_only, int ng) const
Return intersections of Box and BoxArray(+ghostcells).
BoxArray & shift(int dir, int nzones)
Apply Box::shift(int,int) to each Box in the BoxArray.
void clear()
Remove all Boxes from the BoxArray.
A class for managing a List of Boxes that share a common IndexType. This class implements operations ...
Definition: AMReX_BoxList.H:52
Base class for FabArray.
Definition: AMReX_FabArrayBase.H:41
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE CellIndex ixType(int dir) const noexcept
Returns the CellIndex in direction dir.
Definition: AMReX_IndexType.H:116
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE IntVectND< dim > TheUnitVector() noexcept
This static member function returns a reference to a constant IntVectND object, all of whose dim argu...
Definition: AMReX_IntVect.H:682
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE IntVectND< dim > TheZeroVector() noexcept
This static member function returns a reference to a constant IntVectND object, all of whose dim argu...
Definition: AMReX_IntVect.H:672
Definition: AMReX_MFIter.H:57
Encapsulation of the Orientation of the Faces of a Box.
Definition: AMReX_Orientation.H:29
AMREX_GPU_HOST_DEVICE int coordDir() const noexcept
Returns the coordinate direction.
Definition: AMReX_Orientation.H:83
AMREX_GPU_HOST_DEVICE bool isLow() const noexcept
Returns true if Orientation is low.
Definition: AMReX_Orientation.H:89
This provides length of period for periodic domains. 0 means it is not periodic in that direction....
Definition: AMReX_Periodicity.H:17
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition: AMReX_Vector.H:27
AMREX_EXPORT int max_grid_size
Definition: AMReX_EB2.cpp:23
AMREX_GPU_HOST_DEVICE Long size(T const &b) noexcept
integer version
Definition: AMReX_GpuRange.H:26
static int f(amrex::Real t, N_Vector y_data, N_Vector y_rhs, void *user_data)
Definition: AMReX_SundialsIntegrator.H:44
Definition: AMReX_Amr.cpp:49
BoxND< AMREX_SPACEDIM > Box
Definition: AMReX_BaseFwd.H:27
BoxArray intersect(const BoxArray &ba, const Box &b, int ng=0)
Make a BoxArray from the intersection of Box b and BoxArray(+ghostcells).
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE BoxND< dim > convert(const BoxND< dim > &b, const IntVectND< dim > &typ) noexcept
Returns a BoxND with different type.
Definition: AMReX_Box.H:1435
BoxList GetBndryCells(const BoxArray &ba, int ngrow)
Find the ghost cells of a given BoxArray.
IntVectND< AMREX_SPACEDIM > IntVect
Definition: AMReX_BaseFwd.H:30
bool match(const BoxArray &x, const BoxArray &y)
Note that two BoxArrays that match are not necessarily equal.
BoxArray complementIn(const Box &b, const BoxArray &ba)
Make a BoxArray from the complement of BoxArray ba in Box b.
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE BoxND< dim > refine(const BoxND< dim > &b, int ref_ratio) noexcept
Definition: AMReX_Box.H:1342
BoxArray decompose(Box const &domain, int nboxes, Array< bool, AMREX_SPACEDIM > const &decomp={AMREX_D_DECL(true, true, true)}, bool no_overlap=false)
Decompose domain box into BoxArray.
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE BoxND< dim > coarsen(const BoxND< dim > &b, int ref_ratio) noexcept
Coarsen BoxND by given (positive) refinement ratio. NOTE: if type(dir) = CELL centered: lo <- lo/rati...
Definition: AMReX_Box.H:1304
IndexTypeND< AMREX_SPACEDIM > IndexType
Definition: AMReX_BaseFwd.H:33
void readBoxArray(BoxArray &ba, std::istream &s, bool b=false)
Read a BoxArray from a stream. If b is true, read in a special way.
BoxArray boxComplement(const Box &b1in, const Box &b2)
Make a BoxArray from the the complement of b2 in b1in.
std::array< T, N > Array
Definition: AMReX_Array.H:24
Definition: AMReX_BoxArray.H:76
static Long total_box_bytes_hwm
Definition: AMReX_BoxArray.H:129
BARef & operator=(const BARef &rhs)=delete
static int numboxarrays
Definition: AMReX_BoxArray.H:126
static Long total_hash_bytes
Definition: AMReX_BoxArray.H:130
BARef(BARef &&rhs)=delete
IntVect crsn
Definition: AMReX_BoxArray.H:117
std::unordered_map< IntVect, std::vector< int >, IntVect::shift_hasher > HashType
Definition: AMReX_BoxArray.H:119
static Long total_hash_bytes_hwm
Definition: AMReX_BoxArray.H:131
static bool initialized
Definition: AMReX_BoxArray.H:135
HashType hash
Definition: AMReX_BoxArray.H:122
Box bbox
Box hash stuff.
Definition: AMReX_BoxArray.H:115
void define(const BoxList &bl)
BARef(BoxList &&bl) noexcept
static int numboxarrays_hwm
Definition: AMReX_BoxArray.H:127
bool has_hashmap
Definition: AMReX_BoxArray.H:124
Vector< Box > m_abox
The data.
Definition: AMReX_BoxArray.H:112
static Long total_box_bytes
Definition: AMReX_BoxArray.H:128
void define(const Box &bx)
void define(std::istream &is, int &ndims)
void define(BoxList &&bl) noexcept
bool HasHashMap() const
Definition: AMReX_BoxArray.H:101
Definition: AMReX_BoxArray.H:194
IndexType index_type() const noexcept
Definition: AMReX_BoxArray.H:256
Box operator()(const Box &a_bx) const noexcept
Definition: AMReX_BoxArray.H:237
BATbndryReg(Orientation a_face, IndexType a_typ, int a_in_rad, int a_out_rad, int a_extent_rad)
Definition: AMReX_BoxArray.H:195
friend bool operator==(BATbndryReg const &a, BATbndryReg const &b) noexcept
Definition: AMReX_BoxArray.H:259
IntVect doiHi() const noexcept
Definition: AMReX_BoxArray.H:254
IntVect coarsen_ratio() const noexcept
Definition: AMReX_BoxArray.H:257
IntVect doiLo() const noexcept
Definition: AMReX_BoxArray.H:253
Orientation m_face
Definition: AMReX_BoxArray.H:265
IntVect m_loshft
Definition: AMReX_BoxArray.H:268
IndexType m_typ
Definition: AMReX_BoxArray.H:266
Box coarsen(Box const &a_box) const noexcept
Definition: AMReX_BoxArray.H:251
IntVect m_doihi
Definition: AMReX_BoxArray.H:271
IntVect m_hishft
Definition: AMReX_BoxArray.H:269
IntVect m_doilo
Definition: AMReX_BoxArray.H:270
IntVect m_crse_ratio
Definition: AMReX_BoxArray.H:267
Definition: AMReX_BoxArray.H:161
BATcoarsenRatio(IntVect const &a_crse_ratio)
Definition: AMReX_BoxArray.H:162
static constexpr IntVect doiHi()
Definition: AMReX_BoxArray.H:166
Box coarsen(Box const &a_box) const noexcept
Definition: AMReX_BoxArray.H:164
static constexpr IndexType index_type()
Definition: AMReX_BoxArray.H:167
static constexpr IntVect doiLo()
Definition: AMReX_BoxArray.H:165
IntVect m_crse_ratio
Definition: AMReX_BoxArray.H:169
Box operator()(const Box &bx) const noexcept
Definition: AMReX_BoxArray.H:163
IntVect coarsen_ratio() const noexcept
Definition: AMReX_BoxArray.H:168
Definition: AMReX_BoxArray.H:173
BATindexType_coarsenRatio(IndexType a_typ, IntVect const &a_crse_ratio)
Definition: AMReX_BoxArray.H:174
static constexpr IntVect doiLo()
Definition: AMReX_BoxArray.H:183
IntVect doiHi() const noexcept
Definition: AMReX_BoxArray.H:184
Box operator()(const Box &bx) const noexcept
Definition: AMReX_BoxArray.H:177
IntVect m_crse_ratio
Definition: AMReX_BoxArray.H:190
IntVect coarsen_ratio() const noexcept
Definition: AMReX_BoxArray.H:187
IndexType index_type() const noexcept
Definition: AMReX_BoxArray.H:186
Box coarsen(Box const &a_box) const noexcept
Definition: AMReX_BoxArray.H:181
IndexType m_typ
Definition: AMReX_BoxArray.H:189
Definition: AMReX_BoxArray.H:149
IntVect doiHi() const noexcept
Definition: AMReX_BoxArray.H:154
Box operator()(const Box &bx) const noexcept
Definition: AMReX_BoxArray.H:151
IndexType index_type() const noexcept
Definition: AMReX_BoxArray.H:155
static Box coarsen(Box const &a_box) noexcept
Definition: AMReX_BoxArray.H:152
BATindexType(IndexType a_typ)
Definition: AMReX_BoxArray.H:150
IndexType m_typ
Definition: AMReX_BoxArray.H:157
static constexpr IntVect coarsen_ratio()
Definition: AMReX_BoxArray.H:156
static constexpr IntVect doiLo()
Definition: AMReX_BoxArray.H:153
Definition: AMReX_BoxArray.H:139
static constexpr Box coarsen(Box const &a_box)
Definition: AMReX_BoxArray.H:141
static constexpr IndexType index_type()
Definition: AMReX_BoxArray.H:144
static constexpr IntVect doiHi()
Definition: AMReX_BoxArray.H:143
Box operator()(const Box &bx) const noexcept
Definition: AMReX_BoxArray.H:140
static constexpr IntVect coarsen_ratio()
Definition: AMReX_BoxArray.H:145
static constexpr IntVect doiLo()
Definition: AMReX_BoxArray.H:142
Definition: AMReX_BoxArray.H:821
friend std::ostream & operator<<(std::ostream &os, const RefID &id)
bool operator<(const RefID &rhs) const noexcept
Definition: AMReX_BoxArray.H:824
bool operator!=(const RefID &rhs) const noexcept
Definition: AMReX_BoxArray.H:826
bool operator==(const RefID &rhs) const noexcept
Definition: AMReX_BoxArray.H:825
BARef * data
Definition: AMReX_BoxArray.H:829