VAPoR  0.1
Classes | Public Types | Public Member Functions | Static Public Attributes | List of all members
VAPoR::AMRTreeBranch Class Reference

This class manages an octree data structure. More...

#include <AMRTreeBranch.h>

Inheritance diagram for VAPoR::AMRTreeBranch:
VetsUtil::MyBase

Public Types

typedef long cid_t
 
- Public Types inherited from VetsUtil::MyBase
typedef void(* ErrMsgCB_T )(const char *msg, int err_code)
 
typedef void(* DiagMsgCB_T )(const char *msg)
 

Public Member Functions

 AMRTreeBranch (XmlNode *parent, const double min[3], const double max[3], const size_t location[3])
 
virtual ~AMRTreeBranch ()
 
void Update ()
 
int DeleteCell (cid_t cellid)
 
cid_t FindCell (const double ucoord[3], int ref_level=-1) const
 
bool ValidCell (cid_t cellid) const
 
int GetCellBounds (cid_t cellid, double minu[3], double maxu[3]) const
 
int GetCellLocation (cid_t cellid, size_t xyz[3], int *reflevel) const
 
AMRTreeBranch::cid_t GetCellID (const size_t xyz[3], int reflevel) const
 
cid_t GetCellChildren (cid_t cellid) const
 
int GetCellLevel (cid_t cellid) const
 
cid_t GetCellNeighbor (cid_t cellid, int face) const
 
cid_t GetNumCells () const
 
cid_t GetNumCells (int ref_level) const
 
cid_t GetCellParent (cid_t cellid) const
 
int GetRefinementLevel () const
 Returns the maximum refinement level of any cell in this branch. More...
 
cid_t GetRoot () const
 Returns the cellid root node. More...
 
int HasChildren (cid_t cellid) const
 
AMRTreeBranch::cid_t RefineCell (cid_t cellid)
 
void EndRefinement ()
 
AMRTreeBranch::cid_t GetNextCell (bool restart)
 
long GetCellOffset (cid_t cellid) const
 
int SetParentTable (const vector< long > &table)
 
- Public Member Functions inherited from VetsUtil::MyBase
 MyBase ()
 
const string & getClassName () const
 

Static Public Attributes

static const string _rootTag
 
static const string _refinementLevelTag
 
static const string _parentTableTag
 
static const string _minExtentsAttr
 
static const string _maxExtentsAttr
 
static const string _locationAttr
 
- Static Public Attributes inherited from VetsUtil::MyBase
static char * ErrMsg
 
static int ErrCode
 
static int ErrMsgSize
 
static FILE * ErrMsgFilePtr
 
static ErrMsgCB_T ErrMsgCB
 
static char * DiagMsg
 
static int DiagMsgSize
 
static FILE * DiagMsgFilePtr
 
static DiagMsgCB_T DiagMsgCB
 
static bool Enabled
 

Additional Inherited Members

- Static Public Member Functions inherited from VetsUtil::MyBase
static void SetErrMsg (const char *format,...)
 Record a formatted error message. More...
 
static void SetErrMsg (int errcode, const char *format,...)
 Record a formatted error message and an error code. More...
 
static const char * GetErrMsg ()
 
static void SetErrCode (int err_code)
 Record an error code. More...
 
static int GetErrCode ()
 Retrieve the current error code. More...
 
static void SetErrMsgCB (ErrMsgCB_T cb)
 
static ErrMsgCB_T GetErrMsgCB ()
 
static void SetErrMsgFilePtr (FILE *fp)
 
static const FILE * SetErrMsgFilePtr ()
 
static void SetDiagMsg (const char *format,...)
 Record a formatted diagnostic message. More...
 
static const char * GetDiagMsg ()
 
static void SetDiagMsgCB (DiagMsgCB_T cb)
 
static DiagMsgCB_T GetDiagMsgCB ()
 
static void SetDiagMsgFilePtr (FILE *fp)
 
static bool EnableErrMsg (bool enable)
 
- Protected Member Functions inherited from VetsUtil::MyBase
void SetClassName (const string &name)
 

Detailed Description

This class manages an octree data structure.

Author
John Clyne
Version
$Revision$
Date
$Date$

This class manages a branch of Adaptive Mesh Refinement tree data structure. In actuality, the tree data structure is simply an octree. There is not much particular about it with regard to AMR. The root of the tree has a single node (cell). Nodes are refined by subdivision into octants. Each node has an integer cell identifier. Cell id's are ordered sequentially based on creation. The root node has id 0 (zero). The root's children are numbered 1-8, with child #1 coresponding to the octant with lowest coordinate bounds and child #8 coresponding to the octant with the highest coordinate bounds.

This class is derived from the MyBase base class. Hence all of the methods make use of MyBase's error reporting capability - the success of any method (including constructors) can (and should) be tested with the GetErrCode() method. If non-zero, an error message can be retrieved with GetErrMsg().

