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

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

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

Public Types

enum  { NUM_CHILDREN = 1 << DIM , NUM_FACE_NEIGHBORS = 2 * DIM }
 
using ChildIndexSet = slam::OrderedSet< int, int, OCTREE_CHILDREN_SIZE >
 
using FaceNeighborIndexSet = slam::OrderedSet< int, int, OCTREE_FACE_NEIGHBORS_SIZE >
 

Public Member Functions

 BlockIndex ()
 Default constructor. More...
 
 BlockIndex (const GridPt &pt, int level)
 Constructor from a point and a level. More...
 
const GridPtpt () const
 Accessor for the BlockIndex instance's point. More...
 
GridPtpt ()
 Accessor for the BlockIndex instance's point. More...
 
const int & level () const
 Accessor for the BlockIndex instance's level. More...
 
int & level ()
 Accessor for the BlockIndex instance's level. More...
 
int parentLevel () const
 The level of the block index's parent. More...
 
int childLevel () const
 The level of the block index's child. More...
 
GridPt parentPt () const
 Returns the grid point of the block's parent. More...
 
GridPt childPt (int childIndex) const
 Returns the grid point of the block's child at index childIndex. More...
 
GridPt neighborPt (const GridPt &offset) const
 Returns a grid point at the specified offset from the current block index's point. More...
 
BlockIndex parent () const
 Returns the parent BlockIndex of this block. More...
 
BlockIndex child (int childIndex) const
 Returns the child BlockIndex of this block. More...
 
BlockIndex faceNeighbor (int neighborIndex) const
 Returns the face neighbor grid point of this block. More...
 
bool operator== (const BlockIndex &other) const
 
bool operator!= (const BlockIndex &other) const
 
bool operator< (const BlockIndex &other) const
 
bool isValid () const
 Checks the validity of the index. More...
 
bool inBounds () const
 Checks the if the block is in bounds for the level. More...
 
bool isDescendantOf (const BlockIndex &ancestor) const
 Predicate to determine if the block instance is a descendant of ancestor block. More...
 
std::ostream & print (std::ostream &os) const
 

Static Public Member Functions

static BlockIndex invalid_index ()
 Helper function to generate an invalid block index. More...
 
static int numChildren ()
 The number of children that an octree block can have. More...
 
static int numFaceNeighbors ()
 The number of face neighbors that an octree block can have (ignoring boundaries) More...
 

Friends

std::ostream & operator<< (std::ostream &os, const BlockIndex &block)
 

Detailed Description

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

Inner class encapsulating the index of an octree block.

