MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
maia::grid::tree::Tree< nDim > Class Template Reference

Class that represents grid tree and contains all relevant per-node data. More...

#include <cartesiangridtree.h>

Inheritance diagram for maia::grid::tree::Tree< nDim >:
[legend]
Collaboration diagram for maia::grid::tree::Tree< nDim >:
[legend]

Public Types

template<class T >
using Invalid = typename maia::grid::tree::Invalid< T >
 
using Cell = maia::grid::tree::Cell
 
using PropertyBitsetType = maia::grid::tree::PropertyBitsetType
 
using SolverBitsetType = maia::grid::tree::SolverBitsetType
 

Public Member Functions

constexpr Tree ()=default
 Default c'tor does nothing. More...
 
MLongparent (const MInt id)
 Accessor for parent node. More...
 
MLong parent (const MInt id) const
 Accessor for parent node (const version). More...
 
MBool hasParent (const MInt id) const
 Return whether node has parent. More...
 
MLongchild (const MInt id, const MInt pos)
 Accessor for child node. More...
 
MLong child (const MInt id, const MInt pos) const
 Accessor for child node (const version). More...
 
MBool hasChild (const MInt id, const MInt pos) const
 Return whether node has child at given position. More...
 
MBool hasChildren (const MInt id) const
 Return whether node has any children. More...
 
MBool hasChildren (const MInt id, const MInt solverId) const
 Return whether node has any children living on the specified solver (Lennart). More...
 
MInt noChildren (const MInt id) const
 Return number of children of given node. More...
 
MLongneighbor (const MInt id, const MInt dir)
 Accessor for neighbor node. More...
 
MLong neighbor (const MInt id, const MInt dir) const
 Accessor for neighbor node (const version). More...
 
MBool hasNeighbor (const MInt id, const MInt dir) const
 Return whether node has same-level neighbor in given direction. More...
 
MBool hasAnyNeighbor (const MInt id, const MInt dir) const
 Return whether node or its parent has neighbor in given direction. More...
 
MLongglobalId (const MInt id)
 Accessor for global id. More...
 
MLong globalId (const MInt id) const
 Accessor for global id (const version). More...
 
MIntlevel (const MInt id)
 Accessor for level. More...
 
MInt level (const MInt id) const
 Accessor for level (const version). More...
 
MFloatcoordinate (const MInt id, const MInt dim)
 Accessor for coordinates. More...
 
MFloat coordinate (const MInt id, const MInt dim) const
 Accessor for coordinates (const version). More...
 
const MFloatcoordinate (const MInt id) const
 
MFloatweight (const MInt id)
 Accessor for weight. More...
 
MFloat weight (const MInt id) const
 Accessor for weight (const version). More...
 
SolverBitsetType::reference solver (const MInt id, const MInt solverId)
 Accessor for solver usage. More...
 
MBool solver (const MInt id, const MInt solverId) const
 Accessor for solver usage (const version). More...
 
void resetSolver (const MInt id)
 Reset all solver use. More...
 
MUlong solverToBits (const MInt id) const
 Convert solver usage to bits. More...
 
void solverFromBits (const MInt id, const MUlong bits)
 Convert solver usage from bits. More...
 
MBool cellHasSolver (const MInt cellId, const MInt solverId)
 Check if solver is contained for cell. More...
 
SolverBitsetTypesolverBits (const MInt id)
 Accessor for properties. More...
 
MBool isLeafCell (const MInt id) const
 Accessor for isLeafCell usage (const version). More...
 
SolverBitsetType::reference isLeafCell (const MInt id, const MInt solverId)
 Accessor for isLeafCell usage. More...
 
MBool isLeafCell (const MInt id, const MInt solverId) const
 Accessor for isLeafCell usage (const version). More...
 
void resetIsLeafCell (const MInt id)
 Reset all isLeafCell. More...
 
SolverBitsetTypeleafCellBits (const MInt id)
 Accessor for properties. More...
 
PropertyBitsetType::reference hasProperty (const MInt id, const Cell p)
 Accessor for properties. More...
 
MBool hasProperty (const MInt id, const Cell p) const
 Accessor for properties (const version). More...
 
void resetProperties (const MInt id)
 Reset all properties. More...
 
MUlong propertiesToBits (const MInt id) const
 Convert properties to bits. More...
 
void propertiesFromBits (const MInt id, const MUlong bits)
 Convert properties from bits. More...
 
MString propertiesToString (const MInt id) const
 Convert properties to string. More...
 
PropertyBitsetTypeproperties (const MInt id)
 Accessor for properties. More...
 
MIntnoOffsprings (const MInt id)
 Accessor for noOffsprings. More...
 
MInt noOffsprings (const MInt id) const
 Accessor for noOffsprings (const version). More...
 
MFloatworkload (const MInt id)
 Accessor for workload. More...
 
MFloat workload (const MInt id) const
 Accessor for workload (const version). More...
 
constexpr MInt noSolvers () const
 Return currently set number of solvers. More...
 
void setNoSolvers (const MInt count)
 Set number of solvers. More...
 
MInt noNodesBySolver (const MInt solverId) const
 Return number of nodes for a given solver. More...
 
MInt nodesBySolver (const MInt solverId, MInt *const ids) const
 Generate list of node ids that are used by a given solver and return number of used nodes. More...
 
MInt capacity ()
 
- Public Member Functions inherited from maia::container::Container< Tree< nDim >, maia::grid::tree::Invalid >
constexpr Container ()=default
 Default c'tor does nothing. More...
 
constexpr MInt capacity () const
 Return capacity (i.e., maximum number of nodes) More...
 
void reset (const MInt capacity)
 Reset tree, re-create data structures with given capacity, and set size to zero. More...
 
void resize (const MInt capacity)
 Resize the container capacity. More...
 
constexpr MInt size () const
 Return size (i.e., currently used number of nodes) More...
 
void size (const MInt size_)
 Resize tree WITHOUT CONSIDERING ANY NODE CONSISTENCY! Use at own risk and remove ASAP... More...
 
