Peano 4
Loading...
Searching...
No Matches
peano4::grid::PeanoCurve Class Reference

Utility functions specific to the Peano SFC. More...

#include <PeanoCurve.h>

Static Public Member Functions

static bool isTraversePositiveAlongAxis (const AutomatonState &state, int axis)
 
static peano4::utils::LoopDirection getLoopDirection (const AutomatonState &state)
 Holds a set bit for each dimension along which the traversal is positive.
 
static void setExitFace (AutomatonState &cell, int axis)
 
static void setEntryFace (AutomatonState &cell, int axis)
 
static void invertEvenFlag (AutomatonState &cell, int axis)
 
static void removeFaceAccessNumber (AutomatonState &cell, int face)
 
static void setFaceAccessNumber (AutomatonState &cell, int face, int value)
 
static std::bitset< Dimensions > getFirstVertexIndex (const AutomatonState &cell)
 Looks into a cell of the spacetree and gives the index of the first local vertex.
 
static int getVertexReadStackNumber (const AutomatonState &state, const std::bitset< Dimensions > &vertex)
 
static int getVertexWriteStackNumber (const AutomatonState &state, const std::bitset< Dimensions > &vertex)
 
static int getFaceNumberAlongCurve (const AutomatonState &state, int logicalFaceNumber)
 Faces are enumerated following the same paradigm as the vertices.
 
static int getFaceReadStackNumber (const AutomatonState &state, int face)
 It is important to get the input/output stack ordering per stack type consistent among all grid entities.
 
static int getFaceWriteStackNumber (const AutomatonState &state, int face)
 
static int getCellReadStackNumber (const AutomatonState &state)
 
static int getCellWriteStackNumber (const AutomatonState &state)
 
static bool isInOutStack (int number)
 
static bool isTemporaryStack (int number)
 
static int getInputStackNumber (const AutomatonState &state)
 
static int getOutputStackNumber (const AutomatonState &state)
 

Static Public Attributes

static constexpr int CallStack = 0
 
static constexpr int NumberOfBaseStacks = 3
 By setting the value to something bigger than 2, we effectively reserve NumberOfBaseStacks - 2 as callstack.
 
static constexpr int NumberOfPeriodicBoundaryConditionStacks = 2*(ThreePowerD-1)
 In principle, there are Dimensions axes along which we can have periodic boundary conditions.
 
static constexpr int MaxNumberOfCoreStacksPerSpacetreeInstance = NumberOfBaseStacks + Dimensions*2 + NumberOfPeriodicBoundaryConditionStacks
 Standard (serial) number of stacks required per spacetree.
 

Detailed Description

Utility functions specific to the Peano SFC.

See also
Namespace description in grid.h

Definition at line 22 of file PeanoCurve.h.

Member Function Documentation

◆ getCellReadStackNumber()

int peano4::grid::PeanoCurve::getCellReadStackNumber ( const AutomatonState & state)
static

Definition at line 259 of file PeanoCurve.cpp.

References state.

Referenced by peano4::grid::GridTraversalEventGenerator::createEnterCellTraversalEvent().

Here is the caller graph for this function:

◆ getCellWriteStackNumber()

int peano4::grid::PeanoCurve::getCellWriteStackNumber ( const AutomatonState & state)
static

Definition at line 264 of file PeanoCurve.cpp.

References state.

Referenced by peano4::grid::GridTraversalEventGenerator::createLeaveCellTraversalEvent().

Here is the caller graph for this function:

◆ getFaceNumberAlongCurve()

int peano4::grid::PeanoCurve::getFaceNumberAlongCurve ( const AutomatonState & state,
int logicalFaceNumber )
static

Faces are enumerated following the same paradigm as the vertices.

Face 0 is the face with a x_0 as normal which runs through the origin (left bottom point), face 1 is the face with x_1 as normal, ... Face 0+d is the face parallel to face 0 but on the opposite side of the cell. In the SFC context, we obviously need a different enumeration scheme. With vertices, deriving this scheme is simple: you get the first vertex and then you xor the vertex numbers. Here, this is not possible, i.e. for faces users have to go through this routine.

