24 class TraversalObserver;
25 struct GridTraversalEvent;
219 bool splittingIsConsideredLocal,
220 bool joiningIsConsideredLocal
276 int axis = Dimensions-1
289 bool splittingIsConsideredLocal,
290 bool joiningIsConsideredLocal
952 bool traversalInverted
1020 const std::bitset<Dimensions>&
periodicBC = 0
std::bitset< Dimensions > periodicBC
Translate grid traversal automaton's transitions into user events.
static bool restrictToCoarseGrid(const tarch::la::Vector< Dimensions, int > &coarseVertexPosition, const tarch::la::Vector< Dimensions, int > &fineVertexPosition)
Determines whether to restrict a vertex to the coarser level or not.
void split(int treeId, const SplitInstruction &instruction)
Add a split instruction.
static tarch::logging::Log _log
void mergeGridVertexAdjacencyListsAtHorizontalDomainBoundary(GridVertex &vertex, const GridVertex &inVertex, int neighbour)
void storeVertices(const AutomatonState &fineGridState, GridVertex coarseGridVertices[TwoPowerD], GridVertex fineGridVertices[TwoPowerD], const tarch::la::Vector< Dimensions, int > &cellPositionWithin3x3Patch, TraversalObserver &observer)
void removeDuplicateEntriesFromAdjancyListInEvent(GridTraversalEvent &event) const
Some of the entries in the event are modelled as array (for example the set of neighbours of a vertex...
GridStatistics getGridStatistics() const
void sendUserData(const AutomatonState &state, TraversalObserver &observer, const GridTraversalEvent &enterCellTraversalEvent, GridVertex fineGridVertices[TwoPowerD])
Send user data.
bool isInvolvedInJoinOrFork() const
void updateVertexAfterLoad(GridVertex &vertex, GridVertex fineGridVertices[TwoPowerD], const tarch::la::Vector< Dimensions, int > &fineVertexPositionWithinPatch, TraversalObserver &observer)
This operation has multiple purposes.
static constexpr int NoJoin
std::set< int > _hasSplit
I need this post-mortem list to identify which tree structures have to be copied/replicated where.
static GridVertexStackMap _vertexStack
peano4::maps::HierarchicalStackMap< peano4::stacks::GridVertexStack > GridVertexStackMap
static void refineState(const AutomatonState &coarseGrid, AutomatonState fineGrid[ThreePowerD], tarch::la::Vector< Dimensions, int > fineGridPosition=tarch::la::Vector< Dimensions, int >(0), int axis=Dimensions-1)
Takes a state (describing a node in the tree) and returns the states on the next finer level along t...
void markVerticesAroundForkedCell(GridVertex coarseGridVertices[TwoPowerD], GridVertex fineGridVertices[TwoPowerD]) const
setIsAntecessorOfRefinedVertexInCurrentTreeSweep()
std::set< int > _joining
If master: Set of workers that should join.
bool areAllVerticesRefined(GridVertex vertices[TwoPowerD]) const
void loadVertices(const AutomatonState &fineGridState, GridVertex coarseGridVertices[TwoPowerD], GridVertex fineGridVertices[TwoPowerD], const tarch::la::Vector< Dimensions, int > &cellPositionWithin3x3Patch, TraversalObserver &observer)
Load the vertices of one cell.
bool mayJoinWithMaster() const
Only ranks that have no kids are allowed to join.
std::string toString() const
void joinWithWorker(int id)
GridStatistics _statistics
static constexpr int RankOfPeriodicBoundaryCondition
Periodic boundary conditions are technically realised as domain decomposition, i.e.
static void incrementNumberOfAdjacentRefinedLocalCells(GridVertex vertices[TwoPowerD])
Every local refined cell should call this routine.
std::set< int > _childrenIds
void receiveAndMergeUserData(const AutomatonState &state, TraversalObserver &observer, const GridTraversalEvent &enterCellTraversalEvent, GridVertex fineGridVertices[TwoPowerD])
int getSplittingTree() const
bool areAllVerticesUnrefined(GridVertex vertices[TwoPowerD]) const
bool isFaceAlongPeriodicBoundaryCondition(GridVertex vertex[TwoPowerD], int faceNumber, bool calledByReceivingProcess) const
void descend(const AutomatonState &state, GridVertex vertices[TwoPowerD], TraversalObserver &observer)
bool isSpacetreeNodeLocal(GridVertex vertices[TwoPowerD], bool splittingIsConsideredLocal, bool joiningIsConsideredLocal) const
Wrapper around GridTraversalEventGenerator::isSpacetreeNodeLocal()
const std::bitset< Dimensions > _periodicBC
Indicate per axis whether we have periodic boundary conditions.
Spacetree(int newId, int masterId, const tarch::la::Vector< Dimensions, double > &offset, const tarch::la::Vector< Dimensions, double > &width, bool traversalInverted)
Only used by SpacetreeSet to create children of the original tree.
static tarch::la::Vector< Dimensions, int > convertToIntegerVector(const std::bitset< Dimensions > &in)
Little helper.
std::set< int > getNeighbourTrees(const GridVertex &vertex, bool calledByReceivingProcess) const
Get the ids of the surrounding cells of a vertex.
void splitOrJoinCellBottomUp(GridVertex vertex[TwoPowerD], GridVertex fineGridVertices[TwoPowerD])
Realise the splits and joins.
SpacetreeState _spacetreeState
void joinWithMaster()
Join with master.
static constexpr int NumberOfStationarySweepsToWaitAtLeastTillJoin
void sendGridVertex(const GridVertex &vertex)
This one is to be invoked if and only if a vertex goes to the in/out stacks.
AutomatonState _root
The root of a spacetree corresponds to the initial state of the tree traversal automaton.
std::set< int > _splitting
std::vector< peano4::grid::GridControlEvent > _gridControlEvents
We get these control events when we kick off the traversal and then realise/interpret them.
void evaluateGridControlEvents(const AutomatonState &fineGridState, GridVertex coarseGridVertices[TwoPowerD], GridVertex fineGridVertices[TwoPowerD])
Should only be called for inner cells.
bool isVertexAdjacentToLocalSpacetree(GridVertex vertex, bool splittingIsConsideredLocal, bool joiningIsConsideredLocal) const
Returns if a vertex is local to adjacent tree.
int _masterId
This is not a static master.
static void updateVertexRanksWithinCell(GridVertex fineGridVertices[TwoPowerD], int newId)
If a cell gets a new id, we have to update its vertices.
GridTraversalEventGenerator _gridTraversalEventGenerator
void mergeGridVertexRefinementStateAtHorizontalDomainBoundary(GridVertex &vertex, const GridVertex &inVertex, int neighbour)
Called by receiveAndMergeGridVertexAtHorizontalBoundary().
void updateVertexBeforeStore(GridVertex &vertex, GridVertex fineGridVertices[TwoPowerD], const tarch::la::Vector< Dimensions, int > &fineVertexPositionWithinPatch)
bool maySplit() const
Is the tree in principle allowed to split.
bool doesRankIndexIdentifyHorizontalDataExchange(int rank, bool calledByReceivingProcess) const
You may exchange data horizontally with rank if and only if.
void traverse(TraversalObserver &observer, bool calledFromSpacetreeSet=false)
bool mayJoinWithWorker() const
We allow at most one join at a time and not while we split.
std::vector< int > _splittedCells
std::set< int > _joinTriggered
This should be -1 if no join is triggered.
SplitSpecification _splitTriggered
A split is identified by a tuple of id and cell count which tells the code how many cells should go t...
void receiveAndMergeGridVertexAtVerticalBoundary(GridVertex &vertex)
This is a merge routine for vertical data exchange.
void receiveAndMergeGridVertexAtHorizontalBoundary(GridVertex &vertex)
Manage the data exchange after a vertex is loaded for the first time.
bool shouldEraseAdjacencyInformation(const GridVertex &vertex, GridVertex coarseGridVertices[TwoPowerD], tarch::la::Vector< Dimensions, int > fineVertexPositionWithinPatch) const
void updateSplittingCounter(int treeId)
Reduce splitting counter.
void mergeCellFromWorkerWithMasterThroughoutJoin(GridVertex vertex[TwoPowerD], GridVertex fineGridVertices[TwoPowerD])
Merge data from worker with master data throughout join.
void splitCellTopDown(GridVertex vertex[TwoPowerD], GridVertex fineGridVertices[TwoPowerD])
Split cell in a top down fashion.
tarch::la::Vector< TwoPowerD, int > getAdjacentRanksForNewVertex(GridVertex coarseGridVertices[TwoPowerD], const tarch::la::Vector< Dimensions, int > &vertexPositionWithin3x3Patch) const
bool areAllVerticesNonHanging(GridVertex vertices[TwoPowerD]) const
Could also be called areAllVerticesPersistent() in the Peano terminology.
bool isCellSplitCandidate(GridVertex coarseGridVertices[TwoPowerD], GridVertex fineGridVertices[TwoPowerD]) const
Can a cell be split (deployed to another rank)
The spacetree set has to be a singleton, as it is reponsible to accept requests for new trees from re...
The parallel namespace is Peano's core abstracts from both MPI and multicore parallelisation.
std::map< int, SplitInstruction > SplitSpecification