void append (const MInt count)
 Append nodes to end of tree. More...
 
void append ()
 
void shrink (const MInt count)
 Remove nodes from end of tree. More...
 
void shrink ()
 
void copy (const T &source, const MInt begin, const MInt end, const MInt to)
 Copy nodes to another location without changing any parent/child/neighbor information. More...
 
void copy (const T &source, const MInt from, const MInt to)
 
void copy (const MInt begin, const MInt end, const MInt to)
 
void copy (const MInt from, const MInt to)
 
void move (const MInt begin, const MInt end, const MInt to)
 Move nodes to another location and update parent/child/neighbor information accordingly. More...
 
void move (const MInt from, const MInt to)
 
void swap (const MInt a, const MInt b)
 Swap two nodes and update parent/child/neighbor information accordingly. More...
 
void insert (const MInt begin, const MInt count)
 
void insert (const MInt id)
 
void erase (const MInt begin, const MInt end)
 Erase nodes in range [begin, end) and update parent/child/neighbor information. More...
 
void erase (const MInt id)
 
void removeAndShift (const MInt begin, const MInt end)
 
void removeAndShift (const MInt id)
 
void removeAndFill (const MInt begin, const MInt end)
 
void removeAndFill (const MInt id)
 
void clear ()
 Clear tree by invalidating all nodes and setting size to zero. More...
 
Tree< nDim > & derived ()
 
const Tree< nDim > & derived () const
 
void rawCopy (const T &source, const MInt begin, const MInt end, const MInt to)
 Copy range of nodes [begin, end) to range starting at 'to'. More...
 
void rawCopy (const T &source, const MInt from, const MInt to)
 
void deleteConnectivity (const MInt NotUsed(begin), const MInt NotUsed(end))
 
void moveConnectivity (const MInt NotUsed(begin), const MInt NotUsed(end), const MInt NotUsed(to))
 
void moveConnectivity (const MInt from, const MInt to)
 
constexpr MInt dummy () const
 

Static Public Member Functions

static constexpr MInt noChildrenPerNode ()
 Return maximum number of children per node. More...
 
static constexpr MInt noNeighborsPerNode ()
 Return maximum number of same-level neighbors per node. More...
 
static constexpr MInt oppositeNeighborDir (const MInt dir)
 Return opposite direction for given neighbor direction. More...
 
static constexpr MInt noProperties ()
 Return number of properties defined for each node. More...
 
static constexpr MInt maxNoSolvers ()
 Return maximum number of supported solvers. More...
 

Private Types

using Base = maia::container::Container< Tree< nDim >, maia::grid::tree::Invalid >
 
template<class T >
using Storage = typename Base::template Storage< T >
 

Private Member Functions

void reset ()
 Reset tree, re-create data structures with given capacity, and set size to zero. More...
 
void invalidate (const MInt begin, const MInt end)
 Erase range of nodes such that they contain no sensible values anymore. More...
 
template<class Functor , class T >
void rawCopyGeneric (Functor &&c, const T &source, const MInt begin, const MInt end, const MInt destination)
 Helper function for rawCopy(). Destination may refer to beginning or end of target range. More...
 
void deleteConnectivity (const MInt begin, const MInt end)
 Update parent/children/neighbors before nodes are erased. More...
 
void moveConnectivity (const MInt begin, const MInt end, const MInt to)
 Update parent/children/neighbors after nodes have moved. More...
 

Private Attributes

Storage< MLongm_parentIds {}
 
Storage< MLongm_childIds {}
 
Storage< MLongm_neighborIds {}
 
Storage< MLongm_globalIds {}
 
Storage< MIntm_levels {}
 
Storage< MFloatm_coordinates {}
 
Storage< MFloatm_weight {}
 
Storage< SolverBitsetTypem_solver {}
 
Storage< SolverBitsetTypem_isLeafCell {}
 
Storage< PropertyBitsetTypem_properties {}
 
Storage< MIntm_noOffsprings {}
 
Storage< MFloatm_workload {}
 
MInt m_noSolvers = -1
 Number of solvers that are actively using this tree. More...
 

Friends

class maia::container::Container< Tree< nDim >, maia::grid::tree::Invalid >
 

Additional Inherited Members

- Protected Types inherited from maia::container::Container< Tree< nDim >, maia::grid::tree::Invalid >
using Storage = std::vector< T >
 
- Protected Member Functions inherited from maia::container::Container< Tree< nDim >, maia::grid::tree::Invalid >
virtual void resize ()
 
void resetStorage (const MInt n, Storage< T > &c)
 Create new container with given size and replace original one. More...
 
void resizeStorage (const MInt n, Storage< T > &c)
 Resize container with given size. More...
 
void fill_invalid (Container_ &c, const MInt begin, const MInt end, const MInt solverSize=1, const T value=maia::grid::tree::Invalid< T >::value())
 
void copyData (const Container_ &source, Container_ &target, Functor &&f, const MInt begin, const MInt end, const MInt dest, const MInt solverSize=1)
 Copy [begin, end) range with given solver size from source to dest position of target. More...
 
MBool isValidId (const MInt id) const
 Return whether given id refers to a valid node (auxiliary method). More...
 

Detailed Description

template<MInt nDim>
class maia::grid::tree::Tree< nDim >

Definition at line 178 of file cartesiangridtree.h.

Member Typedef Documentation

◆ Base

template<MInt nDim>
using maia::grid::tree::Tree< nDim >::Base = maia::container::Container<Tree<nDim>, maia::grid::tree::Invalid>
private

Definition at line 183 of file cartesiangridtree.h.

◆ Cell

template<MInt nDim>
using maia::grid::tree::Tree< nDim >::Cell = maia::grid::tree::Cell

Definition at line 193 of file cartesiangridtree.h.

◆ Invalid

template<MInt nDim>
template<class T >
using maia::grid::tree::Tree< nDim >::Invalid = typename maia::grid::tree::Invalid<T>

Definition at line 192 of file cartesiangridtree.h.

◆ PropertyBitsetType