No field data is stored with the AMRTreeBranch class.

Definition at line 65 of file AMRTreeBranch.h.

Member Typedef Documentation

Definition at line 69 of file AMRTreeBranch.h.

Constructor & Destructor Documentation

VAPoR::AMRTreeBranch::AMRTreeBranch ( XmlNode parent,
const double  min[3],
const double  max[3],
const size_t  location[3] 
)

Constructor for the AMRTreeBranch class.

Contructs a root tree with no children. The refinement level is zero (0)

Parameters
[in]parentParent node of XML tree
[in]minA three element array indicating the minimum X,Y,Z bounds of the tree branch, specified in user coordinates.
[in]maxA three element array indicating the maximum X,Y,Z bounds of the tree branch, specified in user coordinates.
[in]locationA three element integer array indicating the coordinates of this branch relative to other branches in an AMR tree.
See also
AMRTree
virtual VAPoR::AMRTreeBranch::~AMRTreeBranch ( )
virtual

Member Function Documentation

int VAPoR::AMRTreeBranch::DeleteCell ( cid_t  cellid)

Delete a cell from the tree branch

Deletes the indicated cell from the tree branch

Parameters
[in]cellidCell id of cell to delete
Return values
statusReturns a non-negative value on success
void VAPoR::AMRTreeBranch::EndRefinement ( )

End cell refinement

This method informs the class that cell refinement is complete, allowing the class to build data structures that may speed subsequent class methods. Calling this method is optional. The results of calling this method before cell refinement is complete are undefined.

See also
RefineCell()
cid_t VAPoR::AMRTreeBranch::FindCell ( const double  ucoord[3],
int  ref_level = -1 
) const

Find a cell containing a point.

This method returns the cell id of the node containing a point. The coordinates of the point are specfied in the user coordinates defined by the during the branch's construction (it is assumed that the branch occupies Cartesian space and that all cells are rectangular. By default, the leaf node containing the point is returned. However, an ancestor node may be returned by specifying limiting the refinement level.

Parameters
[in]ucoordA three element array containing the coordintes of the point to be found.
[in]ref_levelThe refinement level of the cell to be returned. If -1, a leaf node (cell) is returned.
Return values
cellidA valid cell id is returned if the branch contains the indicated point. Otherwise a negative int is returned.
int VAPoR::AMRTreeBranch::GetCellBounds ( cid_t  cellid,
double  minu[3],
double  maxu[3] 
) const

Return the user coordinate bounds of a cell

This method returns the minimum and maximum extents of the indicated cell. The extents are in user coordinates as defined by the constructor for the class. The bounds for the root cell are guaranteed to be the same as those used to construct the class.

Parameters
[in]cellidThe cell id of the cell whose bounds are to be returned
[out]minuA three element array to which the minimum cell extents will be copied.
[out]maxuA three element array to which the maximum cell extents will be copied.
Return values
statusReturns a non-negative value on success
cid_t VAPoR::AMRTreeBranch::GetCellChildren ( cid_t  cellid) const

Returns the cell id of the first child of a node

This method returns the cell id of the first of the eight children of the cell indicated by cellid. The remaining seven children's ids may be calulated by incrementing the first child's id successively. I.e. the children have contiguous integer ids. Octants are ordered with the X axis varying fastest, followed by Y, then Z.

Parameters
[in]cellidThe cell id of the cell whose first child is to be returned.
Return values
cellidA valid cell id is returned if the branch contains the indicated point. Otherwise a negative int is returned.
AMRTreeBranch::cid_t VAPoR::AMRTreeBranch::GetCellID ( const size_t  xyz[3],
int  reflevel 
) const

Return the cellid for a cell with the given i-j-k coordinates

This method returns the cellid for the cell indicated by the i-j-k coordinates at a given refinement level.

Parameters
[in]xyzThe cell's location
[in]reflevelThe refinement level of the cell
[in]cellidThe cell id of the cell whose bounds are to be returned
Return values
statusReturns a non-negative value on success. A negative int is returned xyz are invalid for refinement level.
See also
GetCellLocation()
int VAPoR::AMRTreeBranch::GetCellLevel ( cid_t  cellid) const

Return the refinement level of a cell

Returns the refinement level of the cell indicated by cellid. The base (coarsest) refinement level is zero (0).

Parameters
[in]cellidThe cell id of the cell whose refinement level is to be returned.
Return values
statusReturns a non-negative value on success
int VAPoR::AMRTreeBranch::GetCellLocation ( cid_t  cellid,
size_t  xyz[3],
int *  reflevel 
) const

Return the topological coordinates of a cell within the branch.

This method returns topological coordinates of a cell within the tree, relative to the cell's refinement level. Each cell in a branch has an i-j-k location for it's refinement level. The range of i-j-k values runs from min to max, where min is given by location * 2^j, where location is provided by the location parameter of the constructor and j is the refinement level of the cell. The value of max is + 2^j - 1, where j is again the cell's refinement level. Hence, the cell's location is relative to the branch's location.

