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

#include <cartesiangridproxy.h>

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

Public Types

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

Public Member Functions

 TreeProxy (const MInt solverId_, Tree &tree_)
 Constructor does nothing but pass arguments to members. More...
 
MInt solver2grid (const MInt id) const
 Convert solver cell id to grid cell id. More...
 
MInt grid2solver (const MInt id) const
 Convert grid cell id to solver cell id (+1 in size is to map "-1" to "-1") More...
 
void setSolver2grid (const MInt solverId, const MInt treeId)
 
void setGrid2solver (const MInt treeId, const MInt solverId)
 
void swapSolverIds (const MInt id0, const MInt id1)
 
void swapGridIds (const MInt id0, const MInt id1)
 
MInt size () const
 Return tree size (= number of cells) More...
 
MInt parent (const MInt id) const
 Accessor for parent node. More...
 
MBool hasParent (const MInt id) const
 Return whether node has parent. More...
 
MInt child (const MInt id, const MInt pos) const
 Accessor for child node. 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...
 
MInt noChildren (const MInt id) const
 Return number of children of given node. More...
 
MBool isLeafCell (const MInt id) const
 Accessor for isLeafCell. More...
 
MInt neighbor (const MInt id, const MInt dir) const
 Accessor for neighbor node. 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...
 
MLong globalId (const MInt id) const
 Accessor for global id. More...
 
MInt localId (const MLong id) const
 Accesor for local id. More...
 
MInt cutOff (const MInt id) const
 Accessor for cutOff dir. More...
 
MInt level (const MInt id) const
 Accessor for level. More...
 
const MFloatcoordinate (const MInt id, const MInt dir) const
 Accessor for coordinates. More...
 
MFloat weight (const MInt id) const
 Accessor for weight (const version). More...
 
MBool hasProperty (const MInt id, const Cell p) const
 Accessor for properties. More...
 

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...
 

Private Member Functions

MInt solverId () const
 Return solver id. More...
 
void update (const Proxy< nDim > &NotUsed(gridProxy_))
 Default implementation does nothing as everything relevant is set by grid proxy class. More...
 
void createGlobalToLocalIdMapping ()
 Create global to local id mapping. More...
 

Private Attributes

Treem_tree
 Reference to actual grid tree. More...
 
const MInt m_solverId = -1
 Solver id. More...
 
std::vector< MIntm_solver2grid
 
std::vector< MIntm_grid2solver
 
std::vector< MLongm_globalIds
 
std::map< MLong, MIntm_globalToLocalId {}
 
std::vector< MIntm_isCutOffCell
 

Friends

template<MInt nDim_>
class maia::grid::Proxy
 

Detailed Description

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

Class that acts like the original grid tree but only for a single solver

Author
Michael Schlottke-Lakemper (mic) mic@a.nosp@m.ia.r.nosp@m.wth-a.nosp@m.ache.nosp@m.n.de
Date
2018-03-16

Definition at line 396 of file cartesiangridproxy.h.

Member Typedef Documentation

◆ Cell

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

Definition at line 406 of file cartesiangridproxy.h.

◆ Tree

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

Definition at line 405 of file cartesiangridproxy.h.

Constructor & Destructor Documentation

◆ TreeProxy()

template<MInt nDim>
maia::grid::tree::TreeProxy< nDim >::TreeProxy ( const MInt  solverId_,
Tree tree_ 
)
inline

Definition at line 409 of file cartesiangridproxy.h.

409 : m_tree(tree_), m_solverId(solverId_) {
410 m_solver2grid.reserve(m_tree.capacity());
411 m_grid2solver.reserve(m_tree.capacity());
412 m_globalIds.reserve(m_tree.capacity());
413 m_isCutOffCell.reserve(m_tree.capacity());
414 }
std::vector< MInt > m_solver2grid
std::vector< MInt > m_isCutOffCell
Tree & m_tree
Reference to actual grid tree.
const MInt m_solverId
Solver id.
std::vector< MInt > m_grid2solver
std::vector< MLong > m_globalIds

Member Function Documentation

◆ child()

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

Definition at line 555 of file cartesiangridproxy.h.

