Box Class Reference

: A Rectangular Domain on an Integer Lattice More...

#include <Box.H>

Collaboration diagram for Box:

Collaboration graph
[legend]

List of all members.

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 IntVectsmallEnd () const
 Get the smallend of the box.
int smallEnd (int dir) const
 Return the coordinate of the low end in the given direction.
const IntVectbigEnd () 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 IntVectlength () 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.
BoxsetSmall (const IntVect &sm)
 Redefine the small end of the Box.
BoxsetSmall (int dir, int sm_index)
 Redefine the small end of the Box.
BoxsetBig (const IntVect &bg)
 Redefine the big end of the Box.
BoxsetBig (int dir, int bg_index)
 Redefine the big end of the Box.
BoxsetRange (int dir, int sm_index, int n_cells=1)
 Set the entire range in a given direction, starting at sm with length n.
Boxshift (int dir, int nzones)
 Shift this Box nzones indexing positions in coordinate direction dir.
Boxshift (const IntVect &iv)
 Equivalent to b.shift(0,iv[0]).shift(1,iv[1]) ....
BoxshiftHalf (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.
BoxshiftHalf (const IntVect &iv)
 Equivalent to b.shiftHalf(0,iv[0]).shiftHalf(1,iv[1]) ...
Boxconvert (IndexType typ)
 Convert the Box from the current type into the argument type.
Boxconvert (const IntVect &typ)
 Convert the Box from the current type into the argument type.
BoxsurroundingNodes ()
 Convert to NODE type in all directions.
BoxsurroundingNodes (int dir)
 Convert to NODE type in given direction.
BoxenclosedCells ()
 Convert to CELL type in all directions.
BoxenclosedCells (int dir)
 Convert to CELL type in given direction.
Box operator & (const Box &) const
 Return Box that is intersection of this Box and argument.
Boxoperator &= (const Box &)
 Intersect this Box with its argument.
BoxminBox (const Box &)
 Modify Box to that of the minimum Box containing both the original Box and the argument.
Boxoperator+= (const IntVect &v)
 Shift Box (relative) by given IntVect.
Box operator+ (const IntVect &v) const
 Shift Box (relative) by given IntVect.
Boxoperator-= (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.
Boxgrow (int i)
 Grow Box in all directions by given amount.
Boxgrow (const IntVect &v)
 Grow Box in each direction by specified amount.
Boxgrow (int idir, int n_cell)
 Grow the Box on the low and high end by n cells in direction idir.
BoxgrowLo (int idir, int n_cell=1)
 Grow the Box on the low end by n cells in direction idir.
BoxgrowHi (int idir, int n_cell=1)
 Grow the Box on the high end by n cells in direction idir.
Boxgrow (const Orientation &face, int n_cell=1)
 Grow in the direction of the given face.
Boxrefine (int refinement_ratio)
 Refine Box by given (positive) refinement ratio.
Boxrefine (const IntVect &refinement_ratio)
 Refine Box by given (positive) refinement ratio.
Boxcoarsen (int refinement_ratio)
 Coarsen Box by given (positive) refinement ratio.
Boxcoarsen (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 BoxTheUnitBox ()
 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 ()


Detailed Description

: A Rectangular Domain on an Integer Lattice

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.


Constructor & Destructor Documentation

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 IntVect big 
)

Construct cell-centered type Box.

Box::Box ( const IntVect small,
const int *  vec_len 
)

Construct box with specified lengths.

Box::Box ( const IntVect small,
const IntVect big,
const IntVect typ 
)

Construct Box with given type.

small and big are expected to be consistent with given type.

References BL_ASSERT, IntVect::TheUnitVector(), and IntVect::TheZeroVector().

Box::Box ( const IntVect small,
const IntVect big,
const IndexType t 
)

Construct dimension specific Boxes.


Member Function Documentation

const IntVect & Box::smallEnd (  )  const [inline]

int Box::smallEnd ( int  dir  )  const [inline]

Return the coordinate of the low end in the given direction.

References smallend.

const IntVect & Box::bigEnd (  )  const [inline]

int Box::bigEnd ( int  dir  )  const [inline]

Return the coordinate of the high end in the given direction.

References bigend.

IndexType Box::ixType (  )  const [inline]

IntVect Box::type (  )  const [inline]

IndexType::CellIndex Box::type ( int  dir  )  const [inline]

Return the indexing type in the specified direction.

References btype, and IndexType::ixType().

const IntVect & Box::length (  )  const [inline]

int Box::length ( int  dir  )  const [inline]

Return the length of the Box in given direction.

References bigend, and smallend.

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]

Checks if it is a proper box (including a valid type).

References numPts().

bool Box::ok (  )  const [inline]

bool Box::contains ( const IntVect p  )  const [inline]

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]

Returns true if Boxes differ (including type).

References operator==().

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]

Is the number calculated by numPts() representable in a long?

Referenced by numPts().

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

Is the number calculated by volume() representable in a long?

Referenced by volume().

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 ( const IntVect sm  ) 

Redefine the small end of the Box.

References smallend.

Referenced by BoxLib::boxDiff().

Box & Box::setSmall ( int  dir,
int  sm_index 
)

Redefine the small end of the Box.

References IntVect::setVal(), and smallend.

Box & Box::setBig ( const IntVect bg  ) 

Redefine the big end of the Box.

References bigend.

Referenced by BoxLib::boxDiff().

Box & Box::setBig ( int  dir,
int  bg_index 
)

Redefine the big end of the Box.

References bigend, and IntVect::setVal().

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().

Box & Box::shift ( const IntVect iv  ) 

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().

Box & Box::shiftHalf ( const IntVect iv  ) 

Equivalent to b.shiftHalf(0,iv[0]).shiftHalf(1,iv[1]) ...

References shiftHalf().

Box & Box::convert ( IndexType  typ  ) 

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().

Box & Box::convert ( const IntVect typ  ) 

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().

Box Box::operator & ( const Box rhs  )  const

Return Box that is intersection of this Box and argument.

The Boxes MUST be of same type.

Box & Box::operator &= ( const Box b  ) 

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.

Box & Box::minBox ( const Box b  ) 

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::operator+= ( const IntVect v  ) 

Shift Box (relative) by given IntVect.

References bigend, and smallend.

Box Box::operator+ ( const IntVect v  )  const

Shift Box (relative) by given IntVect.

Box & Box::operator-= ( const IntVect v  ) 

Shift Box (relative) by given IntVect.

References bigend, and smallend.

Box Box::operator- ( const IntVect v  )  const

Shift Box (relative) by given IntVect.

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 ( const IntVect v  ) 

Grow Box in each direction by specified amount.

References bigend, and smallend.

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().

Box & Box::refine ( const IntVect 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(), 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().

Box & Box::coarsen ( const IntVect 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().

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().


Friends And Related Function Documentation


Member Data Documentation

IntVect Box::smallend [protected]

IntVect Box::bigend [protected]

IntVect Box::len [mutable, protected]

Referenced by length().

IndexType Box::btype [protected]


The documentation for this class was generated from the following files:

Generated on Fri Nov 21 10:11:01 2008 for AMRParticlePaths by  doxygen 1.5.5