rebl-AMR
Tree< N, value > Class Template Reference

This Class Generates a 4:1 balancerd AMR mesh. More...

#include <tree.h>

Inheritance diagram for Tree< N, value >:
FullTree< N, value > Voxel< N, value >

Public Member Functions

 Tree (real *length, real *coords, uint nx, uint ny, uint nz)
 
 Tree (real *length, real *coords)
 
 Tree ()
 
void construct (real *length, real *coords, uint nx, uint ny, uint nz)
 
virtual void level (morton< N > key, uint *level)
 
void centroid (morton< N > key, real *xyz)
 
void enclosingBox (morton< N > key, real *X)
 
virtual bitmap< N, value >::iterator begin ()
 
virtual bitmap< N, value >::iterator end ()
 
virtual uint size ()
 
void reserve (uint *reservedsize)
 
void siblings (morton< N > key, uint mylevel, morton< N > *sibkey)
 
void refine (morton< N > key)
 
void derefine (morton< N > key)
 
void refineRefineList ()
 
void refineRefineList (bitvector< N > &V)
 
void fourToOneP (uint istart, uint iend)
 
void refineRefineList (uint istart, uint iend)
 
void fourToOne ()
 
void findFlipLevel (morton< N > key, uint *mylevel, uint *changedirectionlevel, uint *direction)
 
void flipForNbr (morton< N > *key, uint *mylevel, uint *changedirectionlevel, uint *direction)
 
uint IsInVectorList (morton< N > key)
 
void addToList (morton< N > key)
 
uint count (morton< N > key)
 
void addToDerefineList (morton< N > key)
 If any of the siblings are listed in the dereffinement do not add to the list as derefining one child means removing all the siblings. More...
 
void derefineDerefineList (uint nlevel)
 
uint isInsideSolid (const morton< N > key, const real *geom_xyz, uint n)
 
virtual bitmap< N, value >::iterator find (morton< N > key)
 
void insertKey (morton< N > key)
 
void convertStl2Morton (uint geom_size, real *geom_xyz)
 
void pushToRefinelist (uint level)
 
bool isBoundary (morton< N > &key)
 
void extractBoundary ()
 
void getDirections (morton< N > &key, vector< uint > &directions)
 
uint refineListSize ()
 
void clearRefineList ()
 
void extractBoundaryP (uint istart, uint iend)
 
bool isInMeshList (const morton< N > &key)
 
bool isInRefineList (const morton< N > &key)
 
void constructHigherLevelNbrs (const morton< N > &key, const uint &keylevel, const uint &direction, morton< N > *nbr)
 
void printMesh ()
 
bool isBoundary (const morton< N > &key, uint direction)
 
std::pair< morton< N >, int > readRefineList (typename std::unordered_map< morton< N >, int >::iterator it)
 
morton< N > readDerefineList (typename std::unordered_map< morton< N >, int >::iterator it)
 
void getKey (uint i, morton< N > &key)
 
void clearMortonSTL ()
 
void retainFourToOne ()
 
void removeFromDerefineList (typename std::unordered_map< morton< N >, int >::iterator it)
 
unordered_map< morton< N >, int >::iterator Dbegin ()
 
unordered_map< morton< N >, int >::iterator Dend ()
 
void derefineDerefineList ()
 
void clearMesh ()
 
void pushToDerefinelist (uint nlevel)
 
unordered_map< morton< N >, int >::iterator Rbegin ()
 
unordered_map< morton< N >, int >::iterator Rend ()
 
std::unordered_map< morton< N >, int >::iterator findInDerefine (morton< N > key)
 
void mortonSTLclear ()
 
void flipRefineElemTag (typename std::unordered_map< morton< N >, int >::iterator it)
 
void refinelistReset ()
 
void constructNonlocalHigherLevelNbrs (const morton< N > &key, const uint &keylevel, const uint &direction, morton< N > *nbr)
 
void insertSeed (morton< N > &key)
 
void insertNbrs (vector< int > &Nbrs)
 
void enclosingBoxFixedLevel (morton< N > key, uint mylevel, real *X)
 
void centroidFixedLevel (morton< N > key, const uint mylevel, real *xyz)
 
virtual void convertCoordToMorton (real *xyz, morton< N > &key)
 
std::unordered_map< morton< N >, int >::iterator findInList (morton< N > key)
 
 ~Tree ()
 

Public Attributes

bitvector< N > boundarylist
 

Protected Attributes

real ancestorlength [3]
 
real ancestorcoords [3]
 
morton< N > ancestorkey = 0
 
uint npx
 
uint npy
 
uint npz
 

Private Attributes

bitmap< N, value > mesh
 
std::unordered_map< morton< N >, int > refinelist
 
bitvector< N > mortonSTL
 