template<MInt nDim>
using maia::grid::tree::Tree< nDim >::PropertyBitsetType = maia::grid::tree::PropertyBitsetType

Definition at line 194 of file cartesiangridtree.h.

◆ SolverBitsetType

template<MInt nDim>
using maia::grid::tree::Tree< nDim >::SolverBitsetType = maia::grid::tree::SolverBitsetType

Definition at line 195 of file cartesiangridtree.h.

◆ Storage

template<MInt nDim>
template<class T >
using maia::grid::tree::Tree< nDim >::Storage = typename Base::template Storage<T>
private

Definition at line 186 of file cartesiangridtree.h.

Constructor & Destructor Documentation

◆ Tree()

template<MInt nDim>
constexpr maia::grid::tree::Tree< nDim >::Tree ( )
constexprdefault

Member Function Documentation

◆ capacity()

template<MInt nDim>
MInt maia::grid::tree::Tree< nDim >::capacity ( )
inline

Definition at line 287 of file cartesiangridtree.h.

287{ return m_parentIds.capacity(); }
Storage< MLong > m_parentIds

◆ cellHasSolver()

template<MInt nDim>
MBool maia::grid::tree::Tree< nDim >::cellHasSolver ( const MInt  cellId,
const MInt  solverId 
)

Definition at line 605 of file cartesiangridtree.h.

605 {
606 return m_solver[cellId][solverId];
607}
Storage< SolverBitsetType > m_solver
void const MInt cellId
Definition: collector.h:239

◆ child() [1/2]

template<MInt nDim>
MLong & maia::grid::tree::Tree< nDim >::child ( const MInt  id,
const MInt  pos 
)

Definition at line 359 of file cartesiangridtree.h.

359 {
360// Prevent accidental compilation without support for SoA layout
361#ifdef GRIDTREE_SOA_MEMORY_LAYOUT
362#error Missing implementation for structure-of-arrays memory layout.
363#endif
364 ENSURE_VALID_ID_ACCESSOR(id);
365 ENSURE_VALID_CHILD_POSITION_ACCESSOR(pos);
366 return m_childIds[id * noChildrenPerNode() + pos];
367}
static constexpr MInt noChildrenPerNode()
Return maximum number of children per node.
Storage< MLong > m_childIds

◆ child() [2/2]

template<MInt nDim>
MLong maia::grid::tree::Tree< nDim >::child ( const MInt  id,
const MInt  pos 
) const

Definition at line 370 of file cartesiangridtree.h.

370 {
371// Prevent accidental compilation without support for SoA layout
372#ifdef GRIDTREE_SOA_MEMORY_LAYOUT
373#error Missing implementation for structure-of-arrays memory layout.
374#endif
375 ENSURE_VALID_ID_ACCESSOR(id);
376 ENSURE_VALID_CHILD_POSITION_ACCESSOR(pos);
377 return m_childIds[id * noChildrenPerNode() + pos];
378}

◆ coordinate() [1/3]

template<MInt nDim>
const MFloat * maia::grid::tree::Tree< nDim >::coordinate ( const MInt  id) const

Definition at line 519 of file cartesiangridtree.h.

519 {
520// Prevent accidental compilation without support for SoA layout
521#ifdef GRIDTREE_SOA_MEMORY_LAYOUT
522#error Missing implementation for structure-of-arrays memory layout.
523#endif
524 ENSURE_VALID_ID_ACCESSOR(id);
525 return &m_coordinates[id * nDim];
526}
Storage< MFloat > m_coordinates

◆ coordinate() [2/3]

template<MInt nDim>
MFloat & maia::grid::tree::Tree< nDim >::coordinate ( const MInt  id,
const MInt  dim 
)

Definition at line 497 of file cartesiangridtree.h.

497 {
498// Prevent accidental compilation without support for SoA layout
499#ifdef GRIDTREE_SOA_MEMORY_LAYOUT
500#error Missing implementation for structure-of-arrays memory layout.
501#endif
502 ENSURE_VALID_ID_ACCESSOR(id);
503 ENSURE_VALID_COORDINATE_DIR_ACCESSOR(dir);
504 return m_coordinates[id * nDim + dir];
505}

◆ coordinate() [3/3]

template<MInt nDim>
MFloat maia::grid::tree::Tree< nDim >::coordinate ( const MInt  id,
const MInt  dim 
) const

Definition at line 508 of file cartesiangridtree.h.

508 {
509// Prevent accidental compilation without support for SoA layout
510#ifdef GRIDTREE_SOA_MEMORY_LAYOUT
511#error Missing implementation for structure-of-arrays memory layout.
512#endif
513 ENSURE_VALID_ID_ACCESSOR(id);
514 ENSURE_VALID_COORDINATE_DIR_ACCESSOR(dir);
515 return m_coordinates[id * nDim + dir];
516}

◆ deleteConnectivity()

template<MInt nDim>
void maia::grid::tree::Tree< nDim >::deleteConnectivity ( const MInt  begin,
const MInt  end 
)
private

Definition at line 846 of file cartesiangridtree.h.

846 {
847 for(MInt i = begin; i < end; i++) {
848 // Parent
849 if(hasParent(i)) {
850 const MInt p = parent(i);
851 for(MInt j = 0; j < noChildrenPerNode(); j++) {
852 if(child(p, j) == i) {
853 child(p, j) = -1;
854 }
855 }
856 }
857
858 // Children
859 for(MInt j = 0; j < noChildrenPerNode(); j++) {
860 if(hasChild(i, j)) {
861 parent(child(i, j)) = -1;
862 }
863 }
864
865 // Neighbors
866 for(MInt j = 0; j < noNeighborsPerNode(); j++) {
867 if(hasNeighbor(i, j)) {
868 neighbor(neighbor(i, j), oppositeNeighborDir(j)) = -1;
869 }
870 }
871 }
872}
MBool hasChild(const MInt id, const MInt pos) const
Return whether node has child at given position.
static constexpr MInt oppositeNeighborDir(const MInt dir)
Return opposite direction for given neighbor direction.
MBool hasParent(const MInt id) const
Return whether node has parent.
MLong & neighbor(const MInt id, const MInt dir)
Accessor for neighbor node.
MLong & parent(const MInt id)
Accessor for parent node.
MBool hasNeighbor(const MInt id, const MInt dir) const
Return whether node has same-level neighbor in given direction.
MLong & child(const MInt id, const MInt pos)
Accessor for child node.
static constexpr MInt noNeighborsPerNode()
Return maximum number of same-level neighbors per node.
int32_t MInt
Definition: maiatypes.h:62
constexpr std::underlying_type< FcCell >::type p(const FcCell property)
Converts property name to underlying integer value.

