SAMRAI::pdat::ArrayData< DIM, TYPE > Class Template Reference

Class ArrayData<DIM, TYPE> is a basic templated array structure defined over the index space of a box (with a specified depth) that provides the support for the various standard array-based patch data subclasses. More...

#include <source/patchdata/array/ArrayData.h>

Inheritance diagram for SAMRAI::pdat::ArrayData< DIM, TYPE >:

Inheritance graph
[legend]
List of all members.

Public Types

typedef ArrayDataIterator<
DIM > 
Iterator

Public Member Functions

 ArrayData ()
 ArrayData (const hier::Box< DIM > &box, int depth, tbox::Pointer< tbox::Arena > pool=tbox::Pointer< tbox::Arena >((0)))
 ~ArrayData ()
void initializeArray (const hier::Box< DIM > &box, int depth, const tbox::Pointer< tbox::Arena > pool=tbox::Pointer< tbox::Arena >((0)))
bool isInitialized () const
 Returns true when the array has been properly initialized and storage has been allocated; otherwise, return false.
void undefineData ()
const hier::Box< DIM > & getBox () const
int getDepth () const
int getOffset () const
TYPE * getPointer (const int d=0)
const TYPE * getPointer (const int d=0) const
TYPE & operator() (const hier::Index< DIM > &i, const int d)
const TYPE & operator() (const hier::Index< DIM > &i, const int d) const
void copy (const ArrayData< DIM, TYPE > &src, const hier::Box< DIM > &box)
void copy (const ArrayData< DIM, TYPE > &src, const hier::Box< DIM > &box, const hier::IntVector< DIM > &src_shift)
void copy (const ArrayData< DIM, TYPE > &src, const hier::BoxList< DIM > &boxes, const hier::IntVector< DIM > &src_shift)
void copyDepth (int dst_depth, const ArrayData< DIM, TYPE > &src, int src_depth, const hier::Box< DIM > &box)
void sum (const ArrayData< DIM, TYPE > &src, const hier::Box< DIM > &box)
void sum (const ArrayData< DIM, TYPE > &src, const hier::Box< DIM > &box, const hier::IntVector< DIM > &src_shift)
void sum (const ArrayData< DIM, TYPE > &src, const hier::BoxList< DIM > &boxes, const hier::IntVector< DIM > &src_shift)
int getDataStreamSize (const hier::BoxList< DIM > &boxes, const hier::IntVector< DIM > &src_shift) const
void packStream (tbox::AbstractStream &stream, const hier::Box< DIM > &dest_box, const hier::IntVector< DIM > &src_shift) const
void packStream (tbox::AbstractStream &stream, const hier::BoxList< DIM > &dest_boxes, const hier::IntVector< DIM > &src_shift) const
void unpackStream (tbox::AbstractStream &stream, const hier::Box< DIM > &dest_box, const hier::IntVector< DIM > &src_offset)
void unpackStream (tbox::AbstractStream &stream, const hier::BoxList< DIM > &dest_boxes, const hier::IntVector< DIM > &src_offset)
void unpackStreamAndSum (tbox::AbstractStream &stream, const hier::Box< DIM > &dest_box, const hier::IntVector< DIM > &src_offset)
void unpackStreamAndSum (tbox::AbstractStream &stream, const hier::BoxList< DIM > &dest_boxes, const hier::IntVector< DIM > &src_offset)
void fillAll (const TYPE &t)
void fillAll (const TYPE &t, const hier::Box< DIM > &box)
void fill (const TYPE &t, const int d=0)
void fill (const TYPE &t, const hier::Box< DIM > &box, const int d=0)
void getFromDatabase (tbox::Pointer< tbox::Database > database)
void putToDatabase (tbox::Pointer< tbox::Database > database, bool data_only=false)
void getSpecializedFromDatabase (tbox::Pointer< tbox::Database > database)
void putSpecializedToDatabase (tbox::Pointer< tbox::Database > database)

Static Public Member Functions

static bool canEstimateStreamSizeFromBox ()
static size_t getSizeOfData (const hier::Box< DIM > &box, int depth)

Detailed Description

template<int DIM, class TYPE>
class SAMRAI::pdat::ArrayData< DIM, TYPE >

Class ArrayData<DIM, TYPE> is a basic templated array structure defined over the index space of a box (with a specified depth) that provides the support for the various standard array-based patch data subclasses.

The data storage is in (i,...,k,d) order, where i,...,k indicates spatial indices and the d indicates the component at that location. Memory allocation is in column-major ordering (e.g., Fortran style) so that the leftmost index runs fastest in memory.

