Chombo + EB + MF  3.2
Public Types | Public Member Functions | Static Public Member Functions | Static Protected Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
CodimBox< S > Class Template Reference

An FArrayBox container for storage on the codimensions of a box. More...

#include <CodimBox.H>

Public Types

enum  { numCD = SpaceDim + 1, numAI = 1 << SpaceDim }
 

Public Member Functions

 CodimBox ()
 Default constructor. More...
 
 CodimBox (const int a_codim, const Box &a_box, const int a_nvar)
 Full constructor. More...
 
 ~CodimBox ()
 Destructor. More...
 
void define (const int a_codim, const Box &a_box, const int a_nvar)
 Full define function. More...
 
void define (const Box &a_box, int a_nvar)
 Define function. More...
 
void clear ()
 Deallocate. More...
 
int getCodim () const
 Return the codimension. More...
 
int nComp () const
 Number of components. More...
 
int getNumOrient () const
 Number of different orientations of codimensional objects. More...
 
int bit2seq (const unsigned a_bOrient) const
 
unsigned seq2bit (const int a_iOrient) const
 
int getDirection (const int a_iOrient, int a_i) const
 Get the 'i'th orthogonal direction of an orientation. More...
 
void getDirections (const int a_iOrient, int *const a_dir) const
 Get all the orthogonal directions of an orientation. More...
 
const Boxbox () const
 Returns cell-centered box which defines the CodimBox. More...
 
const S & operator() (const Box &a_box) const
 Returns S in the directions defined by a Box. More...
 
S & operator() (const Box &a_box)
 Returns S in the directions defined by a Box. More...
 
const S & operator() (const IndexType &a_ixType) const
 Returns S in the directions defined by an IndexType. More...
 
S & operator() (const IndexType &a_ixType)
 
const S & getSequential (const int a_iOrient) const
 Returns S from a sequential index. More...
 
S & getSequential (const int a_iOrient)
 
void setVal (const Real a_x)
 Set all values in all FAB. More...
 
Box orientBox (const int a_iOrient) const
 
Box orientBox (const int a_iOrient, const Box &a_cbox) const
 
Accessor functions (1 for each codimension)
Parameters
[in]a_dir0-a_dir5The orthogonal directions define the orientation of the codimensional geometry. Directions can be specified in any order. For example, the edges in 3D orthogonal to directions i and j may be specified as (0, 1) or (1, 0). The individual directions should be unique but assertions are only implemented for codimensions <= 3.
const S & operator() () const
 Returns S in the given direction (codimension 0) More...
 
S & operator() ()
 
const S & operator() (const int a_dir0) const
 Returns S in the given direction (codimension 1) More...
 
S & operator() (const int a_dir0)
 
const S & operator() (const int a_dir0, const int a_dir1) const
 Returns S in the given direction (codimension 2) More...
 
S & operator() (const int a_dir0, const int a_dir1)
 
const S & operator() (const int a_dir0, const int a_dir1, const int a_dir2) const
 Returns S in the given direction (codimension 3) More...
 
S & operator() (const int a_dir0, const int a_dir1, const int a_dir2)
 
const S & operator() (const int a_dir0, const int a_dir1, const int a_dir2, const int a_dir3) const
 Returns S in the given direction (codimension 4) More...
 
S & operator() (const int a_dir0, const int a_dir1, const int a_dir2, const int a_dir3)
 
const S & operator() (const int a_dir0, const int a_dir1, const int a_dir2, const int a_dir3, const int a_dir4) const
 Returns S in the given direction (codimension 5) More...
 
S & operator() (const int a_dir0, const int a_dir1, const int a_dir2, const int a_dir3, const int a_dir4)
 
const S & operator() (const int a_dir0, const int a_dir1, const int a_dir2, const int a_dir3, const int a_dir4, const int a_dir5) const
 Returns S in the given direction (codimension 6) More...
 
S & operator() (const int a_dir0, const int a_dir1, const int a_dir2, const int a_dir3, const int a_dir4, const int a_dir5)
 
Functions for compatability with containers like

BoxLayoutData.h