◆ globalId() [1/2]

template<MInt nDim>
MLong & maia::grid::tree::Tree< nDim >::globalId ( const MInt  id)

Definition at line 469 of file cartesiangridtree.h.

469 {
470 ENSURE_VALID_ID_ACCESSOR(id);
471 return m_globalIds[id];
472}
Storage< MLong > m_globalIds
MInt id
Definition: maiatypes.h:71

◆ globalId() [2/2]

template<MInt nDim>
MLong maia::grid::tree::Tree< nDim >::globalId ( const MInt  id) const

Definition at line 475 of file cartesiangridtree.h.

475 {
476 ENSURE_VALID_ID_ACCESSOR(id);
477 return m_globalIds[id];
478}

◆ hasAnyNeighbor()

template<MInt nDim>
MBool maia::grid::tree::Tree< nDim >::hasAnyNeighbor ( const MInt  id,
const MInt  dir 
) const

Definition at line 460 of file cartesiangridtree.h.

460 {
461 ENSURE_VALID_ID_ACCESSOR(id);
462 ENSURE_VALID_NEIGHBOR_DIR_ACCESSOR(dir);
463 return hasNeighbor(id, dir) || (hasParent(id) && hasNeighbor(parent(id), dir));
464}

◆ hasChild()

template<MInt nDim>
MBool maia::grid::tree::Tree< nDim >::hasChild ( const MInt  id,
const MInt  pos 
) const

Definition at line 383 of file cartesiangridtree.h.

383 {
384// Prevent accidental compilation without support for SoA layout
385#ifdef GRIDTREE_SOA_MEMORY_LAYOUT
386#error Missing implementation for structure-of-arrays memory layout.
387#endif
388 ENSURE_VALID_ID_ACCESSOR(id);
389 ENSURE_VALID_CHILD_POSITION_ACCESSOR(pos);
390 return m_childIds[id * noChildrenPerNode() + pos] > -1;
391}

◆ hasChildren() [1/2]

template<MInt nDim>
MBool maia::grid::tree::Tree< nDim >::hasChildren ( const MInt  id) const

Definition at line 396 of file cartesiangridtree.h.

396 {
397 ENSURE_VALID_ID_ACCESSOR(id);
398 return noChildren(id) > 0;
399}
MInt noChildren(const MInt id) const
Return number of children of given node.

◆ hasChildren() [2/2]

template<MInt nDim>
MBool maia::grid::tree::Tree< nDim >::hasChildren ( const MInt  id,
const MInt  solverId 
) const

Definition at line 403 of file cartesiangridtree.h.

403 {
404 ENSURE_VALID_ID_ACCESSOR(id);
405 return std::any_of(&m_childIds[id * noChildrenPerNode()], &m_childIds[id * noChildrenPerNode() + noChildrenPerNode()],
406 [&](MLong c) { return c > -1 && solver(c, solverId); });
407}
SolverBitsetType::reference solver(const MInt id, const MInt solverId)
Accessor for solver usage.
int64_t MLong
Definition: maiatypes.h:64

◆ hasNeighbor()

template<MInt nDim>
MBool maia::grid::tree::Tree< nDim >::hasNeighbor ( const MInt  id,
const MInt  dir 
) const

Definition at line 449 of file cartesiangridtree.h.

449 {
450// Prevent accidental compilation without support for SoA layout
451#ifdef GRIDTREE_SOA_MEMORY_LAYOUT
452#error Missing implementation for structure-of-arrays memory layout.
453#endif
454 ENSURE_VALID_ID_ACCESSOR(id);
455 ENSURE_VALID_NEIGHBOR_DIR_ACCESSOR(dir);
456 return m_neighborIds[id * noNeighborsPerNode() + dir] > -1;
457}
Storage< MLong > m_neighborIds

◆ hasParent()

template<MInt nDim>
MBool maia::grid::tree::Tree< nDim >::hasParent ( const MInt  id) const

Definition at line 351 of file cartesiangridtree.h.

351 {
352 ENSURE_VALID_ID_ACCESSOR(id);
353 return m_parentIds[id] > -1;
354}

◆ hasProperty() [1/2]

template<MInt nDim>
Tree< nDim >::PropertyBitsetType::reference maia::grid::tree::Tree< nDim >::hasProperty ( const MInt  id,
const Cell  p 
)

Definition at line 653 of file cartesiangridtree.h.

653 {
654 ENSURE_VALID_ID_ACCESSOR(id);
655 ENSURE_VALID_PROPERTY_ACCESSOR(p);
657}
Storage< PropertyBitsetType > m_properties
constexpr std::underlying_type< GridCell >::type p(const GridCell property)
Converts property name to underlying integer value.

◆ hasProperty() [2/2]

template<MInt nDim>
MBool maia::grid::tree::Tree< nDim >::hasProperty ( const MInt  id,
const Cell  p 
) const

Definition at line 660 of file cartesiangridtree.h.

660 {
661 ENSURE_VALID_ID_ACCESSOR(id);
662 ENSURE_VALID_PROPERTY_ACCESSOR(p);
664}

◆ invalidate()

template<MInt nDim>
void maia::grid::tree::Tree< nDim >::invalidate ( const MInt  begin,
const MInt  end 
)
private

Definition at line 753 of file cartesiangridtree.h.