Constructing a face enumeration is in principle similar to the vertex numbers. We start with our normalised enumeration as sketched above. Then we look at the even flags of the cell. For every even flag not set (odd numbers), we invert the enumerations along all other normals. If we run through the grid forward, we have, as pointed out above, first the face with normal 0 running through the origin, then the face with normal 1 running through the origin, ... If we invert the traversal, we first have to handle the face with normal d not running through the origin, then the one with normal d-1, and so forth.

Definition at line 203 of file PeanoCurve.cpp.

References cell().

Referenced by peano4::grid::GridTraversalEventGenerator::createEnterCellTraversalEvent(), and peano4::grid::GridTraversalEventGenerator::createLeaveCellTraversalEvent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFaceReadStackNumber()

int peano4::grid::PeanoCurve::getFaceReadStackNumber ( const AutomatonState & state,
int face )
static

It is important to get the input/output stack ordering per stack type consistent among all grid entities.

That is, in principle it does not matter whether we stream 1 to 2 and then back or 2 to 1 and then back. But if vertices stream from 1 to 2 first, then faces should do so as well. This allows the stack administration in the parallel case to map all stacks consistently (it doesn't have to search which input/output stack is full).

See also
getInputStackNumber()
getOutputStackNumber()

Definition at line 225 of file PeanoCurve.cpp.

References assertion1, peano4::grid::AutomatonState::getAccessNumber(), peano4::grid::AutomatonState::getEvenFlags(), peano4::grid::AutomatonState::getInverted(), and state.

Referenced by peano4::grid::GridTraversalEventGenerator::createEnterCellTraversalEvent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFaceWriteStackNumber()

int peano4::grid::PeanoCurve::getFaceWriteStackNumber ( const AutomatonState & state,
int face )
static

Definition at line 242 of file PeanoCurve.cpp.

References assertion1, and cell().

Referenced by peano4::grid::GridTraversalEventGenerator::createLeaveCellTraversalEvent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFirstVertexIndex()

std::bitset< Dimensions > peano4::grid::PeanoCurve::getFirstVertexIndex ( const AutomatonState & cell)
static

Looks into a cell of the spacetree and gives the index of the first local vertex.

The local enumeration obviously depends on the orientation of the curve. If you iterate over all vertices, an xor with the integer counter and this result makes the iterate a cell-local traversal. So a typical loop over all vertices of a cell along the Peano SFC reads as

const std::bitset<Dimensions> coordinates = PeanoCurve::getFirstVertexIndex(state);
for (int i=0; i<TwoPowerD; i++) {
std::bitset<Dimensions> currentLocalVertexIndex( coordinates ^ std::bitset<Dimensions>(i) );
logDebug( "loadVertices(...)", "handle vertex " << currentLocalVertexIndex );
}
#define TwoPowerD
Definition Globals.h:19
AutomatonState state
#define logDebug(methodName, logMacroMessageStream)
Definition Log.h:50
static std::bitset< Dimensions > getFirstVertexIndex(const AutomatonState &cell)
Looks into a cell of the spacetree and gives the index of the first local vertex.

We heavily exploit bitsets here. They allow us, for example, to invert the whole direction by a simple flip.

Definition at line 88 of file PeanoCurve.cpp.

References cell().

Referenced by peano4::grid::GridTraversalEventGenerator::createEnterCellTraversalEvent(), peano4::grid::GridTraversalEventGenerator::createLeaveCellTraversalEvent(), peano4::grid::Spacetree::loadVertices(), and peano4::grid::Spacetree::storeVertices().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getInputStackNumber()

int peano4::grid::PeanoCurve::getInputStackNumber ( const AutomatonState & state)
static

Definition at line 135 of file PeanoCurve.cpp.

References peano4::grid::AutomatonState::getInverted(), and state.

Referenced by peano4::parallel::SpacetreeSet::streamDataFromSplittingTreesToNewTrees().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getLoopDirection()

peano4::utils::LoopDirection peano4::grid::PeanoCurve::getLoopDirection ( const AutomatonState & state)
static

Holds a set bit for each dimension along which the traversal is positive.

Definition at line 24 of file PeanoCurve.cpp.

References state.

Referenced by peano4::grid::Spacetree::descend().

Here is the caller graph for this function:

◆ getOutputStackNumber()

int peano4::grid::PeanoCurve::getOutputStackNumber ( const AutomatonState & state)
static

Definition at line 140 of file PeanoCurve.cpp.

References peano4::grid::AutomatonState::getInverted(), and state.

Referenced by peano4::parallel::SpacetreeSet::streamDataFromSplittingTreeToNewTree().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getVertexReadStackNumber()

int peano4::grid::PeanoCurve::getVertexReadStackNumber ( const AutomatonState & state,
const std::bitset< Dimensions > & vertex )
static

Implementation details

As the access numbers already are inverted in the new code where all access flags are created on the fly, we don't need the inversion flag here anymore. The only situation where we need it is to toggle input and output stacks.

Returns
0 or 1 if it is about in/out stacks

Definition at line 145 of file PeanoCurve.cpp.

References assertion1, peano4::grid::AutomatonState::getAccessNumber(), peano4::grid::AutomatonState::getEvenFlags(), and state.

Referenced by peano4::grid::GridTraversalEventGenerator::createEnterCellTraversalEvent(), and peano4::grid::Spacetree::loadVertices().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getVertexWriteStackNumber()

int peano4::grid::PeanoCurve::getVertexWriteStackNumber ( const AutomatonState & state,
const std::bitset< Dimensions > & vertex )
static
Returns
0 or 1 if it is about in/out stacks

Definition at line 179 of file PeanoCurve.cpp.

References assertion1, and cell().

Referenced by peano4::grid::GridTraversalEventGenerator::createLeaveCellTraversalEvent(), and peano4::grid::Spacetree::storeVertices().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ invertEvenFlag()

void peano4::grid::PeanoCurve::invertEvenFlag ( AutomatonState & cell,
int axis )
static

Definition at line 59 of file PeanoCurve.cpp.

References assertion, and cell().

Referenced by peano4::grid::Spacetree::refineState().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isInOutStack()

◆ isTemporaryStack()

bool peano4::grid::PeanoCurve::isTemporaryStack ( int number)
static

Definition at line 174 of file PeanoCurve.cpp.

◆ isTraversePositiveAlongAxis()

bool peano4::grid::PeanoCurve::isTraversePositiveAlongAxis ( const AutomatonState & state,
int axis )
static

Definition at line 9 of file PeanoCurve.cpp.

References assertion, and state.

Referenced by peano4::grid::Spacetree::refineState().

Here is the caller graph for this function:

◆ removeFaceAccessNumber()

void peano4::grid::PeanoCurve::removeFaceAccessNumber ( AutomatonState & cell,
int face )
static

Definition at line 66 of file PeanoCurve.cpp.

References assertion, and cell().

Here is the call graph for this function:

◆ setEntryFace()

void peano4::grid::PeanoCurve::setEntryFace ( AutomatonState & cell,
int axis )
static

Definition at line 47 of file PeanoCurve.cpp.

References cell().

Referenced by peano4::grid::Spacetree::refineState().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setExitFace()

void peano4::grid::PeanoCurve::setExitFace ( AutomatonState & cell,
int axis )
static

Definition at line 35 of file PeanoCurve.cpp.

References cell().

Referenced by peano4::grid::Spacetree::refineState().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFaceAccessNumber()

void peano4::grid::PeanoCurve::setFaceAccessNumber ( AutomatonState & cell,
int face,
int value )
static

Definition at line 112 of file PeanoCurve.cpp.

References assertion, and cell().

Here is the call graph for this function:

Field Documentation

◆ CallStack

constexpr int peano4::grid::PeanoCurve::CallStack = 0
staticconstexpr

Definition at line 27 of file PeanoCurve.h.

◆ MaxNumberOfCoreStacksPerSpacetreeInstance

constexpr int peano4::grid::PeanoCurve::MaxNumberOfCoreStacksPerSpacetreeInstance = NumberOfBaseStacks + Dimensions*2 + NumberOfPeriodicBoundaryConditionStacks
staticconstexpr

Standard (serial) number of stacks required per spacetree.

The stacks are ordered as follows:

  • One stack represents the call stack. In our tree world, it represents data on coarser tree levels which we will revisit throughout the backtracking.
  • We need an input and an output stack.
  • Then we need the 2d temporary stacks for the face or vertex exchange with neighbouring cells.
  • We have a number of stacks that we use for all periodic boundary data exchange. These are only used on tree 0. We first hold all the output stacks and then all the input stacks.

From hereon, all further stacks are used for parallel data exchange.

Example 2d

stack number semantics usage
0 call stack every tree
1,2 input/output stack every tree
3-6 temporary stacks to every tree

| | exchange data with | | | adjacent cells | | 7-14 | output stacks for | tree 0 | | periodic BC data | | 15-22 | input stack for | tree 0 | | periodic BC data | | >=23 | parallel data xchange | all trees | | stacks |

Definition at line 86 of file PeanoCurve.h.

Referenced by peano4::parallel::Node::getInputStackNumberForHorizontalDataExchange(), peano4::parallel::Node::getInputStackNumberForVerticalDataExchange(), peano4::parallel::Node::getOutputStackForPeriodicBoundaryExchange(), peano4::parallel::Node::getOutputStackNumberForHorizontalDataExchange(), peano4::parallel::Node::getOutputStackNumberForVerticalDataExchange(), peano4::parallel::Node::getOutputStacksForPeriodicBoundaryExchange(), peano4::parallel::Node::getPeriodicBoundaryExchangeInputStackNumberForOutputStack(), peano4::parallel::Node::getPeriodicBoundaryExchangeInputStackNumberForOutputStack(), peano4::parallel::Node::getTreeNumberTiedToExchangeStackNumber(), peano4::parallel::Node::isHorizontalDataExchangeInputStackNumber(), peano4::parallel::Node::isHorizontalDataExchangeOutputStackNumber(), peano4::parallel::Node::isPeriodicBoundaryExchangeOutputStackNumber(), peano4::parallel::Node::isStorageStackNumber(), peano4::parallel::Node::isVerticalDataExchangeInputStackNumber(), peano4::parallel::Node::isVerticalDataExchangeOutputStackNumber(), and peano4::parallel::Node::mapPeriodicBoundaryExchangeOutputStackOntoInputStack().

◆ NumberOfBaseStacks

constexpr int peano4::grid::PeanoCurve::NumberOfBaseStacks = 3
staticconstexpr

By setting the value to something bigger than 2, we effectively reserve NumberOfBaseStacks - 2 as callstack.

Definition at line 33 of file PeanoCurve.h.

◆ NumberOfPeriodicBoundaryConditionStacks

constexpr int peano4::grid::PeanoCurve::NumberOfPeriodicBoundaryConditionStacks = 2*(ThreePowerD-1)
staticconstexpr

In principle, there are Dimensions axes along which we can have periodic boundary conditions.

The faces along the x axis can wrap over, those along the y axis can wrap over, those along the z axis, too. For each direction, we need two stacks. The first one is for data flow along the coordinate axis, the other one for the flow in the opposite direction.

Overall, we can have up to \( 3^d-1 \) different data flow directions. Obviously, faces use only up to \( 2d \) of these, as faces cannot be exchanged along diagonals.

The whole set of stacks is replicated: We need a set of these stacks to read from (those are the lower ones). They are followed by stacks to write to. The two stacks are swapped over after each iteration.

Definition at line 50 of file PeanoCurve.h.

Referenced by peano4::parallel::Node::getOutputStackForPeriodicBoundaryExchange(), peano4::parallel::Node::getOutputStacksForPeriodicBoundaryExchange(), peano4::parallel::Node::getPeriodicBoundaryExchangeInputStackNumberForOutputStack(), peano4::parallel::Node::getPeriodicBoundaryExchangeInputStackNumberForOutputStack(), peano4::parallel::Node::isPeriodicBoundaryExchangeOutputStackNumber(), and peano4::parallel::Node::mapPeriodicBoundaryExchangeOutputStackOntoInputStack().


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