void copy (const Box &a_R, const Interval &a_Cd, const CodimBox &a_src, const Interval &a_Cs)
 Copy from another CodimBox. More...
 
void copy (const Box &a_Rs, const Interval &a_Cd, const Box &a_Rd, const CodimBox &a_src, const Interval &a_Cs)
 Copy from another CodimBox but to a different region. More...
 
int size (const Box &a_R, const Interval &a_comps) const
 Returns size of serialized data. More...
 
void linearOut (void *a_buf, const Box &a_R, const Interval &a_comps) const
 Writes a serialized representation of this CodimBox. More...
 
void linearIn (void *a_buf, const Box &a_R, const Interval &a_comps)
 Reads a serialized representation of this CodimBox. More...
 

Static Public Member Functions

static void initialize ()
 Initialize static lookup tables. More...
 
static int getNumOrient (const int a_codim)
 
static unsigned seq2bit (const int a_codim, const int a_iOrient)
 
static void getDirections (const int a_codim, const int a_iOrient, int *const a_dir)
 
static Box orientBox (const int a_codim, const int a_iOrient, const Box &a_cbox)
 
static int preAllocatable ()
 Report preallocation capability as non-static but symmetric. More...
 

Static Protected Attributes

static int numOrient [numCD]
 
static int totOrient [numCD]
 
static unsigned bitOrient [CodimBox::numAI]
 
static int indexFAB [CodimBox::numAI]
 

Private Member Functions

 CodimBox (const CodimBox &)
 
CodimBoxoperator= (const CodimBox &)
 
S & getS (const unsigned i)
 Return the FArray box from a bit description of the orientation. More...
 
const S & getS (const unsigned i) const
 Return the FArray box from a bit description of the orientation. More...
 

Static Private Member Functions

static bool isInitialized ()
 Check that static arrays are initialized. More...
 
static void genGetDirections (const int a_codim, int a_bOrient, int *const a_dir)
 Get all the orthogonal directions of an orientation (general) More...
 
static Box genOrientBox (int a_bOrient, Box a_cbox)
 

Private Attributes

Box m_box
 
int m_codim
 
int m_nvar
 Number of components in the S. More...
 
Vector< S * > m_S
 The Ses for each orientation. More...
 

Detailed Description

template<class S>
class CodimBox< S >

An FArrayBox container for storage on the codimensions of a box.

The orientation of a box is described by specifying the orthogonal directions and internally, this is converted to a bit representation. Direction 'i' is bit 2^i (or via shifting as 1 << i). Directions can be specified in any order. For example, the edges in 3D orthogonal to directions i and j may be specified as (0, 1) or (1, 0). Internally, both are converted to 0x3. Orientations can be described by sequential indices or bit representations. The routines seq2bit and bit2seq can be used to switch between the two using lookup tables.

For example, a 3 dimensional space has the following codimensions, bit representations, and sequential indices of the orientations:

*         Codim   Bit   Integer   Sequential   numOrient   totOrient
*   Dir           zyx
*             0   000         0            0           1           0
*             1   001         1            0           3           1
*             1   010         2            1
*             1   100         4            2
*             2   011         3            0           3           4
*             2   101         5            1
*             2   110         6            2
*             3   111         7            0           1           7
*                                                                  

The 'indexFAB' and 'bitOrient' are then defined as follows:

*     indexFAB:  0 0 1 0 2 1 2 0
*     bitOrient: 0 1 2 4 3 5 6 7
*                                                                  
Note
  • CodimBoxFactory is also defined in this file for use with BoxLayoutData and similar containers
  • A FluxBox is essentially a CodimBox with codimension 1.
  • Not much functionality exists in this class beyond creating and retrieving the FArrayBoxes.
  • Codimension 0 is the original object spanning 'SpaceDim' dimensions. Using this is no different from an FArrayBox itself.
  • Codimension 'SpaceDim' is a vertex. This is also the same as an FArrayBox that surrounds all nodes.

Member Enumeration Documentation

template<class S>
anonymous enum
Enumerator
numCD 

Number of codimensions.