std::unordered_map< morton< N >, int > derefinelist
 

Friends

template<size_t N1, typename value2 >
class Hdf5Xmf
 

Detailed Description

template<size_t N, typename value>
class Tree< N, value >

This Class Generates a 4:1 balancerd AMR mesh.

Constructor & Destructor Documentation

◆ Tree() [1/3]

template<size_t N, typename value >
Tree< N, value >::Tree ( real length,
real coords,
uint  nx,
uint  ny,
uint  nz 
)

constructor

◆ Tree() [2/3]

template<size_t N, typename value >
Tree< N, value >::Tree ( real length,
real coords 
)

constructor

◆ Tree() [3/3]

template<size_t N, typename value>
Tree< N, value >::Tree ( )
inline

◆ ~Tree()

template<size_t N, typename value >
Tree< N, value >::~Tree ( )

Destructor of the class, it frees the memeory pointed by pointer in the hashmap value if allocated

Member Function Documentation

◆ addToDerefineList()

template<size_t N, typename value >
void Tree< N, value >::addToDerefineList ( morton< N >  key)

If any of the siblings are listed in the dereffinement do not add to the list as derefining one child means removing all the siblings.

adds the element to derefinelist

◆ addToList()

template<size_t N, typename value >
void Tree< N, value >::addToList ( morton< N >  key)

adds element to refinelist

◆ begin()

template<size_t N, typename value >
bitmap< N, value >::iterator Tree< N, value >::begin ( )
virtual

iterator returning the first object

Reimplemented in FullTree< N, value >.

◆ centroid()

template<size_t N, typename value >
void Tree< N, value >::centroid ( morton< N >  key,
real xyz 
)

calculates the centroid of the cube given the morton key of the element

◆ centroidFixedLevel()

template<size_t N, typename value >
void Tree< N, value >::centroidFixedLevel ( morton< N >  key,
const uint  mylevel,
real xyz 
)

◆ clearMesh()

template<size_t N, typename value >
void Tree< N, value >::clearMesh ( )

◆ clearMortonSTL()

template<size_t N, typename value >
void Tree< N, value >::clearMortonSTL ( )

◆ clearRefineList()

template<size_t N, typename value >
void Tree< N, value >::clearRefineList ( )

◆ construct()

template<size_t N, typename value >
void Tree< N, value >::construct ( real length,
real coords,
uint  nx,
uint  ny,
uint  nz 
)

need to initialize inside forest

◆ constructHigherLevelNbrs()

template<size_t N, typename value >
void Tree< N, value >::constructHigherLevelNbrs ( const morton< N > &  key,
const uint keylevel,
const uint direction,
morton< N > *  nbr 
)

◆ constructNonlocalHigherLevelNbrs()

template<size_t N, typename value >
void Tree< N, value >::constructNonlocalHigherLevelNbrs ( const morton< N > &  key,
const uint keylevel,
const uint direction,
morton< N > *  nbr 
)

◆ convertCoordToMorton()

template<size_t N, typename value >
void Tree< N, value >::convertCoordToMorton ( real xyz,
morton< N > &  key 
)
virtual

converts coordinates of a point to morton code

!< this function is to find a value given the key

Reimplemented in FullTree< N, value >.

◆ convertStl2Morton()

template<size_t N, typename value >
void Tree< N, value >::convertStl2Morton ( uint  geom_size,
real geom_xyz 
)

converts stl coordinates to morton and puts them in morton STL

!< this function is to find a value given the key

◆ count()

template<size_t N, typename value >
uint Tree< N, value >::count ( morton< N >  key)

counts the number of elements

◆ Dbegin()

template<size_t N, typename value >
unordered_map< morton< N >, int >::iterator Tree< N, value >::Dbegin ( )

◆ Dend()

template<size_t N, typename value >
unordered_map< morton< N >, int >::iterator Tree< N, value >::Dend ( )

◆ derefine()

template<size_t N, typename value >
void Tree< N, value >::derefine ( morton< N >  key)

if the morton code does not exist in mesh, refinement is not permitted (derefining a nonexsiting element not permitted) Also, if any of the siblings have a higher level of refinement, derefinement is ignored

<if the key does not exist simply igonre doing anything

◆ derefineDerefineList() [1/2]

template<size_t N, typename value>
void Tree< N, value >::derefineDerefineList ( uint  nlevel)

Derefines the mesh

◆ derefineDerefineList() [2/2]

template<size_t N, typename value >
void Tree< N, value >::derefineDerefineList ( )

◆ enclosingBox()

template<size_t N, typename value >
void Tree< N, value >::enclosingBox ( morton< N >  key,
real X 
)

calculates the range that an element occupies in 3D space for a given Element

◆ enclosingBoxFixedLevel()

