Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

BaseFab< T > Class Template Reference

#include <BaseFab.H>

Inheritance diagram for BaseFab< T >:

Inheritance graph
[legend]
Collaboration diagram for BaseFab< T >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 BaseFab ()
 { constructors, destructor and defines}

 BaseFab (const Box &bx, int n, T *alias=NULL)
 BaseFab (const Interval &a_comps, BaseFab< T > &a_original)
virtual ~BaseFab ()
void resize (const Box &b, int N=1, T *alias=NULL)
virtual void define (const Box &box, int comps, T *alias=NULL)
virtual void define (const Interval &a_comps, BaseFab< T > &a_original)
void clear ()
int nComp () const
 { accessors}

const Boxbox () const
const int * size () const
const IntVectsmallEnd () const
const IntVectbigEnd () const
Interval interval () const
T & operator() (const IntVect &p, int N)
T & operator() (const IntVect &p)
const T & operator() (const IntVect &p, int N) const
const T & operator() (const IntVect &p) const
void getVal (T *data, const IntVect &pos, int N, int numcomp) const
void getVal (T *data, const IntVect &pos) const
const int * loVect () const
 { Fortran interface functions}

const int * hiVect () const
const int * nCompPtr () const
T * dataPtr (int N=0)
const T * dataPtr (int N=0) const
bool contains (const BaseFab< T > &fab) const
 { comparison functions}

bool contains (const Box &bx) const
void setVal (T x, const Box &bx, int nstart, int ncomp)
 { data modification functions}

void setVal (T x, const Box &bx, int N)
void setVal (T x, int N)
void setVal (T x)
BaseFab< T > & copy (const BaseFab< T > &src, const Box &srcbox, int srccomp, const Box &destbox, int destcomp, int numcomp)
BaseFab< T > & copy (const BaseFab< T > &src, int srccomp, int destcomp, int numcomp=1)
BaseFab< T > & copy (const BaseFab< T > &src, const Box &destbox)
BaseFab< T > & copy (const BaseFab< T > &src)
void copy (const Box &RegionFrom, const Interval &Cdest, const Box &RegionTo, const BaseFab< T > &src, const Interval &Csrc)
BaseFab< T > & shift (const IntVect &v)
 { domain modification functions}

BaseFab< T > & shift (int idir, int n_cell)
BaseFab< T > & shiftHalf (int dir, int num_halfs)
BaseFab< T > & shiftHalf (const IntVect &num_halfs)
virtual int size (const Box &b, const Interval &comps) const
 { linearization functions}

virtual void linearOut (void *buf, const Box &R, const Interval &comps) const
virtual void linearIn (void *buf, const Box &R, const Interval &comps)

Static Public Member Functions

int preAllocatable ()

Protected Member Functions

void define ()
void undefine ()
virtual void performCopy (const BaseFab< T > &src, const Box &srcbox, int srccomp, const Box &destbox, int destcomp, int numcomp)
void performSetVal (T x, const Box &bx, int nstart, int numcomp)

Static Protected Member Functions

std::string name ()

Protected Attributes

Box domain
int nvar
long numpts
long truesize
T * dptr
bool aliased

Static Protected Attributes

Arenas_Arena = NULL

Detailed Description

template<class T>
class BaseFab< T >

A Fortran Array-like Container

BaseFab emulates the Fortran array concept. Useful operations can be performed upon BaseFab's in C++, and they provide a convenient interface to Fortran when it is necessary to retreat into that language.

`BaseFab' is a template class. Through use of the template, a `BaseFab' may be based upon any class. So far at least, most applications have been based upon simple types like `integer's, `real's, or `doubleprecision's. Most applications do not use BaseFab's directly, but utilize specialized classes derived from BaseFab.

It will be easier to use a `BaseFab' if you understand the following concepts. `BaseFab' objects depend on the dimensionality of space (indirectly through the DOMAIN `Box' member). It is typical to define the macro `CH_SPACEDIM' to be 1, 2, or 3 to indicate the dimension of space. See the discussion of class `Box' for more information. A `BaseFab' contains a `Box' DOMAIN, which indicates the integer indexing space over which the array is defined. A `BaseFab' also has NVAR components. By components, we mean that for each point in the rectangular indexing space, there are NVAR values associated with that point. A Fortran array corresponding to a `BaseFab' would have (CH_SPACEDIM+1) dimensions.

