Chombo + EB  3.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | List of all members
BaseFab< T > Class Template Reference

#include <BaseFab.H>

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

Public Member Functions

virtual long offset (const IntVect &a_iv, const int &a_ivar) const
 { constructors, destructor and defines} More...
 
 BaseFab ()
 
 BaseFab (const Box &a_bx, int a_n, T *a_alias=NULL)
 
 BaseFab (const Interval &a_comps, BaseFab< T > &a_original)
 
virtual ~BaseFab ()
 
void resize (const Box &a_b, int a_n=1, T *a_alias=NULL)
 
virtual void define (const Box &a_box, int a_comps, T *a_alias=NULL)
 
virtual void define (const Interval &a_comps, BaseFab< T > &a_original)
 
void clear ()
 
int nComp () const
 { accessors} More...
 
const Boxbox () const
 
IntVect size () const
 
const IntVectsmallEnd () const
 
const IntVectbigEnd () const
 
Interval interval () const
 
T & operator() (const IntVect &a_p, int a_N)
 
T & operator() (const IntVect &a_p)
 
const T & operator() (const IntVect &p, int N) const
 
const T & operator() (const IntVect &p) const
 
void getVal (T *a_data, const IntVect &a_pos, int a_N, int a_numcomp) const
 
void getVal (T *a_data, const IntVect &a_pos) const
 
const int * loVect () const
 { Fortran interface functions} More...
 
const int * hiVect () const
 
const int * nCompPtr () const
 
T * dataPtr (int a_n=0)
 
const T * dataPtr (int a_n=0) const
 
bool contains (const BaseFab< T > &a_fab) const
 { comparison functions} More...
 
bool contains (const Box &a_bx) const
 
void setVal (T a_x, const Box &a_bx, int a_nstart, int a_numcomp)
 { data modification functions} More...
 
void setVal (T a_x, const Box &a_bx, int a_n)
 
void setVal (T a_x, int a_n)
 
void setVal (T a_x)
 
BaseFab< T > & copy (const BaseFab< T > &a_src, const Box &a_srcbox, int a_srccomp, const Box &a_destbox, int a_destcomp, int a_numcomp)
 
BaseFab< T > & copy (const BaseFab< T > &a_src, int a_srccomp, int a_destcomp, int a_numcomp=1)
 
BaseFab< T > & copy (const BaseFab< T > &a_src, const Box &a_destbox)
 
BaseFab< T > & copy (const BaseFab< T > &a_src)
 
void copy (const Box &a_RegionFrom, const Interval &a_Cdest, const Box &a_RegionTo, const BaseFab< T > &a_src, const Interval &a_Csrc)
 
BaseFab< T > & shift (const IntVect &a_v)
 { domain modification functions} More...
 
BaseFab< T > & shift (int a_idir, int a_ncells)
 
BaseFab< T > & shiftHalf (int a_dir, int a_numHalfs)
 
BaseFab< T > & shiftHalf (const IntVect &a_v)
 
virtual int size (const Box &a_box, const Interval &a_comps) const
 { linearization functions} More...
 
virtual void linearOut (void *a_buf, const Box &a_R, const Interval &a_comps) const
 
virtual void * linearOut2 (void *a_buf, const Box &a_R, const Interval &a_comps) const
 Same as linearOut, but returns the current location in the buffer. More...
 
virtual void linearIn (void *a_buf, const Box &a_R, const Interval &a_comps)
 
virtual void * linearIn2 (void *a_buf, const Box &a_R, const Interval &a_comps)
 same as linearIn, but returns the current location in the buffer More...
 
void degenerate (BaseFab< T > &a_slice, const SliceSpec &a_sliceSpec) const
 
bool isAliased () const
 

Static Public Member Functions

static int preAllocatable ()
 
static int test ()
 regression test More...
 
static int testBoxAndComp ()
 regression test More...
 

Protected Member Functions

void define ()
 
void undefine ()
 
virtual void performCopy (const BaseFab< T > &a_src, const Box &a_srcbox, int a_srccomp, const Box &a_destbox, int a_destcomp, int a_numcomp)
 
void performSetVal (T a_x, const Box &a_bx, int a_nstart, int a_numcomp)
 

Static Protected Member Functions