numAI 

Total orientations (array indices) for all codimensions

Constructor & Destructor Documentation

template<typename S >
CodimBox< S >::CodimBox ( )

Default constructor.

The codimension can be set by the 'define' function

template<typename S >
CodimBox< S >::CodimBox ( const int  a_codim,
const Box a_box,
const int  a_nvar 
)

Full constructor.

Parameters
[in]a_codimThe codimension intended for the object
[in]a_boxThe cell centered box for the FArrays
[in]a_nvarThe number of components for the FArrays

References CodimBox< S >::define(), and CodimBox< S >::initialize().

template<typename S >
CodimBox< S >::~CodimBox ( )

Destructor.

template<class S>
CodimBox< S >::CodimBox ( const CodimBox< S > &  )
private

Member Function Documentation

template<typename S >
void CodimBox< S >::initialize ( )
static

Initialize static lookup tables.

Construct lookup tables that give the index of the appropriate S for a given codimension and orientation. This function is only called once to initialize the static lookup tables. The constructors will call initialize but if any static members are used before construction, it must be called manually. See class CodimBox for more information on the lookup tables.

Referenced by CodimBox< S >::CodimBox().

template<typename S >
void CodimBox< S >::define ( const int  a_codim,
const Box a_box,
const int  a_nvar 
)

Full define function.

Define function allocates space.

Parameters
[in]a_codimThe codimension intended for the object
[in]a_boxThe cell centered box for the FArrays
[in]a_nvarThe number of components for the FArrays

References CH_assert, and SpaceDim.

Referenced by CodimBox< S >::CodimBox().

template<typename S >
void CodimBox< S >::define ( const Box a_box,
int  a_nvar 
)

Define function.

Define function allocates space.

Codimension set by constructor

Parameters
[in]a_boxThe cell centered box for the FArrays
[in]a_nvarThe number of components for the FArrays

References CH_assert.

template<typename S >
void CodimBox< S >::clear ( )

Deallocate.

Deallocation of all memory.

template<typename S >
int CodimBox< S >::getCodim ( ) const

Return the codimension.

template<typename S >
int CodimBox< S >::nComp ( ) const

Number of components.

template<typename S >
int CodimBox< S >::getNumOrient ( ) const

Number of different orientations of codimensional objects.

template<typename S >
int CodimBox< S >::getNumOrient ( const int  a_codim)
static

Number of different orientations of codimensional objects. Used externally for any codimension.

References CH_assert.

template<typename S >
int CodimBox< S >::bit2seq ( const unsigned  a_bOrient) const

Switch from a bit orientation to a sequential index of the orientation

template<typename S >
unsigned CodimBox< S >::seq2bit ( const int  a_iOrient) const

Switch from a sequential index to a bit representation of the orientation

template<typename S >
unsigned CodimBox< S >::seq2bit ( const int  a_codim,
const int  a_iOrient 
)
static

Switch from a sequential index to a bit representation of the orientation for any codimension

References CH_assert.

template<typename S >
int CodimBox< S >::getDirection ( const int  a_iOrient,
int  a_i 
) const

Get the 'i'th orthogonal direction of an orientation.

Parameters
[in]a_iOrientThe sequential orientation index from which to get the directions
[in]a_iThe 'i'th direction. 0 <= a_i < m_codim
Returns
An integer defining the requested direction 0 <= return < SpaceDim
Note
  • The directions are orderd from smallest to largest so a_i = 0 always returns the smallest direction.

References CH_assert.

template<typename S >
void CodimBox< S >::getDirections ( const int  a_iOrient,
int *const  a_dir 
) const

Get all the orthogonal directions of an orientation.

Parameters
[in]a_iOrientThe sequential orientation index from which to get the directions
[in]a_dirArray with minimum size [m_codim]
[out]a_dirIntegers defining the directions 0 <= dir[i] < SpaceDim
Note
  • The directions are orderd from smallest to largest.
template<typename S >
void CodimBox< S >::getDirections ( const int  a_codim,
const int  a_iOrient,
int *const  a_dir 
)
static

