104 if(gridCellId < 0)
return gridCellId;
111 if(gridCellId < 0)
return gridCellId;
277 const MInt level = refLevel > -1 ? refLevel :
minLevel();
311 template <
typename U>
400 template <MInt nDim_>
439 ASSERT((treeId + 1) > -1 && (treeId + 1) < (
signed)
m_grid2solver.size(),
445 ASSERT(id0 > -1 && id1 > -1 && id0 <
size() && id1 <
size(),
446 "id0, id1, size: " << id0 <<
" , " << id1 <<
" , " <<
size());
542 return grid2solver(m_tree.parent(solver2grid(
id)));
549 return parent(
id) > -1;
556 return grid2solver(m_tree.child(solver2grid(
id), pos));
563 return child(
id, pos) > -1;
570 return noChildren(
id) > 0;
578 for(
MInt pos = 0; pos < noChildrenPerNode(); pos++) {
579 count += hasChild(
id, pos);
587 return m_tree.isLeafCell(solver2grid(
id), solverId());
594 return grid2solver(m_tree.neighbor(solver2grid(
id), dir));
601 return neighbor(
id, dir) > -1;
606 return hasNeighbor(
id, dir) || (hasParent(
id) && hasNeighbor(parent(
id), dir));
613 return m_globalIds[
id];
619 return m_isCutOffCell[
id];
625 return m_tree.level(solver2grid(
id));
632 return m_tree.coordinate(solver2grid(
id), dir);
643 return m_tree.weight(solver2grid(
id));
670 ASSERT(p != Cell::IsWindow,
"Query for IsWindow won't give solver-specific information!");
671 return m_tree.hasProperty(solver2grid(
id), p);
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);
697 ASSERT(m_globalToLocalId.count(globalId(cellId)) == 0,
"Global id already in map");
698 m_globalToLocalId[globalId(cellId)] = cellId;
701 for(
auto it = periodicCells.begin(); it != periodicCells.end(); it++) {
702 if(m_globalToLocalId.count(globalId(*it)) == 0) {
703 m_globalToLocalId[globalId(*it)] = *it;
713 if(m_globalToLocalId.count(
id) > 0) {
714 return m_globalToLocalId.at(
id);
GridCell
Grid cell Property Labels.
MFloat gridCellVolume(const MInt level) const
MFloat cellVolumeAtLevel(const MInt level) const
MInt maxUniformRefinementLevel() const
Return maximum homogeneously-refined level.
void rotateCartesianCoordinates(MFloat *, MFloat)
Rotate caresian coordinates by angle. Azimuthal periodic center is used.
MInt periodicCartesianDir(const MInt dir) const
MString gridInputFileName() const
Return grid file name.
maia::grid::cell::BitsetType::reference a_hasProperty(const MInt cellId, const Cell p)
Returns property p of the cell cellId.
MLong generateHilbertIndex(const MInt cellId, const MInt targetMinLevel)
void centerOfGravity(MFloat *const center) const
MInt noMinCells() const
Return the number of Cells on the minLevel.
MLong noCellsGlobal() const
Return the Global-noCells.
MInt noHaloLayers() const
Return noHalo-a_noHaloLayers.
MBool hasCutOff() const
Returns weather the grid has a cutOff.
MLong localPartitionCellOffsets(const MInt index) const
MInt m_newMinLevel
The new min Level which has been increased at the restart!
MLong bitOffset() const
Return the 32-BitOffset.
MFloat halfCellLength(const MInt cellId) const
Returns the half cell length of cell cellId.
MFloat cellLengthAtCell(const MInt cellId) const
Returns the cell length of cell cellId.
MBool wasBalanced() const
MFloat lengthLevel0() const
Return the length of the level 0 cell.
Tree & treeb()
Full access to tree (for now)
azimuthalBbox m_azimuthalBbox
MFloat periodicCartesianLength(const MInt dir) const
MInt findContainingLeafCell(const MFloat *coord, std::function< MFloat *(MInt, MFloat *const)> correctCellCoord=nullptr, const MInt solverId=-1)
Return the cell Id of the leaf cell containing the coords.
std::array< MInt, 2 > m_azimuthalPeriodicDir
MFloat cellLengthAtLevel(const MInt level) const
Returns cell length at cell level level.
constexpr MBool allowInterfaceRefinement() const
MFloat reductionFactor() const
Return the reductionFactor.
This class is a ScratchSpace.
constexpr MInt size() const
Return size (i.e., currently used number of nodes)
const MInt & leafHaloCell(const MInt domainId, const MInt id) const
void getLocalSameLevelCellIds(std::vector< MInt > &levelCellId, const MInt level)
find all cells on the same level used by the smoothFilter!
MInt domainContainingCell(MInt globalId) const
domain id containing a given global cell id
MBool allowInterfaceRefinement() const
const std::vector< std::vector< MInt > > & windowCells() const
std::vector< MInt > m_leafSendNeighborDomains
MInt leafRecvNeighborDomain(const MInt id) const
void setGrid2solver(const MInt treeId, const MInt solverId)
void swapGridIds(const MInt id0, const MInt id1)
MInt determineAzimuthalBoundarySide(const MFloat *coords)
MLong generateHilbertIndex(const MInt cellId, const MInt refLevel=-1)
MFloat cellVolumeAtLevel(const MInt level) const
MInt noAzimuthalUnmappedHaloCells() const
void checkWindowHaloConsistency() const
std::vector< MInt > m_azimuthalNeighborDomainIndex
const std::vector< std::vector< MInt > > & leafWindowCells() const
MInt noAzimuthalWindowCells(const MInt azimuthalDomainId) const
MFloat cellLengthAtCell(const MInt cellId) const
std::map< MInt, MInt > m_global2solver
static constexpr const MInt m_noDirs
MInt findContainingLeafCell(const MFloat *coord)
std::vector< MInt > m_azimuthalNeighborDomains
MBool isPeriodic(const MInt cellId) const
MInt solverId() const
Return solver id.
void correctAzimuthalHaloCells()
MInt maxUniformRefinementLevel() const
MBool hasInactiveRanks() const
Return whether this solver is inactive on one of the global domains.
void updatePartitionCellOffsets()
updates solver-grid partition cell offsets and globalIds!
const MInt & azimuthalUnmappedHaloCell(const MInt id) const
void setupWindowHaloConnectivityOnLeafLvl(std::map< MInt, MInt > &)
void setSolver2grid(const MInt solverId, const MInt treeId)
MInt noLeafHaloCells(const MInt domainId) const
MFloat lengthLevel0() const
std::vector< std::vector< MInt > > m_windowCells
void findEqualLevelNeighborsParDiagonal(MBool idsAreGlobal=true)
std::vector< MInt > m_azimuthalUnmappedHaloDomains
const MInt & azimuthalUnmappedHaloDomain(const MInt id) const
MLong m_localPartitionCellOffsets[3]
MInt getNghbrCells(MInt cellId, MInt level, MInt *nghbrs, MInt dir0, MInt dir1=-1, MInt dir2=-1)
void descendStoreGlobalId(MInt cellId, MInt &localCnt)
MInt noAzimuthalHaloCells(const MInt azimuthalDomainId) const
MInt globalToLocalId(const MLong globalId) const
const std::vector< MInt > & neighborDomains() const
MInt noLeafSendNeighborDomains() const
std::vector< std::vector< MInt > > m_haloCells
MFloat halfCellLength(const MInt cellId) const
void checkNeighborConsistency() const
MInt noWindowCells(const MInt domainId) const
MLong localPartitionCellOffsetsRestart(const MInt index) const
MInt azimuthalDomainIndex(const MInt id)
MInt minCell(const MInt id) const
void exchangeHaloCellsForVisualizationDG(MFloat *data, const MInt *const polyDegs, const MInt *const dataOffsets)
Exchange DG halo/window cell data for visualization with ParaView.
MInt centerOfGravity(MInt dir) const
void exchangeHaloCellsForVisualizationSBP(MFloat *data, const MInt *const noNodes1D, const MInt *const dataOffsets)
Exchange DG-SBP halo/window cell data for visualization with ParaView.
MInt getAdjacentGridCells(MInt cellId, MInt noLayers, MIntScratchSpace &adjacentCells, MInt level, MInt diagonalNeighbors=0)
Retrieves all direct and diagonal neighboring cells of the given cell on the child level if available...
std::vector< MInt > m_neighborDomainIndex
MInt neighborDomain(const MInt id) const
std::vector< MInt > m_isOutsideWindow
const MLong & domainOffset(const MInt id) const
MInt maxRefinementLevel() const
MString gridInputFileName() const
MInt leafSendNeighborDomain(const MInt id) const
Grid & m_grid
Reference to actual grid.
MInt & neighborList(const MInt cellId, const MInt dir)
MFloat cellLengthAtLevel(const MInt level) const
constexpr MInt noHaloLayers() const
constexpr MBool hasCutOff() const
const MInt & leafWindowCell(const MInt domainId, const MInt id) const
void resizeGridMap(const MInt solverSize)
void findCartesianNghbIds()
MInt noLocalPartitionCells()
std::vector< MInt > m_isOutsideHalo
MInt noHaloCells(const MInt domainId) const
void rotateCartesianCoordinates(MFloat *coords, MFloat angle)
MInt noAzimuthalNeighborDomains() const
void exchangeHaloCellsForVisualization(U *data)
Exchange Halo/Window data in a general way for ParaView or other external visuliazation software.
MInt neighborList(const MInt cellId, const MInt dir) const
void setSolverFlagsForAddedSolver()
Set solver flags for newly added solver.
MInt m_maxRefinementLevel
std::vector< MInt > m_neighborDomains
MBool azimuthalPeriodicity() const
MInt periodicCartesianDir(const MInt dir) const
MLong noCellsGlobal() const
const MInt & windowCell(const MInt domainId, const MInt id) const
MInt findNeighborDomainId(const MLong globalId)
Find neighbor domain id corresponding to given solver-specific globalId.
MBool checkOutsideGeometry(MInt gridId)
MInt a_neighborList(const MInt cellId, const MInt dir) const
void smoothFilter(const MInt level, MFloat **value)
smooth the grid-based values over neighboring leaf cell asure conservation of the total value
MLong * m_partitionCellGlobalId
std::vector< std::vector< MInt > > m_leafWindowCells
std::vector< MInt > m_leafRecvNeighborDomains
static constexpr MInt m_maxNoChilds
TreeProxy m_tree
Tree proxy object.
MInt a_storeNghbrIds(const MInt id) const
std::vector< std::vector< MInt > > m_azimuthalWindowCells
MInt localPartitionCellLocalIds(const MInt id) const
void checkWindowHaloConsistencyAzimuthal() const
MInt a_identNghbrIds(const MInt id) const
MFloat gridCellVolume(const MInt level) const
std::vector< std::vector< MInt > > m_leafHaloCells
MInt findContainingLeafCell(const MFloat *coord, const MInt startId, const MBool allowNonLeafHalo=false)
void findNeighborHood(const MInt, const MInt, std::vector< MInt > &)
Obtain list of neighbors for the given extend, using m_storeNghbrIds and m_identNghbrIds.
std::vector< MInt > m_azimuthalUnmappedHaloCells
MBool isActive() const
Return whether the solver is active on the current domain.
MLong localPartitionCellGlobalIdsRestart(const MInt id) const
const MInt & azimuthalWindowCell(const MInt azimuthalDomainId, const MInt id) const
MLong localPartitionCellGlobalIds(const MInt id) const
const MInt & azimuthalHaloCell(const MInt azimuthalDomainId, const MInt id) const
std::vector< std::vector< MInt > > m_azimuthalHaloCells
Geom * m_geometry
Reference to solver geometry.
MInt noLeafWindowCells(const MInt domainId) const
MBool solverFlag(const MInt gridId, const MInt solverId) const
void checkOffsetConsistency() const
MInt azimuthalDir(MInt dir)
MFloat reductionFactor() const
void getAllLeafChilds(const MInt, std::vector< MInt > &)
gathers all leaf child cells for a given parentId
MInt noInternalCells() const
void checkNeighborConsistencyAzimuthal() const
std::vector< MLong > m_domainOffsets
const TreeProxy & tree() const
void updateLeafCellExchange()
MInt leafSendSize() const
MBool isPeriodic(const MInt cellId)
MInt noNeighborDomains() const
void findDirectNghbrs(const MInt, std::vector< MInt > &)
Obtain list of direct neighbors of given cell. Requires m_identNghbrIds, as such findCartesianNghbIds...
const std::vector< MInt > & azimuthalNeighborDomains() const
const std::vector< std::vector< MInt > > & leafHaloCells() const
const std::vector< std::vector< MInt > > & azimuthalWindowCells() const
const std::vector< std::vector< MInt > > & haloCells() const
const MInt & haloCell(const MInt domainId, const MInt id) const
const std::vector< std::vector< MInt > > & azimuthalHaloCells() const
const MInt m_solverId
Solver id.
void swapSolverIds(const MInt id0, const MInt id1)
MInt noLeafRecvNeighborDomains() const
MFloat periodicCartesianLength(const MInt dir) const
void updateParallelizationInfo()
MLong localPartitionCellOffsets(const MInt index) const
MInt azimuthalNeighborDomain(const MInt azimuthalId) const
MBool wasBalanced() const
MInt domainIndex(const MInt id)
Class that represents grid tree and contains all relevant per-node data.
SolverBitsetType::reference solver(const MInt id, const MInt solverId)
Accessor for solver usage.
PropertyBitsetType::reference hasProperty(const MInt id, const Cell p)
Accessor for properties.
MInt noChildren(const MInt id) const
Return number of children of given node.
MBool hasParent(const MInt id) const
Return whether node has parent.
MInt neighbor(const MInt id, const MInt dir) const
Accessor for neighbor node.
TreeProxy(const MInt solverId_, Tree &tree_)
Constructor does nothing but pass arguments to members.
MBool hasAnyNeighbor(const MInt id, const MInt dir) const
Return whether node or its parent has neighbor in given direction.
MInt solver2grid(const MInt id) const
Convert solver cell id to grid cell id.
MLong globalId(const MInt id) const
Accessor for global id.
MBool isLeafCell(const MInt id) const
Accessor for isLeafCell.
std::vector< MInt > m_solver2grid
std::vector< MInt > m_isCutOffCell
const MFloat & coordinate(const MInt id, const MInt dir) const
Accessor for coordinates.
MBool hasNeighbor(const MInt id, const MInt dir) const
Return whether node has same-level neighbor in given direction.
MBool hasChildren(const MInt id) const
Return whether node has any children.
Tree & m_tree
Reference to actual grid tree.
void createGlobalToLocalIdMapping()
Create global to local id mapping.
void swapGridIds(const MInt id0, const MInt id1)
MInt size() const
Return tree size (= number of cells)
MInt parent(const MInt id) const
Accessor for parent node.
const MInt m_solverId
Solver id.
MBool hasChild(const MInt id, const MInt pos) const
Return whether node has child at given position.
void setGrid2solver(const MInt treeId, const MInt solverId)
MInt cutOff(const MInt id) const
Accessor for cutOff dir.
void setSolver2grid(const MInt solverId, const MInt treeId)
std::vector< MInt > m_grid2solver
MInt localId(const MLong id) const
Accesor for local id.
MBool hasProperty(const MInt id, const Cell p) const
Accessor for properties.
MFloat weight(const MInt id) const
Accessor for weight (const version).
MInt level(const MInt id) const
Accessor for level.
void update(const Proxy< nDim > &NotUsed(gridProxy_))
Default implementation does nothing as everything relevant is set by grid proxy class.
MInt solverId() const
Return solver id.
static constexpr MInt noNeighborsPerNode()
Return maximum number of same-level neighbors per node.
MInt child(const MInt id, const MInt pos) const
Accessor for child node.
std::map< MLong, MInt > m_globalToLocalId
static constexpr MInt oppositeNeighborDir(const MInt dir)
Return opposite direction for given neighbor direction.
static constexpr MInt noChildrenPerNode()
Return maximum number of children per node.
void swapSolverIds(const MInt id0, const MInt id1)
static constexpr MInt noProperties()
Return number of properties defined for each node.
std::vector< MLong > m_globalIds
MInt grid2solver(const MInt id) const
Convert grid cell id to solver cell id (+1 in size is to map "-1" to "-1")
constexpr MLong IPOW2(MInt x)
std::basic_string< char > MString
constexpr std::underlying_type< GridCell >::type p(const GridCell property)
Converts property name to underlying integer value.
GridCell Cell
Underlying enum type for property access.
void exchangeData(const MInt noNghbrDomains, const MInt *const nghbrDomains, const MInt *const noHaloCells, const MInt **const, const MInt *const noWindowCells, const MInt **const windowCells, const MPI_Comm comm, const U *const data, U *const haloBuffer, const MInt noDat=1)
Generic exchange of data.
Namespace for auxiliary functions/classes.