753 {
754// Prevent accidental compilation without support for SoA layout
755#ifdef GRIDTREE_SOA_MEMORY_LAYOUT
756#error Missing implementation for structure-of-arrays memory layout.
757#endif
758
759 // Parent
760 fill_invalid(m_parentIds, begin, end);
761
762 // Children
764
765 // Neighbors
767
768 // Global id
769 fill_invalid(m_globalIds, begin, end);
770
771 // Level
772 fill_invalid(m_levels, begin, end);
773
774 // Coordinates
775 fill_invalid(m_coordinates, begin, end, nDim);
776
777 // Solver usage
778 fill_invalid(m_solver, begin, end);
779
780 // Solver usage
781 fill_invalid(m_isLeafCell, begin, end);
782
783 // Weight
784 fill_invalid(m_weight, begin, end);
785
786 // Properties
787 fill_invalid(m_properties, begin, end);
788
789 // No offsprings
790 fill_invalid(m_noOffsprings, begin, end);
791
792 // Workload
793 fill_invalid(m_workload, begin, end);
794}
void fill_invalid(Container_ &c, const MInt begin, const MInt end, const MInt solverSize=1, const T value=maia::grid::tree::Invalid< T >::value())
Definition: container.h:131
Storage< MFloat > m_weight
Storage< SolverBitsetType > m_isLeafCell
Storage< MInt > m_noOffsprings
Storage< MFloat > m_workload

◆ isLeafCell() [1/3]

template<MInt nDim>
MBool maia::grid::tree::Tree< nDim >::isLeafCell ( const MInt  id) const

Definition at line 618 of file cartesiangridtree.h.

618 {
619 ENSURE_VALID_ID_ACCESSOR(id);
620 return (m_isLeafCell[id].any() && m_isLeafCell[id] == m_solver[id]);
621}

◆ isLeafCell() [2/3]

template<MInt nDim>
Tree< nDim >::SolverBitsetType::reference maia::grid::tree::Tree< nDim >::isLeafCell ( const MInt  id,
const MInt  solverId 
)

Definition at line 624 of file cartesiangridtree.h.

624 {
625 ENSURE_VALID_ID_ACCESSOR(id);
626 ENSURE_VALID_SOLVER_ID_ACCESSOR(solverId);
627 // ASSERT( m_solver[id][solverId], "Invalid cell accessed, not belonging to solver!" );
628 return m_isLeafCell[id][solverId];
629}

◆ isLeafCell() [3/3]

template<MInt nDim>
MBool maia::grid::tree::Tree< nDim >::isLeafCell ( const MInt  id,
const MInt  solverId 
) const

Definition at line 632 of file cartesiangridtree.h.

632 {
633 ENSURE_VALID_ID_ACCESSOR(id);
634 ENSURE_VALID_SOLVER_ID_ACCESSOR(solverId);
635 // ASSERT( m_solver[id][solverId], "Invalid cell accessed, not belonging to solver!" );
636 return m_isLeafCell[id][solverId];
637}

◆ leafCellBits()

template<MInt nDim>
SolverBitsetType & maia::grid::tree::Tree< nDim >::leafCellBits ( const MInt  id)

Definition at line 646 of file cartesiangridtree.h.

646 {
647 ENSURE_VALID_ID_ACCESSOR(id);
648 return m_isLeafCell[id];
649}

◆ level() [1/2]

template<MInt nDim>
MInt & maia::grid::tree::Tree< nDim >::level ( const MInt  id)

Definition at line 483 of file cartesiangridtree.h.

483 {
484 ENSURE_VALID_ID_ACCESSOR(id);
485 return m_levels[id];
486}

◆ level() [2/2]

template<MInt nDim>
MInt maia::grid::tree::Tree< nDim >::level ( const MInt  id) const

Definition at line 489 of file cartesiangridtree.h.

489 {
490 ENSURE_VALID_ID_ACCESSOR(id);
491 return m_levels[id];
492}

◆ maxNoSolvers()

template<MInt nDim>
static constexpr MInt maia::grid::tree::Tree< nDim >::maxNoSolvers ( )
inlinestaticconstexpr

Definition at line 275 of file cartesiangridtree.h.

275{ return SolverBitsetType().size(); }
maia::grid::tree::SolverBitsetType SolverBitsetType

◆ moveConnectivity()

template<MInt nDim>
void maia::grid::tree::Tree< nDim >::moveConnectivity ( const MInt  begin,
const MInt  end,
const MInt  to 
)
private

Definition at line 877 of file cartesiangridtree.h.

877 {
878 // Auxiliary method for checking if a given id is within the original range that was moved
879 auto inMovedRange = [begin, end](const MInt id) { return (id >= begin && id < end); };
880
881 // General strategy:
882 // 1) Loop over moved nodes and check all tree connections (parents/children/neighbors)
883 // 2) If a given connection is to a node that was moved: apply offset to current node
884 // 3) If a given connection is to a node that was not moved: change connectivity in other node
885 for(MInt from = begin; from < end; from++) {
886 const MInt distance = to - begin;
887 const MInt destination = from + distance;
888
889 // Parent
890 if(hasParent(destination)) {
891 const MInt p = parent(destination);
892 if(inMovedRange(p)) {
893 parent(destination) += distance;
894 } else {
895 for(MInt j = 0; j < noChildrenPerNode(); j++) {
896 if(child(p, j) == from) {
897 child(p, j) = destination;
898 }
899 }
900 }
901 }
902
903 // Children
904 for(MInt j = 0; j < noChildrenPerNode(); j++) {
905 if(hasChild(destination, j)) {
906 const MInt c = child(destination, j);
907 if(inMovedRange(c)) {
908 child(destination, j) += distance;
909 } else {
910 parent(c) = destination;
911 }
912 }
913 }
914
915 // Neighbors
916 for(MInt j = 0; j < noNeighborsPerNode(); j++) {
917 if(hasNeighbor(destination, j)) {
918 const MInt n = neighbor(destination, j);
919 if(inMovedRange(n)) {
920 neighbor(destination, j) += distance;
921 } else {
922 neighbor(n, oppositeNeighborDir(j)) = destination;
923 }
924 }
925 }
926 }
927}
MFloat distance(const MFloat *a, const MFloat *b)
Definition: maiamath.h:249

