SAMRAI::hier::Box< DIM > Class Template Reference

#include <source/hierarchy/boxes/Box.h>

List of all members.

Public Types

typedef BoxIterator< DIM > Iterator

Public Member Functions

 Box ()
 Box (const Index< DIM > &lower, const Index< DIM > &upper)
 Box (const Box< DIM > &box)
 Box (const tbox::DatabaseBox &box)
 ~Box ()
Box< DIM > & operator= (const Box< DIM > &box)
Index< DIM > & lower ()
Index< DIM > & upper ()
const Index< DIM > & lower () const
const Index< DIM > & upper () const
int & lower (const int i)
int & upper (const int i)
const int & lower (const int i) const
const int & upper (const int i) const
bool empty () const
void setEmpty ()
int numberCells (const int i) const
IntVector< DIM > numberCells () const
int size () const
int longestDimension () const
int offset (const Index< DIM > &p) const
Index< DIM > index (const int offset) const
bool contains (const Index< DIM > &p) const
bool contains (const Box< DIM > &b) const
int operator== (const Box< DIM > &box) const
int operator!= (const Box< DIM > &box) const
Box< DIM > operator * (const Box< DIM > &box) const
bool intersects (const Box< DIM > &box) const
Box< DIM > operator+ (const Box< DIM > &box) const
Box< DIM > & operator+= (const Box< DIM > &box)
bool coalesceWith (const Box< DIM > &box)
void grow (const IntVector< DIM > &ghosts)
void grow (const int direction, const int ghosts)
void growLower (const IntVector< DIM > &ghosts)
void growLower (const int direction, const int ghosts)
void growUpper (const IntVector< DIM > &ghosts)
void growUpper (const int direction, const int ghosts)
void lengthen (const int direction, const int ghosts)
void shorten (const int direction, const int ghosts)
void shift (const IntVector< DIM > &offset)
void shift (const int direction, const int offset)
void rotate (const int rotation_number)
void refine (const IntVector< DIM > &ratio)
void coarsen (const IntVector< DIM > &ratio)
Box< DIM > & operator= (const tbox::DatabaseBox &box)
Box< DIM > & Box_from_DatabaseBox (const tbox::DatabaseBox &box)
void set_Box_from_DatabaseBox (const tbox::DatabaseBox &box)
tbox::DatabaseBox DatabaseBox_from_Box () const
 operator tbox::DatabaseBox ()
 operator tbox::DatabaseBox () const

Static Public Member Functions

static Box< DIM > grow (const Box< DIM > &box, const IntVector< DIM > &ghosts)
static Box< DIM > shift (const Box< DIM > &box, const IntVector< DIM > &offset)
static Box< DIM > refine (const Box< DIM > &box, const IntVector< DIM > &ratio)
static Box< DIM > coarsen (const Box< DIM > &box, const IntVector< DIM > &ratio)

Friends

template<int D>
std::istream & operator>> (std::istream &s, Box< D > &box)
template<int D>
std::ostream & operator<< (std::ostream &s, const Box< D > &box)


Detailed Description

template<int DIM>
class SAMRAI::hier::Box< DIM >

Class Box represents a n-dimensional box in the AMR index space. It is defined by lower and upper bounds given by index objects. The box semantics assumes that the box is cell-centered. A cell-centered convention implies that the index set covered by the box includes both the lower and upper bounds.

Class Box<DIM> is translated into classes Box1, Box2, and Box3 after being passed through a preprocessor.

See also:
hier::BoxIterator

hier::Index


Member Typedef Documentation

template<int DIM>
typedef BoxIterator<DIM> SAMRAI::hier::Box< DIM >::Iterator

A box iterator iterates over the elements of a box. This class is defined elsewhere, and the typedef is used to point to that class.


Constructor & Destructor Documentation

template<int DIM>
SAMRAI::hier::Box< DIM >::Box (  )  [inline]

The default constructor creates an ``empty'' box.

template<int DIM>
SAMRAI::hier::Box< DIM >::Box ( const Index< DIM > &  lower,
const Index< DIM > &  upper 
) [inline]

