4#include <AMReX_Config.H>
33using Box = BoxND<AMREX_SPACEDIM>;
112 template <
typename T>
113 requires ( 1<=dim && dim<=3 )
116 : smallend(IntVectShrink<dim>(a.
begin)),
117 bigend(IntVectShrink<dim>(a.
end) - 1)
132 int smallEnd (
int dir)
const&
noexcept {
return smallend[dir]; }
144 int bigEnd (
int dir)
const noexcept {
return bigend[dir]; }
162 return bigend - smallend + 1;
169 return bigend - smallend + 1;
174 int length (
int dir)
const noexcept {
return bigend[dir] - smallend[dir] + 1; }
179 requires (1 <= dim && dim <= 3)
182 return {{len3d.
x, len3d.
y, len3d.
z}};
188 requires (1 <= dim && dim <= 3)
190 Dim3 lo3d = smallend.dim3(0);
191 return {{lo3d.
x, lo3d.
y, lo3d.
z}};
197 requires (1 <= dim && dim <= 3)
199 Dim3 hi3d = bigend.dim3(0);
200 return {{hi3d.
x, hi3d.
y, hi3d.
z}};
205 const int*
loVect () const& noexcept {
return smallend.getVect(); }
210 const int*
hiVect () const& noexcept {
return bigend.getVect(); }
217 const int dir = face.coordDir();
218 return face.isLow() ? smallend[dir] : bigend[dir];
229 bool ok () const noexcept {
return bigend.allGE(smallend) && btype.ok(); }
234 return p.allGE(smallend) && p.allLE(bigend);
240 requires (1 <= dim && dim <= 3)
249 requires (1 <= dim && dim <= 3)
251 Dim3 p3d{.
x = i, .y = j, .z = k};
262 return b.smallend.allGE(smallend) && b.bigend.allLE(bigend);
268 return p.allGT(smallend) && p.allLT(bigend);
279 return b.smallend.allGT(smallend) && b.bigend.allLT(bigend);
285 requires (1 <= dim && dim <= 3)
294 requires (1 <= dim && dim <= 3)
296 Dim3 p3d{.
x = i, .y = j, .z = k};
314 return length() == b.length();
323 bool operator== (
const BoxND& b)
const noexcept {
return smallend == b.smallend && bigend == b.bigend && b.btype == btype; }
333 return btype < rhs.btype ||
334 ((btype == rhs.btype) &&
335 ( (smallend < rhs.smallend) ||
336 ((smallend == rhs.smallend) && (bigend < rhs.bigend)) ));
341 return !(rhs < *
this);
351 return !(*
this < rhs);
360 void checkOverflow ()
const {
362 for (
int i = 0; i < dim; ++i) {
363 auto lo =
static_cast<Long>(smallend[i]);
364 auto hi =
static_cast<Long>(bigend[i]);
365 Long len = hi - lo + 1;
367 "Overflow when computing length of box");
370 for (
int i = 1; i < dim; ++i) {
373 num_pts <= std::numeric_limits<Long>::max() / len,
374 "Overflow when computing numPts of box");
386#if defined(AMREX_DEBUG) || defined(AMREX_USE_ASSERTION)
391 for (
int i = 1; i < dim; ++i) {
407 auto num_pts =
static_cast<double>(
length(0));
408 for (
int i = 1; i < dim; ++i) {
409 num_pts *=
static_cast<double>(
length(i));
425 auto num_pts =
static_cast<Long>(
length(0)-btype[0]);
426 for (
int i = 1; i < dim; ++i) {
427 num_pts *=
static_cast<Long>(
length(i)-btype[i]);
443 for (
int i = 1; i < dim; i++)
469 for (
int i = 1; i < dim; i++)
503 requires (1 <= N && N <= 3)
512 BoxND&
setSmall (
int dir,
int sm_index)
noexcept { smallend.setVal(dir,sm_index);
return *
this; }
520 BoxND&
setBig (
int dir,
int bg_index)
noexcept { bigend.setVal(dir,bg_index);
return *
this; }
530 int n_cells = 1) noexcept;
538 BoxND&
shift (
int dir,
int nzones)
noexcept { smallend.shift(dir,nzones); bigend.shift(dir,nzones);
return *
this; }
616 smallend.max(rhs.smallend);
617 bigend.min(rhs.bigend);
630 smallend.min(b.smallend);
631 bigend.max(b.bigend);
668 BoxND&
grow (
int i)
noexcept { smallend.diagShift(-i); bigend.diagShift(i);
return *
this; }
678 BoxND&
grow (
int idir,
int n_cell)
noexcept { smallend.shift(
idir, -n_cell); bigend.shift(
idir, n_cell);
return *
this; }
715 smallend.shift(
idir, -n_cell);
717 bigend.shift(
idir,n_cell);
804 if (!
size().allGE(refrat*min_width)) {
807 BoxND testBox = *
this;
810 return (*
this == testBox);
851 for (
int idim=0; idim < dim; ++idim) {
852 if (this->
length(idim) == 0) {
862 smallend[direction] = slab_index;
863 bigend[direction] = slab_index;
883 static constexpr std::size_t
ndims () noexcept {
884 return static_cast<std::size_t
>(dim);
888 static constexpr int indims () noexcept {
896 template<
int new_dim>
899 static_assert(new_dim <= dim);
900 auto lo = smallend.template shrink<new_dim>();
901 auto hi = bigend.template shrink<new_dim>();
902 auto typ = btype.template shrink<new_dim>();
911 template<
int new_dim>
914 static_assert(new_dim >= dim);
915 auto lo = smallend.template expand<new_dim>(0);
916 auto hi = bigend.template expand<new_dim>(0);
925 template<
int new_dim>
928 if constexpr (new_dim > dim) {
929 return expand<new_dim>();
931 return shrink<new_dim>();
947 if (ref_ratio != 1) {
949 shft -= btype.ixType();
950 smallend *= ref_ratio;
971 for (
int dir = 0; dir < dim; dir++)
974 if (bigend[dir]%ref_ratio[dir]) {
1010 for (
int dir = 0; dir < dim; dir++)
1012 const auto typ = t[dir];
1013 const auto bitval = btype[dir];
1014 const int off = typ - bitval;
1015 bigend.
shift(dir,off);
1029 bigend.
shift(dir,1);
1044 for (
int i = 0; i < dim; ++i) {
1045 if ((btype[i] == 0)) {
1061 bigend.
shift(dir,-1);
1076 for (
int i = 0 ; i < dim; ++i) {
1092 Long result = vz[0];
1094 for (
int i = 1 ; i < dim; ++i) {
1095 result += mult * vz[i];
1109 if constexpr (dim > 1) {
1112 for (
int i = 1 ; i < dim-1; ++i) {
1113 mult[i] = mult[i-1] *
length(i);
1115 for (
int i = dim-1 ; i > 0; --i) {
1117 offset -= idx * mult[i-1];
1118 result[i] +=
static_cast<int>(idx);
1122 result[0] +=
static_cast<int>(
offset);
1129requires (1 <= N && N <= 3)
1136 return {{iv3d.
x, iv3d.
y, iv3d.
z}};
1145 int n_cells)
noexcept
1147 smallend.setVal(dir,sm_index);
1148 bigend.setVal(dir,sm_index+n_cells-1);
1162 for (
int i = 0 ; i < dim-1; ++i) {
1163 if (p[i] > bigend[i]) {
1178 if constexpr (dim == 1) {
1181 bool is_square =
true;
1183 for (
int i = 0 ; i < dim-1; ++i) {
1184 is_square = is_square && (sz[i] == sz[i+1]);
1213 BL_ASSERT(chop_pnt > smallend[dir] && chop_pnt < bigend[dir]);
1217 bigend.setVal(dir,chop_pnt);
1224 BL_ASSERT(chop_pnt > smallend[dir] && chop_pnt <= bigend[dir]);
1228 bigend.setVal(dir,chop_pnt-1);
1239 const int nbit = (num_halfs<0 ? -num_halfs : num_halfs)%2;
1240 int nshift = num_halfs/2;
1244 const unsigned int bit_dir = btype[dir];
1248 if (num_halfs < 0) {
1249 nshift -= (bit_dir ? nbit : 0);
1251 nshift += (bit_dir ? 0 : nbit);
1253 smallend.
shift(dir,nshift);
1254 bigend.
shift(dir,nshift);
1264 for (
int i = 0; i < dim; i++) {
1275 explicit BoxCommHelper (
const Box& bx,
int* p_ =
nullptr);
1277 [[nodiscard]]
int* data () const& noexcept {
return p; }
1278 int* data () && =
delete;
1280 [[nodiscard]] Box make_box () const noexcept {
1281 return Box(IntVect(p), IntVect(p+AMREX_SPACEDIM), IntVect(p+2*AMREX_SPACEDIM));
1284 [[nodiscard]]
static int size () noexcept {
return 3*AMREX_SPACEDIM; }
1380 return grow(b,
static_cast<int>(d), n_cell);
1415 return growLo(b,
static_cast<int>(d), n_cell);
1450 return growHi(b,
static_cast<int>(d), n_cell);
1531 result.
refine(ref_ratio);
1551 result.
shift(dir, nzones);
1569 result.
shift(nzones);
1720 low.
setVal(dir,sm-len+1);
1749 auto const bitval = b.
type()[dir];
1750 int bg = hi[dir] + 1 - bitval%2;
1784 low.
setVal(dir,sm-len+1);
1789 int bitval = b.
type()[dir];
1790 int bg = hi[dir] + 1 - bitval%2;
1823 low.
setVal(dir,sm - len);
1853 int bitval = b.
type()[dir];
1854 int bg = hi[dir] + 1 - bitval%2;
1856 hi.
setVal(dir,bg + len - 1);
1889 low.
setVal(dir,sm - len);
1894 int bitval = b.
type()[dir];
1895 int bg = hi[dir] + 1 - bitval%2;
1897 hi.
setVal(dir,bg + len - 1);
1930 std::ostream& box_write (std::ostream& os,
const int * smallend,
const int * bigend,
1931 const int * type,
int dim);
1932 std::istream& box_read (std::istream& is,
int * smallend,
int * bigend,
int * type,
int dim);
1934 template<std::size_t...Ns,
class T,
class U>
1936 auto BoxSplit_imp (std::index_sequence<Ns...>,
1937 const T& lo,
const T& hi,
const U& typ)
noexcept {
1938 return makeTuple(BoxND(get<Ns>(lo), get<Ns>(hi), get<Ns>(typ))...);
1954 return detail::box_write(os, bx.
smallEnd().begin(), bx.
bigEnd().begin(), type.
begin(), dim);
1983template<
int d,
int...dims>
1986constexpr BoxND<detail::get_sum<d, dims...>()>
1991 return BoxND<detail::get_sum<d, dims...>()>{lo, hi, typ};
2000template<
int d,
int...dims>
2003constexpr GpuTuple<BoxND<d>, BoxND<dims>...>
2008 return detail::BoxSplit_imp(std::make_index_sequence<1 +
sizeof...(dims)>(), lo, hi, typ);
2017template<
int new_dim,
int old_dim>
2020constexpr BoxND<new_dim>
2022 return bx.template shrink<new_dim>();
2033template<
int new_dim,
int old_dim>
2036constexpr BoxND<new_dim>
2038 return bx.template expand<new_dim>();
2047template<
int new_dim,
int old_dim>
2050constexpr BoxND<new_dim>
2052 return bx.template resize<new_dim>();
2067 return box.smallEnd();
2082 return box.bigEnd();
2097 return box.smallEnd();
2114 return box.bigEnd() + 1;
2129 return box.bigEnd() - box.smallEnd() + 1;
2145 return max(b1.smallEnd(), b2.smallEnd());
2161 return max(b1.smallEnd(), lo);
2177 return min(b1.bigEnd(), b2.bigEnd());
2193 return min(b1.bigEnd(), hi);
2203requires ( 1<=dim && dim<=3 )
2219requires ( 1<=dim && dim<=3 )
2225 return box.
bigEnd().dim3();
2235requires ( 1<=dim && dim<=3 )
2253requires ( 1<=dim && dim<=3 )
2259 return (box.
bigEnd() + 1).dim3(1);
2269requires ( 1<=dim && dim<=3 )
2286requires ( 1<=dim && dim<=3 )
2303requires ( 1<=dim && dim<=3 )
2320requires ( 1<=dim && dim<=3 )
2337requires ( 1<=dim && dim<=3 )
2388template <
class T,
class ... Ts>
2411 Long ncells_subtotal = 0;
2413 for (ibox = 0; ibox < nboxes; ++ibox) {
2415 ncells_subtotal += n;
2416 if (icell < ncells_subtotal) {
2417 offset = icell - (ncells_subtotal - n);
2453template<
int dim=AMREX_SPACEDIM>
2454requires ( 1<=dim && dim<=3 )
2460 Dim3 p3d{.
x = i, .y = j, .z = k};
2503 std::uint64_t mult = 1;
2504 for (
int i=0; i<dim-1; ++i) {
2521 for (
int i=dim-1; i>0; --i) {
2522 std::uint64_t quotient, remainder;
2523 fdm[i-1](quotient, remainder, icell);
2524 retval[i] += quotient;
2541 requires (1 <= dim && dim <= 3)
2596 return Dim3{.
x =
int(icell)+
lo, .y = 0, .z = 0};
General-purpose algorithm utilities available on both host and device.
Lightweight non-owning multidimensional array accessors for GPU and CPU.
Fixed-size array types for use on GPU and CPU.
#define AMREX_ALWAYS_ASSERT_WITH_MESSAGE(EX, MSG)
Definition AMReX_BLassert.H:49
#define BL_ASSERT(EX)
Definition AMReX_BLassert.H:39
Iterator over all IntVects in a Box.
#define AMREX_FORCE_INLINE
Definition AMReX_Extension.H:124
#define AMREX_IF_ON_HOST(CODE)
Definition AMReX_GpuQualifiers.H:58
#define AMREX_GPU_HOST_DEVICE
Definition AMReX_GpuQualifiers.H:20
int idir
Definition AMReX_HypreMLABecLap.cpp:1133
Array4< int const > offset
Definition AMReX_HypreMLABecLap.cpp:1129
Array4< Real > fine
Definition AMReX_InterpFaceRegister.cpp:90
Definition AMReX_Box.H:1292
virtual Box doit(const Box &fine) const =0
virtual ~BoxConverter()=default
virtual BoxConverter * clone() const =0
Iterator over all IntVects in a Box.
Definition AMReX_BoxIterator.H:59
A Rectangular Domain on an Integer Lattice.
Definition AMReX_Box.H:54
__host__ __device__ const int * hiVect() &&=delete
__host__ __device__ BoxND & grow(const IntVectND< dim > &v) noexcept
Grow in each direction by the supplied amount (negative shrinks).
Definition AMReX_Box.H:672
__host__ __device__ GpuArray< int, 3 > loVect3d() const noexcept
Return low-end coordinates padded to 3D (missing dims default to 0).
Definition AMReX_Box.H:187
__host__ __device__ constexpr BoxND(const IntVectND< dim > &small, const IntVectND< dim > &big) noexcept
Construct a cell-centered box spanning small through big.
Definition AMReX_Box.H:71
__host__ __device__ bool operator<=(const BoxND &rhs) const noexcept
Return true if this box is <= rhs in the lexicographic ordering.
Definition AMReX_Box.H:340
__host__ __device__ BoxND & grow(int i) noexcept
Grow in all directions by i cells (negative shrinks).
Definition AMReX_Box.H:668
__host__ __device__ GpuArray< int, 3 > length3d() const noexcept
Return lengths padded to 3D (missing dims default to 1).
Definition AMReX_Box.H:178
__host__ __device__ const IntVectND< dim > & bigEnd() const &noexcept
Return the inclusive upper bound of the box.
Definition AMReX_Box.H:136
__host__ __device__ const int * hiVect() const &noexcept
Return a pointer to the high-end coordinates (useful for Fortran calls).
Definition AMReX_Box.H:210
__host__ __device__ BoxND & operator&=(const BoxND &rhs) noexcept
Intersect this BoxND with its argument. The Boxes MUST be of the same type.
Definition AMReX_Box.H:613
__host__ __device__ bool isEmpty() const noexcept
Checks if it is an empty BoxND.
Definition AMReX_Box.H:223
__host__ __device__ BoxND(const IntVectND< dim > &small, const IntVectND< dim > &big, IndexTypeND< dim > t) noexcept
Construct a box with the given index type descriptor.
Definition AMReX_Box.H:105
__host__ static __device__ constexpr int indims() noexcept
Definition AMReX_Box.H:888
__host__ __device__ int bigEnd(int dir) const noexcept
Return the inclusive upper bound in the given direction.
Definition AMReX_Box.H:144
__host__ __device__ BoxND< new_dim > resize() const noexcept
Return a new BoxND of size new_dim by either shrinking or expanding this BoxND.
Definition AMReX_Box.H:927
__host__ __device__ BoxND & operator-=(const IntVectND< dim > &v) noexcept
Shift BoxND (relative) by given IntVectND<dim>.
Definition AMReX_Box.H:645
__host__ __device__ BoxND & surroundingNodes(Direction d) noexcept
Convert to NODE type in given direction.
Definition AMReX_Box.H:590
__host__ __device__ BoxND & makeSlab(int direction, int slab_index) noexcept
Collapse the box to a single slab at coordinate slab_index along direction.
Definition AMReX_Box.H:860
__host__ __device__ BoxND & setBig(const IntVectND< dim > &bg) noexcept
Redefine the big end of the BoxND.
Definition AMReX_Box.H:516
__host__ __device__ int shortside() const noexcept
Return length of shortest side. Ignores type.
Definition AMReX_Box.H:482
__host__ __device__ BoxND & minBox(const BoxND &b) noexcept
Modify BoxND to that of the minimum BoxND containing both the original BoxND and the argument....
Definition AMReX_Box.H:627
__host__ __device__ Long volume() const noexcept
Return the volume, in indexing space, of region enclosed by this BoxND. This is identical to numPts()...
Definition AMReX_Box.H:423
__host__ __device__ BoxND & shift(const IntVectND< dim > &iv) noexcept
Equivalent to b.shift(0,iv[0]).shift(1,iv[1]) ....
Definition AMReX_Box.H:542
__host__ __device__ BoxND< new_dim > expand() const noexcept
Return a new BoxND of size new_dim and assigns all values of this BoxND to it and (small=0,...
Definition AMReX_Box.H:913
__host__ __device__ bool isSquare() const noexcept
Definition AMReX_Box.H:1176
__host__ __device__ bool contains(const Dim3 &p) const noexcept
Return true if argument is contained within BoxND.
Definition AMReX_Box.H:239
__host__ __device__ bool cellCentered() const noexcept
Return true if BoxND is cell-centered in all indexing directions.
Definition AMReX_Box.H:356
__host__ __device__ BoxND(const IntVectND< dim > &small, const int *vec_len) noexcept
Construct a box with lower corner small and lengths vec_len.
Definition AMReX_Box.H:82
__host__ __device__ bool coarsenable(int refrat, int min_width=1) const noexcept
Return whether this Box is coarsenable.
Definition AMReX_Box.H:826
__host__ __device__ BoxND & operator+=(const IntVectND< dim > &v) noexcept
Shift BoxND (relative) by given IntVectND<dim>.
Definition AMReX_Box.H:637
__host__ __device__ const int * loVect() &&=delete
__host__ __device__ Long numPts() const noexcept
Return the number of points contained in the BoxND.
Definition AMReX_Box.H:385
__host__ __device__ bool operator>=(const BoxND &rhs) const noexcept
Return true if this box is >= rhs in the lexicographic ordering.
Definition AMReX_Box.H:350
__host__ __device__ bool sameType(const BoxND &b) const noexcept
Return true if Boxes have same type.
Definition AMReX_Box.H:319
__host__ __device__ bool operator!=(const BoxND &b) const noexcept
Return true if Boxes differ (including type).
Definition AMReX_Box.H:327
__host__ __device__ BoxND & setBig(int dir, int bg_index) noexcept
Redefine the big end of the BoxND.
Definition AMReX_Box.H:520
__host__ __device__ BoxND operator-(const IntVectND< dim > &v) const noexcept
Shift BoxND (relative) by given IntVectND<dim>.
Definition AMReX_Box.H:649
__host__ __device__ BoxND & refine(const IntVectND< dim > &ref_ratio) noexcept
Refine BoxND by given (positive) refinement ratio. NOTE: if type(dir) = CELL centered: lo <- lo*ratio...
Definition AMReX_Box.H:945
__host__ __device__ bool sameSize(const BoxND &b) const noexcept
Return true is Boxes same size, ie translates of each other,. It is an error if they have different t...
Definition AMReX_Box.H:312
__host__ __device__ IntVectND< dim > length() const noexcept
Return the length of the BoxND.
Definition AMReX_Box.H:167
__host__ __device__ GpuArray< int, 3 > hiVect3d() const noexcept
Return high-end coordinates padded to 3D (missing dims default to 0).
Definition AMReX_Box.H:196
__host__ __device__ BoxND & convert(IndexTypeND< dim > typ) noexcept
Convert the BoxND from the current type into the argument type. This may change the BoxND coordinates...
Definition AMReX_Box.H:1008
__host__ __device__ bool contains(const IntVectND< dim > &p) const noexcept
Return true if argument is contained within BoxND.
Definition AMReX_Box.H:233
__host__ __device__ int shortside(int &dir) const noexcept
Return length of shortest side. dir is modified to give direction with shortest side: 0....
Definition AMReX_Box.H:466
__host__ __device__ IntVectND< dim > size() const noexcept
Return the length of the BoxND.
Definition AMReX_Box.H:160
__host__ __device__ int operator[](Orientation face) const noexcept
Return the coordinate normal to the given face.
Definition AMReX_Box.H:216
__host__ __device__ bool strictly_contains(const Dim3 &p) const noexcept
Return true if argument is strictly contained within BoxND.
Definition AMReX_Box.H:284
__host__ __device__ BoxND & shift(int dir, int nzones) noexcept
Shift this BoxND nzones indexing positions in coordinate direction dir.
Definition AMReX_Box.H:538
BoxIteratorND< dim > iterator() const noexcept
Return a BoxIteratorND that can be used to loop over the IntVects contained by the BoxND.
Definition AMReX_Box.H:878
__host__ static __device__ constexpr std::size_t ndims() noexcept
Definition AMReX_Box.H:883
__host__ __device__ bool coarsenable(const IntVectND< dim > &refrat, const IntVectND< dim > &min_width) const noexcept
Return whether this Box is coarsenable.
Definition AMReX_Box.H:802
__host__ __device__ BoxND & setSmall(int dir, int sm_index) noexcept
Redefine the small end of the BoxND.
Definition AMReX_Box.H:512
__host__ __device__ double d_numPts() const noexcept
Return the number of points contained in the BoxND. This is intended for use only in diagnostic messa...
Definition AMReX_Box.H:405
__host__ __device__ IntVectND< dim > atOffset(Long offset) const noexcept
Given the offset, compute IntVectND<dim>
Definition AMReX_Box.H:1105
__host__ __device__ BoxND operator+(const IntVectND< dim > &v) const noexcept
Shift BoxND (relative) by given IntVectND<dim>.
Definition AMReX_Box.H:641
__host__ __device__ BoxND & grow(int idir, int n_cell) noexcept
Grow on both ends in direction idir by n_cell cells (negative shrinks).
Definition AMReX_Box.H:678
__host__ __device__ const int * loVect() const &noexcept
Return a pointer to the low-end coordinates (useful for Fortran calls).
Definition AMReX_Box.H:205
__host__ __device__ BoxND & growLo(int idir, int n_cell=1) noexcept
Grow on the low end by n_cell cells in direction idir (negative shrinks).
Definition AMReX_Box.H:690
__host__ __device__ bool contains(const BoxND &b) const noexcept
Return true if argument is contained within BoxND. It is an error if the Boxes have different types.
Definition AMReX_Box.H:259
__host__ __device__ int longside(int &dir) const noexcept
Return length of longest side. dir is modified to give direction with longest side: 0....
Definition AMReX_Box.H:440
__host__ __device__ IndexTypeND< dim > ixType() const noexcept
Return the indexing type.
Definition AMReX_Box.H:148
__host__ __device__ BoxND & growHi(int idir, int n_cell=1) noexcept
Grow on the high end by n_cell cells in direction idir (negative shrinks).
Definition AMReX_Box.H:702
__host__ __device__ bool strictly_contains(const IntVectND< dim > &p) const noexcept
Return true if argument is strictly contained within BoxND.
Definition AMReX_Box.H:267
__host__ __device__ IntVectND< dim > type() const noexcept
Return the indexing type.
Definition AMReX_Box.H:152
__host__ __device__ BoxND & growHi(Direction d, int n_cell=1) noexcept
Grow on the high end by n_cell cells in direction d (negative shrinks).
Definition AMReX_Box.H:708
__host__ __device__ BoxND & growLo(Direction d, int n_cell=1) noexcept
Grow on the low end by n_cell cells in direction d (negative shrinks).
Definition AMReX_Box.H:696
__host__ __device__ BoxND & coarsen(int ref_ratio) noexcept
Coarsen BoxND by given (positive) refinement ratio. NOTE: if type(dir) = CELL centered: lo <- lo/rati...
Definition AMReX_Box.H:754
__host__ __device__ BoxND & refine(int ref_ratio) noexcept
Refine BoxND by given (positive) refinement ratio. NOTE: if type(dir) = CELL centered: lo <- lo*ratio...
Definition AMReX_Box.H:730
__host__ __device__ BoxND & setRange(int dir, int sm_index, int n_cells=1) noexcept
Set the entire range in a given direction, starting at sm_index with length n_cells....
Definition AMReX_Box.H:1143
__host__ __device__ bool strictly_contains(int i, int j, int k) const noexcept
Return true if argument is strictly contained within BoxND.
Definition AMReX_Box.H:293
__host__ __device__ Long index(const IntVectND< dim > &v) const noexcept
Return offset of point from smallend; i.e. index(smallend) -> 0, bigend would return numPts()-1....
Definition AMReX_Box.H:1089
__host__ __device__ bool contains(int i, int j, int k) const noexcept
Return true if argument is contained within BoxND.
Definition AMReX_Box.H:248
__host__ __device__ BoxND & setType(const IndexTypeND< dim > &t) noexcept
Set indexing type.
Definition AMReX_Box.H:534
__host__ __device__ BoxND & grow(Direction d, int n_cell) noexcept
Grow on both ends in direction d by n_cell cells (negative shrinks).
Definition AMReX_Box.H:684
__host__ __device__ int longside() const noexcept
Return length of longest side. Ignores type.
Definition AMReX_Box.H:456
__host__ __device__ constexpr BoxND() noexcept
Default constructor creates an invalid box (use ok() to test).
Definition AMReX_Box.H:64
__host__ __device__ BoxND & enclosedCells() noexcept
Convert to CELL type in all directions.
Definition AMReX_Box.H:1074
__host__ __device__ GpuArray< int, 3 > atOffset3d(Long offset) const noexcept
Definition AMReX_Box.H:1133
__host__ __device__ void next(IntVectND< dim > &) const noexcept
Step through the rectangle. It is a runtime error to give a point not inside rectangle....
Definition AMReX_Box.H:1156
__host__ __device__ void normalize() noexcept
Ensure each dimension has at least one cell or node by expanding empty directions.
Definition AMReX_Box.H:849
__host__ __device__ BoxND< new_dim > shrink() const noexcept
Return a new BoxND of dimension new_dim and assigns the first new_dim dimension of this BoxND to it.
Definition AMReX_Box.H:898
__host__ __device__ BoxND & coarsen(const IntVectND< dim > &ref_ratio) noexcept
Coarsen BoxND by given (positive) refinement ratio. NOTE: if type(dir) = CELL centered: lo <- lo/rati...
Definition AMReX_Box.H:962
__host__ __device__ BoxND & shiftHalf(int dir, int num_halfs) noexcept
This member shifts the BoxND by "half" indices, thereby converting the BoxND from type CELL to NODE a...
Definition AMReX_Box.H:1237
__host__ __device__ bool operator==(const BoxND &b) const noexcept
Return true if Boxes are identical (including type).
Definition AMReX_Box.H:323
__host__ static __device__ BoxND TheUnitBox() noexcept
This static member function returns a constant reference to an object of type BoxND representing the ...
Definition AMReX_Box.H:783
__host__ __device__ int smallEnd(int dir) const &noexcept
Return the inclusive lower bound in the given direction.
Definition AMReX_Box.H:132
__host__ __device__ BoxND & convert(const IntVectND< dim > &typ) noexcept
Convert the BoxND from the current type into the argument type. This may change the BoxND coordinates...
Definition AMReX_Box.H:995
__host__ __device__ BoxND & shiftHalf(const IntVectND< dim > &iv) noexcept
Equivalent to b.shiftHalf(0,iv[0]).shiftHalf(1,iv[1]) ...
Definition AMReX_Box.H:1262
__host__ __device__ bool coarsenable(const IntVectND< dim > &refrat, int min_width=1) const noexcept
Return whether this Box is coarsenable.
Definition AMReX_Box.H:842
__host__ __device__ BoxND & enclosedCells(Direction d) noexcept
Convert to CELL type in given Direction d.
Definition AMReX_Box.H:602
__host__ __device__ bool operator<(const BoxND &rhs) const noexcept
Lexicographic ordering (type, then lower, then upper corners).
Definition AMReX_Box.H:331
__host__ __device__ bool intersects(const BoxND &b) const noexcept
Return true if Boxes have non-null intersections. It is an error if the Boxes have different types.
Definition AMReX_Box.H:305
__host__ __device__ IndexType::CellIndex type(int dir) const noexcept
Return the indexing type in the specified direction.
Definition AMReX_Box.H:156
__host__ __device__ BoxND chop(int dir, int chop_pnt) noexcept
Chop the BoxND at chop_pnt in the dir direction return one BoxND and modify the object BoxND....
Definition AMReX_Box.H:1200
__host__ __device__ bool ok() const noexcept
Return true if high bounds are >= low bounds and the index type is valid.
Definition AMReX_Box.H:229
__host__ __device__ int length(int dir) const noexcept
Return the length of the BoxND in given direction.
Definition AMReX_Box.H:174
friend class BoxCommHelper
Definition AMReX_Box.H:56
__host__ __device__ BoxND & surroundingNodes() noexcept
Convert to NODE type in all directions.
Definition AMReX_Box.H:1042
__host__ __device__ BoxND & grow(Orientation face, int n_cell=1) noexcept
Grow in the direction of the given face.
Definition AMReX_Box.H:712
__host__ __device__ BoxND operator&(const BoxND &rhs) const noexcept
Return BoxND that is intersection of this BoxND and argument. The Boxes MUST be of same type.
Definition AMReX_Box.H:609
__host__ __device__ BoxND(const IntVectND< dim > &small, const IntVectND< dim > &big, const IntVectND< dim > &typ) noexcept
Construct a box with explicit nodal/cell flags per direction.
Definition AMReX_Box.H:95
__host__ __device__ const IntVectND< dim > & smallEnd() const &noexcept
Return the inclusive lower bound of the box.
Definition AMReX_Box.H:124
__host__ __device__ bool operator>(const BoxND &rhs) const noexcept
Return true if this box is > rhs in the lexicographic ordering.
Definition AMReX_Box.H:345
__host__ __device__ BoxND & setSmall(const IntVectND< dim > &sm) noexcept
Definition AMReX_Box.H:508
__host__ __device__ bool strictly_contains(const BoxND &b) const noexcept
Return true if argument is strictly contained within BoxND. It is an error if the Boxes have differen...
Definition AMReX_Box.H:276
Cell-Based or Node-Based Indices.
Definition AMReX_IndexType.H:36
__host__ __device__ void set(int dir) noexcept
Set IndexTypeND to be NODE based in direction dir.
Definition AMReX_IndexType.H:70
__host__ __device__ void unset(int dir) noexcept
Set IndexTypeND to be CELL based in direction dir.
Definition AMReX_IndexType.H:73
An Integer Vector in dim-Dimensional Space.
Definition AMReX_IntVect.H:149
__host__ __device__ IntVectND & setVal(int i, int val) noexcept
Set i'th coordinate of IntVectND to val.
Definition AMReX_IntVect.H:373
__host__ __device__ constexpr int * begin() noexcept
Returns a pointer to the first element of the IntVectND.
Definition AMReX_IntVect.H:357
__host__ __device__ IntVectND< dim > & coarsen(const IntVectND< dim > &p) noexcept
Modify IntVectND<dim> by component-wise integer projection.
Definition AMReX_IntVect.H:941
Encapsulation of the Orientation of the Faces of a Box.
Definition AMReX_Orientation.H:29
__host__ __device__ bool isLow() const noexcept
Returns true if Orientation is low.
Definition AMReX_Orientation.H:89
__host__ __device__ int coordDir() const noexcept
Returns the coordinate direction.
Definition AMReX_Orientation.H:83
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition AMReX_Vector.H:29
amrex_long Long
Definition AMReX_INT.H:30
__host__ __device__ Dim3 ubound(Array4< T > const &a) noexcept
Return the inclusive upper bounds of an Array4 in Dim3 form.
Definition AMReX_Array4.H:1364
__host__ __device__ Dim3 length(Array4< T > const &a) noexcept
Return the spatial extents of an Array4 in Dim3 form.
Definition AMReX_Array4.H:1378
__host__ __device__ Dim3 lbound(Array4< T > const &a) noexcept
Return the inclusive lower bounds of an Array4 in Dim3 form.
Definition AMReX_Array4.H:1350
__host__ __device__ BoxND< dim > adjCellHi(const BoxND< dim > &b, int dir, int len=1) noexcept
Return the BoxND of length len adjacent to b on the high end along coordinate direction dir.
Definition AMReX_Box.H:1848
__host__ __device__ BoxND< dim > makeSingleCellBox(int i, int j, int k, IndexTypeND< dim > typ=IndexTypeND< dim >::TheCellType())
Create a single-cell box at coordinates (i,j,k).
Definition AMReX_Box.H:2458
__host__ __device__ BoxND< dim > convert(const BoxND< dim > &b, const IntVectND< dim > &typ) noexcept
Return a copy of b converted to the nodal flags typ.
Definition AMReX_Box.H:1630
__host__ __device__ BoxND< dim > adjCellLo(const BoxND< dim > &b, int dir, int len=1) noexcept
Return the BoxND of length len adjacent to b on the low end along coordinate direction dir.
Definition AMReX_Box.H:1817
__host__ __device__ BoxND< dim > surroundingNodes(const BoxND< dim > &b, int dir) noexcept
Return a BoxND with NODE based coordinates in direction dir that encloses BoxND b.
Definition AMReX_Box.H:1582
__host__ __device__ BoxND< dim > bdryLo(const BoxND< dim > &b, int dir, int len=1) noexcept
Return the BoxND of length len on the low boundary of b along coordinate direction dir.
Definition AMReX_Box.H:1715
__host__ __device__ BoxND< dim > minBox(const BoxND< dim > &b1, const BoxND< dim > &b2) noexcept
Return the minimal BoxND containing both b1 and b2.
Definition AMReX_Box.H:1921
__host__ __device__ BoxND< dim > coarsen(const BoxND< dim > &b, int ref_ratio) noexcept
Return a copy of b coarsened by the isotropic ratio ref_ratio.
Definition AMReX_Box.H:1469
__host__ __device__ BoxND< dim > adjCell(const BoxND< dim > &b, Orientation face, int len=1) noexcept
Similar to adjCellLo and adjCellHi except that it operates on the given face of BoxND b.
Definition AMReX_Box.H:1880
__host__ __device__ BoxND< dim > shift(const BoxND< dim > &b, int dir, int nzones) noexcept
Return a copy of b shifted by nzones cells in direction dir.
Definition AMReX_Box.H:1548
__host__ __device__ BoxND< dim > enclosedCells(const BoxND< dim > &b, int dir) noexcept
Return a BoxND with CELL based coordinates in direction dir that is enclosed by b.
Definition AMReX_Box.H:1664
__host__ __device__ BoxND< dim > bdryNode(const BoxND< dim > &b, Orientation face, int len=1) noexcept
Similar to bdryLo and bdryHi except that it operates on the given face of BoxND b.
Definition AMReX_Box.H:1776
__host__ __device__ BoxND< dim > growLo(const BoxND< dim > &b, int idir, int n_cell) noexcept
Return a copy of b with the low end grown by n_cell cells in direction idir.
Definition AMReX_Box.H:1398
__host__ __device__ BoxND< dim > grow(const BoxND< dim > &b, int i) noexcept
Return a copy of b grown uniformly by i cells in every direction.
Definition AMReX_Box.H:1326
__host__ __device__ BoxND< dim > refine(const BoxND< dim > &b, int ref_ratio) noexcept
Return a copy of b refined by the isotropic ratio ref_ratio.
Definition AMReX_Box.H:1510
__host__ __device__ BoxND< dim > bdryHi(const BoxND< dim > &b, int dir, int len=1) noexcept
Return the BoxND of length len on the high boundary of b along coordinate direction dir.
Definition AMReX_Box.H:1745
__host__ __device__ BoxND< dim > growHi(const BoxND< dim > &b, int idir, int n_cell) noexcept
Return a copy of b with the high end grown by n_cell cells in direction idir.
Definition AMReX_Box.H:1433
__host__ __device__ constexpr const T & min(const T &a, const T &b) noexcept
Definition AMReX_Algorithm.H:31
__host__ __device__ constexpr const T & max(const T &a, const T &b) noexcept
Definition AMReX_Algorithm.H:53
int MPI_Datatype
Definition AMReX_ccse-mpi.H:53
Definition AMReX_Amr.cpp:50
std::ostream & operator<<(std::ostream &os, AmrMesh const &amr_mesh)
Stream helper; forwards to the friend declared inside AmrMesh.
Definition AMReX_AmrMesh.cpp:1306
__host__ __device__ BoxND< dim > makeSlab(BoxND< dim > const &b, int direction, int slab_index) noexcept
Return a copy of b collapsed to a slab perpendicular to direction.
Definition AMReX_Box.H:2436
__host__ __device__ constexpr GpuTuple< detail::tuple_decay_t< Ts >... > makeTuple(Ts &&... args)
Definition AMReX_Tuple.H:269
__host__ __device__ IntVectND< dim > end_iv(BoxND< dim > const &box) noexcept
Return the iterator end IntVectND for box.
Definition AMReX_Box.H:2112
__host__ __device__ Dim3 begin(BoxND< dim > const &box) noexcept
Return the iterator begin coordinate of box as Dim3.
Definition AMReX_Box.H:2239
__host__ __device__ IntVectND< dim > lbound_iv(BoxND< dim > const &box) noexcept
Return the inclusive lower corner of box as an IntVectND.
Definition AMReX_Box.H:2065
__host__ __device__ Dim3 min_ubound(BoxND< dim > const &b1, BoxND< dim > const &b2) noexcept
Return the Dim3 minimum of the upper corners of two boxes.
Definition AMReX_Box.H:2324
__host__ __device__ constexpr GpuTuple< IntVectND< d >, IntVectND< dims >... > IntVectSplit(const IntVectND< detail::get_sum< d, dims... >()> &v) noexcept
Returns a tuple of IntVectND obtained by splitting the input IntVectND according to the dimensions sp...
Definition AMReX_IntVect.H:1288
__host__ __device__ IntVectND< dim > min_ubound_iv(BoxND< dim > const &b1, BoxND< dim > const &b2) noexcept
Return the component-wise minimum of the upper corners of two boxes.
Definition AMReX_Box.H:2175
void AllGatherBoxes(Vector< Box > &bxs, int n_extra_reserve)
Gather boxes from all MPI ranks into bxs.
Definition AMReX_Box.cpp:124
BoxND< 3 > Box
Box is an alias for amrex::BoxND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:35
__host__ __device__ constexpr BoxND< new_dim > BoxResize(const BoxND< old_dim > &bx) noexcept
Resize bx to new_dim directions via shrink or expand.
Definition AMReX_Box.H:2051
__host__ __device__ Dim3 max_lbound(BoxND< dim > const &b1, BoxND< dim > const &b2) noexcept
Return the Dim3 maximum of the lower corners of two boxes.
Definition AMReX_Box.H:2290
__host__ __device__ IntVectND< dim > begin_iv(BoxND< dim > const &box) noexcept
Return the iterator begin IntVectND for box.
Definition AMReX_Box.H:2095
__host__ __device__ constexpr BoxND< new_dim > BoxShrink(const BoxND< old_dim > &bx) noexcept
Shrink bx to its first new_dim directions.
Definition AMReX_Box.H:2021
__host__ __device__ constexpr IndexTypeND< detail::get_sum< d, dims... >()> IndexTypeCat(const IndexTypeND< d > &v, const IndexTypeND< dims > &...vects) noexcept
Returns a IndexTypeND obtained by concatenating the input IndexTypeNDs. The dimension of the return v...
Definition AMReX_IndexType.H:293
__host__ __device__ IntVectND< dim > length_iv(BoxND< dim > const &box) noexcept
Return the side lengths of box as an IntVectND.
Definition AMReX_Box.H:2127
Direction
Definition AMReX_Orientation.H:14
__host__ __device__ constexpr BoxND< detail::get_sum< d, dims... >()> BoxCat(const BoxND< d > &bx, const BoxND< dims > &...boxes) noexcept
Concatenate boxes along their dimensions.
Definition AMReX_Box.H:1987
__host__ __device__ IntVectND< dim > ubound_iv(BoxND< dim > const &box) noexcept
Return the inclusive upper corner of box as an IntVectND.
Definition AMReX_Box.H:2080
__host__ __device__ constexpr BoxND< new_dim > BoxExpand(const BoxND< old_dim > &bx) noexcept
Expand bx to new_dim directions, padding with zeros.
Definition AMReX_Box.H:2037
__host__ __device__ IntVectND< dim > getCell(BoxND< dim > const *boxes, int nboxes, Long icell) noexcept
Return the point coordinate corresponding to the flattened index icell.
Definition AMReX_Box.H:2408
const int[]
Definition AMReX_BLProfiler.cpp:1664
std::istream & operator>>(std::istream &is, BoxND< dim > &bx)
Read a BoxND from is.
Definition AMReX_Box.H:1965
__host__ __device__ constexpr IntVectND< detail::get_sum< d, dims... >()> IntVectCat(const IntVectND< d > &v, const IntVectND< dims > &...vects) noexcept
Returns a IntVectND obtained by concatenating the input IntVectNDs. The dimension of the return value...
Definition AMReX_IntVect.H:1272
__host__ __device__ Dim3 end(BoxND< dim > const &box) noexcept
Return the iterator end coordinate of box as Dim3.
Definition AMReX_Box.H:2257
BoxND< dim > getIndexBounds(BoxND< dim > const &b1) noexcept
Definition AMReX_Box.H:2349
__host__ __device__ constexpr GpuTuple< BoxND< d >, BoxND< dims >... > BoxSplit(const BoxND< detail::get_sum< d, dims... >()> &bx) noexcept
Split bx into boxes whose dimensions match the template arguments.
Definition AMReX_Box.H:2004
__host__ __device__ constexpr GpuTuple< IndexTypeND< d >, IndexTypeND< dims >... > IndexTypeSplit(const IndexTypeND< detail::get_sum< d, dims... >()> &v) noexcept
Returns a tuple of IndexTypeND obtained by splitting the input IndexTypeND according to the dimension...
Definition AMReX_IndexType.H:313
__host__ __device__ IntVectND< dim > max_lbound_iv(BoxND< dim > const &b1, BoxND< dim > const &b2) noexcept
Return the component-wise maximum of the lower corners of two boxes.
Definition AMReX_Box.H:2143
A multidimensional array accessor.
Definition AMReX_Array4.H:288
IntVectND< N > end
Exclusive upper bounds.
Definition AMReX_Array4.H:302
IntVectND< N > begin
Inclusive lower bounds.
Definition AMReX_Array4.H:301
BoxIndexerND(BoxND< 1 > const &box)
Construct the 1D indexer; no fast divisors are needed because only one axis exists.
Definition AMReX_Box.H:2570
std::uint64_t npts
Definition AMReX_Box.H:2561
__host__ __device__ std::uint64_t numPts() const
Return the number of points covered by the indexed box.
Definition AMReX_Box.H:2605
__host__ __device__ IntVectND< 1 > intVect(std::uint64_t icell) const
Convert flattened point index icell to the 1D coordinate.
Definition AMReX_Box.H:2582
int lo
Definition AMReX_Box.H:2563
Utility that maps flattened point indices back to IntVectND coordinates.
Definition AMReX_Box.H:2494
__host__ __device__ IntVectND< dim > intVect(std::uint64_t icell) const
Convert flattened point index icell to its IntVectND coordinate.
Definition AMReX_Box.H:2517
BoxIndexerND(BoxND< dim > const &box)
Definition AMReX_Box.H:2499
IntVectND< dim > lo
Definition AMReX_Box.H:2497
__host__ __device__ std::uint64_t numPts() const
Return the number of points covered by the indexed box.
Definition AMReX_Box.H:2552
Math::FastDivmodU64 fdm[dim-1]
Definition AMReX_Box.H:2496
__host__ __device__ Dim3 operator()(std::uint64_t icell) const
Functor returning the coordinate padded to Dim3.
Definition AMReX_Box.H:2540
std::uint64_t npts
Definition AMReX_Box.H:2495
CellIndex
The cell index type: one of CELL or NODE.
Definition AMReX_IndexType.H:21
@ CELL
Definition AMReX_IndexType.H:21
A simple struct holding 3 int values for a 3D index.
Definition AMReX_Dim3.H:24
int x
Definition AMReX_Dim3.H:24
int z
Definition AMReX_Dim3.H:24
int y
Definition AMReX_Dim3.H:24
Fixed-size array that can be used on GPU.
Definition AMReX_Array.H:52
Definition AMReX_Math.H:493
static MPI_Datatype type()