VAPoR
0.1
|
This class manages an AMR tree data structure. More...
#include <AMRTree.h>
Public Types | |
typedef AMRTreeBranch::cid_t | 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 | |
AMRTree (const size_t basedim[3], const double min[3], const double max[3]) | |
AMRTree (const string &path) | |
AMRTree (const size_t basedim[3], const int paramesh_gids[][15], const float paramesh_bboxs[][3][2], const int paramesh_refine_levels[], int paramesh_total_blocks) | |
AMRTree () | |
virtual | ~AMRTree () |
void | DecodeCellID (AMRTree::cid_t cellid, AMRTree::cid_t *baseblockidx, AMRTree::cid_t *nodeidx) const |
int | DeleteCell (AMRTree::cid_t cellid) |
AMRTree::cid_t | FindCell (const double ucoord[3], int reflevel=-1) const |
int | GetCellLocation (AMRTree::cid_t cellid, size_t xyz[3], int *reflevel) const |
AMRTree::cid_t | GetCellID (const size_t xyz[3], int reflevel) const |
const size_t * | GetBaseDim () const |
const AMRTreeBranch * | GetBranch (const size_t xyz[3]) const |
const AMRTreeBranch * | GetBranch (cid_t baseblockidx) const |
int | GetCellBounds (cid_t cellid, double minu[3], double maxu[3]) const |
AMRTree::cid_t | GetCellChildren (AMRTree::cid_t cellid) const |
int | GetCellLevel (AMRTree::cid_t cellid) const |
AMRTree::cid_t | GetCellNeighbor (AMRTree::cid_t cellid, int face) const |
AMRTree::cid_t | GetCellParent (AMRTree::cid_t cellid) const |
int | GetRefinementLevel (const size_t min[3], const size_t max[3]) const |
int | GetRefinementLevel () const |
Returns the maximum refinement of the entire tree. More... | |
AMRTree::cid_t | GetNumCells (const size_t min[3], const size_t max[3], int reflevel=-1) const |
AMRTree::cid_t | GetNumCells (int reflevel=-1) const |
AMRTree::cid_t | RefineCell (AMRTree::cid_t cellid) |
void | EndRefinement () |
AMRTree::cid_t | GetNextCell (bool restart) |
int | MapUserToVoxel (int reflevel, const double ucoord[3], size_t vcoord[3]) |
int | Write (const string &path) const |
int | Read (const string &path) |
int | _parameshGetBaseBlocks (vector< int > &baseblocks, const size_t basedim[3], const int gids[][15], const float bboxs[][3][2], int totalblocks) const |
Public Member Functions inherited from VetsUtil::MyBase | |
MyBase () | |
const string & | getClassName () const |
Public Member Functions inherited from VAPoR::ParsedXml | |
virtual | ~ParsedXml () |
virtual bool | charHandler (ExpatParseMgr *, const XML_Char *, int) |
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) |
Public Attributes inherited from VAPoR::ParsedXml | |
ParsedXml * | previousClass |
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 |
Protected Member Functions inherited from VetsUtil::MyBase | |
void | SetClassName (const string &name) |
Static Protected Attributes inherited from VAPoR::ParsedXml | |
static const string | _stringType |
static const string | _longType |
static const string | _doubleType |
static const string | _typeAttr |
This class manages an AMR tree data structure.
This class manages an Adaptive Mesh Refinement tree data object for a block structured AMR grid. The AMR grid is composed of a Cartesian base grid of cells (blocks) that are recursively refined into octants. Each base block is represented by a AMRTreeBranch object class.
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.
VAPoR::AMRTree::AMRTree | ( | const size_t | basedim[3], |
const double | min[3], | ||
const double | max[3] | ||
) |
Constructor for the AMRTree class.
[in] | basedim | A three element array specifying the topological dimensions of the tree in base blocks |
[in] | min | A tree element array specifying the minimum XYZ extents of the tree in user-defined coordinates. |
[in] | max | A tree element array specifying the maximum XYZ extents of the tree in user-defined coordinates. |
status | A non-negative value is returned on success |
VAPoR::AMRTree::AMRTree | ( | const string & | path | ) |
Construct a tree from a file
This constructor initializes an AMRTree object class from a file previously written by AMRTree::Write()
[in] | path | Path name to file |
VAPoR::AMRTree::AMRTree | ( | const size_t | basedim[3], |
const int | paramesh_gids[][15], | ||
const float | paramesh_bboxs[][3][2], | ||
const int | paramesh_refine_levels[], | ||
int | paramesh_total_blocks | ||
) |
Constructor an AMRTree from a Paramesh AMR grid
This constructor initializes and fully populates an AMR tree from a Paramesh block structured AMR grid stored in an HDF5 file. The arguments to this constructor are read directly from HDF5
[in] | basedim | A three element array specifying the topological dimensions of the tree in base blocks |
[in] | paramesh_gids | An array of Paramesh global identifiers |
[in] | paramesh_bboxs | An array of Paramesh bounding boxes |
[in] | paramesh_refine_levels | An array of Paramesh refinement levels |
[in] | paramesh_total_blocks | Total number of nodes (both leaf and non-leaf) stored in the Paramesh AMR tree. |
VAPoR::AMRTree::AMRTree | ( | ) |
Construct a simple tree
Construct a tree with base dimensions 1x1x1 and min and max user extents set to (0.0, 0.0, 0.0) and (1.0, 1.0, 1.0), respectively
|
virtual |
int VAPoR::AMRTree::_parameshGetBaseBlocks | ( | vector< int > & | baseblocks, |
const size_t | basedim[3], | ||
const int | gids[][15], | ||
const float | bboxs[][3][2], | ||
int | totalblocks | ||
) | const |
void VAPoR::AMRTree::DecodeCellID | ( | AMRTree::cid_t | cellid, |
AMRTree::cid_t * | baseblockidx, | ||
AMRTree::cid_t * | nodeidx | ||
) | const |
Decode an AMRTree cell id
Decode an AMRTree cell indentifier into a AMRTreeBranch cell id and a base block index (branch index). Branch indecies are numbered from 0 to (basedim[0]*basedim[1]*basedim[2])-1, with the X base blocks varying fastest, followed by Y, than Z.
[in] | cellid | The AMRTree cell id to decode |
[out] | baseblockidx | The decoded branch index |
[out] | nodeidx | The decoded AMRTreeBranch cell id |
int VAPoR::AMRTree::DeleteCell | ( | AMRTree::cid_t | cellid | ) |
Delete a node from the tree
Deletes the indicated node from the tree
[in] | cellid | Cell id of node to delete |
status | Returns a non-negative value on success |
void VAPoR::AMRTree::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.
AMRTree::cid_t VAPoR::AMRTree::FindCell | ( | const double | ucoord[3], |
int | reflevel = -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 tree's construction (it is assumed that the tree occupies Cartesian space and that all nodes are rectangular. By default, the leaf node containing the point is returned. However, an ancestor node may be returned by limiting the refinement level.
[in] | ucoord | A three element array containing the coordintes of the point to be found. |
[in] | reflevel | The refinement level of the cell to be returned. If -1, a leaf node is returned. |
cellid | A valid cell id is returned if the tree contains the indicated point. Otherwise a negative integer is returned |
|
inline |
const AMRTreeBranch* VAPoR::AMRTree::GetBranch | ( | const size_t | xyz[3] | ) | const |
Return the AMRTreeBranch associated with a base block
This method returns a pointer to the AMRTreeBranch object for the block with topological coordinates given by xyz
.
[in] | xyz | The toplogical (i-j-k) coordinates of the base block tree branch to return |
[in] | baseblockidx | The serialized offset of xyz |
treebranch | A pointer to a AMRTreeBranch object |
const AMRTreeBranch* VAPoR::AMRTree::GetBranch | ( | cid_t | baseblockidx | ) | const |
Return the AMRTreeBranch associated with a base block
This method returns a pointer to the AMRTreeBranch object for the block with topological coordinates given by xyz
.
[in] | xyz | The toplogical (i-j-k) coordinates of the base block tree branch to return |
[in] | baseblockidx | The serialized offset of xyz |
treebranch | A pointer to a AMRTreeBranch object |
int VAPoR::AMRTree::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.
[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 |
AMRTree::cid_t VAPoR::AMRTree::GetCellChildren | ( | AMRTree::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.
[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 value is returned. |
AMRTree::cid_t VAPoR::AMRTree::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 |
[out] | cellid | The cell id of the cell at the specified location |
status | Returns a non-negative value on success. A negative int is returned xyz are invalid for refinement level. |
int VAPoR::AMRTree::GetCellLevel | ( | AMRTree::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::AMRTree::GetCellLocation | ( | AMRTree::cid_t | cellid, |
size_t | xyz[3], | ||
int * | reflevel | ||
) | const |
Return the topological coordinates of a cell within the tree.
This method returns topological coordinates of a cell within the tree, relative to the cell's refinement level. Each cell in a tree has an i-j-k location for it's refinement level. The range of i-j-k values runs from 0 to basedim * 2^j - 1, where basedim
is the base dimension for the respective i-j-k axis specified in the AMRTree() constructor, and j
is the refinement level. The base refinement level is zer0. 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] | cellid | The refinement 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. |
AMRTree::cid_t VAPoR::AMRTree::GetCellNeighbor | ( | AMRTree::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.
[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 value is returned |
AMRTree::cid_t VAPoR::AMRTree::GetCellParent | ( | AMRTree::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
.
[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. |
AMRTree::cid_t VAPoR::AMRTree::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. |
AMRTree::cid_t VAPoR::AMRTree::GetNumCells | ( | const size_t | min[3], |
const size_t | max[3], | ||
int | reflevel = -1 |
||
) | const |
Return number of nodes in the indicated subtree
The number of leaf and non-leaf nodes in a subtree indicated by min
and max
is returned. If the parameter is non-negative, the number of nodes in the tree up to the refinement level indicated by reflevel
are returned.
[in] | min | Minumum topological (i-j-k) coordinates, specified in base blocks, of the region of interest |
[in] | max | Maximum topological (i-j-k) coordinates, specified in base blocks, of the region of interest |
[in] | reflevel | Requested refinment level. The maximum refinement level is used if the argument is negative |
AMRTree::cid_t VAPoR::AMRTree::GetNumCells | ( | int | reflevel = -1 | ) | const |
Return number of nodes in the tree
The number of leaf and non-leaf nodes is returned. If the parameter is non-negative, the number of nodes in the tree up to the refinement level indicated by reflevel
are returned.
[in] | reflevel | Requested refinment level. The maximum refinement level is used if the argument is negative |
numnodes | The number of nodes |
int VAPoR::AMRTree::GetRefinementLevel | ( | const size_t | min[3], |
const size_t | max[3] | ||
) | const |
Returns the maximum refinement of the indicated subregion
int VAPoR::AMRTree::GetRefinementLevel | ( | ) | const |
Returns the maximum refinement of the entire tree.
int VAPoR::AMRTree::MapUserToVoxel | ( | int | reflevel, |
const double | ucoord[3], | ||
size_t | vcoord[3] | ||
) |
int VAPoR::AMRTree::Read | ( | const string & | path | ) |
Read the AMR tree from a file as XML data
[in] | path | Name of the file to write to |
status | Returns a non-negative integer on success |
AMRTree::cid_t VAPoR::AMRTree::RefineCell | ( | AMRTree::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 value is returned |
int VAPoR::AMRTree::Write | ( | const string & | path | ) | const |
Write the AMR tree to a file as XML data
[in] | path | Name of the file to write to |
status | Returns a non-negative integer on success |