555 {
556 return grid2solver(m_tree.child(solver2grid(id), pos));
557}
MLong & child(const MInt id, const MInt pos)
Accessor for child node.
MInt solver2grid(const MInt id) const
Convert solver cell id to grid cell id.
MInt grid2solver(const MInt id) const
Convert grid cell id to solver cell id (+1 in size is to map "-1" to "-1")

◆ coordinate()

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

Definition at line 631 of file cartesiangridproxy.h.

631 {
632 return m_tree.coordinate(solver2grid(id), dir);
633}
MFloat & coordinate(const MInt id, const MInt dim)
Accessor for coordinates.

◆ createGlobalToLocalIdMapping()

template<MInt nDim>
void maia::grid::tree::TreeProxy< nDim >::createGlobalToLocalIdMapping
private

Create the mapping from global to local cell ids.

Definition at line 687 of file cartesiangridproxy.h.

687 {
688 TRACE();
689
690 std::map<MLong, MInt>().swap(m_globalToLocalId);
691 std::set<MInt> periodicCells;
692 for(MInt cellId = 0; cellId < size(); cellId++) {
693 if(hasProperty(cellId, Cell::IsPeriodic)) {
694 periodicCells.insert(cellId);
695 continue;
696 }
697 ASSERT(m_globalToLocalId.count(globalId(cellId)) == 0, "Global id already in map");
699 }
700
701 for(auto it = periodicCells.begin(); it != periodicCells.end(); it++) {
702 if(m_globalToLocalId.count(globalId(*it)) == 0) {
703 m_globalToLocalId[globalId(*it)] = *it;
704 }
705 }
706}
MLong globalId(const MInt id) const
Accessor for global id.
MInt size() const
Return tree size (= number of cells)
MBool hasProperty(const MInt id, const Cell p) const
Accessor for properties.
std::map< MLong, MInt > m_globalToLocalId
int32_t MInt
Definition: maiatypes.h:62
void const MInt cellId
Definition: collector.h:239

◆ cutOff()

template<MInt nDim>
MInt maia::grid::tree::TreeProxy< nDim >::cutOff ( const MInt  id) const

Definition at line 618 of file cartesiangridproxy.h.

618 {
619 return m_isCutOffCell[id];
620}
MInt id
Definition: maiatypes.h:71

◆ globalId()

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

Definition at line 612 of file cartesiangridproxy.h.

612 {
613 return m_globalIds[id];
614}

◆ grid2solver()

template<MInt nDim>
MInt maia::grid::tree::TreeProxy< nDim >::grid2solver ( const MInt  id) const
inline

Definition at line 425 of file cartesiangridproxy.h.

425 {
426 // TODO labels:GRID c++14
427 //#ifndef NDEBUG
428 // ASSERT(id+1 >= 0 && id+1 < m_grid2solver.size(), "id in grid2solver is out of bounds");
429 //#endif
430 return m_grid2solver[id + 1];
431 }

◆ hasAnyNeighbor()

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

Definition at line 605 of file cartesiangridproxy.h.

605 {
606 return hasNeighbor(id, dir) || (hasParent(id) && hasNeighbor(parent(id), dir));
607}
MBool hasParent(const MInt id) const
Return whether node has parent.
MBool hasNeighbor(const MInt id, const MInt dir) const
Return whether node has same-level neighbor in given direction.
MInt parent(const MInt id) const
Accessor for parent node.

◆ hasChild()

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

Definition at line 562 of file cartesiangridproxy.h.

562 {
563 return child(id, pos) > -1;
564}
MInt child(const MInt id, const MInt pos) const
Accessor for child node.

◆ hasChildren()

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

Definition at line 569 of file cartesiangridproxy.h.

569 {
570 return noChildren(id) > 0;
571}
MInt noChildren(const MInt id) const
Return number of children of given node.

◆ hasNeighbor()

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

Definition at line 600 of file cartesiangridproxy.h.

600 {
601 return neighbor(id, dir) > -1;
602}
MInt neighbor(const MInt id, const MInt dir) const
Accessor for neighbor node.

◆ hasParent()

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

Definition at line 548 of file cartesiangridproxy.h.

548 {
549 return parent(id) > -1;
550}

◆ hasProperty()

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

Definition at line 669 of file cartesiangridproxy.h.

