AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
axom::spin::OctreeBase< DIM, BlockDataType > Class Template Reference

Handles the non-geometric operations for our octree such as refinement, finding the parents and children of a node and determining whether a leaf node exists. More...

#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/latest/src/axom/spin/OctreeBase.hpp>

Inheritance diagram for axom::spin::OctreeBase< DIM, BlockDataType >:

Classes

class  BlockIndex
 Inner class encapsulating the index of an octree block. More...
 

Public Types

using CoordType = axom::IndexType
 
using GridPt = primal::Point< CoordType, DIM >
 
using GridVec = primal::Vector< CoordType, DIM >
 
using MAX_LEVEL_SIZE = slam::policies::CompileTimeSize< CoordType, std::numeric_limits< CoordType >::digits >
 
using OctreeLevels = slam::OrderedSet< CoordType, CoordType, MAX_LEVEL_SIZE >
 
using OctreeLevelType = OctreeLevel< DIM, BlockDataType >
 
using LeafIndicesLevelMap = slam::Map< OctreeLevelType * >
 

Public Member Functions

 OctreeBase ()
 
 ~OctreeBase ()
 OctreeBase destructor. More...
 
int maxLeafLevel () const
 The max level for leaf blocks of the octree. More...
 
int maxInternalLevel () const
 The max level for internal blocks of the octree. More...
 
BlockIndex parent (const GridPt &pt, int level) const
 Finds the grid index and level of the current octree block's parent. More...
 
BlockIndex parent (const BlockIndex &block) const
 Finds the BlockIndex of the given block's parent. More...
 
BlockIndex child (const GridPt &pt, int level, int childIndex) const
 Finds the BlockIndex of the given block's child. More...
 
BlockIndex child (const BlockIndex &block, int childIndex) const
 Finds the BlockIndex of the given block's child. More...
 
OctreeLevelTypegetOctreeLevel (int lev)
 Accessor for a reference to the octree level instance at level lev. More...
 
const OctreeLevelTypegetOctreeLevel (int lev) const
 Const accessor for a reference to the octree level instance at level lev. More...
 
bool isLevelValid (int lev) const
 Predicate to determine if level lev is in the range. More...
 
bool isLeaf (const GridPt &pt, int lev) const
 Determine whether the octree contains a leaf block associated with grid point pt at level lev. More...
 
bool isLeaf (const BlockIndex &block) const
 Determine whether the octree contains a leaf block associated with this BlockIndex. More...
 
bool isInternal (const GridPt &pt, int lev) const
 Determine whether the octree contains an internal block associated with grid point pt at level lev. More...
 
bool isInternal (const BlockIndex &block) const
 Determine whether the octree contains an internal block associated with this BlockIndex. More...
 
bool hasBlock (const GridPt &pt, int lev) const
 Determine whether the octree contains a block (internal or leaf) associated with grid point pt at level lev. More...
 
bool hasBlock (const BlockIndex &block) const
 Determine whether the octree contains a block (internal or leaf) associated with this BlockIndex. More...
 
bool inBounds (const GridPt &pt, int lev) const
 Determine whether the octree block associated with grid point pt and level lev is a possible block in this octree. More...
 
bool inBounds (const BlockIndex &block) const
 Determine whether the octree block associated with BlockIndex is a possible block in this octree. More...
 
void refineLeaf (const BlockIndex &leafBlock)
 Refines the given leaf block in the octree. More...
 
BlockDataType & operator[] (const BlockIndex &block)
 Accessor to the data associated with block. More...
 
const BlockDataType & operator[] (const BlockIndex &block) const
 Const accessor to the data associated with block. More...
 
BlockIndex coveringLeafBlock (const BlockIndex &blk, bool checkInBounds=true) const
 Finds the finest octree leaf covering BlockIndex blk. More...
 

Static Public Member Functions

static CoordType maxCoordAtLevel (int level)
 Utility function to find the number of (possible) grid cells at a given level or resolution. More...
 
static BlockIndex root ()
 

Protected Member Functions

TreeBlockStatus blockStatus (const GridPt &pt, int lev) const
 Helper function to determine the status of a BlockIndex within an octree instance. More...
 
TreeBlockStatus blockStatus (const BlockIndex &blk) const
 Helper function to determine the status of a BlockIndex within an octree instance. More...
 