Each block index is represented as a point on an integer grid (the minimum point of the block's extent) at a given level of resolution.

Each level of resolution is a regular grid with \( 2^{level} \) grid points along each dimension. The root block (at level 0) covers the entire domain. An octree block at level \( \ell \) has \( 2^{DIM} \) children at level \( \ell + 1 \) covering its domain.

Member Typedef Documentation

◆ ChildIndexSet

template<int DIM, typename BlockDataType >
using axom::spin::OctreeBase< DIM, BlockDataType >::BlockIndex::ChildIndexSet = slam::OrderedSet<int, int, OCTREE_CHILDREN_SIZE>

◆ FaceNeighborIndexSet

template<int DIM, typename BlockDataType >
using axom::spin::OctreeBase< DIM, BlockDataType >::BlockIndex::FaceNeighborIndexSet = slam::OrderedSet<int, int, OCTREE_FACE_NEIGHBORS_SIZE>

Member Enumeration Documentation

◆ anonymous enum

template<int DIM, typename BlockDataType >
anonymous enum
Enumerator
NUM_CHILDREN 

The number of children of an octree block (2^D in dimension D)

NUM_FACE_NEIGHBORS 

The number of face neighbors of an octree block (2*D in dimension D)

Constructor & Destructor Documentation

◆ BlockIndex() [1/2]

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

Default constructor.

◆ BlockIndex() [2/2]

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

Constructor from a point and a level.

Member Function Documentation

◆ pt() [1/2]

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

Accessor for the BlockIndex instance's point.

Returns
const reference to the instance's point

◆ pt() [2/2]

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

Accessor for the BlockIndex instance's point.

Returns
reference to the instance's point

◆ level() [1/2]

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

Accessor for the BlockIndex instance's level.

Returns
const reference to the instance's level

◆ level() [2/2]

template<int DIM, typename BlockDataType >
int& axom::spin::OctreeBase< DIM, BlockDataType >::BlockIndex::level ( )
inline

Accessor for the BlockIndex instance's level.

Returns
reference to the instance's level

◆ parentLevel()

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

The level of the block index's parent.

◆ childLevel()

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

The level of the block index's child.

◆ parentPt()

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

Returns the grid point of the block's parent.

References axom::primal::Point< T, NDIMS >::array().

◆ childPt()

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

Returns the grid point of the block's child at index childIndex.

Parameters
[in]childIndexThe index of the child whose grid point we are finding
Precondition
\( 0 \le childIndex < \) Octree::NUM_CHILDREN

References SLIC_ASSERT.

◆ neighborPt()

template<int DIM, typename BlockDataType >
GridPt axom::spin::OctreeBase< DIM, BlockDataType >::BlockIndex::neighborPt ( const GridPt offset) const
inline

Returns a grid point at the specified offset from the current block index's point.

◆ parent()

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

◆ child()

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

Returns the child BlockIndex of this block.

Parameters
[in]childIndexThe index of the child whose grid point we are finding
Precondition
\( 0 \le childIndex < \) Octree::NUM_CHILDREN

References axom::spin::OctreeBase< DIM, BlockDataType >::BlockIndex::BlockIndex(), axom::spin::OctreeBase< DIM, BlockDataType >::BlockIndex::childLevel(), and axom::spin::OctreeBase< DIM, BlockDataType >::BlockIndex::childPt().

◆ faceNeighbor()

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

Returns the face neighbor grid point of this block.

Precondition
0 <= neighborIndex < 2 * DIM
Note
The face neighbors indices cycle through the dimensions, two per dimension, e.g. Neighbor 0 is at offset (-1, 0,0,...,0), neighbor 1 is at offset (1,0,0,..,0) and neighbor 2 is at offset (0,-1, 0, 0, ..., 0) etc...

References axom::spin::OctreeBase< DIM, BlockDataType >::BlockIndex::BlockIndex(), axom::spin::OctreeBase< DIM, BlockDataType >::BlockIndex::neighborPt(), and SLIC_ASSERT.

◆ operator==()

template<int DIM, typename BlockDataType >
bool axom::spin::OctreeBase< DIM, BlockDataType >::BlockIndex::operator== ( const BlockIndex other) const
inline

◆ operator!=()

template<int DIM, typename BlockDataType >
bool axom::spin::OctreeBase< DIM, BlockDataType >::BlockIndex::operator!= ( const BlockIndex other) const
inline

◆ operator<()

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

◆ isValid()

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

Checks the validity of the index.

A block index is valid when its level is \( \ge 0 \) and it is inBounds

Returns
true if the block index is valid, else false
See also
inBounds()

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

◆ inBounds()

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

Checks the if the block is in bounds for the level.

A block index is in bounds when each coordinate p[i] of its grid point is \( 0 \le p[i] < 2^{level()} \).

Returns
true if the block index is inBounds, else false

◆ isDescendantOf()

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

Predicate to determine if the block instance is a descendant of ancestor block.

Parameters
ancestorThe potential ancestor of the block
Note
A block is an ancestor of another block if neither block is an invalid_index() and the block's are equivalent after 0 or more calls to BlockIndex::parent()
Returns
True, if the block instance is a descendant of the ancestor block

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

◆ print()

template<int DIM, typename BlockDataType >
std::ostream& axom::spin::OctreeBase< DIM, BlockDataType >::BlockIndex::print ( std::ostream &  os) const
inline

◆ invalid_index()

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

Helper function to generate an invalid block index.

Returns
A new BlockIndex instance blk
Postcondition
blk.isValid() will return false

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

◆ numChildren()

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

The number of children that an octree block can have.

◆ numFaceNeighbors()

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

The number of face neighbors that an octree block can have (ignoring boundaries)

Friends And Related Function Documentation

◆ operator<<

template<int DIM, typename BlockDataType >
std::ostream& operator<< ( std::ostream &  os,
const BlockIndex block 
)
friend

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