template<size_t N, typename value >
void Tree< N, value >::enclosingBoxFixedLevel ( morton< N >  key,
uint  mylevel,
real X 
)

◆ end()

template<size_t N, typename value >
bitmap< N, value >::iterator Tree< N, value >::end ( )
virtual

iterator returning the last object

Reimplemented in FullTree< N, value >.

◆ extractBoundary()

template<size_t N, typename value >
void Tree< N, value >::extractBoundary ( )

◆ extractBoundaryP()

template<size_t N, typename value >
void Tree< N, value >::extractBoundaryP ( uint  istart,
uint  iend 
)

◆ find()

template<size_t N, typename value >
bitmap< N, value >::iterator Tree< N, value >::find ( morton< N >  key)
virtual

this function is to find a value given the key

!< this function is to find a value given the key

Reimplemented in FullTree< N, value >.

◆ findFlipLevel()

template<size_t N, typename value >
void Tree< N, value >::findFlipLevel ( morton< N >  key,
uint mylevel,
uint changedirectionlevel,
uint direction 
)

detects the flip level, this info used in finding nonlocal neighbors

◆ findInDerefine()

template<size_t N, typename value >
std::unordered_map< morton< N >, int >::iterator Tree< N, value >::findInDerefine ( morton< N >  key)

Get the iterator from derefinelist

Parameters
keyE;iminate from derefinelist

◆ findInList()

template<size_t N, typename value >
std::unordered_map< morton< N >, int >::iterator Tree< N, value >::findInList ( morton< N >  key)

!< this function is to find a value given the key

◆ flipForNbr()

template<size_t N, typename value >
void Tree< N, value >::flipForNbr ( morton< N > *  key,
uint mylevel,
uint changedirectionlevel,
uint direction 
)

perform the actual operation to identify the nonlocal nbr

◆ flipRefineElemTag()

template<size_t N, typename value >
void Tree< N, value >::flipRefineElemTag ( typename std::unordered_map< morton< N >, int >::iterator  it)

◆ fourToOne()

template<size_t N, typename value >
void Tree< N, value >::fourToOne ( )

imposes 4:1 balance given the list of elments to be refined in the vector refine list

< all we are interested is the nonlocal neighbors, i.e. the neighbors of the parents as siblings will have same level

< this approach eliminates search algorithm as now we do not have the restrictions on cutting the cube that we had in the previous approach

◆ fourToOneP()

template<size_t N, typename value>
void Tree< N, value >::fourToOneP ( uint  istart,
uint  iend 
)

imposes 4:1 balance locally for each tree, while loop is eliminated due to parallel implementation

◆ getDirections()

template<size_t N, typename value >
void Tree< N, value >::getDirections ( morton< N > &  key,
vector< uint > &  directions 
)

◆ getKey()

template<size_t N, typename value >
void Tree< N, value >::getKey ( uint  i,
morton< N > &  key 
)

◆ insertKey()

template<size_t N, typename value >
void Tree< N, value >::insertKey ( morton< N >  key)

◆ insertNbrs()

template<size_t N, typename value >
void Tree< N, value >::insertNbrs ( vector< int > &  Nbrs)
Parameters
Nbrsadd neighbors

◆ insertSeed()

template<size_t N, typename value >
void Tree< N, value >::insertSeed ( morton< N > &  key)
Parameters
keyEliminate from derefinelist

◆ isBoundary() [1/2]

template<size_t N, typename value >
bool Tree< N, value >::isBoundary ( morton< N > &  key)

◆ isBoundary() [2/2]

template<size_t N, typename value >
bool Tree< N, value >::isBoundary ( const morton< N > &  key,
uint  direction 
)

◆ isInMeshList()

template<size_t N, typename value >
bool Tree< N, value >::isInMeshList ( const morton< N > &  key)

◆ isInRefineList()

template<size_t N, typename value >
bool Tree< N, value >::isInRefineList ( const morton< N > &  key)

◆ isInsideSolid()

template<size_t N, typename value >
uint Tree< N, value >::isInsideSolid ( const morton< N >  key,
const real geom_xyz,
uint  n 
)

tags the elements if any points of the gemoetry resides in the enclosing box

◆ IsInVectorList()

template<size_t N, typename value >
uint Tree< N, value >::IsInVectorList ( morton< N >  key)

checks to see if a given code is already in the list

◆ level()

template<size_t N, typename value >
void Tree< N, value >::level ( morton< N >  key,
uint level 
)
virtual

obtains the level of the element from morton key

to prevent unnecesary bit operation, the morton code is placed from starting from left hand side

now look and see if any siblings exist

Reimplemented in FullTree< N, value >.

◆ mortonSTLclear()

template<size_t N, typename value >
void Tree< N, value >::mortonSTLclear ( )