◆ neighbor() [1/2]

template<MInt nDim>
MLong & maia::grid::tree::Tree< nDim >::neighbor ( const MInt  id,
const MInt  dir 
)

Definition at line 425 of file cartesiangridtree.h.

425 {
426// Prevent accidental compilation without support for SoA layout
427#ifdef GRIDTREE_SOA_MEMORY_LAYOUT
428#error Missing implementation for structure-of-arrays memory layout.
429#endif
430 ENSURE_VALID_ID_ACCESSOR(id);
431 ENSURE_VALID_NEIGHBOR_DIR_ACCESSOR(dir);
432 return m_neighborIds[id * noNeighborsPerNode() + dir];
433}

◆ neighbor() [2/2]

template<MInt nDim>
MLong maia::grid::tree::Tree< nDim >::neighbor ( const MInt  id,
const MInt  dir 
) const

Definition at line 436 of file cartesiangridtree.h.

436 {
437// Prevent accidental compilation without support for SoA layout
438#ifdef GRIDTREE_SOA_MEMORY_LAYOUT
439#error Missing implementation for structure-of-arrays memory layout.
440#endif
441 ENSURE_VALID_ID_ACCESSOR(id);
442 ENSURE_VALID_NEIGHBOR_DIR_ACCESSOR(dir);
443 return m_neighborIds[id * noNeighborsPerNode() + dir];
444}

◆ noChildren()

template<MInt nDim>
MInt maia::grid::tree::Tree< nDim >::noChildren ( const MInt  id) const

Definition at line 411 of file cartesiangridtree.h.

411 {
412// Prevent accidental compilation without support for SoA layout
413#ifdef GRIDTREE_SOA_MEMORY_LAYOUT
414#error Missing implementation for structure-of-arrays memory layout.
415#endif
416 ENSURE_VALID_ID_ACCESSOR(id);
417 return std::count_if(&m_childIds[id * noChildrenPerNode() + 0],
419 [](const ParallelIo::size_type childId) { return childId > -1; });
420}

◆ noChildrenPerNode()

template<MInt nDim>
static constexpr MInt maia::grid::tree::Tree< nDim >::noChildrenPerNode ( )
inlinestaticconstexpr

Definition at line 264 of file cartesiangridtree.h.

264{ return 4 * nDim - 4; }

◆ nodesBySolver()

template<MInt nDim>
MInt maia::grid::tree::Tree< nDim >::nodesBySolver ( const MInt  solverId,
MInt *const  ids 
) const

Definition at line 727 of file cartesiangridtree.h.

727 {
728 MAIA_CONTAINER_ENSURE(solverId >= 0 && solverId < noSolvers(),
729 "solver id = " + std::to_string(solverId) + " out-of-bounds [0, " + std::to_string(noSolvers())
730 + ")",
731 AT_);
732 MAIA_CONTAINER_ENSURE(ids != nullptr, "Data pointer must not be null", AT_);
733
734 // Loop over all nodes and store ids with solver bit set
735 MInt count = 0;
736 for(MInt id = 0; id < this->size(); id++) {
737 // Skip node if solver bit not set
738 if(!solver(id, solverId)) {
739 continue;
740 }
741
742 // Add id to list and increase count
743 ids[count] = id;
744 count++;
745 }
746
747 return count;
748}
constexpr MInt size() const
Return size (i.e., currently used number of nodes)
Definition: container.h:89
constexpr MInt noSolvers() const
Return currently set number of solvers.

◆ noNeighborsPerNode()

template<MInt nDim>
static constexpr MInt maia::grid::tree::Tree< nDim >::noNeighborsPerNode ( )
inlinestaticconstexpr

Definition at line 266 of file cartesiangridtree.h.

266{ return 2 * nDim; }

◆ noNodesBySolver()

template<MInt nDim>
MInt maia::grid::tree::Tree< nDim >::noNodesBySolver ( const MInt  solverId) const

Definition at line 709 of file cartesiangridtree.h.

709 {
710 MAIA_CONTAINER_ENSURE(solverId >= 0 && solverId < noSolvers(),
711 "solver id = " + std::to_string(solverId) + " out-of-bounds [0, " + std::to_string(noSolvers())
712 + ")",
713 AT_);
714
715 // Count nodes with solver bit set
716 MInt noNodes = 0;
717 for(MInt id = 0; id < this->size(); id++) {
718 noNodes += solver(id, solverId);
719 }
720
721 return noNodes;
722}

◆ noOffsprings() [1/2]

template<MInt nDim>
MInt & maia::grid::tree::Tree< nDim >::noOffsprings ( const MInt  id)

Definition at line 545 of file cartesiangridtree.h.

545 {
546 ENSURE_VALID_ID_ACCESSOR(id);
547 return m_noOffsprings[id];
548}

◆ noOffsprings() [2/2]

template<MInt nDim>
MInt maia::grid::tree::Tree< nDim >::noOffsprings ( const MInt  id) const

Definition at line 551 of file cartesiangridtree.h.

551 {
552 ENSURE_VALID_ID_ACCESSOR(id);
553 return m_noOffsprings[id];
554}

◆ noProperties()

template<MInt nDim>
static constexpr MInt maia::grid::tree::Tree< nDim >::noProperties ( )
inlinestaticconstexpr

Definition at line 272 of file cartesiangridtree.h.

272{ return maia::grid::cell::p(Cell::NumProperties); }

◆ noSolvers()

template<MInt nDim>
constexpr MInt maia::grid::tree::Tree< nDim >::noSolvers ( ) const
inlineconstexpr

Definition at line 279 of file cartesiangridtree.h.

279{ return m_noSolvers; }
MInt m_noSolvers
Number of solvers that are actively using this tree.

◆ oppositeNeighborDir()

template<MInt nDim>
static constexpr MInt maia::grid::tree::Tree< nDim >::oppositeNeighborDir ( const MInt  dir)
inlinestaticconstexpr