Create a box describing the index space between lower and upper. The box is assumed to be cell centered and include all elements between lower and upper, including the end points.

template<int DIM>
SAMRAI::hier::Box< DIM >::Box ( const Box< DIM > &  box  )  [inline]

The copy constructor copies the index space of the argument box.

template<int DIM>
SAMRAI::hier::Box< DIM >::Box ( const tbox::DatabaseBox< DIM > &  box  )  [inline]

Construct a Box<DIM> from a DatabaseBox.

template<int DIM>
SAMRAI::hier::Box< DIM >::~Box (  ) 

The destructor for Box.


Member Function Documentation

template<int DIM>
Box< DIM > & SAMRAI::hier::Box< DIM >::operator= ( const Box< DIM > &  box  )  [inline]

The assignment operator copies the index space of the argument box.

template<int DIM>
Index< DIM > & SAMRAI::hier::Box< DIM >::lower (  )  [inline]

Return a non-const lower index of the box.

template<int DIM>
Index< DIM > & SAMRAI::hier::Box< DIM >::upper (  )  [inline]

Return a non-const upper index of the box.

template<int DIM>
const Index< DIM > & SAMRAI::hier::Box< DIM >::lower (  )  const [inline]

Return a const lower index of the box.

template<int DIM>
const Index< DIM > & SAMRAI::hier::Box< DIM >::upper (  )  const [inline]

Return a const upper index of the box.

template<int DIM>
int & SAMRAI::hier::Box< DIM >::lower ( const int  i  )  [inline]

Return the i'th component (non-const) of the lower index of the box.

template<int DIM>
int & SAMRAI::hier::Box< DIM >::upper ( const int  i  )  [inline]

Return the i'th component (non-const) of the upper index of the box.

template<int DIM>
const int & SAMRAI::hier::Box< DIM >::lower ( const int  i  )  const [inline]

Return the i'th component (const) of the lower index of the box.

template<int DIM>
const int & SAMRAI::hier::Box< DIM >::upper ( const int  i  )  const [inline]

Return the i'th component (const) of the upper index of the box.

template<int DIM>
bool SAMRAI::hier::Box< DIM >::empty (  )  const [inline]

Return whether the box is ``empty''. A box is empty if any of the lower bounds is greater than the corresponding upper bound. An empty box has a size of zero.

template<int DIM>
void SAMRAI::hier::Box< DIM >::setEmpty (  )  [inline]

Set the index space represented by the box to empty.

template<int DIM>
int SAMRAI::hier::Box< DIM >::numberCells ( const int  i  )  const [inline]

Return the number of cells (an integer) represented by the box in the given coordinate direction.

template<int DIM>
IntVector< DIM > SAMRAI::hier::Box< DIM >::numberCells (  )  const [inline]

Return the number of cells (a vector of integers) represented by the box in every coordinate direction.

template<int DIM>
int SAMRAI::hier::Box< DIM >::size (  )  const [inline]

Calculate the number of indices represented by the box. If the box is empty, then the number of index points within the box is zero.

template<int DIM>
int SAMRAI::hier::Box< DIM >::longestDimension (  )  const

Return the dimension of the box that is longest.

template<int DIM>
int SAMRAI::hier::Box< DIM >::offset ( const Index< DIM > &  p  )  const [inline]

Given an index, calculate the offset of the index into the box. This function assumes column-major (e.g., Fortran) ordering of the indices within the box. This operation is a convenience function for later array indexing operations.

template<int DIM>
Index< DIM > SAMRAI::hier::Box< DIM >::index ( const int  offset  )  const [inline]

Given an offset, calculate the index of the offset into the box. This function assumes column-major (e.g., Fortran) ordering of the indices within the box. This operation is a convenience function for later array indexing operations.

template<int DIM>
bool SAMRAI::hier::Box< DIM >::contains ( const Index< DIM > &  p  )  const [inline]

Check whether an index lies within the bounds of the box.

template<int DIM>
bool SAMRAI::hier::Box< DIM >::contains ( const Box< DIM > &  b  )  const [inline]

Check whether a given box lies within the bounds of the box.