static std::string name ()
 

Protected Attributes

Box m_domain
 
int m_nvar
 
long m_numpts
 
long m_truesize
 
T * m_dptr
 
bool m_aliased
 

Static Protected Attributes

static Arenas_Arena = NULL
 

Private Member Functions

BaseFab< T > & operator= (const BaseFab< T > &)
 
 BaseFab (const BaseFab< T > &)
 

Constructor & Destructor Documentation

◆ BaseFab() [1/4]

template<class T >
BaseFab< T >::BaseFab ( )
inline

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.

Referenced by BaseFab< Real >::offset().

◆ BaseFab() [2/4]

template<class T>
BaseFab< T >::BaseFab ( const Box a_bx,
int  a_n,
T *  a_alias = NULL 
)
inline

Constructs a BaseFab with desired domain and number of components.

◆ BaseFab() [3/4]

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.

◆ ~BaseFab()

template<class T >
BaseFab< T >::~BaseFab ( )
inlinevirtual

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

Referenced by BaseFab< Real >::offset().

◆ BaseFab() [4/4]

template<class T>
BaseFab< T >::BaseFab ( const BaseFab< T > &  )
private

Member Function Documentation

◆ offset()

template<class T>
virtual long BaseFab< T >::offset ( const IntVect a_iv,
const int &  a_ivar 
) const
inlinevirtual

{ constructors, destructor and defines}

for AggStencil and its minions

Referenced by BaseFab< Real >::offset().

◆ resize()

template<class T>
void BaseFab< T >::resize ( const Box a_b,
int  a_n = 1,
T *  a_alias = NULL 
)

This function resizes a `BaseFab' so it covers the `Box' a_b with a_n components. If a_alias is not NULL the memory it points to is used (without checking size); otherwise the existing data is lost and the new data is uninitialized.

Referenced by BaseIFFAB< FaceStencil >::define(), BaseFab< Real >::define(), and BaseFab< Real >::offset().

◆ define() [1/3]

template<class T>
virtual void BaseFab< T >::define ( const Box a_box,
int  a_comps,
T *  a_alias = NULL 
)
inlinevirtual

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

Reimplemented in FArrayBox.

Referenced by BaseFab< Real >::degenerate(), and BaseFab< Real >::testBoxAndComp().

◆ define() [2/3]

template<class T>
void BaseFab< T >::define ( const Interval a_comps,
BaseFab< T > &  a_original 
)
inlinevirtual

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

Reimplemented in FArrayBox.

◆ clear()

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.

Referenced by BaseFab< Real >::define().

◆ nComp()

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

◆ box()

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

◆ size() [1/2]

template<class T >
IntVect BaseFab< T >::size ( ) const
inline

Returns an IntVect giving the length of the domain in each direction.

Referenced by BaseFab< Real >::define(), BaseFab< Real >::getVal(), BaseFab< Real >::interval(), and BaseFab< Real >::testBoxAndComp().

◆ smallEnd()

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

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

Referenced by BaseFab< Real >::define(), and BaseFab< Real >::testBoxAndComp().

◆ bigEnd()

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

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

Referenced by BaseFab< Real >::define(), and BaseFab< Real >::testBoxAndComp().

◆ interval()

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

Returns an Interval for the entire range on components.

◆ operator()() [1/4]