By design, the array layout in a `BaseFab' mirrors that of a Fortran array. The first index (x direction for example) varies most rapidly, the next index (y direction), if any, varies next fastest. The component index varies last, after all the spatial indices.

It is sometimes convenient to be able to treat a sub-array within an existing `BaseFab' as a `BaseFab' in its own right. This is often referred to as 'aliasing' the `BaseFab'. Note that when aliasing is used, the BaseFab's domain will not, in general, be the same as the parent BaseFab's domain, nor will the number of components. BaseFab is a dimension dependent class, so CH_SPACEDIM must be defined as either 1, 2, or 3 when compiling.

This is NOT a polymorphic class.

It does NOT provide a copy constructor or assignment operator.

T MUST have a default constructor and an assignment operator.


Constructor & Destructor Documentation

template<class T>
BaseFab< T >::BaseFab  )  [inline]
 

{ constructors, destructor and defines}

: Constructs an invalid `BaseFab'. The domain is invalid, the number of components is zero, and no actual array memory is allocated. An invalid `BaseFab' must be resize()d (see `BaseFab::resize') before use.

template<class T>
BaseFab< T >::BaseFab const Box bx,
int  n,
T *  alias = NULL
[inline]
 

Constructs a BaseFab with desired domain and number of components.

template<class T>
BaseFab< T >::BaseFab const Interval a_comps,
BaseFab< T > &  a_original
[inline]
 

Constructs an 'aliased' BaseFab of the requested interval of the argument BaseFab. This BaseFab does not allocate any memory, but sets its data pointer into the memory pointed to by the argument BaseFab. It is the users responsiblity to ensure this aliased BaseFab is not used after the original BaseFab has deleted its data ptr (resize, define(..) called, or destruction, etc.).

This aliased BaseFab will also generate side effects (modifying the values of data in one will modify the other's data).

This aliased BaseFab will have a_comps.size() components, starting at zero.

template<class T>
BaseFab< T >::~BaseFab  )  [inline, virtual]
 

The destructor deletes the array memory. Unless this was an aliased BaseFab.


Member Function Documentation

template<class T>
const IntVect & BaseFab< T >::bigEnd  )  const [inline]
 

: Returns the upper corner of the domain. See class `Box' for analogue.

template<class T>
const Box & BaseFab< T >::box  )  const [inline]
 

Returns the domain (box) where the array is defined.

template<class T>
void BaseFab< T >::clear  )  [inline]
 

: The function returns the `BaseFab' to the invalid state. (See comments for constructors above.) The memory is freed.

Reimplemented in BinFab< T >.

template<class T>
bool BaseFab< T >::contains const Box bx  )  const [inline]
 

: Returns true if bx is totally contained within the domain of this `BaseFab'.

template<class T>
bool BaseFab< T >::contains const BaseFab< T > &  fab  )  const [inline]
 

{ comparison functions}

: Returns true if the domain of fab is totally contained within the domain of this `BaseFab'.

template<class T>
void BaseFab< T >::copy const Box RegionFrom,
const Interval Cdest,
const Box RegionTo,
const BaseFab< T > &  src,
const Interval Csrc
[inline]
 

Copy from a subsection of one box into another. Assumes the boxes are both in the same index space, and that box R is completely contained in both the source and destination boxes.

template<class T>
BaseFab< T > & BaseFab< T >::copy const BaseFab< T > &  src  )  [inline]
 

: Modifies this BaseFab by coping the contents of the argument BaseFab into it. A copy within the intersecting region of the domains of the two BaseFabs is performed. All components are copied.

template<class T>
BaseFab< T > & BaseFab< T >::copy const BaseFab< T > &  src,
const Box destbox
[inline]
 

: Modifies this BaseFab by coping the contents of the argument BaseFab into it. A copy within the intersecting region of the domains of the two BaseFabs and the specified Box destbox is performed. All components are copied.

template<class T>
BaseFab< T > & BaseFab< T >::copy const BaseFab< T > &  src,
int  srccomp,
int  destcomp,
int  numcomp = 1
[inline]
 

: Modifies this BaseFab by copying the contents of the argument BaseFab into it. A copy within the intersecting region of the domains of the two BaseFabs is performed. The user specifies how many components are copied, starting at component srccomp in src and stored starting at component destcomp.

template<class T>
BaseFab< T > & BaseFab< T >::copy const BaseFab< T > &  src,
const Box srcbox,
int  srccomp,
const Box destbox,
int  destcomp,
int  numcomp
[inline]
 

: Modifies this BaseFab by copying the contents of the argument BaseFab into it. This, the most general form of copy, specifies the contents of any sub-box srcbox in `BaseFab' src may be copied into a (possibly different) destbox in the destination `BaseFab'. Note that although the srcbox and the destbox may be disjoint, they must be the same size and shape. If the sizes differ, the copy is undefined and a runtime error results. This copy function is the only one of the copy functions to allow a copy between differing boxes. The user also specifies how many components are copied, starting at component srccomp in src and stored starting at component destcomp. The results are UNDEFINED if the src and dest BaseFabs are the same and the srcbox and destbox overlap.