template<int DIM>
int SAMRAI::hier::Box< DIM >::operator== ( const Box< DIM > &  box  )  const [inline]

Check whether two boxes represent the same portion of index space.

template<int DIM>
int SAMRAI::hier::Box< DIM >::operator!= ( const Box< DIM > &  box  )  const [inline]

Check whether two boxes cover different portions of index space.

template<int DIM>
Box< DIM > SAMRAI::hier::Box< DIM >::operator * ( const Box< DIM > &  box  )  const [inline]

Calculate the intersection of the index spaces of two boxes. The intersection with an empty box always yields an empty box.

template<int DIM>
bool SAMRAI::hier::Box< DIM >::intersects ( const Box< DIM > &  box  )  const [inline]

Return true if two boxes have a non-empty intersection. Otherwise, return false.

template<int DIM>
Box< DIM > SAMRAI::hier::Box< DIM >::operator+ ( const Box< DIM > &  box  )  const [inline]

Calculate the bounding box of two boxes. Note that this is not the union of the two boxes (since union is not closed over boxes), but rather the smallest box that contains both boxes.

template<int DIM>
Box< DIM > & SAMRAI::hier::Box< DIM >::operator+= ( const Box< DIM > &  box  ) 

Increase the bounding box to include the argument box.

template<int DIM>
bool SAMRAI::hier::Box< DIM >::coalesceWith ( const Box< DIM > &  box  ) 

Return true if this box can be coalesced with the argument box, and set this box to the union of the boxes. Otherwise, return false and leave boxes as is. Two boxes may be coalesced if their union is a box (recall that index set union is not closed over boxes). If either box is empty, then the return value is true and this box becomes the union of the two.

template<int DIM>
void SAMRAI::hier::Box< DIM >::grow ( const IntVector< DIM > &  ghosts  )  [inline]

Grow a box by the specified ghost cell width. The lower bound is decremented by the width, and the upper bound is incremented by the width. All dimensions are grown by the corresponding component in the IntVector; ghost cell widths may be different in each dimension. Negative ghost cell widths will shrink the box.

template<int DIM>
void SAMRAI::hier::Box< DIM >::grow ( const int  direction,
const int  ghosts 
) [inline]

Grow a box by the specified ghost cell width in the given coordinate direction in index space. The lower bound is decremented by the width, and the upper bound is incremented by the width. Note that negative ghost cell widths will shrink the box.

template<int DIM>
void SAMRAI::hier::Box< DIM >::growLower ( const IntVector< DIM > &  ghosts  )  [inline]

Similar to grow() functions. However, box is only grown in lower directions (i.e., only lower index is changed).

template<int DIM>
void SAMRAI::hier::Box< DIM >::growLower ( const int  direction,
const int  ghosts 
) [inline]

Similar to grow() functions. However, box is only grown in lower bound of given direction in index space.

template<int DIM>
void SAMRAI::hier::Box< DIM >::growUpper ( const IntVector< DIM > &  ghosts  )  [inline]

Similar to grow() function. However, box is only grown in upper directions (i.e., only upper index is changed).

template<int DIM>
void SAMRAI::hier::Box< DIM >::growUpper ( const int  direction,
const int  ghosts 
) [inline]

Similar to grow() functions. However, box is only grown in upper bound of given direction in index space.

template<int DIM>
void SAMRAI::hier::Box< DIM >::lengthen ( const int  direction,
const int  ghosts 
) [inline]

Similar to growUpper() and growLower() functions. However, box is lengthened (never shortened). The sign of ghosts refer to whether the box is lengthened in the upper or lower side.

template<int DIM>
void SAMRAI::hier::Box< DIM >::shorten ( const int  direction,
const int  ghosts 
) [inline]

Similar to growUpper() and growLower() functions. However, box is shortened (never lengthened). The sign of ghosts refer to whether the box is shortened in the upper or lower side.

template<int DIM>
void SAMRAI::hier::Box< DIM >::shift ( const IntVector< DIM > &  offset  )  [inline]

Shift a box by the specified amount (a vector of integers). The new box is located at (lower+offset, upper+offset).

