Chombo + EB  3.0
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 Class 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 FArrayBoxoperator() (const Box &a_box) const
 Returns FArrayBox in the directions defined by a Box. More...
 
FArrayBoxoperator() (const Box &a_box)
 Returns FArrayBox in the directions defined by a Box. More...
 
const FArrayBoxoperator() (const IndexType &a_ixType) const
 Returns FArrayBox in the directions defined by an IndexType. More...
 
FArrayBoxoperator() (const IndexType &a_ixType)
 
const FArrayBoxoperator() () const
 Returns FArrayBox in the given direction (codimension 0) More...
 
FArrayBoxoperator() ()
 
const FArrayBoxoperator() (const int a_dir0) const
 Returns FArrayBox in the given direction (codimension 1) More...
 
FArrayBoxoperator() (const int a_dir0)
 
const FArrayBoxoperator() (const int a_dir0, const int a_dir1) const
 Returns FArrayBox in the given direction (codimension 2) More...
 
FArrayBoxoperator() (const int a_dir0, const int a_dir1)
 
const FArrayBoxoperator() (const int a_dir0, const int a_dir1, const int a_dir2) const
 Returns FArrayBox in the given direction (codimension 3) More...
 
FArrayBoxoperator() (const int a_dir0, const int a_dir1, const int a_dir2)
 
const FArrayBoxoperator() (const int a_dir0, const int a_dir1, const int a_dir2, const int a_dir3) const
 Returns FArrayBox in the given direction (codimension 4) More...
 
FArrayBoxoperator() (const int a_dir0, const int a_dir1, const int a_dir2, const int a_dir3)
 
const FArrayBoxoperator() (const int a_dir0, const int a_dir1, const int a_dir2, const int a_dir3, const int a_dir4) const
 Returns FArrayBox in the given direction (codimension 5) More...
 
FArrayBoxoperator() (const int a_dir0, const int a_dir1, const int a_dir2, const int a_dir3, const int a_dir4)
 