template<class T>
const T * BaseFab< T >::dataPtr int  N = 0  )  const [inline]
 

: Returns a constant pointer to an object of type T that is the value of the Nth component associated with the cell at the low end of the domain. This is commonly used to get a pointer to data in the array which is then handed off to a Fortran subroutine. It should not be used in any other context!!! Remember that data is stored in Fortran array order, with the component index coming last. In other words, `dataPtr' returns a pointer to all the Nth components.

template<class T>
T * BaseFab< T >::dataPtr int  N = 0  )  [inline]
 

: Returns a pointer to an object of type T that is the value of the Nth component associated with the cell at the low end of the domain. This is commonly used to get a pointer to data in the array which is then handed off to a Fortran subroutine. It should not be used in any other context!!! Remember that data is stored in Fortran array order, with the component index coming last. In other words, `dataPtr' returns a pointer to all the Nth components.

template<class T>
void BaseFab< T >::define  )  [inline, protected]
 

template<class T>
void BaseFab< T >::define const Interval a_comps,
BaseFab< T > &  a_original
[inline, virtual]
 

alias define. no memory allocated. this BaseFab sets its data ptr directly in the a_original BaseFab data.

template<class T>
virtual void BaseFab< T >::define const Box box,
int  comps,
T *  alias = NULL
[inline, virtual]
 

: Make BaseFab with desired domain and number of components. existing data is lost. Data is in uninialized state.

Reimplemented in FArrayBox.

template<class T>
void BaseFab< T >::getVal T *  data,
const IntVect pos
const [inline]
 

: This function puts all component values, starting at component 0, from position pos in the domain into array data, that must be allocated by the user.

template<class T>
void BaseFab< T >::getVal T *  data,
const IntVect pos,
int  N,
int  numcomp
const [inline]
 

: This function puts numcomp component values, starting at component N, from position pos in the domain into array data, that must be allocated by the user.

template<class T>
const int * BaseFab< T >::hiVect  )  const [inline]
 

: Returns the upper corner of the domain. Instead of returning them in the form of IntVects, as in smallEnd and bigEnd, it returns the values as a pointer to an array of constant integers. This is useful when interfacing to Fortran subroutines. It should not be used in any other context!!!

template<class T>
Interval BaseFab< T >::interval  )  const [inline]
 

Returns an Interval for the entire range on components.

template<class T>
void BaseFab< T >::linearIn void *  buf,
const Box R,
const Interval comps
[inline, virtual]
 

Reimplemented in BinFab< T >.

template<class T>
void BaseFab< T >::linearOut void *  buf,
const Box R,
const Interval comps
const [inline, virtual]
 

Write a linear representation of the internal data. Assumes that sufficient memory for the buffer has already been allocated by the caller.

Reimplemented in BinFab< T >.

template<class T>
const int * BaseFab< T >::loVect  )  const [inline]
 

{ Fortran interface functions}

: Returns the lower corner of the domain. Instead of returning them in the form of IntVects, as in smallEnd and bigEnd, it returns the values as a pointer to an array of constant integers. This is useful when interfacing to Fortran subroutines. It should not be used in any other context!!!

template<class T>
std::string BaseFab< T >::name  )  [inline, static, protected]
 

template<class T>
int BaseFab< T >::nComp  )  const [inline]
 

{ accessors}

Returns the number of components.

template<class T>
const int * BaseFab< T >::nCompPtr  )  const [inline]
 

: Returns a pointer to an integer that contains the number of components in the BaseFab. This is useful when interfacing to Fortran subroutines. It should not be used in any other context!!!

template<class T>
const T & BaseFab< T >::operator() const IntVect p  )  const [inline]
 

template<class T>
const T & BaseFab< T >::operator() const IntVect p,
int  N
const [inline]
 

: Returns a conatant reference to the Nth component value defined at position p in the domain. This operator may be inefficient if the C++ compiler is unable to optimize the C++ code.

template<class T>
T & BaseFab< T >::operator() const IntVect p  )  [inline]
 

template<class T>
T & BaseFab< T >::operator() const IntVect p,
int  N
[inline]
 

: Returns a modifiable lvalue reference to the Nth component value defined at position p in the domain. This operator may be inefficient if the C++ compiler is unable to optimize the C++ code.