template<int DIM>
void SAMRAI::hier::Box< DIM >::shift ( const int  direction,
const int  offset 
) [inline]

Similar to shift() function above, but shift occurs only in specified direction in index space. The new box is located at (lower+offset, upper+offset) in that direction.

template<int DIM>
void SAMRAI::hier::Box< DIM >::rotate ( const int  rotation_number  ) 

Rotate 90 degrees around origin. Currently works for 2D only.

template<int DIM>
void SAMRAI::hier::Box< DIM >::refine ( const IntVector< DIM > &  ratio  )  [inline]

Refine the index space of a box by specified vector ratio. Each component of the box is multiplied by the refinement ratio, then (ratio-1) is added to the upper corner.

template<int DIM>
void SAMRAI::hier::Box< DIM >::coarsen ( const IntVector< DIM > &  ratio  )  [inline]

Coarsen the index space of a box by specified vector ratio. Each component is divided by the specified coarsening ratio and rounded (if necessary) such that the coarsened box contains the cells that are the parents of the refined box. In other words, refining a coarsened box will always yield a box that is equal to or larger than the original box.

template<int DIM>
Box< DIM > & SAMRAI::hier::Box< DIM >::operator= ( const tbox::DatabaseBox< DIM > &  box  )  [inline]

This assignment operator constructs a Box<DIM> given a DatabaseBox.

template<int DIM>
Box< DIM > & SAMRAI::hier::Box< DIM >::Box_from_DatabaseBox ( const tbox::DatabaseBox< DIM > &  box  )  [inline]

Sets a Box<DIM> from a tbox::DatabaseBox and returns a reference to the Box<DIM>.

template<int DIM>
void SAMRAI::hier::Box< DIM >::set_Box_from_DatabaseBox ( const tbox::DatabaseBox< DIM > &  box  ) 

Sets a Box<DIM> from a DatabaseBox.

template<int DIM>
tbox::DatabaseBox SAMRAI::hier::Box< DIM >::DatabaseBox_from_Box (  )  const

Returns a tbox::DatabaseBox generated from a Box<DIM>.

template<int DIM>
SAMRAI::hier::Box< DIM >::operator tbox::DatabaseBox (  )  [inline]

Type conversion from Box<DIM> to Box

template<int DIM>
SAMRAI::hier::Box< DIM >::operator tbox::DatabaseBox (  )  const [inline]

Type conversion from Box<DIM> to Box

template<int DIM>
Box< DIM > SAMRAI::hier::Box< DIM >::grow ( const Box< DIM > &  box,
const IntVector< DIM > &  ghosts 
) [inline, static]

Utility function to grow a box by the specified vector ghost cell width. A new box is returned and the argument is not changed.

template<int DIM>
Box< DIM > SAMRAI::hier::Box< DIM >::shift ( const Box< DIM > &  box,
const IntVector< DIM > &  offset 
) [inline, static]

Utility function to shift a box by the specified offset. A new box is returned and the argument is not changed.

template<int DIM>
Box< DIM > SAMRAI::hier::Box< DIM >::refine ( const Box< DIM > &  box,
const IntVector< DIM > &  ratio 
) [inline, static]

Utility function to refine the index space of a box by the specified refinement ratio. A new box is returned and the argument is not changed.

template<int DIM>
Box< DIM > SAMRAI::hier::Box< DIM >::coarsen ( const Box< DIM > &  box,
const IntVector< DIM > &  ratio 
) [inline, static]

Utility function to coarsen the index space of a box by the specified coarsening ratio. A new box is returned and the argument is not changed.


Friends And Related Function Documentation

template<int DIM>
template<int D>
std::istream& operator>> ( std::istream &  s,
Box< D > &  box 
) [friend]

Read the box description in the form [L,U], where L and U are the lower and upper bounds of the box.

template<int DIM>
template<int D>
std::ostream& operator<< ( std::ostream &  s,
const Box< D > &  box 
) [friend]

Output the box description in the form [L,U], where L and U are the lower and upper bounds of the box.


The documentation for this class was generated from the following files:
Generated on Thu Jun 18 11:28:27 2009 for SAMRAI by  doxygen 1.5.1