◆ printMesh()

template<size_t N, typename value >
void Tree< N, value >::printMesh ( )

◆ pushToDerefinelist()

template<size_t N, typename value >
void Tree< N, value >::pushToDerefinelist ( uint  nlevel)

!< this function is to find a value given the key

◆ pushToRefinelist()

template<size_t N, typename value >
void Tree< N, value >::pushToRefinelist ( uint  nlevel)

Note that for dynamic mesh we need to make sure the element exists before adding to this list

!< this function is to find a value given the key

◆ Rbegin()

template<size_t N, typename value >
unordered_map< morton< N >, int >::iterator Tree< N, value >::Rbegin ( )

◆ readDerefineList()

template<size_t N, typename value >
morton< N > Tree< N, value >::readDerefineList ( typename std::unordered_map< morton< N >, int >::iterator  it)

◆ readRefineList()

template<size_t N, typename value >
std::pair< morton< N >, int > Tree< N, value >::readRefineList ( typename std::unordered_map< morton< N >, int >::iterator  it)

◆ refine()

template<size_t N, typename value >
void Tree< N, value >::refine ( morton< N >  key)

perfomrs refinement for a tagged element given the Morton Key

◆ refinelistReset()

template<size_t N, typename value >
void Tree< N, value >::refinelistReset ( )

◆ refineListSize()

template<size_t N, typename value >
uint Tree< N, value >::refineListSize ( )

◆ refineRefineList() [1/3]

template<size_t N, typename value >
void Tree< N, value >::refineRefineList ( )

performs derefinement on a single element given a morton key performs the refinement

◆ refineRefineList() [2/3]

template<size_t N, typename value >
void Tree< N, value >::refineRefineList ( bitvector< N > &  V)

performs the refinement

◆ refineRefineList() [3/3]

template<size_t N, typename value >
void Tree< N, value >::refineRefineList ( uint  istart,
uint  iend 
)

performs the refinement

◆ removeFromDerefineList()

template<size_t N, typename value >
void Tree< N, value >::removeFromDerefineList ( typename std::unordered_map< morton< N >, int >::iterator  it)
Parameters
itE;iminate from derefinelist

◆ Rend()

template<size_t N, typename value >
unordered_map< morton< N >, int >::iterator Tree< N, value >::Rend ( )

◆ reserve()

template<size_t N, typename value >
void Tree< N, value >::reserve ( uint reservedsize)

this function reserves the memory given the reservedsize of the mesh

◆ retainFourToOne()

template<size_t N, typename value >
void Tree< N, value >::retainFourToOne ( )

◆ siblings()

template<size_t N, typename value >
void Tree< N, value >::siblings ( morton< N >  key,
uint  mylevel,
morton< N > *  sibkey 
)

extracts the siblings from morton code

◆ size()

template<size_t N, typename value >
uint Tree< N, value >::size ( )
virtual

returns the size of the mesh

Reimplemented in FullTree< N, value >.

Friends And Related Function Documentation

◆ Hdf5Xmf

template<size_t N, typename value>
template<size_t N1, typename value2 >
friend class Hdf5Xmf
friend

this is a friend class to write out in hdf5 format

Member Data Documentation

◆ ancestorcoords

template<size_t N, typename value>
real Tree< N, value >::ancestorcoords[3]
protected

centeroid of the of the first generation (root) element

◆ ancestorkey

template<size_t N, typename value>
morton<N> Tree< N, value >::ancestorkey = 0
protected

root value is always set as 0000000000000

◆ ancestorlength

template<size_t N, typename value>
real Tree< N, value >::ancestorlength[3]
protected

original length of the first generation (root) element

◆ boundarylist

template<size_t N, typename value>
bitvector<N> Tree< N, value >::boundarylist

list of elements of refinelist that are boundary elements

◆ derefinelist

template<size_t N, typename value>
std::unordered_map<morton<N>, int> Tree< N, value >::derefinelist
private

list of elements tagged to be removed, due to 4:1 balance this listi

◆ mesh

template<size_t N, typename value>
bitmap<N, value> Tree< N, value >::mesh
private

base main container

◆ mortonSTL

template<size_t N, typename value>
bitvector<N> Tree< N, value >::mortonSTL
private

vector to store geometric points in morton code

◆ npx

template<size_t N, typename value>
uint Tree< N, value >::npx
protected

discritization in x direction

◆ npy

template<size_t N, typename value>
uint Tree< N, value >::npy
protected

discretization in y direction

◆ npz

template<size_t N, typename value>
uint Tree< N, value >::npz
protected

discretization in y direction

◆ refinelist

template<size_t N, typename value>
std::unordered_map<morton<N>, int> Tree< N, value >::refinelist
private

list of elements tagged to be refined


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