template<class T >
T & BaseFab< T >::operator() ( const IntVect a_p,
int  a_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.

Referenced by BaseFab< Real >::interval().

◆ operator()() [2/4]

template<class T >
T & BaseFab< T >::operator() ( const IntVect a_p)
inline

◆ operator()() [3/4]

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.

◆ operator()() [4/4]

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

◆ getVal() [1/2]

template<class T>
void BaseFab< T >::getVal ( T *  a_data,
const IntVect a_pos,
int  a_N,
int  a_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.

Referenced by BaseFab< Real >::getVal(), and BaseFab< Real >::interval().

◆ getVal() [2/2]

template<class T>
void BaseFab< T >::getVal ( T *  a_data,
const IntVect a_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.

◆ loVect()

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!!!

Referenced by BaseFab< Real >::interval().

◆ hiVect()

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!!!

Referenced by BaseFab< Real >::interval().

◆ nCompPtr()

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!!!

Referenced by BaseFab< Real >::interval().

◆ dataPtr() [1/2]

template<class T >
T * BaseFab< T >::dataPtr ( int  a_n = 0)
inline

Returns a pointer to an object of type T that is the value of the a_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 a_nth components.

Referenced by BaseFab< Real >::define(), and BaseFab< Real >::interval().

◆ dataPtr() [2/2]

template<class T >
const T * BaseFab< T >::dataPtr ( int  a_n = 0) const
inline

Returns a constant pointer to an object of type T that is the value of the a_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 a_nth components.

◆ contains() [1/2]

template<class T>
bool BaseFab< T >::contains ( const BaseFab< T > &  a_fab) const
inline

{ comparison functions}

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

Referenced by BaseFab< Real >::interval(), and BaseFab< Real >::performCopy().

◆ contains() [2/2]

template<class T>
bool BaseFab< T >::contains ( const Box a_bx) const
inline

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

◆ setVal() [1/4]

template<class T>
void BaseFab< T >::setVal ( a_x,
const Box a_bx,
int  a_nstart,
int  a_numcomp 
)
inline

{ data modification functions}

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

Referenced by PetscSolver< LevelData< FArrayBox > >::create_mat_vec(), BaseIFFAB< FaceStencil >::define(), and BaseFab< Real >::interval().

◆ setVal() [2/4]

template<class T>
void BaseFab< T >::setVal ( a_x,
const Box a_bx,
int  a_n 
)
inline

Modifies this BaseFab so that all values of a component, a_n, in the specified Box, a_bx, are set to the given value, a_x.

◆ setVal() [3/4]

template<class T>
void BaseFab< T >::setVal ( a_x,
int  a_n 
)
inline

Modifies this BaseFab so that all values of a component, a_n, are set to the given value, a_x.

◆ setVal() [4/4]

template<class T>
void BaseFab< T >::setVal ( a_x)
inline

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

◆ copy() [1/5]

template<class T>
BaseFab< T > & BaseFab< T >::copy ( const BaseFab< T > &  a_src,
const Box a_srcbox,
int  a_srccomp,
const Box a_destbox,
int  a_destcomp,
int  a_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 a_srcbox in `BaseFab' a_src may be copied into a (possibly different) a_destbox in the destination `BaseFab'. Note that although the a_srcbox and the a_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 a_srccomp in a_src and stored starting at component a_destcomp. The results are UNDEFINED if the a_src and dest BaseFabs are the same and the a_srcbox and a_destbox overlap.

Referenced by BaseFab< Real >::copy(), BaseFab< Real >::degenerate(), and BaseFab< Real >::interval().

◆ copy() [2/5]

template<class T>
BaseFab< T > & BaseFab< T >::copy ( const BaseFab< T > &  a_src,
int  a_srccomp,
int  a_destcomp,
int  a_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 a_srccomp in a_src and stored starting at component a_destcomp.

◆ copy() [3/5]

template<class T>
BaseFab< T > & BaseFab< T >::copy ( const BaseFab< T > &  a_src,
const Box a_destbox 
)
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 and the specified Box a_destbox is performed. All components are copied.

◆ copy() [4/5]

template<class T>
BaseFab< T > & BaseFab< T >::copy ( const BaseFab< T > &  a_src)
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. All components are copied.

◆ copy() [5/5]

template<class T>
void BaseFab< T >::copy ( const Box a_RegionFrom,
const Interval a_Cdest,
const Box a_RegionTo,
const BaseFab< T > &  a_src,
const Interval a_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.

◆ shift() [1/2]

template<class T >
BaseFab< T > & BaseFab< T >::shift ( const IntVect a_v)
inline

{ domain modification functions}

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

Referenced by BaseFab< Real >::interval().

◆ shift() [2/2]

template<class T >
BaseFab< T > & BaseFab< T >::shift ( int  a_idir,
int  a_ncells 
)
inline

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

◆ shiftHalf() [1/2]

template<class T >
BaseFab< T > & BaseFab< T >::shiftHalf ( int  a_dir,
int  a_numHalfs 
)
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 a_numHalfs is EVEN the shift is a_numHalfs/2 full zones and hence will not change the type. This is: fab.shiftHalf(1,4) == fab.shift(1,2). Directions are zero-based. It is an error if not 0 <= a_dir < SpaceDim. There is no effect upon the array memory.

Referenced by BaseFab< Real >::interval().

◆ shiftHalf() [2/2]

template<class T >
BaseFab< T > & BaseFab< T >::shiftHalf ( const IntVect a_v)
inline

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

◆ size() [2/2]

template<class T >
int BaseFab< T >::size ( const Box a_box,
const Interval a_comps 
) const
inlinevirtual

{ 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 a_box and the component Interval a_comps. The size does not include the size of a_box and a_comps.

◆ linearOut()

template<class T >
void BaseFab< T >::linearOut ( void *  a_buf,
const Box a_R,
const Interval a_comps 
) const
inlinevirtual

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

Referenced by BaseFab< Real >::interval().

◆ linearOut2()

template<class T >
void * BaseFab< T >::linearOut2 ( void *  a_buf,
const Box a_R,
const Interval a_comps 
) const
inlinevirtual

Same as linearOut, but returns the current location in the buffer.

Referenced by BaseFab< Real >::interval(), and BaseFab< Real >::linearOut().

◆ linearIn()

template<class T >
void BaseFab< T >::linearIn ( void *  a_buf,
const Box a_R,
const Interval a_comps 
)
inlinevirtual

◆ linearIn2()

template<class T >
void * BaseFab< T >::linearIn2 ( void *  a_buf,
const Box a_R,
const Interval a_comps 
)
inlinevirtual

same as linearIn, but returns the current location in the buffer

Referenced by BaseFab< Real >::interval(), and BaseFab< Real >::linearIn().

◆ preAllocatable()

template<class T>
static int BaseFab< T >::preAllocatable ( )
inlinestatic

◆ degenerate()

template<class T>
void BaseFab< T >::degenerate ( BaseFab< T > &  a_slice,
const SliceSpec a_sliceSpec 
) const

Turns a_slice into a BaseFab that's the same as *this except that it's just one cell thick in the a_sliceSpec.direction-th direction, and its coordinate in that direction is a_sliceSpec.position.

If a_sliceSpec.position is outside the range of *this, that's a fatal error.

Referenced by BaseFab< Real >::preAllocatable().

◆ isAliased()

template<class T >
bool BaseFab< T >::isAliased ( ) const

◆ test()

template<class T >
int BaseFab< T >::test ( )
static

regression test

Referenced by BaseFab< Real >::preAllocatable().

◆ testBoxAndComp()

template<class T >
int BaseFab< T >::testBoxAndComp ( )
static

regression test

Referenced by BaseFab< Real >::preAllocatable().

◆ define() [3/3]

template<class T>
void BaseFab< T >::define ( )
inlineprotected

◆ undefine()

template<class T >
void BaseFab< T >::undefine ( )
inlineprotected

◆ name()

template<class T >
std::string BaseFab< T >::name ( )
inlinestaticprotected

◆ performCopy()

template<class T>
void BaseFab< T >::performCopy ( const BaseFab< T > &  a_src,
const Box a_srcbox,
int  a_srccomp,
const Box a_destbox,
int  a_destcomp,
int  a_numcomp 
)
inlineprotectedvirtual

◆ performSetVal()

template<class T>
void BaseFab< T >::performSetVal ( a_x,
const Box a_bx,
int  a_nstart,
int  a_numcomp 
)
inlineprotected

◆ operator=()

template<class T>
BaseFab<T>& BaseFab< T >::operator= ( const BaseFab< T > &  )
private

Member Data Documentation

◆ s_Arena

template<class T>
Arena * BaseFab< T >::s_Arena = NULL
staticprotected

◆ m_domain

template<class T>
Box BaseFab< T >::m_domain
protected

◆ m_nvar

template<class T>
int BaseFab< T >::m_nvar
protected

◆ m_numpts

template<class T>
long BaseFab< T >::m_numpts
protected

◆ m_truesize

template<class T>
long BaseFab< T >::m_truesize
protected

◆ m_dptr

template<class T>
T* BaseFab< T >::m_dptr
protected

◆ m_aliased

template<class T>
bool BaseFab< T >::m_aliased
protected

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