4#include <AMReX_Config.H>
16#include <unordered_map>
74 bool no_overlap =
false);
83 explicit BARef (std::istream& is);
94 void define (std::istream& is,
int& ndims);
97#ifdef AMREX_MEM_PROFILING
98 void updateMemoryUsage_box (
int s);
99 void updateMemoryUsage_hash (
int s);
105#pragma omp atomic read
120 using HashType = std::unordered_map< IntVect, std::vector<int>, IntVect::shift_hasher > ;
142 [[nodiscard]]
static constexpr Box coarsen (
Box const& a_box) {
return a_box; }
153 [[nodiscard]]
static Box coarsen (
Box const& a_box)
noexcept {
return a_box; }
197 int a_in_rad,
int a_out_rad,
int a_extent_rad)
220 m_hishft[d] = nodal[d] + a_in_rad - 1;
261 return a.m_face ==
b.m_face && a.m_typ ==
b.m_typ && a.m_crse_ratio ==
b.m_crse_ratio
262 && a.m_loshft ==
b.m_loshft && a.m_hishft ==
b.m_hishft
263 && a.m_doilo ==
b.m_doilo && a.m_doihi ==
b.m_doihi;
289 :
m_bndryReg(f,t,in_rad,out_rad,extent_rad) {}
305 m_op(f,t,in_rad,out_rad,extent_rad) {}
403 [[nodiscard]]
bool is_null () const noexcept {
471 if (typ.cellCentered()) {
481 if (typ.cellCentered()) {
491 if (typ.cellCentered()) {
503 if (typ.cellCentered()) {
523 return a.index_type() ==
b.index_type()
524 && a.coarsen_ratio() ==
b.coarsen_ratio();
526 return a.m_op.m_bndryReg ==
b.m_op.m_bndryReg;
600 [[nodiscard]] Long
capacity () const noexcept {
return static_cast<Long
>(
m_ref->m_abox.capacity()); }
603 [[nodiscard]]
bool empty () const noexcept {
return m_ref->m_abox.empty(); }
606 [[nodiscard]] Long
numPts() const noexcept;
622 [[nodiscard]]
bool operator== (const
BoxArray& rhs) const noexcept;
625 [[nodiscard]]
bool operator!= (const
BoxArray& rhs) const noexcept;
627 [[nodiscard]]
bool operator== (const
Vector<
Box>& bv) const noexcept;
628 [[nodiscard]]
bool operator!= (const
Vector<
Box>& bv) const noexcept;
653 [[nodiscard]]
bool coarsenable (
int refinement_ratio,
int min_width=1) const;
719 [[nodiscard]]
Box operator[] (
int index) const noexcept {
738 [[nodiscard]]
bool ok ()
const;
794 std::vector< std::pair<int,Box> >
intersections (
const Box& bx,
bool first_only,
int ng)
const;
804 bool first_only,
int ng)
const;
807 bool first_only,
const IntVect& ng)
const;
877std::ostream& operator<< (std::ostream& os, const
BoxArray& ba);
879std::ostream& operator<< (std::ostream& os, const
BoxArray::RefID&
id);
int idir
Definition AMReX_HypreMLABecLap.cpp:1093
Definition AMReX_AmrMesh.H:62
A collection of Boxes stored in an Array.
Definition AMReX_BoxArray.H:550
IndexType ixType() const noexcept
Return index type of this BoxArray.
Definition AMReX_BoxArray.H:837
Box operator[](int index) const noexcept
Return element index of this BoxArray.
Definition AMReX_BoxArray.H:719
Long capacity() const noexcept
Return the number of boxes that can be held in the current allocated storage.
Definition AMReX_BoxArray.H:600
std::vector< std::pair< int, Box > > intersections(const Box &bx, bool first_only, int ng) const
Return intersections of Box and BoxArray(+ghostcells).
RefID getRefID() const noexcept
Return a unique ID of the reference.
Definition AMReX_BoxArray.H:834
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...
BoxArray & grow(int n)
Grow each Box in the BoxArray by the specified amount.
bool intersects(const Box &b, const IntVect &ng) const
std::vector< std::pair< int, Box > > intersections(const Box &bx) const
Return intersections of Box and BoxArray.
std::ostream & writeOn(std::ostream &) const
Output this BoxArray to a checkpoint file.
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::shared_ptr< BARef > & getSharedRef()
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:870
BoxList const & simplified_list() const
BoxList boxList() const
Create a BoxList from this BoxArray.
BoxArray simplified() const
IntVect crseRatio() const noexcept
Return crse ratio of this BoxArray.
Definition AMReX_BoxArray.H:840
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...
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:873
BARef::HashType & getHashMap() const
IntVect getDoiHi() const noexcept
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 & minmaxSize(const IntVect &min_size, const IntVect &max_size)
BoxArray & refine(int refinement_ratio)
Refine each Box in the BoxArray to the specified ratio.
std::weak_ptr< BARef > getWeakRef() const
bool coarsenable(int refinement_ratio, int min_width=1) const
Coarsen each Box in the BoxArray to the specified ratio.
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.
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
BoxArray & enclosedCells()
Apply Box::enclosedCells() to each Box in the BoxArray.
std::shared_ptr< BARef > const & getSharedRef() const
Box getCellCenteredBox(int index) const noexcept
Return cell-centered box at element index of this BoxArray.
Definition AMReX_BoxArray.H:730
double d_numPts() const noexcept
Returns the total number of cells (in double type) contained in all boxes in the BoxArray.
BATransformer const & transformer() const
static bool initialized
Definition AMReX_BoxArray.H:844
static bool SameRefs(const BoxArray &lhs, const BoxArray &rhs)
whether two BoxArrays share the same data
Definition AMReX_BoxArray.H:820
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.
BoxList complementIn(const Box &b) const
Return box - boxarray.
void type_update()
Update BoxArray index type according the box type, and then convert boxes to cell-centered.
std::vector< std::pair< int, Box > > intersections(const Box &bx, bool first_only, const IntVect &ng) const
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:872
void removeOverlap(bool simplify=true)
Change the BoxArray to one with no overlap and then simplify it (see the simplify function in BoxList...
BoxArray & coarsen(int refinement_ratio)
Coarsen each Box in the BoxArray to the specified ratio.
BoxArray & shift(int dir, int nzones)
Apply Box::shift(int,int) to each Box in the BoxArray.
BoxArray & surroundingNodes()
Apply surroundingNodes(Box) to each Box in BoxArray. See the documentation of Box for details.
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:597
Box get(int index) const noexcept
Return element index of this BoxArray.
Definition AMReX_BoxArray.H:727
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 & growcoarsen(int n, const IntVect &iv)
Grow and then coarsen each Box in the BoxArray.
BoxArray & convert(IndexType typ)
Apply Box::convert(IndexType) to each Box in the BoxArray.
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:603
bool isDisjoint() const
Return true if set of intersecting Boxes in BoxArray is null.
BoxArray & maxSize(int block_size)
Forces each Box in BoxArray to have sides <= block_size.
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 AMREX_FORCE_INLINE constexpr CellIndex ixType(int dir) const noexcept
Returns the CellIndex in direction dir.
Definition AMReX_IndexType.H:116
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE constexpr 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 AMREX_FORCE_INLINE constexpr 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
Definition AMReX_Amr.cpp:49
BoxND< AMREX_SPACEDIM > Box
Definition AMReX_BaseFwd.H:27
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
BoxArray intersect(const BoxArray &ba, const Box &b, int ng=0)
Make a BoxArray from the intersection of Box b and BoxArray(+ghostcells).
BoxList GetBndryCells(const BoxArray &ba, int ngrow)
Find the ghost cells of a given 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
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.
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:77
static Long total_box_bytes_hwm
Definition AMReX_BoxArray.H:130
static int numboxarrays
Definition AMReX_BoxArray.H:127
static Long total_hash_bytes
Definition AMReX_BoxArray.H:131
BARef(BARef &&rhs)=delete
IntVect crsn
Definition AMReX_BoxArray.H:118
std::unordered_map< IntVect, std::vector< int >, IntVect::shift_hasher > HashType
Definition AMReX_BoxArray.H:120
static Long total_hash_bytes_hwm
Definition AMReX_BoxArray.H:132
static bool initialized
Definition AMReX_BoxArray.H:136
HashType hash
Definition AMReX_BoxArray.H:123
BARef & operator=(const BARef &rhs)=delete
Box bbox
Box hash stuff.
Definition AMReX_BoxArray.H:116
void define(const BoxList &bl)
BARef(BoxList &&bl) noexcept
static int numboxarrays_hwm
Definition AMReX_BoxArray.H:128
bool has_hashmap
Definition AMReX_BoxArray.H:125
Vector< Box > m_abox
The data.
Definition AMReX_BoxArray.H:113
static Long total_box_bytes
Definition AMReX_BoxArray.H:129
void define(const Box &bx)
void define(std::istream &is, int &ndims)
void define(BoxList &&bl) noexcept
bool HasHashMap() const
Definition AMReX_BoxArray.H:102
Definition AMReX_BoxArray.H:195
IndexType index_type() const noexcept
Definition AMReX_BoxArray.H:257
Box operator()(const Box &a_bx) const noexcept
Definition AMReX_BoxArray.H:238
BATbndryReg(Orientation a_face, IndexType a_typ, int a_in_rad, int a_out_rad, int a_extent_rad)
Definition AMReX_BoxArray.H:196
friend bool operator==(BATbndryReg const &a, BATbndryReg const &b) noexcept
Definition AMReX_BoxArray.H:260
IntVect doiHi() const noexcept
Definition AMReX_BoxArray.H:255
IntVect coarsen_ratio() const noexcept
Definition AMReX_BoxArray.H:258
IntVect doiLo() const noexcept
Definition AMReX_BoxArray.H:254
Orientation m_face
Definition AMReX_BoxArray.H:266
IntVect m_loshft
Definition AMReX_BoxArray.H:269
IndexType m_typ
Definition AMReX_BoxArray.H:267
Box coarsen(Box const &a_box) const noexcept
Definition AMReX_BoxArray.H:252
IntVect m_doihi
Definition AMReX_BoxArray.H:272
IntVect m_hishft
Definition AMReX_BoxArray.H:270
IntVect m_doilo
Definition AMReX_BoxArray.H:271
IntVect m_crse_ratio
Definition AMReX_BoxArray.H:268
Definition AMReX_BoxArray.H:162
BATcoarsenRatio(IntVect const &a_crse_ratio)
Definition AMReX_BoxArray.H:163
static constexpr IntVect doiHi()
Definition AMReX_BoxArray.H:167
Box coarsen(Box const &a_box) const noexcept
Definition AMReX_BoxArray.H:165
static constexpr IndexType index_type()
Definition AMReX_BoxArray.H:168
static constexpr IntVect doiLo()
Definition AMReX_BoxArray.H:166
IntVect m_crse_ratio
Definition AMReX_BoxArray.H:170
Box operator()(const Box &bx) const noexcept
Definition AMReX_BoxArray.H:164
IntVect coarsen_ratio() const noexcept
Definition AMReX_BoxArray.H:169
Definition AMReX_BoxArray.H:174
BATindexType_coarsenRatio(IndexType a_typ, IntVect const &a_crse_ratio)
Definition AMReX_BoxArray.H:175
static constexpr IntVect doiLo()
Definition AMReX_BoxArray.H:184
IntVect doiHi() const noexcept
Definition AMReX_BoxArray.H:185
Box operator()(const Box &bx) const noexcept
Definition AMReX_BoxArray.H:178
IntVect m_crse_ratio
Definition AMReX_BoxArray.H:191
IntVect coarsen_ratio() const noexcept
Definition AMReX_BoxArray.H:188
IndexType index_type() const noexcept
Definition AMReX_BoxArray.H:187
Box coarsen(Box const &a_box) const noexcept
Definition AMReX_BoxArray.H:182
IndexType m_typ
Definition AMReX_BoxArray.H:190
Definition AMReX_BoxArray.H:150
IntVect doiHi() const noexcept
Definition AMReX_BoxArray.H:155
Box operator()(const Box &bx) const noexcept
Definition AMReX_BoxArray.H:152
IndexType index_type() const noexcept
Definition AMReX_BoxArray.H:156
static Box coarsen(Box const &a_box) noexcept
Definition AMReX_BoxArray.H:153
BATindexType(IndexType a_typ)
Definition AMReX_BoxArray.H:151
IndexType m_typ
Definition AMReX_BoxArray.H:158
static constexpr IntVect coarsen_ratio()
Definition AMReX_BoxArray.H:157
static constexpr IntVect doiLo()
Definition AMReX_BoxArray.H:154
Definition AMReX_BoxArray.H:140
static constexpr Box coarsen(Box const &a_box)
Definition AMReX_BoxArray.H:142
static constexpr IndexType index_type()
Definition AMReX_BoxArray.H:145
static constexpr IntVect doiHi()
Definition AMReX_BoxArray.H:144
Box operator()(const Box &bx) const noexcept
Definition AMReX_BoxArray.H:141
static constexpr IntVect coarsen_ratio()
Definition AMReX_BoxArray.H:146
static constexpr IntVect doiLo()
Definition AMReX_BoxArray.H:143
Definition AMReX_BoxArray.H:822
friend std::ostream & operator<<(std::ostream &os, const RefID &id)
bool operator<(const RefID &rhs) const noexcept
Definition AMReX_BoxArray.H:825
bool operator!=(const RefID &rhs) const noexcept
Definition AMReX_BoxArray.H:827
bool operator==(const RefID &rhs) const noexcept
Definition AMReX_BoxArray.H:826
BARef * data
Definition AMReX_BoxArray.H:830