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;
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;
597 [[nodiscard]] Long
size () const noexcept {
return m_ref->m_abox.size(); }
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;
877 std::ostream& operator<< (std::ostream& os, const
BoxArray& ba);
879 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: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
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:600
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: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...
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:870
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: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...
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:873
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.
std::shared_ptr< BARef > & getSharedRef()
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:730
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:844
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:820
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:872
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: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 & 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:603
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::shared_ptr< BARef > const & getSharedRef() const
std::vector< std::pair< int, Box > > intersections(const Box &bx, bool first_only, int ng) const
Return intersections of Box and BoxArray(+ghostcells).
std::weak_ptr< BARef > getWeakRef() const
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:77
static Long total_box_bytes_hwm
Definition: AMReX_BoxArray.H:130
BARef & operator=(const BARef &rhs)=delete
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
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