The data type TYPE must define a default constructor (that takes no arguments) and also the assignment operator. Note that a number of functions only work for standard built-in types (bool, char, double, float, and int). To use this class with other user-defined types, many of these functions will need to be specialized, especially those that deal with message packing and unpacking.


Member Typedef Documentation

template<int DIM, class TYPE>
typedef ArrayDataIterator<DIM> SAMRAI::pdat::ArrayData< DIM, TYPE >::Iterator

The array data iterator iterates over the elements of a box associated with an ArrayData object. This typedef is convenient link to the ArrayDataIterator<DIM> class.


Constructor & Destructor Documentation

template<int DIM, class TYPE>
SAMRAI::pdat::ArrayData< DIM, TYPE >::ArrayData (  ) 

The default constructor creates an empty array data object. The initializeArray() member function must be called before the array can be used.

template<int DIM, class TYPE>
SAMRAI::pdat::ArrayData< DIM, TYPE >::ArrayData ( const hier::Box< DIM > &  box,
int  depth,
tbox::Pointer< tbox::Arena pool = tbox::Pointertbox::Arena >((0)) 
)

Construct an array data object.

Parameters:
box Const reference to box object describing the spatial extents of the index space associated with the array data object.
depth Integer number of data values at each spatial location in the array.
pool Optional pointer to memory pool for allocating array data storage. Default is null indicating that standard allocator will be used.

template<int DIM, class TYPE>
SAMRAI::pdat::ArrayData< DIM, TYPE >::~ArrayData (  ) 

The destructor for an array data object releases all memory allocated for the array elements.


Member Function Documentation

template<int DIM, class TYPE>
bool SAMRAI::pdat::ArrayData< DIM, TYPE >::canEstimateStreamSizeFromBox (  )  [inline, static]

Static member function that returns tru when the amount of buffer space in a message stream can be estimated from box only. For built-in types (bool, char, double, float, int, and dcomplex), this routine returns true. For other data types (template paramters) that may require special handling, a different implementation must be provided.

template<int DIM, class TYPE>
size_t SAMRAI::pdat::ArrayData< DIM, TYPE >::getSizeOfData ( const hier::Box< DIM > &  box,
int  depth 
) [inline, static]

Static member function that returns the amount of memory space needed to store data of given depth on a box.

Note that this function is only defined for the standard data types: bool, char, double, float, int, and dcomplex. It must be provided for other template parameter types.

Returns:
size_t value indicating the amount of memory space needed for the data.
Parameters:
box Const reference to box object describing the spatial extents of the array data index region of interest.
depth Integer number of data values at each spatial location in the array.

template<int DIM, class TYPE>
void SAMRAI::pdat::ArrayData< DIM, TYPE >::initializeArray ( const hier::Box< DIM > &  box,
int  depth,
const tbox::Pointer< tbox::Arena pool = tbox::Pointertbox::Arena >((0)) 
)

Initialize the array data. This routine is normally called to allocate storage when the array data object is created using the default constructor.

Parameters:
box Const reference to box object describing the spatial extents of the index space associated with the array data object.
depth Integer number of data values at each spatial location in the array.
pool Optional pointer to memory pool for allocating array data storage. Default is null indicating that standard allocator will be used.

template<int DIM, class TYPE>
bool SAMRAI::pdat::ArrayData< DIM, TYPE >::isInitialized (  )  const [inline]

Returns true when the array has been properly initialized and storage has been allocated; otherwise, return false.

Note: Only arrays that have been initialized can do anything useful. Initialize an uninitialized array by calling the initializeArray() method.

template<int DIM, class TYPE>
void SAMRAI::pdat::ArrayData< DIM, TYPE >::undefineData (  ) 

Set the array data to an ``undefined'' state appropriate for the data type. For example, for float and double, this means setting data to signaling NaNs that cause a floating point exception when used in a numerical expression without being set to valid values.

template<int DIM, class TYPE>
const hier::Box< DIM > & SAMRAI::pdat::ArrayData< DIM, TYPE >::getBox (  )  const [inline]

Return the box over which the array is defined.

template<int DIM, class TYPE>
int SAMRAI::pdat::ArrayData< DIM, TYPE >::getDepth (  )  const [inline]

Return the depth (e.g., the number of data values at each spatial location) of this array.

template<int DIM, class TYPE>
int SAMRAI::pdat::ArrayData< DIM, TYPE >::getOffset (  )  const [inline]