669 {
670 ASSERT(p != Cell::IsWindow, "Query for IsWindow won't give solver-specific information!");
671 return m_tree.hasProperty(solver2grid(id), p);
672}
PropertyBitsetType::reference hasProperty(const MInt id, const Cell p)
Accessor for properties.

◆ isLeafCell()

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

Definition at line 586 of file cartesiangridproxy.h.

586 {
587 return m_tree.isLeafCell(solver2grid(id), solverId());
588}
MBool isLeafCell(const MInt id) const
Accessor for isLeafCell usage (const version).
MInt solverId() const
Return solver id.

◆ level()

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

Definition at line 624 of file cartesiangridproxy.h.

624 {
625 return m_tree.level(solver2grid(id));
626}
MInt & level(const MInt id)
Accessor for level.

◆ localId()

template<MInt nDim>
MInt maia::grid::tree::TreeProxy< nDim >::localId ( const MLong  id) const

Definition at line 710 of file cartesiangridproxy.h.

710 {
711 TRACE();
712
713 if(m_globalToLocalId.count(id) > 0) {
714 return m_globalToLocalId.at(id);
715 } else {
716 return -1;
717 }
718}

◆ neighbor()

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

Definition at line 593 of file cartesiangridproxy.h.

593 {
594 return grid2solver(m_tree.neighbor(solver2grid(id), dir));
595}
MLong & neighbor(const MInt id, const MInt dir)
Accessor for neighbor node.

◆ noChildren()

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

Definition at line 576 of file cartesiangridproxy.h.

576 {
577 MInt count = 0;
578 for(MInt pos = 0; pos < noChildrenPerNode(); pos++) {
579 count += hasChild(id, pos);
580 }
581 return count;
582}
MBool hasChild(const MInt id, const MInt pos) const
Return whether node has child at given position.
static constexpr MInt noChildrenPerNode()
Return maximum number of children per node.

◆ noChildrenPerNode()

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

Definition at line 503 of file cartesiangridproxy.h.

503{ return 4 * nDim - 4; }

◆ noNeighborsPerNode()

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

Definition at line 505 of file cartesiangridproxy.h.

505{ return 2 * nDim; }

◆ noProperties()

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

Definition at line 511 of file cartesiangridproxy.h.

511{ return maia::grid::cell::p(Cell::NumProperties); }
constexpr std::underlying_type< GridCell >::type p(const GridCell property)
Converts property name to underlying integer value.

◆ oppositeNeighborDir()

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

Definition at line 508 of file cartesiangridproxy.h.

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

◆ parent()

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

Definition at line 541 of file cartesiangridproxy.h.

541 {
543}
MLong & parent(const MInt id)
Accessor for parent node.

◆ setGrid2solver()

template<MInt nDim>
void maia::grid::tree::TreeProxy< nDim >::setGrid2solver ( const MInt  treeId,
const MInt  solverId 
)
inline

Definition at line 438 of file cartesiangridproxy.h.

438 {
439 ASSERT((treeId + 1) > -1 && (treeId + 1) < (signed)m_grid2solver.size(),
440 "id size: " << treeId + 1 << " " << m_grid2solver.size());
441 m_grid2solver[treeId + 1] = solverId;
442 }

◆ setSolver2grid()

template<MInt nDim>
void maia::grid::tree::TreeProxy< nDim >::setSolver2grid ( const MInt  solverId,
const MInt  treeId 
)
inline

Definition at line 433 of file cartesiangridproxy.h.

433 {
434 ASSERT(solverId > -1 && solverId < (signed)m_solver2grid.size(),
435 "id, size: " << solverId << " " << m_solver2grid.size());
436 m_solver2grid[solverId] = treeId;
437 }

◆ size()

template<MInt nDim>
MInt maia::grid::tree::TreeProxy< nDim >::size ( ) const
inline

Definition at line 466 of file cartesiangridproxy.h.

466{ return m_solver2grid.size(); }

◆ solver2grid()

template<MInt nDim>
MInt maia::grid::tree::TreeProxy< nDim >::solver2grid ( const MInt  id) const
inline

Definition at line 417 of file cartesiangridproxy.h.

417 {
418 // TODO labels:GRID c++14
419 //#ifndef NDEBUG
420 // ASSERT(id >= 0 && id < m_solver2grid.size(), "id in solver2grid is out of bounds");
421 //#endif
422 return m_solver2grid[id];
423 }