Definition at line 269 of file cartesiangridtree.h.

269{ return dir + 1 - 2 * (dir % 2); }

◆ parent() [1/2]

template<MInt nDim>
MLong & maia::grid::tree::Tree< nDim >::parent ( const MInt  id)

Definition at line 337 of file cartesiangridtree.h.

337 {
338 ENSURE_VALID_ID_ACCESSOR(id);
339 return m_parentIds[id];
340}

◆ parent() [2/2]

template<MInt nDim>
MLong maia::grid::tree::Tree< nDim >::parent ( const MInt  id) const

Definition at line 343 of file cartesiangridtree.h.

343 {
344 ENSURE_VALID_ID_ACCESSOR(id);
345 return m_parentIds[id];
346}

◆ properties()

template<MInt nDim>
PropertyBitsetType & maia::grid::tree::Tree< nDim >::properties ( const MInt  id)

Definition at line 691 of file cartesiangridtree.h.

691 {
692 ENSURE_VALID_ID_ACCESSOR(id);
693 return m_properties[id];
694}

◆ propertiesFromBits()

template<MInt nDim>
void maia::grid::tree::Tree< nDim >::propertiesFromBits ( const MInt  id,
const MUlong  bits 
)

Definition at line 679 of file cartesiangridtree.h.

679 {
680 ENSURE_VALID_ID_ACCESSOR(id);
682}
maia::grid::tree::PropertyBitsetType PropertyBitsetType

◆ propertiesToBits()

template<MInt nDim>
MUlong maia::grid::tree::Tree< nDim >::propertiesToBits ( const MInt  id) const

Definition at line 673 of file cartesiangridtree.h.

673 {
674 ENSURE_VALID_ID_ACCESSOR(id);
675 return m_properties[id].to_ulong();
676}

◆ propertiesToString()

template<MInt nDim>
MString maia::grid::tree::Tree< nDim >::propertiesToString ( const MInt  id) const

Definition at line 685 of file cartesiangridtree.h.

685 {
686 ENSURE_VALID_ID_ACCESSOR(id);
687 return m_properties[id].to_string();
688}

◆ rawCopyGeneric()

template<MInt nDim>
template<class Functor , class T >
void maia::grid::tree::Tree< nDim >::rawCopyGeneric ( Functor &&  c,
const T &  source,
const MInt  begin,
const MInt  end,
const MInt  destination 
)
private

Definition at line 800 of file cartesiangridtree.h.

801 {
802// Prevent accidental compilation without support for SoA layout
803#ifdef GRIDTREE_SOA_MEMORY_LAYOUT
804#error Missing implementation for structure-of-arrays memory layout.
805#endif
806 // Parent
807 copyData(source.m_parentIds, m_parentIds, c, begin, end, destination);
808
809 // Children
810 copyData(source.m_childIds, m_childIds, c, begin, end, destination, noChildrenPerNode());
811
812 // Neighbors
813 copyData(source.m_neighborIds, m_neighborIds, c, begin, end, destination, noNeighborsPerNode());
814
815 // Global id
816 copyData(source.m_globalIds, m_globalIds, c, begin, end, destination);
817
818 // Level
819 copyData(source.m_levels, m_levels, c, begin, end, destination);
820
821 // Coordinates
822 copyData(source.m_coordinates, m_coordinates, c, begin, end, destination, nDim);
823
824 // Solver usage
825 copyData(source.m_solver, m_solver, c, begin, end, destination);
826
827 // Leaf cell flags
828 copyData(source.m_isLeafCell, m_isLeafCell, c, begin, end, destination);
829
830 // Weight
831 copyData(source.m_weight, m_weight, c, begin, end, destination);
832
833 // Properties
834 copyData(source.m_properties, m_properties, c, begin, end, destination);
835
836 // No offsprings
837 copyData(source.m_noOffsprings, m_noOffsprings, c, begin, end, destination);
838
839 // Workload
840 copyData(source.m_workload, m_workload, c, begin, end, destination);
841}
void copyData(const Container_ &source, Container_ &target, Functor &&f, const MInt begin, const MInt end, const MInt dest, const MInt solverSize=1)
Copy [begin, end) range with given solver size from source to dest position of target.
Definition: container.h:138

◆ reset()

template<MInt nDim>
void maia::grid::tree::Tree< nDim >::reset
private

Definition at line 319 of file cartesiangridtree.h.

319 {
332}
void resetStorage(const MInt n, Storage< T > &c)
Create new container with given size and replace original one.
Definition: container.h:420

◆ resetIsLeafCell()

template<MInt nDim>
void maia::grid::tree::Tree< nDim >::resetIsLeafCell ( const MInt  id)

Definition at line 640 of file cartesiangridtree.h.

640 {
641 ENSURE_VALID_ID_ACCESSOR(id);
642 m_isLeafCell[id].reset();
643}

◆ resetProperties()

template<MInt nDim>
void maia::grid::tree::Tree< nDim >::resetProperties ( const MInt  id)

Definition at line 667 of file cartesiangridtree.h.

667 {
668 ENSURE_VALID_ID_ACCESSOR(id);
669 m_properties[id].reset();
670}

◆ resetSolver()

template<MInt nDim>
void maia::grid::tree::Tree< nDim >::resetSolver ( const MInt  id)

Definition at line 587 of file cartesiangridtree.h.

587 {
588 ENSURE_VALID_ID_ACCESSOR(id);
589 m_solver[id].reset();
590}

◆ setNoSolvers()

template<MInt nDim>
void maia::grid::tree::Tree< nDim >::setNoSolvers ( const MInt  count)

Definition at line 699 of file cartesiangridtree.h.

699 {
700 MAIA_CONTAINER_ENSURE(count > 0, "Number of solvers must be greater than zero.", AT_);
701 MAIA_CONTAINER_ENSURE(count <= maxNoSolvers(),
702 "Number of solvers out-of-bounds [0, " + std::to_string(maxNoSolvers()) + "].", AT_);
703 m_noSolvers = count;
704}
static constexpr MInt maxNoSolvers()
Return maximum number of supported solvers.