Return the offset (e.g., the number of data values for each depth component) of this array.

template<int DIM, class TYPE>
TYPE * SAMRAI::pdat::ArrayData< DIM, TYPE >::getPointer ( const int  d = 0  )  [inline]

Get a non-const pointer to the beginning of the given depth component of this data array.

template<int DIM, class TYPE>
const TYPE * SAMRAI::pdat::ArrayData< DIM, TYPE >::getPointer ( const int  d = 0  )  const [inline]

Get a const pointer to the beginning of the given depth component of this data array.

template<int DIM, class TYPE>
TYPE & SAMRAI::pdat::ArrayData< DIM, TYPE >::operator() ( const hier::Index< DIM > &  i,
const int  d 
) [inline]

Return reference to value in this array associated with the given box index and depth component.

template<int DIM, class TYPE>
const TYPE & SAMRAI::pdat::ArrayData< DIM, TYPE >::operator() ( const hier::Index< DIM > &  i,
const int  d 
) const [inline]

Return const reference to value in this array associated with the given box index and depth component.

template<int DIM, class TYPE>
void SAMRAI::pdat::ArrayData< DIM, TYPE >::copy ( const ArrayData< DIM, TYPE > &  src,
const hier::Box< DIM > &  box 
)

Copy data from the source array data object to this array data object on the specified index space region.

Note that this routine assumes that the source and destination box regions require no shifting to make them consistent. This routine will intersect the specified box with the source and destination boxes to find the region of intersection.

Parameters:
src Const reference to source array data object.
box Const reference to box object describing the spatial extents of the index space region over which to perform the copy operation. Note: the box is in either the source or destination index space (which are assumed to be the same).

template<int DIM, class TYPE>
void SAMRAI::pdat::ArrayData< DIM, TYPE >::copy ( const ArrayData< DIM, TYPE > &  src,
const hier::Box< DIM > &  box,
const hier::IntVector< DIM > &  src_shift 
)

Copy data from the source array data object to this array data object on the specified index space region.

Note that this routine assumes that the source array box region must be shifted to be consistent with the destination (this) array box region. This routine will intersect the specified box with the destination box and shifted source box to find the region of intersection.

Parameters:
src Const reference to source array data object.
box Const reference to box object describing the spatial extents of the index space region over which to perform the copy operation. Note: the box is in the destination index space.
src_shift Const reference to shift vector used to put the source array data box into the index space region of this array data object.

template<int DIM, class TYPE>
void SAMRAI::pdat::ArrayData< DIM, TYPE >::copy ( const ArrayData< DIM, TYPE > &  src,
const hier::BoxList< DIM > &  boxes,
const hier::IntVector< DIM > &  src_shift 
)

Copy data from the source array data object to this array data object on the specified index space regions.

Note that this routine assumes that the source array box region must be shifted to be consistent with the destination (this) array box region. This routine will intersect the specified boxes with the destination box and shifted source box to find the regions of intersection.

Parameters:
src Const reference to source array data object.
boxes Const reference to box list describing the spatial extents of the index space regions over which to perform the copy operation. Note: the boxes are in the destination index space.
src_shift Const reference to shift vector used to put the source array data box into the index space region of this array data object.

template<int DIM, class TYPE>
void SAMRAI::pdat::ArrayData< DIM, TYPE >::copyDepth ( int  dst_depth,
const ArrayData< DIM, TYPE > &  src,
int  src_depth,
const hier::Box< DIM > &  box 
)

Copy given source depth of source array data object to given destination depth of this array data object on the specified index space region.

Note that this routine assumes that the source and destination box regions require no shifting to make them consistent. This routine will intersect the specified box with the source and destination boxes to find the region of intersection.

Parameters:
dst_depth Integer depth of destination array.
src Const reference to source array data object.
src_depth Integer depth of source array.
box Const reference to box object describing the spatial extents of the index space region over which to perform the copy operation. Note: the box is in either the source or destination index space (which are assumed to be the same).

template<int DIM, class TYPE>
void SAMRAI::pdat::ArrayData< DIM, TYPE >::sum ( const ArrayData< DIM, TYPE > &  src,
const hier::Box< DIM > &  box 
)

Add data from the source array data object to this array data object on the specified index space region.

Note that this routine assumes that the source and destination box regions require no shifting to make them consistent. This routine will intersect the specified box with the source and destination boxes to find the region of intersection.