template<class T>
void BaseFab< T >::performCopy const BaseFab< T > &  src,
const Box srcbox,
int  srccomp,
const Box destbox,
int  destcomp,
int  numcomp
[inline, protected, virtual]
 

Reimplemented in FArrayBox.

template<class T>
void BaseFab< T >::performSetVal x,
const Box bx,
int  nstart,
int  numcomp
[inline, protected]
 

template<class T>
int BaseFab< T >::preAllocatable  )  [inline, static]
 

Reimplemented in BinFab< T >.

template<class T>
void BaseFab< T >::resize const Box b,
int  N = 1,
T *  alias = NULL
 

This function resizes a `BaseFab' so it covers the `Box' B with N components. The default action is that under resize()ing, the memory allocated for the `BaseFab' only grows and never shrinks. This function is particularly useful when a `BaseFab' is used as a temporary space which must be a different size whenever it is used. Resize()ing a temp will often be faster than re-allocating a `BaseFab' because memory allocation can often be avoided.

template<class T>
void BaseFab< T >::setVal x  )  [inline]
 

Modifies this BaseFab so that all values of all components are set to the given value x.

template<class T>
void BaseFab< T >::setVal x,
int  N
[inline]
 

Modifies this BaseFab so that all values of component N are set to the given value x.

template<class T>
void BaseFab< T >::setVal x,
const Box bx,
int  N
[inline]
 

Modifies this BaseFab so that all values of component N in the specified Box bx are set to the given value x.

template<class T>
void BaseFab< T >::setVal x,
const Box bx,
int  nstart,
int  ncomp
[inline]
 

{ data modification functions}

: The setVal functions set subregions in the `BaseFab' to a constant value. This most general form specifies the sub-box, the starting component number, and the number of components to be set.

template<class T>
BaseFab< T > & BaseFab< T >::shift int  idir,
int  n_cell
[inline]
 

Modifies the domain of this BaseFab by shifting it n_cells indexing positions in coordinate direction idir. Directions are zero-based. It is an error if not 0 <= idir < SpaceDim.There is no effect upon the array memory.

template<class T>
BaseFab< T > & BaseFab< T >::shift const IntVect v  )  [inline]
 

{ domain modification functions}

Modifies the domain of this BaseFab by shifting. Equivalent to fab.shift(0,iv[0]).shift(1,iv[1]) .... There is no effect upon the array memory.

template<class T>
BaseFab< T > & BaseFab< T >::shiftHalf const IntVect num_halfs  )  [inline]
 

Modifies the domain of this BaseFab by shifting by half indices. Equivalent to fab.shiftHalf(0,iv[0]).shiftHalf(1,iv[1]) ... There is no effect upon the array memory.

template<class T>
BaseFab< T > & BaseFab< T >::shiftHalf int  dir,
int  num_halfs
[inline]
 

Modifies the domain of this BaseFab by shifting by "half" indices, thereby converting the Box from type CELL to NODE or vice-versa. fab.shiftHalf(0,1) shifts the domain to the right by 1/2 cells. fab.shiftHalf(1,-3) shifts the domain 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: fab.shifthalf(4) == fab.shift(2). Directions are zero-based. It is an error if not 0 <= dir < SpaceDim. There is no effect upon the array memory.

template<class T>
int BaseFab< T >::size const Box b,
const Interval comps
const [inline, virtual]
 

{ linearization functions}

Returns the size, in number of bytes, of a flat linear representation of the data in this object in the area defined by the input Box R and the component Interval comps. The size does not include the size of R and comps.

Reimplemented in BinFab< T >.

template<class T>
const int * BaseFab< T >::size  )  const [inline]
 

: Returns a pointer to an array of SpaceDim integers giving the length of the domain in each direction.

template<class T>
const IntVect & BaseFab< T >::smallEnd  )  const [inline]
 

: Returns the lower corner of the domain. See class `Box' for analogue.

template<class T>
void BaseFab< T >::undefine  )  [inline, protected]
 


Member Data Documentation

template<class T>
bool BaseFab< T >::aliased [protected]
 

template<class T>
Box BaseFab< T >::domain [protected]
 

template<class T>
T* BaseFab< T >::dptr [protected]
 

template<class T>
long BaseFab< T >::numpts [protected]
 

template<class T>
int BaseFab< T >::nvar [protected]
 

template<class T>
Arena * BaseFab< T >::s_Arena = NULL [static, protected]
 

template<class T>
long BaseFab< T >::truesize [protected]
 


The documentation for this class was generated from the following files:
Generated on Wed Jun 2 13:58:14 2004 for Chombo&INSwithParticles by doxygen 1.3.2