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

anonymous enum
Enumerator
numCD 

Number of codimensions.

numAI 

Total orientations (array indices) for all codimensions

Constructor & Destructor Documentation

◆ CodimBox() [1/3]

CodimBox::CodimBox ( )

Default constructor.

Referenced by CodimBoxFactory::create().

◆ CodimBox() [2/3]

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

Full constructor.

◆ ~CodimBox()

CodimBox::~CodimBox ( )

Destructor.

◆ CodimBox() [3/3]

CodimBox::CodimBox ( const CodimBox )
private

Member Function Documentation

◆ initialize()

static void CodimBox::initialize ( )
static

Initialize static lookup tables.

◆ define() [1/2]

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

Full define function.

◆ define() [2/2]

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

Define function.

◆ clear()

void CodimBox::clear ( )

Deallocate.

◆ getCodim()

int CodimBox::getCodim ( ) const
inline

Return the codimension.

References m_codim.

◆ nComp()

int CodimBox::nComp ( ) const
inline

Number of components.

References m_nvar.

◆ getNumOrient() [1/2]

int CodimBox::getNumOrient ( ) const
inline

Number of different orientations of codimensional objects.

References m_codim, and numOrient.

◆ getNumOrient() [2/2]

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.

◆ bit2seq()

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().

◆ seq2bit() [1/2]

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().

◆ seq2bit() [2/2]

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.

◆ getDirection()

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

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

◆ getDirections() [1/2]

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().

◆ getDirections() [2/2]

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().

◆ box()

const Box & CodimBox::box ( ) const
inline

Returns cell-centered box which defines the CodimBox.

References m_box.

◆ operator()() [1/18]

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

Returns FArrayBox in the directions defined by a Box.

◆ operator()() [2/18]

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

Returns FArrayBox in the directions defined by a Box.

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

◆ operator()() [3/18]

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

Returns FArrayBox in the directions defined by an IndexType.

◆ operator()() [4/18]

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

◆ operator()() [5/18]

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

Returns FArrayBox in the given direction (codimension 0)

Referenced by operator()().

◆ operator()() [6/18]

FArrayBox& CodimBox::operator() ( )

◆ operator()() [7/18]

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

Returns FArrayBox in the given direction (codimension 1)

◆ operator()() [8/18]

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

◆ operator()() [9/18]

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

Returns FArrayBox in the given direction (codimension 2)

◆ operator()() [10/18]

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

◆ operator()() [11/18]

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)

◆ operator()() [12/18]

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

◆ operator()() [13/18]

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)

◆ operator()() [14/18]

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

◆ operator()() [15/18]

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)

◆ operator()() [16/18]

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

◆ operator()() [17/18]

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)

◆ operator()() [18/18]

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 
)

◆ getSequential() [1/2]

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.

◆ getSequential() [2/2]

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

References CH_assert, m_codim, m_FArrayBox, and numOrient.

◆ setVal()

void CodimBox::setVal ( const Real  a_x)

Set all values in all FAB.

◆ orientBox() [1/3]

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.

◆ orientBox() [2/3]

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().

◆ orientBox() [3/3]

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().

◆ copy() [1/2]

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

Copy from another CodimBox.

◆ copy() [2/2]

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.

◆ preAllocatable()

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

◆ size()

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

Returns size of serialized data.

◆ linearOut()

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

Writes a serialized representation of this CodimBox.

◆ linearIn()

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

Reads a serialized representation of this CodimBox.

◆ operator=()

CodimBox& CodimBox::operator= ( const CodimBox )
private

◆ isInitialized()

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().

◆ getFArrayBox() [1/2]

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

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

References bit2seq(), and m_FArrayBox.

◆ getFArrayBox() [2/2]

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.

◆ genGetDirections()

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().

◆ genOrientBox()

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

◆ numOrient

int CodimBox::numOrient[numCD]
staticprotected

Number of orientations for an object of a given codimension

Referenced by getNumOrient(), and getSequential().

◆ totOrient

int CodimBox::totOrient[numCD]
staticprotected

Total of number of orientations for all smaller codimensions

Referenced by seq2bit().

◆ bitOrient

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

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

Referenced by seq2bit().

◆ indexFAB

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().

◆ m_box

Box CodimBox::m_box
private

Cell-centered box over which this CodimBox is defined

Referenced by box(), and orientBox().

◆ m_codim

int CodimBox::m_codim
private

Codimension for which the FArrayBoxes are defined

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

◆ m_nvar

int CodimBox::m_nvar
private

Number of components in the FArrayBox.

Referenced by nComp().

◆ m_FArrayBox

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: