Block-Structured AMR Software Framework
 
Loading...
Searching...
No Matches
AMReX_BoxList.H
Go to the documentation of this file.
1
2#ifndef BL_BOXLIST_H
3#define BL_BOXLIST_H
4#include <AMReX_Config.H>
5
6#include <AMReX_IntVect.H>
7#include <AMReX_IndexType.H>
8#include <AMReX_Box.H>
9#include <AMReX_Array.H>
10#include <AMReX_Vector.H>
11
12#include <iosfwd>
13
14namespace amrex
15{
16 class BoxArray;
17 class BoxList;
18
20 BoxList complementIn (const Box& b, const BoxList& bl);
21
23 BoxList boxDiff (const Box& b1in, const Box& b2);
24
25 void boxDiff (BoxList& bl_diff, const Box& b1in, const Box& b2);
26
28 BoxList refine (const BoxList& bl, int ratio);
29
31 BoxList coarsen (const BoxList& bl, int ratio);
32
34 BoxList intersect (const BoxList& bl, const Box& b);
35
37 BoxList accrete (const BoxList& bl, int sz);
38
40 BoxList removeOverlap (const BoxList& bl);
41
42
44 std::ostream& operator<< (std::ostream& os, const BoxList& blist);
45
46
52{
53public:
54
55 friend class BoxDomain;
56
59
61 BoxList ();
62
64 explicit BoxList (const Box& bx);
65
67 explicit BoxList (IndexType _btype);
68
70 explicit BoxList (const BoxArray& ba);
71
73 explicit BoxList (Vector<Box>&& bxs);
74
76 BoxList (const Box& bx, const IntVect& tilesize);
77
79 BoxList (const Box& bx, int nboxes);
80
82 BoxList (const Box& bx, int nboxes, Direction dir);
83
84 ~BoxList () = default;
85 BoxList (const BoxList& rhs) = default;
86 BoxList (BoxList&& rhs) = default;
87 BoxList& operator= (const BoxList& rhs) = default;
88 BoxList& operator= (BoxList&& rhs) = default;
89
90 void reserve (std::size_t n) { m_lbox.reserve(n); }
91
93 void push_back (const Box& bn) {
94 if (m_lbox.empty()) { btype = bn.ixType(); }
95 BL_ASSERT(ixType() == bn.ixType());
96 m_lbox.push_back(bn);
97 }
98
99 [[nodiscard]] Box& front () noexcept { BL_ASSERT(!m_lbox.empty()); return m_lbox.front(); }
100
101 [[nodiscard]] const Box& front () const noexcept { BL_ASSERT(!m_lbox.empty()); return m_lbox.front(); }
102
104 void join (const BoxList& blist);
106 void join (const Vector<Box>& barr);
108 void catenate (BoxList& blist);
109
111 void clear ();
113 [[nodiscard]] Long size () const noexcept { return m_lbox.size(); }
114
115 [[nodiscard]] std::size_t capacity () const noexcept { return m_lbox.capacity(); }
116
117 [[nodiscard]] iterator begin () noexcept { return m_lbox.begin(); }
118 [[nodiscard]] const_iterator begin () const noexcept { return m_lbox.cbegin(); }
119 [[nodiscard]] const_iterator cbegin () const noexcept { return m_lbox.cbegin(); }
120
121 [[nodiscard]] iterator end () noexcept { return m_lbox.end(); }
122 [[nodiscard]] const_iterator end () const noexcept { return m_lbox.cend(); }
123 [[nodiscard]] const_iterator cend () const noexcept { return m_lbox.cend(); }
129 [[nodiscard]] bool ok () const noexcept;
131 bool operator== (const BoxList& rhs) const;
133 bool operator!= (const BoxList& rhs) const;
135 [[nodiscard]] bool isEmpty () const noexcept { return m_lbox.empty(); }
137 [[nodiscard]] bool isNotEmpty () const noexcept { return !m_lbox.empty(); }
139 [[nodiscard]] bool isDisjoint () const;
141 [[nodiscard]] bool contains (const BoxList& bl) const;
143 BoxList& intersect (const Box& b);
145 BoxList& intersect (const BoxList& bl);
148
149 BoxList& complementIn (const Box& b, const BoxList& bl);
150 BoxList& complementIn (const Box& b, BoxList&& bl);
151 BoxList& complementIn (const Box& b, const BoxArray& ba);
152 BoxList& parallelComplementIn (const Box& b, const BoxList& bl);
153 BoxList& parallelComplementIn (const Box& b, BoxList&& bl);
154 BoxList& parallelComplementIn (const Box& b, const BoxArray& ba);
155
157 BoxList& refine (int ratio);
159 BoxList& refine (const IntVect& ratio);
161 BoxList& coarsen (int ratio);
163 BoxList& coarsen (const IntVect& ratio);
165 BoxList& accrete (int sz);
166 BoxList& accrete (const IntVect& sz);
168 BoxList& shift (int dir,
169 int nzones);
171 BoxList& shiftHalf (int dir,
172 int num_halfs);
174 BoxList& shiftHalf (const IntVect& iv);
184 int simplify (bool best = false);
186 int ordered_simplify ();
188 BoxList& maxSize (int chunk);
190 BoxList& maxSize (const IntVect& chunk);
192 [[nodiscard]] Box minimalBox () const;
194 [[nodiscard]] IndexType ixType () const noexcept { return btype; }
196 void set (IndexType ixtyp) noexcept { BL_ASSERT(m_lbox.empty()); btype = ixtyp; }
201 BoxList& surroundingNodes () noexcept;
206 BoxList& surroundingNodes (int dir) noexcept;
208 BoxList& enclosedCells () noexcept;
210 BoxList& enclosedCells (int dir) noexcept;
212 BoxList& convert (IndexType typ) noexcept;
213
215 [[nodiscard]] Vector<Box>& data () noexcept { return m_lbox; }
217 [[nodiscard]] const Vector<Box>& data () const noexcept { return m_lbox; }
218
219 void swap (BoxList& rhs) noexcept {
220 std::swap(m_lbox, rhs.m_lbox);
221 std::swap(btype, rhs.btype);
222 }
223
224 void Bcast ();
225
226private:
228 int simplify_doit (int depth);
229
234
235};
236
237}
238
239#endif /*BL_BOXLIST_H*/
#define BL_ASSERT(EX)
Definition AMReX_BLassert.H:39
A collection of Boxes stored in an Array.
Definition AMReX_BoxArray.H:551
A List of Disjoint Boxes.
Definition AMReX_BoxDomain.H:67
A class for managing a List of Boxes that share a common IndexType. This class implements operations ...
Definition AMReX_BoxList.H:52
bool ok() const noexcept
True if this BoxList is valid; i.e. all the Boxes are valid and they all have the same IndexType....
Definition AMReX_BoxList.cpp:237
bool contains(const BoxList &bl) const
True if all Boxes in bl are contained in this BoxList.
Definition AMReX_BoxList.cpp:254
const_iterator cend() const noexcept
Definition AMReX_BoxList.H:123
bool isDisjoint() const
True if the set of intersecting Boxes is empty.
Definition AMReX_BoxList.cpp:244
BoxList & convert(IndexType typ) noexcept
Applies Box::convert(IndexType) to each Box in the BoxList.
Definition AMReX_BoxList.cpp:867
BoxList & refine(int ratio)
Refine each Box in the BoxList by the ratio.
Definition AMReX_BoxList.cpp:505
void clear()
Remove all Boxes from this BoxList.
Definition AMReX_BoxList.cpp:65
BoxList & shiftHalf(int dir, int num_halfs)
Applies Box::shiftHalf(int,int) to each Box in the BoxList.
Definition AMReX_BoxList.cpp:575
BoxList & coarsen(int ratio)
Coarsen each Box in the BoxList by the ratio.
Definition AMReX_BoxList.cpp:525
const Box & front() const noexcept
Definition AMReX_BoxList.H:101
IndexType ixType() const noexcept
Returns the IndexType of Boxes in this BoxList.
Definition AMReX_BoxList.H:194
const_iterator cbegin() const noexcept
Definition AMReX_BoxList.H:119
BoxList()
Construct an empty BoxList with IndexType::TheCellType().
Definition AMReX_BoxList.cpp:148
const_iterator end() const noexcept
Definition AMReX_BoxList.H:122
BoxList & intersect(const Box &b)
Modify this BoxList to contain only its intersection with Box b.
Definition AMReX_BoxList.cpp:267
iterator end() noexcept
Definition AMReX_BoxList.H:121
Vector< Box > & data() noexcept
Returns a reference to the Vector<Box>.
Definition AMReX_BoxList.H:215
const Vector< Box > & data() const noexcept
Returns a constant reference to the Vector<Box>.
Definition AMReX_BoxList.H:217
void catenate(BoxList &blist)
Catenate the BoxList to ourselves. Removes entries from blist.
Definition AMReX_BoxList.cpp:85
bool isEmpty() const noexcept
Is this BoxList empty?
Definition AMReX_BoxList.H:135
void set(IndexType ixtyp) noexcept
Set the type of the BoxList. It's an error if the BoxList isn't empty.
Definition AMReX_BoxList.H:196
BoxList(const BoxList &rhs)=default
std::size_t capacity() const noexcept
Definition AMReX_BoxList.H:115
void Bcast()
Definition AMReX_BoxList.cpp:910
~BoxList()=default
BoxList(BoxList &&rhs)=default
bool isNotEmpty() const noexcept
Is this BoxList not empty?
Definition AMReX_BoxList.H:137
IndexType btype
The IndexType of Boxes in the BoxList.
Definition AMReX_BoxList.H:233
void reserve(std::size_t n)
Definition AMReX_BoxList.H:90
int simplify(bool best=false)
Merge adjacent Boxes in this BoxList. Return the number of Boxes merged. If "best" is specified we do...
Definition AMReX_BoxList.cpp:654
const_iterator begin() const noexcept
Definition AMReX_BoxList.H:118
BoxList & surroundingNodes() noexcept
Applies surroundingNodes(Box) to each Box in BoxArray. See the documentation of Box for details.
Definition AMReX_BoxList.cpp:827
BoxList & enclosedCells() noexcept
Applies Box::enclosedCells() to each Box in the BoxList.
Definition AMReX_BoxList.cpp:847
Box & front() noexcept
Definition AMReX_BoxList.H:99
void swap(BoxList &rhs) noexcept
Definition AMReX_BoxList.H:219
BoxList & accrete(int sz)
Grow each Box in the BoxList by size sz.
Definition AMReX_BoxList.cpp:545
BoxList & parallelComplementIn(const Box &b, const BoxList &bl)
Definition AMReX_BoxList.cpp:399
BoxList & maxSize(int chunk)
Forces each Box in the BoxList to have sides of length <= chunk.
Definition AMReX_BoxList.cpp:821
int simplify_doit(int depth)
Core simplify routine.
Definition AMReX_BoxList.cpp:680
void push_back(const Box &bn)
Append a Box to this BoxList.
Definition AMReX_BoxList.H:93
int ordered_simplify()
Assuming the boxes are nicely ordered.
Definition AMReX_BoxList.cpp:670
iterator begin() noexcept
Definition AMReX_BoxList.H:117
BoxList & removeEmpty()
Remove empty Boxes from this BoxList.
Definition AMReX_BoxList.cpp:93
Long size() const noexcept
The number of Boxes in this BoxList.
Definition AMReX_BoxList.H:113
Box minimalBox() const
Returns smallest Box that contains all Boxes in this BoxList.
Definition AMReX_BoxList.cpp:749
Vector< Box >::iterator iterator
Definition AMReX_BoxList.H:57
BoxList & complementIn(const Box &b, const BoxList &bl)
Definition AMReX_BoxList.cpp:307
Vector< Box > m_lbox
The list of Boxes.
Definition AMReX_BoxList.H:231
Vector< Box >::const_iterator const_iterator
Definition AMReX_BoxList.H:58
BoxList & shift(int dir, int nzones)
Applies Box::shift(int,int) to each Box in the BoxList.
Definition AMReX_BoxList.cpp:565
BoxList & operator=(const BoxList &rhs)=default
void join(const BoxList &blist)
Join the BoxList to ourselves.
Definition AMReX_BoxList.cpp:71
__host__ __device__ IndexTypeND< dim > ixType() const noexcept
Returns the indexing type.
Definition AMReX_Box.H:130
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition AMReX_Vector.H:28
Definition AMReX_Amr.cpp:49
void accrete(BoxDomain &dest, const BoxDomain &fin, int sz)
Grow each Box in BoxDomain fin by size sz and place the result into BoxDomain dest.
Definition AMReX_BoxDomain.cpp:45
BoxArray intersect(const BoxArray &ba, const Box &b, int ng)
Make a BoxArray from the intersection of Box b and BoxArray(+ghostcells).
Definition AMReX_BoxArray.cpp:1705
__host__ __device__ 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:1322
BoxND< 3 > Box
Definition AMReX_BaseFwd.H:27
BoxList boxDiff(const Box &b1in, const Box &b2)
Returns BoxList defining the compliment of b2 in b1in.
Definition AMReX_BoxList.cpp:599
BoxArray complementIn(const Box &b, const BoxArray &ba)
Make a BoxArray from the complement of BoxArray ba in Box b.
Definition AMReX_BoxArray.cpp:1698
Direction
Definition AMReX_Orientation.H:14
__host__ __device__ BoxND< dim > refine(const BoxND< dim > &b, int ref_ratio) noexcept
Definition AMReX_Box.H:1360
std::ostream & operator<<(std::ostream &os, AmrMesh const &amr_mesh)
Definition AMReX_AmrMesh.cpp:1236
BoxList removeOverlap(const BoxList &bl)
Return BoxList which covers the same area but has no overlapping boxes.
Definition AMReX_BoxList.cpp:135