◆ solver() [1/2]

template<MInt nDim>
Tree< nDim >::SolverBitsetType::reference maia::grid::tree::Tree< nDim >::solver ( const MInt  id,
const MInt  solverId 
)

Definition at line 573 of file cartesiangridtree.h.

573 {
574 ENSURE_VALID_ID_ACCESSOR(id);
575 ENSURE_VALID_SOLVER_ID_ACCESSOR(solverId);
576 return m_solver[id][solverId];
577}

◆ solver() [2/2]

template<MInt nDim>
MBool maia::grid::tree::Tree< nDim >::solver ( const MInt  id,
const MInt  solverId 
) const

Definition at line 580 of file cartesiangridtree.h.

580 {
581 ENSURE_VALID_ID_ACCESSOR(id);
582 ENSURE_VALID_SOLVER_ID_ACCESSOR(solverId);
583 return m_solver[id][solverId];
584}

◆ solverBits()

template<MInt nDim>
SolverBitsetType & maia::grid::tree::Tree< nDim >::solverBits ( const MInt  id)

Definition at line 610 of file cartesiangridtree.h.

610 {
611 ENSURE_VALID_ID_ACCESSOR(id);
612 return m_solver[id];
613}

◆ solverFromBits()

template<MInt nDim>
void maia::grid::tree::Tree< nDim >::solverFromBits ( const MInt  id,
const MUlong  bits 
)

Definition at line 599 of file cartesiangridtree.h.

599 {
600 ENSURE_VALID_ID_ACCESSOR(id);
602}

◆ solverToBits()

template<MInt nDim>
MUlong maia::grid::tree::Tree< nDim >::solverToBits ( const MInt  id) const

Definition at line 593 of file cartesiangridtree.h.

593 {
594 ENSURE_VALID_ID_ACCESSOR(id);
595 return m_solver[id].to_ulong();
596}

◆ weight() [1/2]

template<MInt nDim>
MFloat & maia::grid::tree::Tree< nDim >::weight ( const MInt  id)

Definition at line 531 of file cartesiangridtree.h.

531 {
532 ENSURE_VALID_ID_ACCESSOR(id);
533 return m_weight[id];
534}

◆ weight() [2/2]

template<MInt nDim>
MFloat maia::grid::tree::Tree< nDim >::weight ( const MInt  id) const

Definition at line 537 of file cartesiangridtree.h.

537 {
538 ENSURE_VALID_ID_ACCESSOR(id);
539 return m_weight[id];
540}

◆ workload() [1/2]

template<MInt nDim>
MFloat & maia::grid::tree::Tree< nDim >::workload ( const MInt  id)

Definition at line 559 of file cartesiangridtree.h.

559 {
560 ENSURE_VALID_ID_ACCESSOR(id);
561 return m_workload[id];
562}

◆ workload() [2/2]

template<MInt nDim>
MFloat maia::grid::tree::Tree< nDim >::workload ( const MInt  id) const

Definition at line 565 of file cartesiangridtree.h.

565 {
566 ENSURE_VALID_ID_ACCESSOR(id);
567 return m_workload[id];
568}

Friends And Related Function Documentation

◆ maia::container::Container< Tree< nDim >, maia::grid::tree::Invalid >

template<MInt nDim>
friend class maia::container::Container< Tree< nDim >, maia::grid::tree::Invalid >
friend

Definition at line 159 of file cartesiangridtree.h.

Member Data Documentation

◆ m_childIds

template<MInt nDim>
Storage<MLong> maia::grid::tree::Tree< nDim >::m_childIds {}
private

Definition at line 300 of file cartesiangridtree.h.

◆ m_coordinates

template<MInt nDim>
Storage<MFloat> maia::grid::tree::Tree< nDim >::m_coordinates {}
private

Definition at line 304 of file cartesiangridtree.h.

◆ m_globalIds

template<MInt nDim>
Storage<MLong> maia::grid::tree::Tree< nDim >::m_globalIds {}
private

Definition at line 302 of file cartesiangridtree.h.

◆ m_isLeafCell

template<MInt nDim>
Storage<SolverBitsetType> maia::grid::tree::Tree< nDim >::m_isLeafCell {}
private

Definition at line 307 of file cartesiangridtree.h.

◆ m_levels

template<MInt nDim>
Storage<MInt> maia::grid::tree::Tree< nDim >::m_levels {}
private

Definition at line 303 of file cartesiangridtree.h.

◆ m_neighborIds

template<MInt nDim>
Storage<MLong> maia::grid::tree::Tree< nDim >::m_neighborIds {}
private

Definition at line 301 of file cartesiangridtree.h.

◆ m_noOffsprings

template<MInt nDim>
Storage<MInt> maia::grid::tree::Tree< nDim >::m_noOffsprings {}
private

Definition at line 309 of file cartesiangridtree.h.

◆ m_noSolvers

template<MInt nDim>
MInt maia::grid::tree::Tree< nDim >::m_noSolvers = -1
private

Definition at line 313 of file cartesiangridtree.h.

◆ m_parentIds

template<MInt nDim>
Storage<MLong> maia::grid::tree::Tree< nDim >::m_parentIds {}
private

Definition at line 299 of file cartesiangridtree.h.

◆ m_properties

template<MInt nDim>
Storage<PropertyBitsetType> maia::grid::tree::Tree< nDim >::m_properties {}
private

Definition at line 308 of file cartesiangridtree.h.

◆ m_solver

template<MInt nDim>
Storage<SolverBitsetType> maia::grid::tree::Tree< nDim >::m_solver {}
private

Definition at line 306 of file cartesiangridtree.h.

◆ m_weight

template<MInt nDim>
Storage<MFloat> maia::grid::tree::Tree< nDim >::m_weight {}
private

Definition at line 305 of file cartesiangridtree.h.

◆ m_workload

template<MInt nDim>
Storage<MFloat> maia::grid::tree::Tree< nDim >::m_workload {}
private

Definition at line 310 of file cartesiangridtree.h.


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