#include <TreeSpatialGrid.hpp>
Public Member Functions | |
~TreeSpatialGrid () | |
int | cellIndex (Position bfr) const override |
Position | centralPositionInCell (int m) const override |
std::unique_ptr< PathSegmentGenerator > | createPathSegmentGenerator () const override |
double | diagonal (int m) const override |
int | numCells () const override |
Position | randomPositionInCell (int m) const override |
double | volume (int m) const override |
void | writeTopology (TextOutFile *outfile) const |
![]() | |
Box | boundingBox () const override |
int | dimension () const override |
double | maxX () const |
double | maxY () const |
double | maxZ () const |
double | minX () const |
double | minY () const |
double | minZ () const |
![]() | |
virtual Box | boundingBox () const =0 |
virtual int | cellIndex (Position bfr) const =0 |
virtual Position | centralPositionInCell (int m) const =0 |
virtual std::unique_ptr< PathSegmentGenerator > | createPathSegmentGenerator () const =0 |
virtual double | diagonal (int m) const =0 |
virtual int | dimension () const =0 |
virtual int | numCells () const =0 |
virtual Position | randomPositionInCell (int m) const =0 |
virtual double | volume (int m) const =0 |
virtual void | writeGridPlotFiles (const SimulationItem *probe) const |
![]() | |
template<class T > | |
T * | find (bool setup=true) const |
template<class T > | |
T * | interface (int levels=-999999, bool setup=true) const |
virtual string | itemName () const |
void | setup () |
string | typeAndName () const |
![]() | |
Item (const Item &)=delete | |
virtual | ~Item () |
void | addChild (Item *child) |
const vector< Item * > & | children () const |
virtual void | clearItemListProperty (const PropertyDef *property) |
void | destroyChild (Item *child) |
virtual bool | getBoolProperty (const PropertyDef *property) const |
virtual vector< double > | getDoubleListProperty (const PropertyDef *property) const |
virtual double | getDoubleProperty (const PropertyDef *property) const |
virtual string | getEnumProperty (const PropertyDef *property) const |
virtual int | getIntProperty (const PropertyDef *property) const |
virtual vector< Item * > | getItemListProperty (const PropertyDef *property) const |
virtual Item * | getItemProperty (const PropertyDef *property) const |
virtual string | getStringProperty (const PropertyDef *property) const |
int | getUtilityProperty (string name) const |
virtual void | insertIntoItemListProperty (const PropertyDef *property, int index, Item *item) |
Item & | operator= (const Item &)=delete |
Item * | parent () const |
virtual void | removeFromItemListProperty (const PropertyDef *property, int index) |
virtual void | setBoolProperty (const PropertyDef *property, bool value) |
virtual void | setDoubleListProperty (const PropertyDef *property, vector< double > value) |
virtual void | setDoubleProperty (const PropertyDef *property, double value) |
virtual void | setEnumProperty (const PropertyDef *property, string value) |
virtual void | setIntProperty (const PropertyDef *property, int value) |
virtual void | setItemProperty (const PropertyDef *property, Item *item) |
virtual void | setStringProperty (const PropertyDef *property, string value) |
void | setUtilityProperty (string name, int value) |
virtual string | type () const |
![]() | |
Box () | |
Box (double xmin, double ymin, double zmin, double xmax, double ymax, double zmax) | |
Box (Vec rmin, Vec rmax) | |
void | cellIndices (int &i, int &j, int &k, Vec r, int nx, int ny, int nz) const |
Vec | center () const |
bool | contains (const Box &box) const |
bool | contains (double x, double y, double z) const |
bool | contains (Vec r) const |
double | diagonal () const |
void | extend (const Box &box) |
const Box & | extent () const |
void | extent (double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) const |
Vec | fracPos (double xfrac, double yfrac, double zfrac) const |
Vec | fracPos (int xd, int yd, int zd, int xn, int yn, int zn) const |
bool | intersects (const Box &box) const |
bool | intersects (Vec r, const Vec k, double &smin, double &smax) const |
bool | intersects (Vec rc, double r) const |
Vec | rmax () const |
Vec | rmin () const |
double | volume () const |
Vec | widths () const |
double | xmax () const |
double | xmin () const |
double | xwidth () const |
double | ymax () const |
double | ymin () const |
double | ywidth () const |
double | zmax () const |
double | zmin () const |
double | zwidth () const |
Protected Member Functions | |
TreeSpatialGrid () | |
virtual vector< TreeNode * > | constructTree ()=0 |
void | setupSelfAfter () override |
void | write_xy (SpatialGridPlotFile *outfile) const override |
void | write_xyz (SpatialGridPlotFile *outfile) const override |
void | write_xz (SpatialGridPlotFile *outfile) const override |
void | write_yz (SpatialGridPlotFile *outfile) const override |
![]() | |
BoxSpatialGrid () | |
void | setupSelfBefore () override |
![]() | |
SpatialGrid () | |
Random * | random () const |
void | setupSelfBefore () override |
virtual void | write_xy (SpatialGridPlotFile *outfile) const |
virtual void | write_xyz (SpatialGridPlotFile *outfile) const |
virtual void | write_xz (SpatialGridPlotFile *outfile) const |
virtual void | write_yz (SpatialGridPlotFile *outfile) const |
![]() | |
SimulationItem () | |
virtual bool | offersInterface (const std::type_info &interfaceTypeInfo) const |
virtual void | setupSelfAfter () |
virtual void | setupSelfBefore () |
![]() | |
Item () | |
![]() | |
void | setExtent (const Box &extent) |
void | setExtent (double xmin, double ymin, double zmin, double xmax, double ymax, double zmax) |
Private Types | |
using | BaseType = BoxSpatialGrid |
using | ItemType = TreeSpatialGrid |
Private Member Functions | |
int | cellIndexForNode (const TreeNode *node) const |
TreeNode * | nodeForCellIndex (int m) const |
TreeNode * | root () const |
Private Attributes | |
vector< int > | _cellindexv |
double | _eps |
vector< int > | _idv |
vector< TreeNode * > | _nodev |
Friends | |
class | ItemRegistry |
class | MySegmentGenerator |
TreeSpatialGrid is an abstract subclass of the BoxSpatialGrid class, and represents three-dimensional spatial grids with cuboidal cells organized in a hierarchical tree. The tree's root node encloses the complete spatial domain, and nodes on subsequent levels recursively divide space into ever finer nodes. The depth of the tree can vary from place to place. The leaf nodes (those that are not further subdivided) are the actual spatial cells.
The actual tree construction, including the choice of node type (a subclass of TreeNode) is delegated to each concrete subclass. This base class implements all other aspects required for using the grid, such as calculating paths traversing the grid. Depending on the type of TreeNode, the tree can become an octtree (8 children per node) or a binary tree (2 children per node). Other node types could be implemented, as long as they are cuboids lined up with the coordinate axes.
|
inlineprotected |
Default constructor for abstract Item subclass TreeSpatialGrid : "a hierarchical tree spatial grid" .
TreeSpatialGrid::~TreeSpatialGrid | ( | ) |
The destructor deletes all tree nodes created during setup.
|
overridevirtual |
This function returns the index of the cell that contains the position
Implements SpatialGrid.
|
private |
This function returns the cell index
|
overridevirtual |
This function returns the central location of the cell with index
Implements SpatialGrid.
|
protectedpure virtual |
This function must be implemented in a subclass. It constructs the hierarchical tree and all (interconnected) nodes forming the tree. All nodes are instances of the same TreeNode subclass, selected by this function. The function returns a list of pointers to all created nodes (leaf and nonleaf). Ownership of the nodes resides in this returned list (not in the node hierarchy itself) and is thus handed to the caller.
Each (leaf and nonleaf) node is given an identifier (ID) corresponding to its index in the list. The first node in the list is the root node of tree, i.e. the node encompasssing the complete spatial domain. Thus, by definition, the root node has an ID of zero.
This function also causes the nodes to construct neighbor lists, interconnecting the nodes according to their spatial relationship. The neighbor lists are sorted so that the neighbors with the largest overlapping border area are listed first, increasing (on average) the probability of locating the correct neighbor early in the list.
Implemented in FileTreeSpatialGrid, and PolicyTreeSpatialGrid.
|
overridevirtual |
This function creates and hands over ownership of a path segment generator (an instance of a PathSegmentGenerator subclass) appropriate for a tree grid, implemented as a private PathSegmentGenerator subclass. The algorithm used to construct the path is described below.
The function uses a rather straighforward algorithm. It determines the cell that contains the starting position, and calculates the first wall of the cell that will be crossed. The pathlength
where
By adding this small extra bit, we ensure that the new position is now within the next cell, and we can repeat this exercise. This loop is terminated when the next position is outside the grid.
To determine the cell index of the "next cell" in this algorithm, the function uses the neighbor lists constructed for each tree node during setup.
Implements SpatialGrid.
|
overridevirtual |
This function returns the actuale diagonal of the cell with index
Implements SpatialGrid.
|
private |
This function returns a pointer to the node corresponding to cell index
|
overridevirtual |
This function returns the number of cells in the grid.
Implements SpatialGrid.
|
overridevirtual |
This function returns a random location from the cell with index
with
Implements SpatialGrid.
|
private |
This function returns a pointer to the root node of the tree.
|
overrideprotectedvirtual |
This function invokes the constructTree() function, to be implemented by a subclass, causing the tree to be constructed. The subclass returns a list of all created nodes back to the base class, and gives each node an identifier (ID) corresponding to its index in this list. Ownership of the nodes resides in the list passed back to the base class (not in the subclass, and not in the node hierarchy itself).
After the subclass passes back the tree nodes, this function creates an extra vector that contains the node IDs of all leaf nodes, i.e. all nodes corresponding to the actual spatial cells. Conversely, the function also creates a vector with the cell indices of all the nodes, i.e. the rank
Reimplemented from SimulationItem.
|
overridevirtual |
This function returns the volume of the cell with index
Implements SpatialGrid.
|
overrideprotectedvirtual |
This function writes the intersection of the grid with the xy plane to the specified SpatialGridPlotFile object.
Reimplemented from SpatialGrid.
|
overrideprotectedvirtual |
This function writes 3D information for the cells up to a certain level in the grid structure to the specified SpatialGridPlotFile object. The output is limited to some predefined number of cells to keep the line density in the output plot within reason.
Reimplemented from SpatialGrid.
|
overrideprotectedvirtual |
This function writes the intersection of the grid with the xz plane to the specified SpatialGridPlotFile object.
Reimplemented from SpatialGrid.
|
overrideprotectedvirtual |
This function writes the intersection of the grid with the yz plane to the specified SpatialGridPlotFile object.
Reimplemented from SpatialGrid.
void TreeSpatialGrid::writeTopology | ( | TextOutFile * | outfile | ) | const |
This function writes the topology of the tree to the specified text file in a simple, proprietary format. After a brief descriptive header, it writes lines that each contain just a single integer number. The first line specifies the number of children for each nonleaf node (2 for a binary tree, 8 for an octtree, or 0 if the root node has not been subdivided). The second line contains 1 if the root node is subdivided, or 0 if not. The following lines similarly contain 1 or 0 indicating subdivision for any children of the preceding node, recursively, in a depth-first traversal of the tree.