#include <Box.H>
Public Member Functions | |
Box () | |
The default constructor. | |
Box (const IntVect &small, const IntVect &big) | |
Construct cell-centered type Box. | |
Box (const IntVect &small, const int *vec_len) | |
Construct box with specified lengths. | |
Box (const IntVect &small, const IntVect &big, const IntVect &typ) | |
Construct Box with given type. | |
Box (const IntVect &small, const IntVect &big, const IndexType &t) | |
Construct dimension specific Boxes. | |
const IntVect & | smallEnd () const |
Get the smallend of the box. | |
int | smallEnd (int dir) const |
Return the coordinate of the low end in the given direction. | |
const IntVect & | bigEnd () const |
Get the bigend. | |
int | bigEnd (int dir) const |
Return the coordinate of the high end in the given direction. | |
IndexType | ixType () const |
Return the indexing type. | |
IntVect | type () const |
Return the indexing type. | |
IndexType::CellIndex | type (int dir) const |
Return the indexing type in the specified direction. | |
const IntVect & | length () const |
Return the length of the Box. | |
int | length (int dir) const |
Return the length of the Box in given direction. | |
const int * | loVect () const |
Returns a constant pointer the array of low end coordinates. | |
const int * | hiVect () const |
Returns a constant pointer the array of high end coordinates. | |
const int * | getVect () const |
Returns a constant pointer to the array of coordinates in the Box. | |
int | operator[] (const Orientation &face) const |
Returns the coordinate normal to given face. | |
bool | isEmpty () const |
Checks if it is a proper box (including a valid type). | |
bool | ok () const |
Checks if it is a proper Box (including a valid type). | |
bool | contains (const IntVect &p) const |
Returns true if argument is contained within Box. | |
bool | contains (const Box &b) const |
Returns true if argument is contained within Box. | |
bool | intersects (const Box &b) const |
Returns true if Boxes have non-null intersections. | |
bool | sameSize (const Box &b) const |
Returns true is Boxes same size, ie translates of each other,. | |
bool | sameType (const Box &b) const |
Returns true if Boxes have same type. | |
bool | operator== (const Box &b) const |
Returns true if Boxes are identical (including type). | |
bool | operator!= (const Box &b) const |
Returns true if Boxes differ (including type). | |
bool | cellCentered () const |
Returns true if Box is cell-centered in all indexing directions. | |
bool | numPtsOK () const |
Is the number calculated by numPts() representable in a long? | |
long | numPts () const |
Returns the number of points contained in the Box, else abort()s if the number cannot be represented in a long. | |
bool | volumeOK () const |
Is the number calculated by volume() representable in a long? | |
long | volume () const |
Return the volume, in indexing space, of region enclosed by this Box. | |
int | longside (int &dir) const |
Returns length of longest side. | |
int | longside () const |
Returns length of longest side. Ignores type. | |
int | shortside (int &dir) const |
Returns length of shortest side. | |
int | shortside () const |
Returns length of shortest side. Ignores type. | |
long | index (const IntVect &v) const |
Returns offset of point from smallend; i.e. | |
Box & | setSmall (const IntVect &sm) |
Redefine the small end of the Box. | |
Box & | setSmall (int dir, int sm_index) |
Redefine the small end of the Box. | |
Box & | setBig (const IntVect &bg) |
Redefine the big end of the Box. | |
Box & | setBig (int dir, int bg_index) |
Redefine the big end of the Box. | |
Box & | setRange (int dir, int sm_index, int n_cells=1) |
Set the entire range in a given direction, starting at sm with length n. | |
Box & | shift (int dir, int nzones) |
Shift this Box nzones indexing positions in coordinate direction dir. | |
Box & | shift (const IntVect &iv) |
Equivalent to b.shift(0,iv[0]).shift(1,iv[1]) .... | |
Box & | shiftHalf (int dir, int num_halfs) |
This member shifts the Box by "half" indicies, thereby converting the Box from type CELL to NODE and visa-versa. | |
Box & | shiftHalf (const IntVect &iv) |
Equivalent to b.shiftHalf(0,iv[0]).shiftHalf(1,iv[1]) ... | |
Box & | convert (IndexType typ) |
Convert the Box from the current type into the argument type. | |
Box & | convert (const IntVect &typ) |
Convert the Box from the current type into the argument type. | |
Box & | surroundingNodes () |
Convert to NODE type in all directions. | |
Box & | surroundingNodes (int dir) |
Convert to NODE type in given direction. | |
Box & | enclosedCells () |
Convert to CELL type in all directions. | |
Box & | enclosedCells (int dir) |
Convert to CELL type in given direction. | |
Box | operator & (const Box &) const |
Return Box that is intersection of this Box and argument. | |
Box & | operator &= (const Box &) |
Intersect this Box with its argument. | |
Box & | minBox (const Box &) |
Modify Box to that of the minimum Box containing both the original Box and the argument. | |
Box & | operator+= (const IntVect &v) |
Shift Box (relative) by given IntVect. | |
Box | operator+ (const IntVect &v) const |
Shift Box (relative) by given IntVect. | |
Box & | operator-= (const IntVect &v) |
Shift Box (relative) by given IntVect. | |
Box | operator- (const IntVect &v) const |
Shift Box (relative) by given IntVect. | |
Box | chop (int dir, int chop_pnt) |
Chop the Box at the chop in the dir direction returns one Box, modifies the object Box. | |
Box & | grow (int i) |
Grow Box in all directions by given amount. | |
Box & | grow (const IntVect &v) |
Grow Box in each direction by specified amount. | |
Box & | grow (int idir, int n_cell) |
Grow the Box on the low and high end by n cells in direction idir. | |
Box & | growLo (int idir, int n_cell=1) |
Grow the Box on the low end by n cells in direction idir. | |
Box & | growHi (int idir, int n_cell=1) |
Grow the Box on the high end by n cells in direction idir. | |
Box & | grow (const Orientation &face, int n_cell=1) |
Grow in the direction of the given face. | |
Box & | refine (int refinement_ratio) |
Refine Box by given (positive) refinement ratio. | |
Box & | refine (const IntVect &refinement_ratio) |
Refine Box by given (positive) refinement ratio. | |
Box & | coarsen (int refinement_ratio) |
Coarsen Box by given (positive) refinement ratio. | |
Box & | coarsen (const IntVect &refinement_ratio) |
Coarsen Box by given (positive) refinement ratio. | |
void | next (IntVect &) const |
Step through the rectangle. | |
void | next (IntVect &p, const int *shv) const |
Scan argument IntVect over object second arg is increment vector. | |
Static Public Member Functions | |
static const Box & | TheUnitBox () |
This static member function returns a constant reference to an object of type Box representing the unit box in BL-dimensional space. | |
Protected Member Functions | |
bool | numPtsOK (long &N) const |
bool | volumeOK (long &N) const |
Protected Attributes | |
IntVect | smallend |
IntVect | bigend |
IntVect | len |
IndexType | btype |
Friends | |
MPI_Datatype | ParallelDescriptor::Mpi_typemap () |
A Box is an abstraction for defining discrete regions of SPACEDIM indexing space. Boxes have an IndexType, which defines IndexType::CELL or IndexType::NODE based points for each direction and a low and high INTVECT which defines the lower and upper corners of the Box. Boxes can exist in positive and negative indexing space.
Box is a dimension dependent class, so SPACEDIM must be defined as either 1, 2, or 3 when compiling.
For historical reasons, BOX is synonomous with Box. That usage is deprecated, however.
Box::Box | ( | ) |
The default constructor.
For safety, the constructed Box is invalid and may be tested for validity with ok().
Referenced by chop(), and operator>>().
Box::Box | ( | const IntVect & | small, | |
const int * | vec_len | |||
) |
Construct box with specified lengths.
Construct Box with given type.
small and big are expected to be consistent with given type.
References BL_ASSERT, IntVect::TheUnitVector(), and IntVect::TheZeroVector().
Construct dimension specific Boxes.
const IntVect & Box::smallEnd | ( | ) | const [inline] |
Get the smallend of the box.
References smallend.
Referenced by BoxLib::adjCell(), BoxLib::adjCellHi(), BoxLib::adjCellLo(), BoxLib::bdryHi(), BoxLib::bdryLo(), BoxLib::bdryNode(), CommData::CommData(), BaseFab< T >::maxIndex(), BaseFab< T >::minIndex(), operator<<(), and BaseFab< T >::smallEnd().
int Box::smallEnd | ( | int | dir | ) | const [inline] |
const IntVect & Box::bigEnd | ( | ) | const [inline] |
Get the bigend.
References bigend.
Referenced by BoxLib::adjCell(), BoxLib::adjCellHi(), BoxLib::adjCellLo(), BoxLib::bdryHi(), BoxLib::bdryLo(), BoxLib::bdryNode(), BaseFab< T >::bigEnd(), CommData::CommData(), and operator<<().
int Box::bigEnd | ( | int | dir | ) | const [inline] |
IndexType Box::ixType | ( | ) | const [inline] |
Return the indexing type.
References btype.
Referenced by BoxDomain::add(), FabArrayCopyDescriptor< FAB >::AddBox(), BoxLib::adjCell(), BoxLib::adjCellHi(), BoxLib::adjCellLo(), BoxLib::bdryHi(), BoxLib::bdryLo(), BoxLib::bdryNode(), BoxLib::boxDiff(), BoxLib::complementIn(), BoxLib::linInterpAddBox(), BoxList::push_back(), BoxList::push_front(), BoxList::remove(), and BoxDomain::rmBox().
IntVect Box::type | ( | ) | const [inline] |
Return the indexing type.
References btype, and IndexType::ixType().
Referenced by BoxLib::adjCell(), BoxLib::adjCellHi(), BoxLib::bdryHi(), BoxLib::bdryNode(), CommData::CommData(), and operator<<().
IndexType::CellIndex Box::type | ( | int | dir | ) | const [inline] |
const IntVect & Box::length | ( | ) | const [inline] |
Return the length of the Box.
References bigend, len, and smallend.
Referenced by index(), BaseFab< T >::length(), longside(), numPtsOK(), BaseFab< T >::performCopy(), sameSize(), shortside(), and volumeOK().
int Box::length | ( | int | dir | ) | const [inline] |
const int * Box::loVect | ( | ) | const [inline] |
Returns a constant pointer the array of low end coordinates.
Useful for calls to FORTRAN.
References IntVect::getVect(), and smallend.
Referenced by BoxLib::boxDiff(), BaseFab< T >::loVect(), and BaseFab< T >::performCopy().
const int * Box::hiVect | ( | ) | const [inline] |
Returns a constant pointer the array of high end coordinates.
Useful for calls to FORTRAN.
References bigend, and IntVect::getVect().
Referenced by BoxLib::boxDiff(), and BaseFab< T >::hiVect().
const int * Box::getVect | ( | ) | const [inline] |
Returns a constant pointer to the array of coordinates in the Box.
Useful for fortran, but otherwise too dangerous for use.
References IntVect::getVect(), and smallend.
int Box::operator[] | ( | const Orientation & | face | ) | const [inline] |
Returns the coordinate normal to given face.
References bigend, Orientation::coordDir(), Orientation::isLow(), and smallend.
bool Box::isEmpty | ( | ) | const [inline] |
bool Box::ok | ( | ) | const [inline] |
Checks if it is a proper Box (including a valid type).
References bigend, btype, IndexType::ok(), and smallend.
Referenced by FabArrayCopyDescriptor< FAB >::AddBoxDoIt(), MultiFab::Copy(), BaseFab< T >::copy(), intersects(), MultiFab::invert(), MultiFab::max(), MultiFab::min(), minBox(), MultiFab::mult(), MultiFab::negate(), numPtsOK(), BoxArray::ok(), BaseFab< T >::performCopy(), MultiFab::plus(), FabArray< FAB >::setVal(), and volumeOK().
bool Box::contains | ( | const IntVect & | p | ) | const [inline] |
Returns true if argument is contained within Box.
References bigend, and smallend.
Referenced by BoxLib::boxDiff(), BaseFab< T >::contains(), BaseFab< T >::copy(), next(), BaseFab< T >::operator()(), BaseFab< T >::performCopy(), and BaseFab< T >::performSetVal().
bool Box::contains | ( | const Box & | b | ) | const [inline] |
Returns true if argument is contained within Box.
It is an error if the Boxes have different types.
References bigend, BL_ASSERT, sameType(), and smallend.
bool Box::intersects | ( | const Box & | b | ) | const |
Returns true if Boxes have non-null intersections.
It is an error if the Boxes have different types.
References ok().
Referenced by BoxLib::boxDiff(), and FabArray< FAB >::copy().
bool Box::sameSize | ( | const Box & | b | ) | const [inline] |
Returns true is Boxes same size, ie translates of each other,.
It is an error if they have different types.
References BL_ASSERT, length(), and sameType().
Referenced by BaseFab< T >::copy(), FabArrayCopyDescriptor< FAB >::FillFab(), and BaseFab< T >::performCopy().
bool Box::sameType | ( | const Box & | b | ) | const [inline] |
Returns true if Boxes have same type.
References btype.
Referenced by contains(), BaseFab< T >::copy(), minBox(), BoxArray::ok(), operator &=(), and sameSize().
bool Box::operator== | ( | const Box & | b | ) | const [inline] |
Returns true if Boxes are identical (including type).
References bigend, btype, and smallend.
Referenced by operator!=().
bool Box::operator!= | ( | const Box & | b | ) | const [inline] |
bool Box::cellCentered | ( | ) | const [inline] |
Returns true if Box is cell-centered in all indexing directions.
References IndexType::any(), and btype.
bool Box::numPtsOK | ( | ) | const [inline] |
long Box::numPts | ( | ) | const |
Returns the number of points contained in the Box, else abort()s if the number cannot be represented in a long.
References BoxLib::Error(), and numPtsOK().
Referenced by BaseFab< T >::BaseFab(), FabArrayCopyDescriptor< FAB >::CollectData(), FabArray< FAB >::copy(), BaseFab< T >::getVal(), isEmpty(), BaseFab< T >::operator=(), and BaseFab< T >::resize().
bool Box::volumeOK | ( | ) | const |
long Box::volume | ( | ) | const |
Return the volume, in indexing space, of region enclosed by this Box.
This is identical to numPts() for CELL centered Box; i.e. consider a edge-based box in 2D which has two edges in it. This box has one cell center, located between the two edges. numPts() would return 2 as would volume(). Otherwise, numPts() >= volume(). Abort()s if the number cannot be represented in a long.
References BoxLib::Error(), and volumeOK().
int Box::longside | ( | int & | dir | ) | const |
Returns length of longest side.
dir is modified to give direction with longest side: 0...SPACEDIM-1. Ignores type.
References length().
int Box::longside | ( | ) | const |
Returns length of longest side. Ignores type.
int Box::shortside | ( | int & | dir | ) | const |
Returns length of shortest side.
dir is modified to give direction with shortest side: 0...SPACEDIM-1. Ignores type.
References length().
int Box::shortside | ( | ) | const |
Returns length of shortest side. Ignores type.
long Box::index | ( | const IntVect & | v | ) | const |
Returns offset of point from smallend; i.e.
index(smallend) -> 0, bigend would return volume()-1. Is used in accessing FArrayBox.
References length(), and smallend.
Referenced by BaseFab< T >::getVal(), and BaseFab< T >::operator()().
Box & Box::setSmall | ( | int | dir, | |
int | sm_index | |||
) |
Box & Box::setBig | ( | int | dir, | |
int | bg_index | |||
) |
Box & Box::setRange | ( | int | dir, | |
int | sm_index, | |||
int | n_cells = 1 | |||
) |
Set the entire range in a given direction, starting at sm with length n.
NOTE: This will yield an illegal Box if n <= 0.
References bigend, IntVect::setVal(), and smallend.
Box & Box::shift | ( | int | dir, | |
int | nzones | |||
) |
Shift this Box nzones indexing positions in coordinate direction dir.
References bigend, IntVect::shift(), and smallend.
Referenced by BaseFab< T >::shift().
Equivalent to b.shift(0,iv[0]).shift(1,iv[1]) ....
References bigend, IntVect::shift(), and smallend.
Box & Box::shiftHalf | ( | int | dir, | |
int | num_halfs | |||
) |
This member shifts the Box by "half" indicies, thereby converting the Box from type CELL to NODE and visa-versa.
b.shiftHalf(0,1) shifts b to the right by 1/2 cells. b.shiftHalf(1,-3) shifts b in the -j direction by 3/2 cells. NOTE: If num is EVEN the shift is num/2 full zones and hence will not change the type. This is: b.shifthalf(4) == b.shift(2).
References bigend, btype, IndexType::flip(), IntVect::shift(), and smallend.
Referenced by shiftHalf(), and BaseFab< T >::shiftHalf().
Convert the Box from the current type into the argument type.
This may change the Box coordinates: type CELL -> NODE : increase coordinate by one on high end type NODE -> CELL : reduce coordinate by one on high end other type mappings make no change.
References bigend, btype, IndexType::setType(), and IntVect::shift().
Convert the Box from the current type into the argument type.
This may change the Box coordinates: type CELL -> NODE : increase coordinate by one on high end type NODE -> CELL : reduce coordinate by one on high end other type mappings make no change.
References bigend, BL_ASSERT, btype, IndexType::ixType(), IntVect::TheUnitVector(), and IntVect::TheZeroVector().
Box & Box::surroundingNodes | ( | ) |
Convert to NODE type in all directions.
References bigend, btype, IndexType::setall(), and IntVect::shift().
Referenced by BoxLib::surroundingNodes().
Box & Box::surroundingNodes | ( | int | dir | ) |
Convert to NODE type in given direction.
References bigend, btype, IndexType::set(), and IntVect::shift().
Box & Box::enclosedCells | ( | ) |
Convert to CELL type in all directions.
References bigend, btype, IndexType::clear(), and IntVect::shift().
Referenced by BoxLib::enclosedCells().
Box & Box::enclosedCells | ( | int | dir | ) |
Convert to CELL type in given direction.
References bigend, btype, IntVect::shift(), and IndexType::unset().
Intersect this Box with its argument.
The Boxes MUST be of the same type.
References bigend, BL_ASSERT, btype, IntVect::max(), IntVect::min(), sameType(), and smallend.
Modify Box to that of the minimum Box containing both the original Box and the argument.
Both Boxes must have identical type.
References bigend, BL_ASSERT, IntVect::max(), IntVect::min(), ok(), sameType(), and smallend.
Referenced by BoxLib::minBox(), BoxList::minimalBox(), and BoxArray::minimalBox().
Box Box::chop | ( | int | dir, | |
int | chop_pnt | |||
) |
Chop the Box at the chop in the dir direction returns one Box, modifies the object Box.
The union of the two is the original Box. The modified Box is the low end, the returned Box is the high end. If type(dir) = CELL, the Boxes are disjoint with the chop included in the high end (new Box). It is an ERROR if chop is the low end of the orig Box. If type(dir) = NODE, the chop is included in both Boxes but is the only point in common. It is also an error if the chop is an end node of the Box.
References bigend, BL_ASSERT, Box(), btype, IntVect::setVal(), and smallend.
Box & Box::grow | ( | int | i | ) |
Grow Box in all directions by given amount.
NOTE: n negative shrinks the Box by that number of cells.
References bigend, IntVect::diagShift(), and smallend.
Referenced by BoxLib::grow().
Box & Box::grow | ( | int | idir, | |
int | n_cell | |||
) |
Grow the Box on the low and high end by n cells in direction idir.
References bigend, IntVect::shift(), and smallend.
Box & Box::growLo | ( | int | idir, | |
int | n_cell = 1 | |||
) |
Grow the Box on the low end by n cells in direction idir.
NOTE: n negative shrinks the Box by that number of cells.
References IntVect::shift(), and smallend.
Box & Box::growHi | ( | int | idir, | |
int | n_cell = 1 | |||
) |
Grow the Box on the high end by n cells in direction idir.
NOTE: n negative shrinks the Box by that number of cells.
References bigend, and IntVect::shift().
Box & Box::grow | ( | const Orientation & | face, | |
int | n_cell = 1 | |||
) |
Grow in the direction of the given face.
References bigend, Orientation::coordDir(), Orientation::isLow(), IntVect::shift(), and smallend.
Box & Box::refine | ( | int | refinement_ratio | ) |
Refine Box by given (positive) refinement ratio.
NOTE: if type(dir) = CELL centered: lo <- lo*ratio and hi <- (hi+1)*ratio - 1. NOTE: if type(dir) = NODE centered: lo <- lo*ratio and hi <- hi*ratio.
References bigend, btype, IndexType::ixType(), IntVect::scale(), smallend, and IntVect::TheUnitVector().
Referenced by BoxLib::refine().
Refine Box by given (positive) refinement ratio.
NOTE: if type(dir) = CELL centered: lo <- lo*ratio and hi <- (hi+1)*ratio - 1. NOTE: if type(dir) = NODE centered: lo <- lo*ratio and hi <- hi*ratio.
References bigend, btype, IndexType::ixType(), smallend, and IntVect::TheUnitVector().
Box & Box::coarsen | ( | int | refinement_ratio | ) |
Coarsen Box by given (positive) refinement ratio.
NOTE: if type(dir) = CELL centered: lo <- lo/ratio and hi <- hi/ratio. NOTE: if type(dir) = NODE centered: lo <- lo/ratio and hi <- hi/ratio + ((hiratio)==0 ? 0 : 1). That is, refinement of coarsened Box must contain the original Box.
References IndexType::any(), bigend, btype, IntVect::coarsen(), IntVect::setVal(), smallend, and IntVect::TheZeroVector().
Referenced by BoxLib::coarsen().
Coarsen Box by given (positive) refinement ratio.
NOTE: if type(dir) = CELL centered: lo <- lo/ratio and hi <- hi/ratio. NOTE: if type(dir) = NODE centered: lo <- lo/ratio and hi <- hi/ratio + ((hiratio)==0 ? 0 : 1). That is, refinement of coarsened Box must contain the original Box.
References IndexType::any(), bigend, btype, IntVect::coarsen(), IntVect::setVal(), smallend, and IntVect::TheZeroVector().
void Box::next | ( | IntVect & | p | ) | const |
Step through the rectangle.
It is a runtime error to give a point not inside rectangle. Iteration may not be efficient.
References bigend, BL_ASSERT, contains(), IntVect::setVal(), IntVect::shift(), and smallend.
void Box::next | ( | IntVect & | p, | |
const int * | shv | |||
) | const |
Scan argument IntVect over object second arg is increment vector.
Runtime error if IntVect is not contained in object Box. Iteration may not be efficient.
References bigend, BL_ASSERT, contains(), IntVect::setVal(), IntVect::shift(), and smallend.
const Box & Box::TheUnitBox | ( | ) | [static] |
This static member function returns a constant reference to an object of type Box representing the unit box in BL-dimensional space.
References IntVect::TheZeroVector().
bool Box::numPtsOK | ( | long & | N | ) | const [protected] |
References BL_ASSERT, length(), BoxLib::max(), and ok().
bool Box::volumeOK | ( | long & | N | ) | const [protected] |
References BL_ASSERT, btype, length(), BoxLib::max(), and ok().
MPI_Datatype ParallelDescriptor::Mpi_typemap | ( | ) | [friend] |
IntVect Box::smallend [protected] |
Referenced by chop(), coarsen(), contains(), getVect(), grow(), growLo(), index(), length(), loVect(), minBox(), next(), ok(), operator &=(), operator+=(), operator-=(), operator==(), operator[](), refine(), setRange(), setSmall(), shift(), shiftHalf(), and smallEnd().
IntVect Box::bigend [protected] |
Referenced by bigEnd(), chop(), coarsen(), contains(), convert(), enclosedCells(), grow(), growHi(), hiVect(), length(), minBox(), next(), ok(), operator &=(), operator+=(), operator-=(), operator==(), operator[](), refine(), setBig(), setRange(), shift(), shiftHalf(), and surroundingNodes().
IndexType Box::btype [protected] |
Referenced by cellCentered(), chop(), coarsen(), convert(), enclosedCells(), ixType(), ok(), operator &=(), operator==(), refine(), sameType(), shiftHalf(), surroundingNodes(), type(), and volumeOK().