◆ solverId()

template<MInt nDim>
MInt maia::grid::tree::TreeProxy< nDim >::solverId ( ) const
inlineprivate

Definition at line 515 of file cartesiangridproxy.h.

515{ return m_solverId; }

◆ swapGridIds()

template<MInt nDim>
void maia::grid::tree::TreeProxy< nDim >::swapGridIds ( const MInt  id0,
const MInt  id1 
)
inline

Definition at line 454 of file cartesiangridproxy.h.

454 {
455 ASSERT(id0 > -1 && id1 > -1 && id0 < m_tree.size() && id1 < m_tree.size()
456 && (id0 + 1) < (signed)m_grid2solver.size() && (id1 + 1) < (signed)m_grid2solver.size(),
457 "");
458 const MInt b0 = m_grid2solver[id0 + 1];
459 const MInt b1 = m_grid2solver[id1 + 1];
460 if(b0 > -1) m_solver2grid[b0] = id1;
461 if(b1 > -1) m_solver2grid[b1] = id0;
462 std::swap(m_grid2solver[id0 + 1], m_grid2solver[id1 + 1]);
463 }
constexpr MInt size() const
Return size (i.e., currently used number of nodes)
Definition: container.h:89

◆ swapSolverIds()

template<MInt nDim>
void maia::grid::tree::TreeProxy< nDim >::swapSolverIds ( const MInt  id0,
const MInt  id1 
)
inline

Definition at line 444 of file cartesiangridproxy.h.

444 {
445 ASSERT(id0 > -1 && id1 > -1 && id0 < size() && id1 < size(),
446 "id0, id1, size: " << id0 << " , " << id1 << " , " << size());
447 const MInt g0 = m_solver2grid[id0];
448 const MInt g1 = m_solver2grid[id1];
449 if(g0 > -1) m_grid2solver[g0 + 1] = id1;
450 if(g1 > -1) m_grid2solver[g1 + 1] = id0;
451 std::swap(m_solver2grid[id0], m_solver2grid[id1]);
452 }

◆ update()

template<MInt nDim>
void maia::grid::tree::TreeProxy< nDim >::update ( const Proxy< nDim > &  NotUsedgridProxy_)
inlineprivate

Definition at line 518 of file cartesiangridproxy.h.

518{}

◆ weight()

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

Definition at line 642 of file cartesiangridproxy.h.

642 {
643 return m_tree.weight(solver2grid(id));
644}
MFloat & weight(const MInt id)
Accessor for weight.

Friends And Related Function Documentation

◆ maia::grid::Proxy

template<MInt nDim>
template<MInt nDim_>
friend class maia::grid::Proxy
friend

Definition at line 401 of file cartesiangridproxy.h.

Member Data Documentation

◆ m_globalIds

template<MInt nDim>
std::vector<MLong> maia::grid::tree::TreeProxy< nDim >::m_globalIds
private

Definition at line 533 of file cartesiangridproxy.h.

◆ m_globalToLocalId

template<MInt nDim>
std::map<MLong, MInt> maia::grid::tree::TreeProxy< nDim >::m_globalToLocalId {}
private

Definition at line 534 of file cartesiangridproxy.h.

◆ m_grid2solver

template<MInt nDim>
std::vector<MInt> maia::grid::tree::TreeProxy< nDim >::m_grid2solver
private

Definition at line 532 of file cartesiangridproxy.h.

◆ m_isCutOffCell

template<MInt nDim>
std::vector<MInt> maia::grid::tree::TreeProxy< nDim >::m_isCutOffCell
private

Definition at line 535 of file cartesiangridproxy.h.

◆ m_solver2grid

template<MInt nDim>
std::vector<MInt> maia::grid::tree::TreeProxy< nDim >::m_solver2grid
private

Definition at line 531 of file cartesiangridproxy.h.

◆ m_solverId

template<MInt nDim>
const MInt maia::grid::tree::TreeProxy< nDim >::m_solverId = -1
private

Definition at line 528 of file cartesiangridproxy.h.

◆ m_tree

template<MInt nDim>
Tree& maia::grid::tree::TreeProxy< nDim >::m_tree
private

Definition at line 525 of file cartesiangridproxy.h.


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