Get all the orthogonal directions of an orientation. Used externally for any codimension.

Get all the orthogonal directions of an orientation. Used externally for any codimension.

Parameters
[in]a_codimThe codimension
[in]a_iOrientThe sequential orientation index from which to get the directions
[in]a_dirArray with minimum size [m_codim]
[out]a_dirIntegers defining the directions 0 <= dir[i] < SpaceDim
Note
  • The directions are orderd from smallest to largest.

References CH_assert.

template<typename S >
const Box & CodimBox< S >::box ( ) const

Returns cell-centered box which defines the CodimBox.

template<class S>
const S& CodimBox< S >::operator() ( const Box a_box) const

Returns S in the directions defined by a Box.

template<typename S >
S & CodimBox< S >::operator() ( const Box a_box)

Returns S in the directions defined by a Box.

References Box::ixType().

template<typename S >
const S & CodimBox< S >::operator() ( const IndexType a_ixType) const

Returns S in the directions defined by an IndexType.

Parameters
[in]a_ixTypeBox index type which must define exactly m_codim directions as 'NODE'Returns S in the directions defined by an IndexType

References CH_assert, and SpaceDim.

template<typename S >
S & CodimBox< S >::operator() ( const IndexType a_ixType)

References CH_assert, and SpaceDim.

template<typename S >
const S & CodimBox< S >::operator() ( ) const

Returns S in the given direction (codimension 0)

Returns S in the given direction (codimension 0 or SpaceDim)

Formally this operator is for codimension 0 objects but it is also allowed for codimension 'SpaceDim' objects since there is also only one codimension object (the vertices) in that case. A codimension 'SpaceDim' object can also be accessed by specifying all the directions as orthogonal.

References CH_assert, and SpaceDim.

template<typename S >
S & CodimBox< S >::operator() ( )

References CH_assert, and SpaceDim.

template<typename S >
const S & CodimBox< S >::operator() ( const int  a_dir0) const

Returns S in the given direction (codimension 1)

References CH_assert, and SpaceDim.

template<typename S >
S & CodimBox< S >::operator() ( const int  a_dir0)

References CH_assert, and SpaceDim.

template<typename S >
const S & CodimBox< S >::operator() ( const int  a_dir0,
const int  a_dir1 
) const

Returns S in the given direction (codimension 2)

References CH_assert, and SpaceDim.

template<typename S >
S & CodimBox< S >::operator() ( const int  a_dir0,
const int  a_dir1 
)

References CH_assert, and SpaceDim.

template<typename S >
const S & CodimBox< S >::operator() ( const int  a_dir0,
const int  a_dir1,
const int  a_dir2 
) const

Returns S in the given direction (codimension 3)

References CH_assert, and SpaceDim.

template<typename S >
S & CodimBox< S >::operator() ( const int  a_dir0,
const int  a_dir1,
const int  a_dir2 
)

References CH_assert, and SpaceDim.

template<typename S >
const S & CodimBox< S >::operator() ( const int  a_dir0,
const int  a_dir1,
const int  a_dir2,
const int  a_dir3 
) const

Returns S in the given direction (codimension 4)

References CH_assert, and SpaceDim.

template<typename S >
S & CodimBox< S >::operator() ( const int  a_dir0,
const int  a_dir1,
const int  a_dir2,
const int  a_dir3 
)

References CH_assert, and SpaceDim.

template<typename S >
const S & CodimBox< S >::operator() ( const int  a_dir0,
const int  a_dir1,
const int  a_dir2,
const int  a_dir3,
const int  a_dir4 
) const

Returns S in the given direction (codimension 5)

References CH_assert, and SpaceDim.

template<typename S >
S & CodimBox< S >::operator() ( const int  a_dir0,
const int  a_dir1,
const int  a_dir2,
const int  a_dir3,
const int  a_dir4 
)

References CH_assert, and SpaceDim.

template<typename S >
const S & CodimBox< S >::operator() ( const int  a_dir0,
const int  a_dir1,
const int  a_dir2,
const int  a_dir3,
const int  a_dir4,
const int  a_dir5 
) const

Returns S in the given direction (codimension 6)

References CH_assert, and SpaceDim.

template<typename S >
S & CodimBox< S >::operator() ( const int  a_dir0,
const int  a_dir1,
const int  a_dir2,
const int  a_dir3,
const int  a_dir4,
const int  a_dir5 
)

References CH_assert, and SpaceDim.

template<typename S >
const S & CodimBox< S >::getSequential ( const int  a_iOrient) const

Returns S from a sequential index.

Parameters
[in]a_iOrientA sequential orientation index.
Note
  • A bit description of the orientation can be obtained from
    *            bitOrient[totOrient[a_codim] + a_iOrient]
    *          

References CH_assert.

template<typename S >
S & CodimBox< S >::getSequential ( const int  a_iOrient)

References CH_assert.

template<typename S >
void CodimBox< S >::setVal ( const Real  a_x)

Set all values in all FAB.

Parameters
[in]a_xNew value
template<typename S >
Box CodimBox< S >::orientBox ( const int  a_bOrient) const

Orient the stored box in the othogonal directions of the given orientation

Orient the stored box in the othogonal directions of the given orientation

Parameters
[in]a_bOrientA bit orientation index.
template<typename S >
Box CodimBox< S >::orientBox ( const int  a_iOrient,
const Box a_cbox 
) const

Orient a centered box in the othogonal directions of the given orientation

Orient a centered box in the othogonal directions of the given orientation

Parameters
[in]a_iOrientA sequential orientation index. This is converted to a bit orientation for finding the orthogonal directions.
[in]a_cboxA centered box.
Returns
The orientated box
template<typename S >
Box CodimBox< S >::orientBox ( const int  a_codim,
const int  a_iOrient,
const Box a_cbox 
)
static

Orient a centered box in the othogonal directions of the given orientation. Used externally for any codimension.

Orient a centered box in the othogonal directions of the given orientation. Used externally for any codimension.

Parameters
[in]a_codimThe codimension of the box
[in]a_iOrientA sequential orientation index. This is converted to a bit orientation for finding the orthogonal directions.
[in]a_cboxA centered box.
Returns
The orientated box

References CH_assert.

template<typename S >
void CodimBox< S >::copy ( const Box a_R,
const Interval a_Cd,
const CodimBox< S > &  a_src,
const Interval a_Cs 
)

Copy from another CodimBox.

Parameters
[in]a_RCentered box describing region to copy
[in]a_CdInterval for components at destination
[in]a_srcThe source CodimBox (must be same codimension)
[in]a_CsInterval for components at source
Note
  • It is assumed that both CodimBoxes have the same orientation at their intersection.
  • a_R is not assumed to be contained within m_box because higher-level copy routines generally work on cell centers.

References CH_assert, Box::copy(), Box::isEmpty(), CodimBox< S >::m_codim, and CodimBox< S >::m_S.

template<typename S >
void CodimBox< S >::copy ( const Box a_Rs,
const Interval a_Cd,
const Box a_Rd,
const CodimBox< S > &  a_src,
const Interval a_Cs 
)

Copy from another CodimBox but to a different region.

Parameters
[in]a_RsCentered box describing region to copy from in source
[in]a_CdInterval for components at destination
[in]a_RdCentered box describing region to copy to in destination
[in]a_srcThe source CodimBox (must be same codimension)
[in]a_CsInterval for components at source
Note
  • It is assumed that both CodimBoxes have the same orientation at their intersection.
  • Beware that the source and destination arguments are not grouped together.
  • The story here seems to be that copyTo in a LevelData uses centered boxes to see who to copy to. So we need +1 ghost cells in the destination to ensure abutting boxes are matched and that we can then copy abutting codimension objects. Hence, a_Rd may not be contained in m_box and must be intersected. Then make assumtions about what a_Rs should be.

References CH_assert, Box::copy(), Box::isEmpty(), CodimBox< S >::m_codim, CodimBox< S >::m_S, Box::sameSize(), Box::shift(), and Box::smallEnd().