Parameters:
src Const reference to source array data object.
box Const reference to box object describing the spatial extents of the index space region over which to perform the sum operation. Note: the box is in either the source or destination index space (which are assumed to be the same).

template<int DIM, class TYPE>
void SAMRAI::pdat::ArrayData< DIM, TYPE >::sum ( const ArrayData< DIM, TYPE > &  src,
const hier::Box< DIM > &  box,
const hier::IntVector< DIM > &  src_shift 
)

Add data from the source array data object to this array data object on the specified index space region.

Note that this routine assumes that the source array box region must be shifted to be consistent with the destination (this) array box region. This routine will intersect the specified box with the destination box and shifted source box to find the region of intersection.

Parameters:
src Const reference to source array data object.
box Const reference to box object describing the spatial extents of the index space region over which to perform the sum operation. Note: the box is in the destination index space.
src_shift Const reference to shift vector used to put the source array data box into the index space region of this array data object.

template<int DIM, class TYPE>
void SAMRAI::pdat::ArrayData< DIM, TYPE >::sum ( const ArrayData< DIM, TYPE > &  src,
const hier::BoxList< DIM > &  boxes,
const hier::IntVector< DIM > &  src_shift 
)

Add data from the source array data object to this array data object on the specified index space regions.

Note that this routine assumes that the source array box region must be shifted to be consistent with the destination (this) array box region. This routine will intersect the specified boxes with the destination box and shifted source box to find the regions of intersection.

Parameters:
src Const reference to source array data object.
boxes Const reference to box list describing the spatial extents of the index space regions over which to perform the sum operation. Note: the boxes are in the destination index space.
src_shift Const reference to shift vector used to put the source array data box into the index space region of this array data object.

template<int DIM, class TYPE>
int SAMRAI::pdat::ArrayData< DIM, TYPE >::getDataStreamSize ( const hier::BoxList< DIM > &  boxes,
const hier::IntVector< DIM > &  src_shift 
) const [inline]

Calculate the number of bytes needed to stream the data living in the specified box domains. This routine is only defined for the built-in types of bool, char, double, float, int, and dcomplex. For all other types, a specialized implementation must be provided.

Parameters:
boxes Const reference to box list describing the spatial extents of the index space regions of interest. Note: the boxes are assumed to be in the index space of this array data object.
src_shift Const reference to vector used to shift the given boxes into the index space region of this array data object. Note: this argument is currently ignored.

template<int DIM, class TYPE>
void SAMRAI::pdat::ArrayData< DIM, TYPE >::packStream ( tbox::AbstractStream stream,
const hier::Box< DIM > &  dest_box,
const hier::IntVector< DIM > &  src_shift 
) const

Pack data living on the specified index region into the stream.

Note that this routine assumes that the given box region must be shifted to be consistent with the source (this) array box region.

Parameters:
stream Reference to stream into which to pack data.
dest_box Const reference to box describing the spatial extent of the destination index space region of interest.
src_shift Const reference to vector used to shift the given box into the index space region of this (source) array data object.
Note: The shifted box must lie completely within the index space of this array data object. When assertion checking is active, the routine will abort if the box is not contained in the index space of this array.

template<int DIM, class TYPE>
void SAMRAI::pdat::ArrayData< DIM, TYPE >::packStream ( tbox::AbstractStream stream,
const hier::BoxList< DIM > &  dest_boxes,
const hier::IntVector< DIM > &  src_shift 
) const

Pack data living on the specified index regions into the stream.

Note that this routine assumes that the given box regions must be shifted to be consistent with the source (this) array box region.

Parameters:
stream Reference to stream into which to pack data.
dest_boxes Const reference to boxes describing the spatial extents of the destination index space regions of interest.
src_shift Const reference to vector used to shift the given boxes into the index space region of this (source) array data object.
Note: The shifted boxes must lie completely within the index space of this array. If compiled with assertions enabled, the routine will abort if the shifted boxes are not contained in the index space of this array.

template<int DIM, class TYPE>
void SAMRAI::pdat::ArrayData< DIM, TYPE >::unpackStream ( tbox::AbstractStream stream,
const hier::Box< DIM > &  dest_box,
const hier::IntVector< DIM > &  src_offset 
)

Unpack data from the stream into the index region specified.

Parameters:
stream Reference to stream from which to unpack data.
dest_box Const reference to box describing the spatial extent of the destination index space region of interest.
src_offset Const reference to vector used to offset box into the index space region of some (source) array data object. Currently, this argument is ignored.
Note: The given box must lie completely within the index space of this array data object. When assertion checking is active, the routine will abort if the box is not contained in the index space of this array.

