VAPoR
0.1
|
This class manages an octree data structure. More...
#include <AMRTreeBranch.h>
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) |
This class manages an octree data structure.
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.
typedef long VAPoR::AMRTreeBranch::cid_t |
Definition at line 69 of file AMRTreeBranch.h.
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)
[in] | parent | Parent node of XML tree |
[in] | min | A three element array indicating the minimum X,Y,Z bounds of the tree branch, specified in user coordinates. |
[in] | max | A three element array indicating the maximum X,Y,Z bounds of the tree branch, specified in user coordinates. |
[in] | location | A three element integer array indicating the coordinates of this branch relative to other branches in an AMR tree. |
|
virtual |
int VAPoR::AMRTreeBranch::DeleteCell | ( | cid_t | cellid | ) |
Delete a cell from the tree branch
Deletes the indicated cell from the tree branch
[in] | cellid | Cell id of cell to delete |
status | Returns 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.
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.
[in] | ucoord | A three element array containing the coordintes of the point to be found. |
[in] | ref_level | The refinement level of the cell to be returned. If -1, a leaf node (cell) is returned. |
cellid | A 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.
[in] | cellid | The cell id of the cell whose bounds are to be returned |
[out] | minu | A three element array to which the minimum cell extents will be copied. |
[out] | maxu | A three element array to which the maximum cell extents will be copied. |
status | Returns a non-negative value on success |
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.
[in] | cellid | The cell id of the cell whose first child is to be returned. |
cellid | A 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.
[in] | xyz | The cell's location |
[in] | reflevel | The refinement level of the cell |
[in] | cellid | The cell id of the cell whose bounds are to be returned |
status | Returns a non-negative value on success. A negative int is returned xyz are invalid for refinement level. |
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).
[in] | cellid | The cell id of the cell whose refinement level is to be returned. |
status | Returns 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.
[in] | cellid | The cell id of the cell whose bounds are to be returned |
[out] | xyz | The cell's location |
[out] | reflevel | The refinment level of the cell |
status | Returns a non-negative value on success. A negative int is returned if cellid does not exist in the tree. |
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.
[in] | cellid | The cell id of the cell whose neighbor is to be returned. |
[in] | face | Indicates the cell's face adjacent to the desired neighbor. |
cellid | A 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
cellid | This method returns the offset to the indicated cell in a breath-first traversal of the tree. |
offset | Returns a negative int of cellid is invalid, otherwise returns the offset of the cell |
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
.
[in] | cellid | The cell id of the cell whose parent is to be returned. |
cellid | A 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.
[in] | restart | If 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.
|
inline |
Returns the maximum refinement level of any cell in this branch.
Definition at line 272 of file AMRTreeBranch.h.
|
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.
[in] | cellid | The cell id of the cell to be refined |
cellid | A 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 | ( | ) |
|
inline |
Definition at line 140 of file AMRTreeBranch.h.
|
static |
Definition at line 85 of file AMRTreeBranch.h.
|
static |
Definition at line 84 of file AMRTreeBranch.h.
|
static |
Definition at line 83 of file AMRTreeBranch.h.
|
static |
Definition at line 77 of file AMRTreeBranch.h.
|
static |
Definition at line 75 of file AMRTreeBranch.h.
|
static |
Definition at line 74 of file AMRTreeBranch.h.