Parameters
[in]cellidThe cell id of the cell whose bounds are to be returned
[out]xyzThe cell's location
[out]reflevelThe refinment level of the cell
Return values
statusReturns a non-negative value on success. A negative int is returned if cellid does not exist in the tree.
cid_t VAPoR::AMRTreeBranch::GetCellNeighbor ( cid_t  cellid,
int  face 
) const

Return the cell id of a cell's neighbor.

Returns the cell id of the cell adjacent to the indicated face of the cell with id cellid. The face parameter is an integer in the range [0..5], where 0 coresponds to the face on the XY plane with Z = 0; 1 is the YZ plane with X = 1; 2 is the XY plane, Z = 1; 3 is the YZ plane; Z = 0, 4 is the XZ plane, Y = 0; and 5 is the XZ plane, Z = 1.

Parameters
[in]cellidThe cell id of the cell whose neighbor is to be returned.
[in]faceIndicates the cell's face adjacent to the desired neighbor.
Return values
cellidA valid cell id is returned if the branch contains the indicated point. Otherwise a negative int is returned.
long VAPoR::AMRTreeBranch::GetCellOffset ( cid_t  cellid) const

Return the serialized offset of the block with id

Parameters
cellidThis method returns the offset to the indicated cell in a breath-first traversal of the tree.
Return values
offsetReturns a negative int of cellid is invalid, otherwise returns the offset of the cell
cid_t VAPoR::AMRTreeBranch::GetCellParent ( cid_t  cellid) const

Returns the cell id of the parent of a child node

This method returns the cell id of the parent of the cell indicated by cellid.

Parameters
[in]cellidThe cell id of the cell whose parent is to be returned.
Return values
cellidA valid cell id is returned if the branch contains the indicated point. Otherwise a negative int is returned.
AMRTreeBranch::cid_t VAPoR::AMRTreeBranch::GetNextCell ( bool  restart)

Return next node in a tree treversal

Each time this method is called it returns the cellid for the next node in a complete treversal of the tree. If restart is true the first node in the tree is returned: the node with topological coordinates (0,0,0), and refinement level zero. The order of the treversal is as follows: branches are treversed, one at a time in a top-to-bottom, breadth first manner. The branch with branch id zero is treversed first, followed by branch id 1, and so on. When the entire tree has been completely treversed a negative cell id is returned.

Parameters
[in]restartIf true, the treversal is restarted from the first cell in the tree.
cid_t VAPoR::AMRTreeBranch::GetNumCells ( ) const

Return number of cells in the branch

Returns the total number of cells in a branch, including parent cells

cid_t VAPoR::AMRTreeBranch::GetNumCells ( int  ref_level) const

Return number of cells in the branch

Returns the total number of cells in a branch, including parent cells, up to and including the indicated refinement level.

int VAPoR::AMRTreeBranch::GetRefinementLevel ( ) const
inline

Returns the maximum refinement level of any cell in this branch.

Definition at line 272 of file AMRTreeBranch.h.

cid_t VAPoR::AMRTreeBranch::GetRoot ( ) const
inline

Returns the cellid root node.

Definition at line 278 of file AMRTreeBranch.h.

int VAPoR::AMRTreeBranch::HasChildren ( cid_t  cellid) const

Returns true if the cell with id cellid has children.

Returns true or false indicated whether the specified cell has children or not.

AMRTreeBranch::cid_t VAPoR::AMRTreeBranch::RefineCell ( cid_t  cellid)

Refine a cell

This method refines a cell, creating eight new child octants. Upon success the cell id of the first child is returned.

Parameters
[in]cellidThe cell id of the cell to be refined
Return values
cellidA valid cell id is returned if the branch contains the indicated point. Otherwise a negative int is returned.
int VAPoR::AMRTreeBranch::SetParentTable ( const vector< long > &  table)
void VAPoR::AMRTreeBranch::Update ( )
bool VAPoR::AMRTreeBranch::ValidCell ( cid_t  cellid) const
inline

Definition at line 140 of file AMRTreeBranch.h.

Member Data Documentation

const string VAPoR::AMRTreeBranch::_locationAttr
static

Definition at line 85 of file AMRTreeBranch.h.

const string VAPoR::AMRTreeBranch::_maxExtentsAttr
static

Definition at line 84 of file AMRTreeBranch.h.

const string VAPoR::AMRTreeBranch::_minExtentsAttr
static

Definition at line 83 of file AMRTreeBranch.h.

const string VAPoR::AMRTreeBranch::_parentTableTag
static

Definition at line 77 of file AMRTreeBranch.h.

const string VAPoR::AMRTreeBranch::_refinementLevelTag
static

Definition at line 75 of file AMRTreeBranch.h.

const string VAPoR::AMRTreeBranch::_rootTag
static

Definition at line 74 of file AMRTreeBranch.h.


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