One can think of an EBIndexSpace as a function which, for a given
, returns one of three values:
A naive representation of such a function would be as a Fab over the problem domain. One would define a BaseFab<Foo>, where the class Foo would contain the following data:
class Foo
{
...
enum CellType {Irregular,Regular,Covered}
CellType ct; // Type of cell.
Vector<Bar> ir; // Vector of data for cell fragments, one element for
// each fragment. ir.length() = 0 if ct != Irregular.
}
Here, Bar is a container class for the irregular cell attributes.
This constitutes an inefficient way to store the regular cell and
covered cell information, if those make up the bulk of the domain. For example,
if a large rectangular block consists of regular cells, one needs
only to specify that rectangle as a Box and a single value to
indicate that the entire rectangle consists of regular cells. For this
reason, we will use a different internal representation of the
EBIndexSpace as a
class Tree
{
public:
Tree();
// Root constructor.
Tree(Box BaseBox, int Depth);
// define function for root, corresponding to root constructor.
define(Box BaseBox, int Depth);
// Subtree constructor.
Tree(Tree* Parent, int Level)
// Destructor.
~Tree()
// Adds Leaf to tree, or augments irregular Leaf.
Leaf& addLeaf(IntVect iv,LeafType lt);
// Gets Leaf corrsponding to input IntVect.
Leaf& getLeaf(IntVect iv);
// Returns size of irregular vector.
int getIrregSize();
protected:
// root.
Tree* root;
// parent; NULL if *this is root.
Tree* parent;
// children of *this. children.box() is a 2x2 / 2x2x2 box, except for
// the root, for which it can be any nonempty box.
BaseFab<Tree*> children;
// Leaf contained in *this; only one of children or lf can be defined.
Leaf lf;
// Does this Tree have a leaf ?
bool hasLeaf;
// total depth of Tree.
int depth;
// depth of *this, where level==0 for root.
int level;
// Total number of irregular Leaves; defined only for the root.
int irregSize;
}
class Leaf
{
public:
enum LeafType(Irregular,Covered,Regular);
// Default constructor.
Leaf();
// Destructor.
~Leaf();
// Type of Leaf.
LeafType lt;
// Locations in linear array corresponding to Irregular Nodes
// located at this Leaf (defined only if lt == Irregular.
Vector<int> irregLocs;
}