template<typename S >
int CodimBox< S >::preAllocatable ( )
static

Report preallocation capability as non-static but symmetric.

The size of the class is dependent upon the codimension. See BoxLayoutData.H for more info

template<typename S >
int CodimBox< S >::size ( const Box a_R,
const Interval a_comps 
) const

Returns size of serialized data.

Returns size, in number of bytes, of a 1D representation of data in the class.

Parameters
[in]a_RCentered box describing size
[in]a_compsNumber of components for describing size
template<typename S >
void CodimBox< S >::linearOut ( void *  a_buf,
const Box a_R,
const Interval a_comps 
) const

Writes a serialized representation of this CodimBox.

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

Parameters
[in]a_bufBuffer for linear representation
[in]a_RCentered box from which to write
[in]a_compsComponents to be written

References CH_assert.

template<typename S >
void CodimBox< S >::linearIn ( void *  a_buf,
const Box a_R,
const Interval a_comps 
)

Reads a serialized representation of this CodimBox.

Reads in the output of linearOut.

Parameters
[in]a_bufBuffer for linear representation
[in]a_RCentered box to read to
[in]a_compsComponents to be read

References CH_assert.

template<class S>
CodimBox& CodimBox< S >::operator= ( const CodimBox< S > &  )
private
template<typename S >
bool CodimBox< S >::isInitialized ( )
staticprivate

Check that static arrays are initialized.

Test assumes static arrays have at least been default initialized.

Returns
T - Arrays initialized
template<typename S >
S & CodimBox< S >::getS ( const unsigned  i)
private

Return the FArray box from a bit description of the orientation.

template<typename S >
const S & CodimBox< S >::getS ( const unsigned  a_bOrient) const
private

Return the FArray box from a bit description of the orientation.

The appropriate FArray box for this codimension and orientation is given by a query to 'indexFAB'

Parameters
[in]a_bOrientBit description of the orientation
template<typename S >
void CodimBox< S >::genGetDirections ( const int  a_codim,
int  a_bOrient,
int *const  a_dir 
)
staticprivate

Get all the orthogonal directions of an orientation (general)

General static routine for a given codimension and a bit representation of the orientation

Parameters
[in]a_codimThe codimension
[in]a_bOrientBit representation of the orientation
[in]a_dirArray with minimum size [a_codim]
[out]a_dirIntegers defining the directions 0 <= dir[i] < SpaceDim
Note
  • The directions are orderd from smallest to largest.
template<typename S >
Box CodimBox< S >::genOrientBox ( int  a_bOrient,
Box  a_cbox 
)
staticprivate

Orient a centered box in the othogonal directions of the given orientation (general)

Orient a centered box in the othogonal directions of the given orientation (general) General static routine for a given codimension and a bit representation of the orientation

Parameters
[in]a_bOrientBit representation of the orientation
[in]a_cboxA centered box.
Returns
The orientated box

References Box::surroundingNodes().

Member Data Documentation

template<class S>
int CodimBox< S >::numOrient
staticprotected
Initial value:
=
{
-1
}

Number of orientations for an object of a given codimension

template<class S>
int CodimBox< S >::totOrient
staticprotected
Initial value:
=
{
-1
}

Total of number of orientations for all smaller codimensions

template<class S>
unsigned CodimBox< S >::bitOrient
staticprotected
Initial value:
=
{
0
}

A sequential list of bit representations of possible orientations for each codimension

template<class S>
int CodimBox< S >::indexFAB
staticprotected
Initial value:
=
{
-1
}

Returns the index of the S for a given codimension and orientation. The input index expresses the orientation as the sum of the orthogonal directions.

template<class S>
Box CodimBox< S >::m_box
private

Cell-centered box over which this CodimBox is defined

template<class S>
int CodimBox< S >::m_codim
private

Codimension for which the Ses are defined

Referenced by CodimBox< S >::copy().

template<class S>
int CodimBox< S >::m_nvar
private

Number of components in the S.

template<class S>
Vector<S*> CodimBox< S >::m_S
private

The Ses for each orientation.

Referenced by CodimBox< S >::copy().


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