Protected Attributes

OctreeLevels m_levels
 
LeafIndicesLevelMap m_leavesLevelMap
 

Detailed Description

template<int DIM, typename BlockDataType>
class axom::spin::OctreeBase< DIM, BlockDataType >

Handles the non-geometric operations for our octree such as refinement, finding the parents and children of a node and determining whether a leaf node exists.

There are two concepts here: A set of nested dyadic integer grids – A grid at level n has 2^n cells in each of the DIM dimensions and an adaptive octree defined by a subset of the grid cells from these nested grids. The former is a conceptual aid in the sense that it is implicitly encoded.

An octree block at level l is refined by adding its 2^DIM children blocks at level (l+1). The root of the octree covers the entire domains and has no parent. The leaf blocks of the octree have no children. The interior of the children do not overlap, and their union covers that of their parent block. Non-leaf blocks are referred to as 'internal'

Requirements for BlockDataType: it must be default constructible and provide an isLeaf() predicate as well as a setInternal() function that changes its state from representing a leaf block to an internal block.

Member Typedef Documentation

◆ CoordType

template<int DIM, typename BlockDataType >
using axom::spin::OctreeBase< DIM, BlockDataType >::CoordType = axom::IndexType

◆ GridPt

template<int DIM, typename BlockDataType >
using axom::spin::OctreeBase< DIM, BlockDataType >::GridPt = primal::Point<CoordType, DIM>

◆ GridVec

template<int DIM, typename BlockDataType >
using axom::spin::OctreeBase< DIM, BlockDataType >::GridVec = primal::Vector<CoordType, DIM>

◆ MAX_LEVEL_SIZE

template<int DIM, typename BlockDataType >
using axom::spin::OctreeBase< DIM, BlockDataType >::MAX_LEVEL_SIZE = slam::policies::CompileTimeSize<CoordType, std::numeric_limits<CoordType>::digits>

◆ OctreeLevels

template<int DIM, typename BlockDataType >
using axom::spin::OctreeBase< DIM, BlockDataType >::OctreeLevels = slam::OrderedSet<CoordType, CoordType, MAX_LEVEL_SIZE>

◆ OctreeLevelType

template<int DIM, typename BlockDataType >
using axom::spin::OctreeBase< DIM, BlockDataType >::OctreeLevelType = OctreeLevel<DIM, BlockDataType>

◆ LeafIndicesLevelMap

template<int DIM, typename BlockDataType >
using axom::spin::OctreeBase< DIM, BlockDataType >::LeafIndicesLevelMap = slam::Map<OctreeLevelType*>

Constructor & Destructor Documentation

◆ OctreeBase()

◆ ~OctreeBase()

template<int DIM, typename BlockDataType >
axom::spin::OctreeBase< DIM, BlockDataType >::~OctreeBase ( )
inline

Member Function Documentation

◆ maxLeafLevel()

template<int DIM, typename BlockDataType >
int axom::spin::OctreeBase< DIM, BlockDataType >::maxLeafLevel ( ) const
inline

◆ maxInternalLevel()

template<int DIM, typename BlockDataType >
int axom::spin::OctreeBase< DIM, BlockDataType >::maxInternalLevel ( ) const
inline

◆ maxCoordAtLevel()

template<int DIM, typename BlockDataType >
static CoordType axom::spin::OctreeBase< DIM, BlockDataType >::maxCoordAtLevel ( int  level)
inlinestatic

Utility function to find the number of (possible) grid cells at a given level or resolution.