const FArrayBoxoperator() (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 FArrayBox in the given direction (codimension 6) More...
 
FArrayBoxoperator() (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 FArrayBoxgetSequential (const int a_iOrient) const
 Returns FArrayBox from a sequential index. More...
 
FArrayBoxgetSequential (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
 
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 &)
 
FArrayBoxgetFArrayBox (const unsigned i)
 Return the FArray box from a bit description of the orientation. More...
 
const FArrayBoxgetFArrayBox (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 FArrayBox. More...
 
Vector< FArrayBox * > m_FArrayBox
 The FArrayBoxes for each orientation. More...
 

Detailed Description

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

anonymous enum
Enumerator
numCD 

Number of codimensions.

numAI 

Total orientations (array indices) for all codimensions

Constructor & Destructor Documentation

CodimBox::CodimBox ( )

Default constructor.

CodimBox::CodimBox ( const int  a_codim,
const Box a_box,
const int  a_nvar 
)

Full constructor.

CodimBox::~CodimBox ( )

Destructor.

CodimBox::CodimBox ( const CodimBox )
private

Member Function Documentation

static void CodimBox::initialize ( )
static

Initialize static lookup tables.

void CodimBox::define ( const int  a_codim,
const Box a_box,
const int  a_nvar 
)

Full define function.

void CodimBox::define ( const Box a_box,
int  a_nvar 
)

Define function.

void CodimBox::clear ( )

Deallocate.

int CodimBox::getCodim ( ) const
inline

Return the codimension.

References m_codim.

int CodimBox::nComp ( ) const
inline

Number of components.

References m_nvar.

int CodimBox::getNumOrient ( ) const
inline

Number of different orientations of codimensional objects.

References m_codim, and numOrient.

int CodimBox::getNumOrient ( const int  a_codim)
inlinestatic

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

References CH_assert, isInitialized(), and numOrient.

int CodimBox::bit2seq ( const unsigned  a_bOrient) const
inline

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

References indexFAB.

Referenced by getFArrayBox().

unsigned CodimBox::seq2bit ( const int  a_iOrient) const
inline

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

References bitOrient, m_codim, and totOrient.

Referenced by getDirections(), and orientBox().

unsigned CodimBox::seq2bit ( const int  a_codim,
const int  a_iOrient 
)
inlinestatic

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

References bitOrient, CH_assert, isInitialized(), and totOrient.

int CodimBox::getDirection ( const int  a_iOrient,
int  a_i 
) const

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

void CodimBox::getDirections ( const int  a_iOrient,
int *const  a_dir 
) const
inline

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.

References genGetDirections(), m_codim, and seq2bit().

void CodimBox::getDirections ( const int  a_codim,
const int  a_iOrient,
int *const  a_dir 
)
inlinestatic

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, genGetDirections(), isInitialized(), and seq2bit().

const Box & CodimBox::box ( ) const
inline

Returns cell-centered box which defines the CodimBox.

References m_box.

const FArrayBox& CodimBox::operator() ( const Box a_box) const

Returns FArrayBox in the directions defined by a Box.

FArrayBox & CodimBox::operator() ( const Box a_box)
inline

Returns FArrayBox in the directions defined by a Box.

References Box::ixType(), and operator()().

const FArrayBox& CodimBox::operator() ( const IndexType a_ixType) const

Returns FArrayBox in the directions defined by an IndexType.

FArrayBox& CodimBox::operator() ( const IndexType a_ixType)
const FArrayBox& CodimBox::operator() ( ) const

Returns FArrayBox in the given direction (codimension 0)

Referenced by operator()().

FArrayBox& CodimBox::operator() ( )
const FArrayBox& CodimBox::operator() ( const int  a_dir0) const

Returns FArrayBox in the given direction (codimension 1)

FArrayBox& CodimBox::operator() ( const int  a_dir0)
const FArrayBox& CodimBox::operator() ( const int  a_dir0,
const int  a_dir1 
) const

Returns FArrayBox in the given direction (codimension 2)

FArrayBox& CodimBox::operator() ( const int  a_dir0,
const int  a_dir1 
)
const FArrayBox& CodimBox::operator() ( const int  a_dir0,
const int  a_dir1,
const int  a_dir2 
) const

Returns FArrayBox in the given direction (codimension 3)

FArrayBox& CodimBox::operator() ( const int  a_dir0,
const int  a_dir1,
const int  a_dir2 
)
const FArrayBox& CodimBox::operator() ( const int  a_dir0,
const int  a_dir1,
const int  a_dir2,
const int  a_dir3 
) const

Returns FArrayBox in the given direction (codimension 4)

FArrayBox& CodimBox::operator() ( const int  a_dir0,
const int  a_dir1,
const int  a_dir2,
const int  a_dir3 
)
const FArrayBox& CodimBox::operator() ( const int  a_dir0,
const int  a_dir1,
const int  a_dir2,
const int  a_dir3,
const int  a_dir4 
) const

Returns FArrayBox in the given direction (codimension 5)

FArrayBox& CodimBox::operator() ( const int  a_dir0,
const int  a_dir1,
const int  a_dir2,
const int  a_dir3,
const int  a_dir4 
)
const FArrayBox& CodimBox::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 FArrayBox in the given direction (codimension 6)

FArrayBox& CodimBox::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 FArrayBox & CodimBox::getSequential ( const int  a_iOrient) const
inline

Returns FArrayBox 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, m_codim, m_FArrayBox, and numOrient.

FArrayBox & CodimBox::getSequential ( const int  a_iOrient)
inline

References CH_assert, m_codim, m_FArrayBox, and numOrient.

void CodimBox::setVal ( const Real  a_x)

Set all values in all FAB.

Box CodimBox::orientBox ( const int  a_bOrient) const
inline

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.

References m_box.

Box CodimBox::orientBox ( const int  a_iOrient,
const Box a_cbox 
) const
inline

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

References genOrientBox(), and seq2bit().

Box CodimBox::orientBox ( const int  a_codim,
const int  a_iOrient,
const Box a_cbox 
)
inlinestatic

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, genOrientBox(), isInitialized(), and seq2bit().

void CodimBox::copy ( const Box a_R,
const Interval a_Cd,
const CodimBox a_src,
const Interval a_Cs 
)

Copy from another CodimBox.

void CodimBox::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.

int CodimBox::preAllocatable ( )
inlinestatic

Report preallocation capability as non-static but symmetric.

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

int CodimBox::size ( const Box a_R,
const Interval a_comps 
) const

Returns size of serialized data.

void CodimBox::linearOut ( void *  a_buf,
const Box a_R,
const Interval a_comps 
) const

Writes a serialized representation of this CodimBox.

void CodimBox::linearIn ( void *  a_buf,
const Box a_R,
const Interval a_comps 
)

Reads a serialized representation of this CodimBox.

CodimBox& CodimBox::operator= ( const CodimBox )
private
bool CodimBox::isInitialized ( )
inlinestaticprivate

Check that static arrays are initialized.

Test assumes static arrays have at least been default initialized.

Returns
T - Arrays initialized

References indexFAB.

Referenced by getDirections(), getNumOrient(), orientBox(), and seq2bit().

FArrayBox & CodimBox::getFArrayBox ( const unsigned  i)
inlineprivate

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

References bit2seq(), and m_FArrayBox.

const FArrayBox & CodimBox::getFArrayBox ( const unsigned  a_bOrient) const
inlineprivate

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

References bit2seq(), and m_FArrayBox.

static void CodimBox::genGetDirections ( const int  a_codim,
int  a_bOrient,
int *const  a_dir 
)
staticprivate

Get all the orthogonal directions of an orientation (general)

Referenced by getDirections().

static Box CodimBox::genOrientBox ( int  a_bOrient,
Box  a_cbox 
)
staticprivate

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

Referenced by orientBox().

Member Data Documentation

int CodimBox::numOrient[numCD]
staticprotected

Number of orientations for an object of a given codimension

Referenced by getNumOrient(), and getSequential().

int CodimBox::totOrient[numCD]
staticprotected

Total of number of orientations for all smaller codimensions

Referenced by seq2bit().

unsigned CodimBox::bitOrient[CodimBox::numAI]
staticprotected

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

Referenced by seq2bit().

int CodimBox::indexFAB[CodimBox::numAI]
staticprotected

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

Referenced by bit2seq(), and isInitialized().

Box CodimBox::m_box
private

Cell-centered box over which this CodimBox is defined

Referenced by box(), and orientBox().

int CodimBox::m_codim
private

Codimension for which the FArrayBoxes are defined

Referenced by getCodim(), getDirections(), getNumOrient(), getSequential(), and seq2bit().

int CodimBox::m_nvar
private

Number of components in the FArrayBox.

Referenced by nComp().

Vector<FArrayBox*> CodimBox::m_FArrayBox
private

The FArrayBoxes for each orientation.

Referenced by getFArrayBox(), and getSequential().


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