template<int DIM, class TYPE>
void SAMRAI::pdat::ArrayData< DIM, TYPE >::unpackStream ( tbox::AbstractStream stream,
const hier::BoxList< DIM > &  dest_boxes,
const hier::IntVector< DIM > &  src_offset 
)

Unpack data from the stream into the index regions specified.

Parameters:
stream Reference to stream from which to unpack data.
dest_boxes Const reference to box list describing the spatial extents of the destination index space regions of interest.
src_offset Const reference to vector used to offset the given boxes into the index space region of some (source) array data object. Currently, this argument is ignored.
Note: The given boxes must lie completely within the index space of this array data object. When assertion checking is active, the routine will abort if some box is not contained in the index space of this array.

template<int DIM, class TYPE>
void SAMRAI::pdat::ArrayData< DIM, TYPE >::unpackStreamAndSum ( tbox::AbstractStream stream,
const hier::Box< DIM > &  dest_box,
const hier::IntVector< DIM > &  src_offset 
)

Unpack data from the stream and add to the array in the index region specified.

Parameters:
stream Reference to stream from which to unpack data.
dest_box Const reference to box describing the spatial extent of the destination index space region of interest.
src_offset Const reference to vector used to offset the given box into the index space region of some (source) array data object. Currently, this argument is ignored.
Note: The given box must lie completely within the index space of this array data object. When assertion checking is active, the routine will abort if the box is not contained in the index space of this array.

template<int DIM, class TYPE>
void SAMRAI::pdat::ArrayData< DIM, TYPE >::unpackStreamAndSum ( tbox::AbstractStream stream,
const hier::BoxList< DIM > &  dest_boxes,
const hier::IntVector< DIM > &  src_offset 
)

Unpack data from the stream and ad to the array in the index region specified.

Parameters:
stream Reference to stream from which to unpack data.
dest_boxes Const reference to box list describing the spatial extents of the destination index space regions of interest.
src_offset Const reference to vector used to offset the given boxes into the index space region of some (source) array data object. Currently, this argument is ignored.
Note: The given boxes must lie completely within the index space of this array. If compiled with assertions enabled, the routine will abort if some box is not contained in the index space of this array.

template<int DIM, class TYPE>
void SAMRAI::pdat::ArrayData< DIM, TYPE >::fillAll ( const TYPE &  t  ) 

Fill all array values with value t.

template<int DIM, class TYPE>
void SAMRAI::pdat::ArrayData< DIM, TYPE >::fillAll ( const TYPE &  t,
const hier::Box< DIM > &  box 
)

Fill all array values within the box with value t.

template<int DIM, class TYPE>
void SAMRAI::pdat::ArrayData< DIM, TYPE >::fill ( const TYPE &  t,
const int  d = 0 
)

Fill all array values associated with depth component d with the value t.

template<int DIM, class TYPE>
void SAMRAI::pdat::ArrayData< DIM, TYPE >::fill ( const TYPE &  t,
const hier::Box< DIM > &  box,
const int  d = 0 
)

Fill all array values associated with depth component d within the box with the value t.

template<int DIM, class TYPE>
void SAMRAI::pdat::ArrayData< DIM, TYPE >::getFromDatabase ( tbox::Pointer< tbox::Database database  ) 

Check to make sure that the class version and restart file version are equal. If so, read in data from database. This routine calls getSpecializedFromDatabase() to read in the proper data type.

Assertions: database must be a non-null pointer.

template<int DIM, class TYPE>
void SAMRAI::pdat::ArrayData< DIM, TYPE >::putToDatabase ( tbox::Pointer< tbox::Database database,
bool  data_only = false 
)

Write out array data object data to database. This routine calls putSpecializedToDatabase() to read in the proper data type. The default behavior (boolean argument is false) is to put all data members in database. Otherwise, only the array contents are written out.

Assertions: database must be a non-null pointer.

template<int DIM, class TYPE>
void SAMRAI::pdat::ArrayData< DIM, TYPE >::getSpecializedFromDatabase ( tbox::Pointer< tbox::Database database  ) 

Use specialized template method to get the correct behavior when reading in the array of data.

template<int DIM, class TYPE>
void SAMRAI::pdat::ArrayData< DIM, TYPE >::putSpecializedToDatabase ( tbox::Pointer< tbox::Database database  ) 

Use specialized template method to get the correct behavior when writing out the array of data.


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