![]() |
Peano
|
The grid namespace is Peano's core. More...
Namespaces | |
namespace | internal |
namespace | tests |
Data Structures | |
struct | AutomatonState |
class | EmptyTraversalObserver |
Empty observer. More... | |
struct | GridControlEvent |
struct | GridStatistics |
struct | GridTraversalEvent |
class | GridTraversalEventGenerator |
Translate grid traversal automaton's transitions into user events. More... | |
struct | GridVertex |
class | PeanoCurve |
Utility functions specific to the Peano SFC. More... | |
class | Spacetree |
Represents one tree. More... | |
class | TraversalObserver |
class | TraversalVTKPlotter |
Observer which pipes the automaton transitions into a VTK file. More... | |
Enumerations | |
enum class | VertexType { New , Hanging , Persistent , Delete } |
enum class | FaceType { New , Hanging , Persistent , Delete } |
enum class | CellType { New , Persistent , Delete } |
enum class | SpacetreeState { EmptyRun , NewRoot , NewFromSplit , Running , JoinTriggered , Joining , Joined } |
enum class | LoadStoreComputeFlag { LoadFromInputStream_ProvideToCalculations_StoreToOutputStream , LoadFromInputStream_ProvideToCalculations_Discard , CreateDummy_ProvideToCalculations_StoreToOutputStream , CreateDummy_ProvideToCalculations_Discard , NoData } |
Flag to control data movements. More... | |
Functions | |
void | clear (GridStatistics &statistics, bool isGlobalMasterTree) |
The term clear() is not 100% correct, as the number of stationary traversals is not reset to a dummy but instead incremented. | |
std::vector< GridControlEvent > | merge (std::vector< GridControlEvent > events, const double Tolerance=0.1) |
Merge set of refinement/coarsening commands. | |
GridVertex | createVertex (GridVertex::State state, const tarch::la::Vector< Dimensions, double > &x, int level, const tarch::la::Vector< TwoPowerD, int > &adjacentRanks, bool isNewFineGridVertex) |
Factory mechanism. | |
bool | isSpacetreeNodeRefined (GridVertex vertices[TwoPowerD]) |
A spacetree node is refined if any of its adjacent vertices holds one of the following flags: | |
bool | willVertexBeRefined (const GridVertex &vertex) |
A vertex will be refined if it is already refined or currently refining. | |
bool | hasVertexBeenRefined (const GridVertex &vertex) |
A vertex has been refined if it is (already) refined or is erasing or the erase has been triggered. | |
std::bitset< TwoPowerD > | willVerticesBeRefined (GridVertex vertices[TwoPowerD]) |
A vertex is unrefined if it is hanging. | |
std::bitset< TwoPowerD > | haveVerticesBeenRefined (GridVertex vertices[TwoPowerD]) |
bool | isSpacetreeNodeLocal (GridVertex vertices[TwoPowerD], bool splittingIsConsideredLocal, bool joiningIsConsideredLocal, int id) |
A spacetree node as 2^d adjacent vertices. | |
std::string | toString (VertexType type) |
std::string | toString (FaceType type) |
std::string | toString (CellType type) |
constexpr int | InvalidRank (-1) |
std::string | toString (SpacetreeState state) |
bool | overlaps (const tarch::la::Vector< Dimensions, double > &x, const GridControlEvent &event) |
bool | overlaps (const AutomatonState &x, const GridControlEvent &event) |
bool | isContained (const AutomatonState &x, const GridControlEvent &event, double upscaleAutomatonState=1.0) |
isContained() is defined over the closed interval, i.e. | |
void | reduceGridControlEvents (std::vector< GridControlEvent > &events) |
Peano 4 does not reduce any grid control events globally. | |
std::string | toString (const std::vector< GridControlEvent > &events) |
std::string | toString (const std::list< GridControlEvent > &events) |
bool | loadPersistently (LoadStoreComputeFlag flag) |
Data is stored persistently on input/output stream. | |
bool | storePersistently (LoadStoreComputeFlag flag) |
Data is stored persistently on input/output stream. | |
bool | computeOnData (LoadStoreComputeFlag flag) |
Data is stored persistently on input/output stream. | |
std::string | toString (LoadStoreComputeFlag flag) |
LoadStoreComputeFlag | constructLoadStoreComputeFlag (bool predicateForLoad, bool predicateForStore) |
Constructs a data storage scheme. | |
LoadStoreComputeFlag | constructLoadStoreComputeFlag (bool predicateToUseData, bool predicateForLoad, bool predicateForStore) |
Constructs a data storage scheme. | |
The grid namespace is Peano's core.
There are a few key classes in this namespace which realise Peano's core:
|
strong |
|
strong |
|
strong |
Flag to control data movements.
This flag is used to determine data movements. It has nothing to do with which events are triggered at any point. It simply controls which data is moved between the stacks by the tree traversal automaton. The routine constructLoadStoreComputeFlag() provides some documentation of the semantics of the variants, while loadPersistently(), storePersistently() and computeOnData() are used to make decisions which data to copy/move from stack to stack.
Definition at line 22 of file LoadStoreComputeFlag.h.
|
strong |
|
strong |
void peano4::grid::clear | ( | GridStatistics & | statistics, |
bool | isGlobalMasterTree ) |
The term clear() is not 100% correct, as the number of stationary traversals is not reset to a dummy but instead incremented.
Definition at line 230 of file grid.cpp.
References peano4::grid::GridStatistics::getStationarySweeps(), peano4::grid::GridStatistics::setCoarseningHasBeenVetoed(), peano4::grid::GridStatistics::setMinH(), peano4::grid::GridStatistics::setNumberOfLocalRefinedCells(), peano4::grid::GridStatistics::setNumberOfLocalUnrefinedCells(), peano4::grid::GridStatistics::setNumberOfRemoteRefinedCells(), peano4::grid::GridStatistics::setNumberOfRemoteUnrefinedCells(), peano4::grid::GridStatistics::setRemovedEmptySubtree(), and peano4::grid::GridStatistics::setStationarySweeps().
Referenced by peano4::grid::Spacetree::Spacetree(), peano4::grid::Spacetree::Spacetree(), and peano4::grid::Spacetree::traverse().
bool peano4::grid::computeOnData | ( | LoadStoreComputeFlag | flag | ) |
Data is stored persistently on input/output stream.
These actions are derived from the storage annotation. They do not imply in any way that events are called or are not called. That is, we we only control data movements and initialisations. In this particular case, we use the predicate to find out if we have to initialise stack data once we have created it (as it is hanging or brand new). We always set the meta data, but some stack entries holds (smart) pointers and by default point into the nirvana. They might have to be initialised explicitly by using the default constructor.
Definition at line 57 of file LoadStoreComputeFlag.cpp.
References assertion.
peano4::grid::LoadStoreComputeFlag peano4::grid::constructLoadStoreComputeFlag | ( | bool | predicateForLoad, |
bool | predicateForStore ) |
Constructs a data storage scheme.
Same as constructLoadStoreComputeFlag(bool,bool,bool), assuming that its predicateToUseData holds all the time.
Definition at line 75 of file LoadStoreComputeFlag.cpp.
References constructLoadStoreComputeFlag().
Referenced by constructLoadStoreComputeFlag().
peano4::grid::LoadStoreComputeFlag peano4::grid::constructLoadStoreComputeFlag | ( | bool | predicateToUseData, |
bool | predicateForLoad, | ||
bool | predicateForStore ) |
Constructs a data storage scheme.
Same as the other constructor, assuming that its predicateToUseData holds all the time. This routine is often used by user code to construct the enum, i.e. it is a sole helper routine. Peano itself does not directly use it.
predicateToUseData | predicateForLoad | predicateForStore | Result | Description |
---|---|---|---|---|
False | False | False | NoData | Just ignore the data, as it is not used |
False | True | False | LoadFromInputStream_ProvideToCalculations_Discard | Load it (and keep it as you've loaded it anyway) but then throw it away, as it is not used |
False | False | True | CreateDummy_ProvideToCalculations_StoreToOutputStream | It will not be used, but create a dummy, as it has to be stored eventually |
False | True | True | assertion | Makes no sense |
True | False | False | CreateDummy_ProvideToCalculations_Discard | Data is required temporarily throughout calculations but not persistent in-between two grid sweeps |
True | True | False | LoadFromInputStream_ProvideToCalculations_Discard | Data flow-wisely the same as False, True, False |
True | False | True | CreateDummy_ProvideToCalculations_StoreToOutputStream | Introduce a new piece of data into the data flow. Same as false, false, true |
True | True | True | LoadFromInputStream_ProvideToCalculations_StoreToOutputStream | Proper piece of data that's held persistently in-between two mesh sweeps |
Definition at line 79 of file LoadStoreComputeFlag.cpp.
References assertion, CreateDummy_ProvideToCalculations_Discard, CreateDummy_ProvideToCalculations_StoreToOutputStream, LoadFromInputStream_ProvideToCalculations_Discard, LoadFromInputStream_ProvideToCalculations_StoreToOutputStream, and NoData.
peano4::grid::GridVertex peano4::grid::createVertex | ( | GridVertex::State | state, |
const tarch::la::Vector< Dimensions, double > & | x, | ||
int | level, | ||
const tarch::la::Vector< TwoPowerD, int > & | adjacentRanks, | ||
bool | isNewFineGridVertex ) |
Factory mechanism.
We expect the calling code to tell us about the adjacent ranks of a vertex. There is a routine Spacetree::getAdjacentRanksForNewVertex() which allows you to distill adjacency information while you step down within the tree and create new vertices. This is information we write directly into the new data plus the backup of the old data. This means, by the time we create a new vertex, anybody analysing the adjacency information things that this data has always been there.
There are a few attributes which should have dummy values. There are also a few attributes which are set later on throughout the traversal, but I should initialise them here properly to ensure that valgrind's memchecker doesn't complain.
adjacentRanks | Typically the result from Spacetree::getAdjacentRanksForNewVertex(coarseGridVertices,vertexPositionWithin3x3Patch). |
Definition at line 61 of file grid.cpp.
References peano4::grid::GridVertex::setAdjacentRanks(), peano4::grid::GridVertex::setBackupOfAdjacentRanks(), peano4::grid::GridVertex::setHasBeenAntecessorOfRefinedVertexInPreviousTreeSweep(), peano4::grid::GridVertex::setHasBeenParentOfSubtreeVertexInPreviousTreeSweep(), peano4::grid::GridVertex::setIsAntecessorOfRefinedVertexInCurrentTreeSweep(), peano4::grid::GridVertex::setIsParentOfSubtreeVertexInCurrentTreeSweep(), peano4::grid::GridVertex::setLevel(), peano4::grid::GridVertex::setNumberOfAdjacentRefinedLocalCells(), peano4::grid::GridVertex::setState(), and state.
Referenced by peano4::grid::Spacetree::loadVertices(), and peano4::grid::Spacetree::traverse().
bool peano4::grid::hasVertexBeenRefined | ( | const GridVertex & | vertex | ) |
A vertex has been refined if it is (already) refined or is erasing or the erase has been triggered.
Definition at line 253 of file grid.cpp.
References peano4::grid::GridVertex::getState().
Referenced by haveVerticesBeenRefined(), and isSpacetreeNodeRefined().
std::bitset< TwoPowerD > peano4::grid::haveVerticesBeenRefined | ( | GridVertex | vertices[TwoPowerD] | ) |
Definition at line 267 of file grid.cpp.
References assertion, hasVertexBeenRefined(), and TwoPowerD.
Referenced by peano4::grid::GridTraversalEventGenerator::createGenericCellTraversalEvent().
|
constexpr |
Referenced by peano4::grid::Spacetree::doesRankIndexIdentifyHorizontalDataExchange(), peano4::grid::Spacetree::getAdjacentRanksForNewVertex(), peano4::grid::GridTraversalEventGenerator::getAdjacentRanksOfFace(), peano4::grid::Spacetree::getNeighbourTrees(), peano4::grid::GridTraversalEventGenerator::getTreeOwningSpacetreeNode(), peano4::grid::Spacetree::mergeGridVertexAdjacencyListsAtHorizontalDomainBoundary(), peano4::grid::Spacetree::receiveAndMergeGridVertexAtHorizontalBoundary(), peano4::grid::tests::GridTraversalEventGeneratorTest::testAreFacesLocal1(), peano4::grid::tests::GridTraversalEventGeneratorTest::testCreateLeaveCellTraversalEvent1(), peano4::grid::Spacetree::traverse(), and peano4::grid::Spacetree::updateVertexBeforeStore().
bool peano4::grid::isContained | ( | const AutomatonState & | x, |
const GridControlEvent & | event, | ||
double | upscaleAutomatonState = 1.0 ) |
isContained() is defined over the closed interval, i.e.
we look if x is contained within the cube spanned by x including its faces.
Definition at line 40 of file grid.cpp.
References tarch::la::allGreaterEquals(), tarch::la::allSmallerEquals(), assertion1, peano4::grid::GridControlEvent::getOffset(), peano4::grid::GridControlEvent::getWidth(), and state.
Referenced by peano4::grid::Spacetree::evaluateGridControlEvents().
bool peano4::grid::isSpacetreeNodeLocal | ( | GridVertex | vertices[TwoPowerD], |
bool | splittingIsConsideredLocal, | ||
bool | joiningIsConsideredLocal, | ||
int | id ) |
A spacetree node as 2^d adjacent vertices.
So there are 2^d integers stored within these vertices that overlap with the current node. They all have to be the same. If they identify the local _id, then the node is local. They are also local if the markers are set to RankOfCellWitchWillBeJoined. This magic constant identifies cells on a worker which might join into their master.
Throughout the splitting process, an id might be already set to a remote rank, though it still is technically and logically local. So this routine interprets locality pretty technical and even marks those cells as non-local (anymore) which still are for another grid sweep or two.
Referenced by peano4::grid::GridTraversalEventGenerator::createGenericCellTraversalEvent(), peano4::grid::Spacetree::descend(), peano4::grid::GridTraversalEventGenerator::getTreeOwningSpacetreeNode(), peano4::grid::Spacetree::isCellSplitCandidate(), peano4::grid::Spacetree::mergeCellFromWorkerWithMasterThroughoutJoin(), peano4::grid::Spacetree::splitCellTopDown(), and peano4::grid::Spacetree::splitOrJoinCellBottomUp().
bool peano4::grid::isSpacetreeNodeRefined | ( | GridVertex | vertices[TwoPowerD] | ) |
A spacetree node is refined if any of its adjacent vertices holds one of the following flags:
Definition at line 241 of file grid.cpp.
References dfor2, enddforx, hasVertexBeenRefined(), and willVertexBeRefined().
Referenced by peano4::grid::Spacetree::descend(), peano4::grid::Spacetree::splitCellTopDown(), and peano4::grid::Spacetree::splitOrJoinCellBottomUp().
bool peano4::grid::loadPersistently | ( | LoadStoreComputeFlag | flag | ) |
Data is stored persistently on input/output stream.
These actions are derived from the storage annotation. They do not imply in any way that events are called or are not called. That is, we we only control data movements and initialisations.
Definition at line 22 of file LoadStoreComputeFlag.cpp.
References assertion.
std::vector< peano4::grid::GridControlEvent > peano4::grid::merge | ( | std::vector< GridControlEvent > | events, |
const double | Tolerance = 0.1 ) |
Merge set of refinement/coarsening commands.
This routine has two roles:
The algorithm works in multiple steps:
We sort the respective events along x,y,z offset. In 2d, this doesn't make that much of a difference, for d>2 it is important: The merger of multiple events works in a greedy fashion. Otherwise, it would be too slow. Due to this greediness, we now might run into situations where we are stuck. Consider a 2x2x2 cube of refinement operations which all have the same target resolution. It should be possible to merge this cube into one single large cube. However, we might end up with
(r_111,r_211), (r_121,r_122), (r_212,r_222), r_112, r221)
These six events now can't be merged greedily anymore.
Once we sort the events by x,y,z, the original input sequence implicitly ensures that we first merge along the z direction, then along y, and finally along x:
(r_111,r1_112,r_121,r_122,r_211,r1_212,r_221,r_222)
We have to create the power sets over all erase events. This gives the mesh the opportunity to see faster where erases are possible, as it also handle non-rectangular regions: Assume there's a large L-shape of erase instructions consisting of three erase commands. Our algorithm will create a rectangle plus a square when it fuses the erases.
Consequently, any cell overlapping with the boundary between the square and the rectangle will not be erased.
If we had not merged the three cubic erases forming the L into 2+1 but into 2+2, we would also cover the boundary of the L shape. Therefore, it is important that we construct the power set before we merge events.
The power set construction very quickly explodes, i.e. leads to a vast number of events. I thus manually truncate the creation of new events.
Remark: I had to remove this power set step, as it turned out to be too time consuming.
The algorithm has to be idempotent, i.e. if we invoke it multiple times over the input set, the outcome should always remain the same.
events | Set of events which we try to merge |
Tolerance | Relative tolerance passed into the actual merger, i.e. the tolerance at which two events are merged, even though they might not exactly be adjacent. A default of 10% (relative tolerance) is sufficient for most cases, but there might be situation where a larger tolerance is reasonable to ensure that some events which are slightly disjoint are actually merged, too. |
Definition at line 112 of file grid.cpp.
References logDebug, logTraceInWith1Argument, and logTraceOutWith1Argument.
Referenced by swift2::commitGridControlEvents(), exahype2::RefinementControlService::finishStep(), peano4::grid::tests::GridControlEventTest::testMerge1(), peano4::grid::tests::GridControlEventTest::testMerge2(), peano4::grid::tests::GridControlEventTest::testMerge3(), and peano4::grid::Spacetree::traverse().
bool peano4::grid::overlaps | ( | const AutomatonState & | x, |
const GridControlEvent & | event ) |
Definition at line 51 of file grid.cpp.
References tarch::la::allGreaterEquals(), tarch::la::allSmallerEquals(), peano4::grid::GridControlEvent::getOffset(), peano4::grid::GridControlEvent::getWidth(), and state.
bool peano4::grid::overlaps | ( | const tarch::la::Vector< Dimensions, double > & | x, |
const GridControlEvent & | event ) |
Definition at line 56 of file grid.cpp.
References tarch::la::allGreaterEquals(), tarch::la::allSmallerEquals(), peano4::grid::GridControlEvent::getOffset(), and peano4::grid::GridControlEvent::getWidth().
Referenced by peano4::grid::Spacetree::evaluateGridControlEvents(), and peano4::grid::internal::removeEraseEventsThatAreCancelledByRefineEvents().
void peano4::grid::reduceGridControlEvents | ( | std::vector< GridControlEvent > & | events | ) |
Peano 4 does not reduce any grid control events globally.
If you want to reduce these events, you have to do so manually. Operation becomes identify if you don't compile with MPI.
This is a blocking routine, and it thus requires all ranks to call it at exactly the same time. Use it with care. In ExaHyPE 2, e.g., I prefer a more anarchic exchange of grid control events.
Definition at line 394 of file grid.cpp.
References tarch::mpi::Rank::getCommunicator(), tarch::mpi::Rank::getInstance(), tarch::mpi::Rank::getNumberOfRanks(), tarch::mpi::Rank::getRank(), and logDebug.
bool peano4::grid::storePersistently | ( | LoadStoreComputeFlag | flag | ) |
Data is stored persistently on input/output stream.
These actions are derived from the storage annotation. They do not imply in any way that events are called or are not called. That is, we we only control data movements and initialisations.
Definition at line 39 of file LoadStoreComputeFlag.cpp.
References assertion.
std::string peano4::grid::toString | ( | const std::list< GridControlEvent > & | events | ) |
std::string peano4::grid::toString | ( | const std::vector< GridControlEvent > & | events | ) |
std::string peano4::grid::toString | ( | LoadStoreComputeFlag | flag | ) |
Definition at line 6 of file LoadStoreComputeFlag.cpp.
std::string peano4::grid::toString | ( | SpacetreeState | state | ) |
std::string peano4::grid::toString | ( | VertexType | type | ) |
Definition at line 276 of file grid.cpp.
Referenced by peano4::grid::Spacetree::descend(), peano4::grid::Spacetree::evaluateGridControlEvents(), peano4::parallel::SpacetreeSet::exchangeHorizontalDataBetweenTrees(), peano4::parallel::SpacetreeSet::exchangeVerticalDataBetweenTrees(), peano4::grid::GridTraversalEventGenerator::getFaceType(), peano4::grid::GridTraversalEventGenerator::getTreeOwningSpacetreeNode(), peano4::grid::GridTraversalEventGenerator::getVertexType(), peano4::grid::Spacetree::incrementNumberOfAdjacentRefinedLocalCells(), peano4::grid::Spacetree::joinWithWorker(), peano4::grid::Spacetree::loadVertices(), peano4::grid::Spacetree::markVerticesAroundForkedCell(), peano4::grid::Spacetree::mergeCellFromWorkerWithMasterThroughoutJoin(), peano4::grid::Spacetree::receiveAndMergeUserData(), peano4::grid::Spacetree::refineState(), peano4::grid::Spacetree::sendGridVertex(), peano4::grid::Spacetree::sendUserData(), peano4::grid::Spacetree::split(), peano4::grid::Spacetree::splitCellTopDown(), peano4::grid::Spacetree::storeVertices(), peano4::grid::tests::GridTraversalEventGeneratorTest::testGetFaceType(), peano4::grid::tests::GridControlEventTest::testMerge1(), peano4::grid::tests::GridControlEventTest::testSortWithinMerge(), peano4::grid::Spacetree::toString(), peano4::grid::Spacetree::traverse(), and peano4::grid::Spacetree::updateVertexBeforeStore().
bool peano4::grid::willVertexBeRefined | ( | const GridVertex & | vertex | ) |
A vertex will be refined if it is already refined or currently refining.
It also will be refined if the erase is only triggered.
Definition at line 248 of file grid.cpp.
References peano4::grid::GridVertex::getState().
Referenced by isSpacetreeNodeRefined(), and willVerticesBeRefined().
std::bitset< TwoPowerD > peano4::grid::willVerticesBeRefined | ( | GridVertex | vertices[TwoPowerD] | ) |
A vertex is unrefined if it is hanging.
Definition at line 258 of file grid.cpp.
References assertion, TwoPowerD, and willVertexBeRefined().
Referenced by peano4::grid::GridTraversalEventGenerator::createGenericCellTraversalEvent().