Parameters
[in]levelThe level or resolution.
Precondition
\( 0 \le lev */ static GridPt maxGridCellAtLevel(int level) { return GridPt(maxCoordAtLevel(level)); } /** \brief Finds the highest coordinate value at a given level or resolution \param [in] level The level or resolution. \pre \) 0 \le lev

◆ root()

template<int DIM, typename BlockDataType >
static BlockIndex axom::spin::OctreeBase< DIM, BlockDataType >::root ( )
inlinestatic

Auxiliary function to return the root of the octree

Note
The root block has no parent. Its parent is an invalid BlockIndex. I.e. octree.parent( octree.root()).isValid() = false.

◆ parent() [1/2]

template<int DIM, typename BlockDataType >
BlockIndex axom::spin::OctreeBase< DIM, BlockDataType >::parent ( const GridPt pt,
int  level 
) const
inline

Finds the grid index and level of the current octree block's parent.

Note
The root level is 0 and its children are at level 1
The root node has no parent. The returned level will be '-1'
Parameters
[in]ptThe grid index of the block whose parent we want to find.
[in]levelThe level of the block whose parent we want to find.
Returns
The parent of the provided octree leaf.

References axom::spin::OctreeBase< DIM, BlockDataType >::BlockIndex::parent().

◆ parent() [2/2]

template<int DIM, typename BlockDataType >
BlockIndex axom::spin::OctreeBase< DIM, BlockDataType >::parent ( const BlockIndex block) const
inline

Finds the BlockIndex of the given block's parent.

Parameters
[in]blockThe block whose parent we want to find
Returns
The BlockIndex of the parent of the provided octree leaf.

References axom::spin::OctreeBase< DIM, BlockDataType >::BlockIndex::parent().

◆ child() [1/2]

template<int DIM, typename BlockDataType >
BlockIndex axom::spin::OctreeBase< DIM, BlockDataType >::child ( const GridPt pt,
int  level,
int  childIndex 
) const
inline

Finds the BlockIndex of the given block's child.

Parameters
[in]ptThe grid index of the block whose child we want to find.
[in]levelThe level of the block whose child we want to find.
[in]childIndexThe index of the child to find
Precondition
\( 0 \le childIndex < 2^{DIM} \)
Returns
The BlockIndex of the child of the provided octree leaf.

References axom::spin::OctreeBase< DIM, BlockDataType >::BlockIndex::child().

◆ child() [2/2]

template<int DIM, typename BlockDataType >
BlockIndex axom::spin::OctreeBase< DIM, BlockDataType >::child ( const BlockIndex block,
int  childIndex 
) const
inline

Finds the BlockIndex of the given block's child.

Parameters
[in]blockThe block whose child we want to find
[in]childIndexThe index of the child to find
Precondition
\( 0 \le childIndex < 2^{DIM} \)
Returns
The BlockIndex of the child of the provided octree leaf.

References axom::spin::OctreeBase< DIM, BlockDataType >::BlockIndex::child().

◆ getOctreeLevel() [1/2]

template<int DIM, typename BlockDataType >
OctreeLevelType& axom::spin::OctreeBase< DIM, BlockDataType >::getOctreeLevel ( int  lev)
inline

Accessor for a reference to the octree level instance at level lev.

References axom::spin::OctreeBase< DIM, BlockDataType >::m_leavesLevelMap.

◆ getOctreeLevel() [2/2]

template<int DIM, typename BlockDataType >
const OctreeLevelType& axom::spin::OctreeBase< DIM, BlockDataType >::getOctreeLevel ( int  lev) const
inline

Const accessor for a reference to the octree level instance at level lev.

References axom::spin::OctreeBase< DIM, BlockDataType >::m_leavesLevelMap.

◆ isLevelValid()

template<int DIM, typename BlockDataType >
bool axom::spin::OctreeBase< DIM, BlockDataType >::isLevelValid ( int  lev) const
inline

Predicate to determine if level lev is in the range.

Note
lev is in range if 0 <= lev <= maxLeafLevel()

References axom::spin::OctreeBase< DIM, BlockDataType >::maxLeafLevel().

◆ isLeaf() [1/2]

template<int DIM, typename BlockDataType >
bool axom::spin::OctreeBase< DIM, BlockDataType >::isLeaf ( const GridPt pt,
int  lev 
) const
inline

Determine whether the octree contains a leaf block associated with grid point pt at level lev.

Parameters
[in]ptThe grid point to check
[in]levThe level of the grid point
Returns
true if the associated block is a leaf in the octree, false otherwise

References axom::spin::OctreeBase< DIM, BlockDataType >::getOctreeLevel(), axom::spin::OctreeLevel< DIM, BlockDataType >::isLeaf(), and axom::spin::OctreeBase< DIM, BlockDataType >::isLevelValid().

◆ isLeaf() [2/2]

template<int DIM, typename BlockDataType >
bool axom::spin::OctreeBase< DIM, BlockDataType >::isLeaf ( const BlockIndex block) const
inline

Determine whether the octree contains a leaf block associated with this BlockIndex.

Parameters
[in]blockThe BlockIndex of the tree to check
Returns
true if the associated block is a leaf in the octree, false otherwise

References axom::spin::OctreeBase< DIM, BlockDataType >::getOctreeLevel(), axom::spin::OctreeLevel< DIM, BlockDataType >::isLeaf(), axom::spin::OctreeBase< DIM, BlockDataType >::isLevelValid(), axom::spin::OctreeBase< DIM, BlockDataType >::BlockIndex::level(), and axom::spin::OctreeBase< DIM, BlockDataType >::BlockIndex::pt().

◆ isInternal() [1/2]

template<int DIM, typename BlockDataType >
bool axom::spin::OctreeBase< DIM, BlockDataType >::isInternal ( const GridPt pt,
int  lev 
) const
inline

Determine whether the octree contains an internal block associated with grid point pt at level lev.

Parameters
[in]ptThe grid point to check
[in]levThe level of the grid point
Returns
true if the associated block is an internal block of the octree, false otherwise

References axom::spin::OctreeBase< DIM, BlockDataType >::getOctreeLevel(), axom::spin::OctreeLevel< DIM, BlockDataType >::isInternal(), and axom::spin::OctreeBase< DIM, BlockDataType >::isLevelValid().

◆ isInternal() [2/2]

template<int DIM, typename BlockDataType >
bool axom::spin::OctreeBase< DIM, BlockDataType >::isInternal ( const BlockIndex block) const
inline

Determine whether the octree contains an internal block associated with this BlockIndex.

Parameters
[in]blockThe BlockIndex of the tree to check
Returns
true if the associated block is an internal block of the octree, false otherwise

References axom::spin::OctreeBase< DIM, BlockDataType >::getOctreeLevel(), axom::spin::OctreeLevel< DIM, BlockDataType >::isInternal(), axom::spin::OctreeBase< DIM, BlockDataType >::isLevelValid(), axom::spin::OctreeBase< DIM, BlockDataType >::BlockIndex::level(), and axom::spin::OctreeBase< DIM, BlockDataType >::BlockIndex::pt().

◆ hasBlock() [1/2]

template<int DIM, typename BlockDataType >
bool axom::spin::OctreeBase< DIM, BlockDataType >::hasBlock ( const GridPt pt,
int  lev 
) const
inline

Determine whether the octree contains a block (internal or leaf) associated with grid point pt at level lev.

Parameters
[in]ptThe grid point to check
[in]levThe level of the grid point
Returns
true if the associated block is in the octree, false otherwise

References axom::spin::OctreeBase< DIM, BlockDataType >::isLevelValid(), axom::spin::OctreeBase< DIM, BlockDataType >::m_leavesLevelMap, and SLIC_ASSERT.

◆ hasBlock() [2/2]

template<int DIM, typename BlockDataType >
bool axom::spin::OctreeBase< DIM, BlockDataType >::hasBlock ( const BlockIndex block) const
inline

Determine whether the octree contains a block (internal or leaf) associated with this BlockIndex.

Parameters
[in]blockThe BlockIndex of the tree to check
Returns
true if the associated block is a block of the octree, false otherwise

References axom::spin::OctreeBase< DIM, BlockDataType >::hasBlock(), axom::spin::OctreeBase< DIM, BlockDataType >::BlockIndex::level(), and axom::spin::OctreeBase< DIM, BlockDataType >::BlockIndex::pt().

◆ inBounds() [1/2]

template<int DIM, typename BlockDataType >
bool axom::spin::OctreeBase< DIM, BlockDataType >::inBounds ( const GridPt pt,
int  lev 
) const
inline

Determine whether the octree block associated with grid point pt and level lev is a possible block in this octree.

Note
A block index is out of bounds if its level is not in the tree, or its grid point is out of the range of possible grid points for its level

References axom::spin::OctreeBase< DIM, BlockDataType >::BlockIndex::inBounds(), and axom::spin::OctreeBase< DIM, BlockDataType >::isLevelValid().

◆ inBounds() [2/2]

template<int DIM, typename BlockDataType >
bool axom::spin::OctreeBase< DIM, BlockDataType >::inBounds ( const BlockIndex block) const
inline

Determine whether the octree block associated with BlockIndex is a possible block in this octree.

Note
A block index is out of bounds if its level is not in the tree, or its grid point is out of the range of possible grid points for its level

References axom::spin::OctreeBase< DIM, BlockDataType >::BlockIndex::inBounds(), axom::spin::OctreeBase< DIM, BlockDataType >::isLevelValid(), and axom::spin::OctreeBase< DIM, BlockDataType >::BlockIndex::level().

◆ refineLeaf()

template<int DIM, typename BlockDataType >
void axom::spin::OctreeBase< DIM, BlockDataType >::refineLeaf ( const BlockIndex leafBlock)
inline

◆ operator[]() [1/2]

template<int DIM, typename BlockDataType >
BlockDataType& axom::spin::OctreeBase< DIM, BlockDataType >::operator[] ( const BlockIndex block)
inline

◆ operator[]() [2/2]

template<int DIM, typename BlockDataType >
const BlockDataType& axom::spin::OctreeBase< DIM, BlockDataType >::operator[] ( const BlockIndex block) const
inline

◆ coveringLeafBlock()

template<int DIM, typename BlockDataType >
BlockIndex axom::spin::OctreeBase< DIM, BlockDataType >::coveringLeafBlock ( const BlockIndex blk,
bool  checkInBounds = true 
) const
inline

Finds the finest octree leaf covering BlockIndex blk.

Parameters
blkA BlockIndex, not necessarily in the octree
checkInBoundsA flag to determine if we should check that the block lies within the octree bounds (default=true)
Postcondition
The returned block, if valid, is blk or one of its ancestor blocks.
Returns
The blockIndex of the finest octree leaf covering blk, if it exists, BlockIndex::invalid_index otherwise (e.g. blk is an internal block of the tree or is out of bounds)

References axom::spin::BlockNotInTree, axom::spin::OctreeBase< DIM, BlockDataType >::blockStatus(), axom::spin::OctreeBase< DIM, BlockDataType >::hasBlock(), axom::spin::OctreeBase< DIM, BlockDataType >::inBounds(), axom::spin::InternalBlock, axom::spin::OctreeBase< DIM, BlockDataType >::BlockIndex::invalid_index(), axom::spin::OctreeBase< DIM, BlockDataType >::isLeaf(), axom::spin::LeafBlock, axom::spin::OctreeBase< DIM, BlockDataType >::BlockIndex::parent(), SLIC_ASSERT, and SLIC_ASSERT_MSG.

◆ blockStatus() [1/2]

template<int DIM, typename BlockDataType >
TreeBlockStatus axom::spin::OctreeBase< DIM, BlockDataType >::blockStatus ( const GridPt pt,
int  lev 
) const
inlineprotected

Helper function to determine the status of a BlockIndex within an octree instance.

Note
This function is meant to help with implementing basic octree functionality and is not meant to be exposed in the public API
Parameters
ptThe grid point of the block index that we are testing
levThe level of the block index that we are testing

References axom::spin::BlockNotInTree, axom::spin::OctreeBase< DIM, BlockDataType >::isLevelValid(), axom::spin::OctreeBase< DIM, BlockDataType >::m_leavesLevelMap, and SLIC_ASSERT.

◆ blockStatus() [2/2]

template<int DIM, typename BlockDataType >
TreeBlockStatus axom::spin::OctreeBase< DIM, BlockDataType >::blockStatus ( const BlockIndex blk) const
inlineprotected

Helper function to determine the status of a BlockIndex within an octree instance.

Note
This function is meant to help with implementing basic octree functionality and is not meant to be exposed in the public API
Parameters
blkThe block index we are testing

References axom::spin::OctreeBase< DIM, BlockDataType >::blockStatus(), axom::spin::OctreeBase< DIM, BlockDataType >::BlockIndex::level(), and axom::spin::OctreeBase< DIM, BlockDataType >::BlockIndex::pt().

Member Data Documentation

◆ m_levels

template<int DIM, typename BlockDataType >
OctreeLevels axom::spin::OctreeBase< DIM, BlockDataType >::m_levels
protected

◆ m_leavesLevelMap

template<int DIM, typename BlockDataType >
LeafIndicesLevelMap axom::spin::OctreeBase< DIM, BlockDataType >::m_leavesLevelMap
protected

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