Peano
Loading...
Searching...
No Matches
peano4::datamanagement::VertexMarker Struct Reference

Vertex marker to provide information about selected vertex. More...

#include <VertexMarker.h>

Collaboration diagram for peano4::datamanagement::VertexMarker:

Public Member Functions

 VertexMarker (const ::peano4::grid::GridTraversalEvent &event, int select=0)
 
VertexMarkerselect (int number)
 Picks a vertex within a cell.
 
int getSelectedVertexNumber () const
 Information about selected vertex.
 
tarch::la::Vector< Dimensions, doublex (int i) const
 We do enumerate the vertices in a lexicographic way, i.e.
 
tarch::la::Vector< Dimensions, doublex () const
 
bool isParentOfSubtree (int i) const
 
bool isParentOfSubtree () const
 
tarch::la::Vector< Dimensions, doubleh () const
 
std::string toString () const
 
bool hasBeenRefined () const
 A vertex is refined iff it is surrounded by \( 2^d \) cells which are refined.
 
bool hasBeenRefined (int i) const
 
bool willBeRefined () const
 
bool willBeRefined (int i) const
 
int getNumberOfAdjacentTrees () const
 Number of adjacent trees of current vertex.
 
int getNumberOfAdjacentTrees (int i) const
 
bool isLocal () const
 
bool isLocal (int i) const
 Is a vertex local, i.e.
 
bool isHanging () const
 
bool isHanging (int i) const
 
bool isAdjacentToParallelDomainBoundary () const
 Is currently selected/analysed vertex adjacent to parallel domain boundary.
 
bool isAdjacentToParallelDomainBoundary (int i) const
 Is one vertex of cell adjacent to parallel domain boundary.
 
bool isParentCellLocal () const
 Whenever we touch a vertex the first or the last time, we touch it from a cell: If we touch a vertex the first time, the traversal is just about to enter a cell and sees that one of its vertices is not loaded yet.
 
bool isParentVertexLocal (int i) const
 Is the parent vertex local.
 
tarch::la::Vector< Dimensions, intgetRelativePositionWithinFatherCell () const
 Relative position within parent cell.
 
tarch::la::Vector< Dimensions, intgetRelativePositionWithinFatherCell (int i) const
 
bool coincidesWithCoarseGridVertex () const
 Does vertex spatially coincide with coarser level's vertex.
 
bool isContainedInAdjacentCells (const tarch::la::Vector< Dimensions, double > &x, double scaleAdjacentCells=1.0, double tolerance=tarch::la::NUMERICAL_ZERO_DIFFERENCE) const
 Will return true if x is contained within the adjacent cells.
 
tarch::la::Vector< Dimensions, intgetRelativeAdjacentCell (const tarch::la::Vector< Dimensions, double > &x) const
 Each vertex is surrounded by \( 2^d \) cells.
 
tarch::la::Vector< Dimensions, doublegetInvokingCellCentre () const
 Return centre of cell from which this vertex marker is constructed.
 
tarch::la::Vector< Dimensions, doublegetInvokingParentCellsCentre () const
 See getInvokingCellCentre().
 
std::bitset< TwoPowerDareAdjacentCellsLocal () const
 Are adjacent cells of selected vertex local.
 

Private Member Functions

bool isParentLocal () const
 
 VertexMarker ()=default
 Some unit tests prefer to construct a marker manually, so I offer a dummy default constructor.
 

Private Attributes

tarch::la::Vector< Dimensions, double_cellCentre
 Centre of the underlying cell.
 
tarch::la::Vector< Dimensions, double_h
 Size of the underlying cell.
 
int _select
 
std::bitset< TwoPowerD_hasBeenRefined
 
std::bitset< TwoPowerD_willBeRefined
 
std::bitset< TwoPowerD_isLocal
 
std::bitset< TwoPowerD_isHanging
 
std::bitset< TwoPowerD_isParentVertexLocal
 
std::bitset< ThreePowerD_isAdjacentCellLocal
 
std::bitset< TwoPowerD_isParentOfSubtree
 
bool _isParentCellLocal
 
std::bitset< TwoPowerD_isAdjacentToParallelDomainBoundary
 
tarch::la::Vector< Dimensions, int_relativePositionOfCellWithinFatherCell
 Entries from (0,1,2).
 
tarch::la::Vector< TwoPowerD, int_numberOfAdjacentTrees
 Number of adjacent trees per vertex.
 

Friends

class toolbox::particles::tests::MultiscaleTransitionsTest
 For unit tests.
 
class toolbox::particles::tests::TestHelpers
 

Detailed Description

Vertex marker to provide information about selected vertex.

A vertex marker is handed into each and every observer/action set routine which is vertex-based. That is routines such as touchVertexFirstTime(). The marker provides information about the underlying vertex.

Notably, we can provide

  • geometric information such as the position of a vertex or the size of the adjacent cells.
  • status information such as whether a vertex is hanging.
  • grid layout information such as the vertex's position within the parent cell.

Rationale

Peano's events (observer and action set routines) are internally all implemented on a per cell basis. So we invoke touchVertexFirstTime() from the cell when the first adjacent cell of a vertex is entered. Therefore, we know the selected vertex.

Peano runs through the mesh with a tree automaton. A lot of information about vertices thus is recomputed on-the-fly all the time, as it is easy to derive it from the context. We know, for example, from the state of the traversal automaton if a vertex is hanging or not or which position in space it has. Therefore, such information is not stored within the vertex (unless for debugging purposes). Not only would the information be redundant, it would also be very inefficient: If you work with k data records per vertex, each one would hold the same information about the underlying vertex's position. So it makes more sense to encode such information with a separate object.

See also
FaceMarker for the analogous information for faces.

Definition at line 90 of file VertexMarker.h.

Constructor & Destructor Documentation

◆ VertexMarker() [1/2]

peano4::datamanagement::VertexMarker::VertexMarker ( )
privatedefault

Some unit tests prefer to construct a marker manually, so I offer a dummy default constructor.

The normal code should and does not use a default constructor.

◆ VertexMarker() [2/2]

peano4::datamanagement::VertexMarker::VertexMarker ( const ::peano4::grid::GridTraversalEvent & event,
int select = 0 )

Member Function Documentation

◆ areAdjacentCellsLocal()

std::bitset< TwoPowerD > peano4::datamanagement::VertexMarker::areAdjacentCellsLocal ( ) const

Are adjacent cells of selected vertex local.

Correctness

I originally thought I could add the assertion

assertion2( result.all() or isAdjacentToParallelDomainBoundary(), result, toString() );
#define assertion2(expr, param0, param1)
bool isAdjacentToParallelDomainBoundary() const
Is currently selected/analysed vertex adjacent to parallel domain boundary.

However, this assertion fails at the global domain boundary, where some adjacent cells are not local (they are outside) and the vertices nevertheless are not parallel boundary vertices either.

Definition at line 275 of file VertexMarker.cpp.

References dfor2, peano4::utils::dLinearised(), and enddforx.

Here is the call graph for this function:

◆ coincidesWithCoarseGridVertex()

bool peano4::datamanagement::VertexMarker::coincidesWithCoarseGridVertex ( ) const

Does vertex spatially coincide with coarser level's vertex.

The vertex (0,0,0) coincides with a coarse grid vertex, the (3,0,0) does so too, and so forth.

Frequent use case

If you want to program some simply injection, it helps to identify vertices which coincide spatially with vertices on the next coarser level. A classic are codes like

if ( marker.coincidesWithCoarseGridVertex() ) {
tarch::la::Vector<Dimensions,int> parent = marker.getRelativePositionWithinFatherCell() / 3;
coarseGridVerticesX( peano4::utils::dLinearised(parent,2) ).set...
}
CPUGPUMethod int dLinearised(const tarch::la::Vector< Dimensions, int > &counter, int max)
Map d-dimensional vector onto integer index.
Definition Loop.cpp:106
Simple vector class.
Definition Vector.h:134

within touchVertexLastTime. This snippet looks if two vertices coincide spatially. If so, it computes the parent's relative position within the parent cell which is simply a division by 3. We then linearise this vector index and thus have access to the parent.

Definition at line 103 of file VertexMarker.cpp.

◆ getInvokingCellCentre()

tarch::la::Vector< Dimensions, double > peano4::datamanagement::VertexMarker::getInvokingCellCentre ( ) const

Return centre of cell from which this vertex marker is constructed.

Peano runs through the mesh element-wisely. That is, each touchVertexFirstTime() and touchVertexLastTime() is called from a cell. It looks at its \( 2^d \) adjacent vertices and then invokes the vertex events for these vertices if necessary. This routine yields the centre of this cell.

Definition at line 254 of file VertexMarker.cpp.

◆ getInvokingParentCellsCentre()

tarch::la::Vector< Dimensions, double > peano4::datamanagement::VertexMarker::getInvokingParentCellsCentre ( ) const

See getInvokingCellCentre().

This routine gives you the centre of its parent cell.

Definition at line 259 of file VertexMarker.cpp.

References assertion1, and toString().

Here is the call graph for this function:

◆ getNumberOfAdjacentTrees() [1/2]

int peano4::datamanagement::VertexMarker::getNumberOfAdjacentTrees ( ) const

Number of adjacent trees of current vertex.

This routine is valid if and only if you call it for a local, non-hanging vertex. Otherwise, its behaviour is undefined (and will actually trigger an assertion).

Definition at line 202 of file VertexMarker.cpp.

◆ getNumberOfAdjacentTrees() [2/2]

int peano4::datamanagement::VertexMarker::getNumberOfAdjacentTrees ( int i) const

Definition at line 207 of file VertexMarker.cpp.

References assertion1, and toString().

Here is the call graph for this function:

◆ getRelativeAdjacentCell()

tarch::la::Vector< Dimensions, int > peano4::datamanagement::VertexMarker::getRelativeAdjacentCell ( const tarch::la::Vector< Dimensions, double > & x) const

Each vertex is surrounded by \( 2^d \) cells.

In reality, it might be fewer of them, as we might have to deal with a hanging vertex, but logically we can always assume that there were \( 2^d \). Let's assume that they are grouped lexicographically around the vertex, i.e. we have

2 | 3
--+--
0 | 1

cells centred around a central vertex denoted by the plus in this fancy ASCII art. If x falls into the cell 1, this routine would return (1,0). If it falls into cell 3, it would return (1,1).

Definition at line 224 of file VertexMarker.cpp.

◆ getRelativePositionWithinFatherCell() [1/2]

tarch::la::Vector< Dimensions, int > peano4::datamanagement::VertexMarker::getRelativePositionWithinFatherCell ( ) const

Relative position within parent cell.

Return relative position within father cell. The result is from (0,1,2,3)^d and denotes the vertex position within a 3x3 or 3x3x3 respectively mesh.

You can reconstruct the left bottom vertex of the coarser cell through

tarch::la::convertScalar<double>(marker.getRelativePositionWithinFatherCell()),
marker.h()
)
Matrix< Rows, Cols, Scalar > multiplyComponents(const Matrix< Rows, X, Scalar > &lhs, const Matrix< X, Cols, Scalar > &rhs)

If you want to know a particular position of a coarse grid vertex identified through the bitset target, you can do through

marker.x()
-
tarch::la::convertScalar<double>(marker.getRelativePositionWithinFatherCell()),
marker.h()
)
+
3.0*marker.h()
)
See also
coincidesWithCoarseGridVertex()

Definition at line 79 of file VertexMarker.cpp.

◆ getRelativePositionWithinFatherCell() [2/2]

tarch::la::Vector< Dimensions, int > peano4::datamanagement::VertexMarker::getRelativePositionWithinFatherCell ( int i) const

Definition at line 84 of file VertexMarker.cpp.

◆ getSelectedVertexNumber()

int peano4::datamanagement::VertexMarker::getSelectedVertexNumber ( ) const

Information about selected vertex.

Even though you are given a vertex marker for a vertex routine such as touchVertexFirstTime(), Peano behind the scenes invokes this routine from a cell. That is, it enters a cell, then runs over all \( 2^d \) adjacent vertex and puzzles out for each vertex if it has to call touchVertexFirstTime() or not.

getSelectedVertexNumber() tells you which logical number a vertex has within the underlying cell behind the scenes.

The routine is barely used by user codes. Some technical helper routines use the selected number for some arithmetics, but the code indeed might be cleaner if we did hide this routine from the user altogether and make the routine explicitly available only to friends.

Definition at line 161 of file VertexMarker.cpp.

◆ h()

tarch::la::Vector< Dimensions, double > peano4::datamanagement::VertexMarker::h ( ) const

Definition at line 148 of file VertexMarker.cpp.

Referenced by exahypype.kernel::Evaluate(), and exahypype.kernel::halo().

Here is the caller graph for this function:

◆ hasBeenRefined() [1/2]

bool peano4::datamanagement::VertexMarker::hasBeenRefined ( ) const

A vertex is refined iff it is surrounded by \( 2^d \) cells which are refined.

Definition at line 166 of file VertexMarker.cpp.

◆ hasBeenRefined() [2/2]

bool peano4::datamanagement::VertexMarker::hasBeenRefined ( int i) const

Definition at line 171 of file VertexMarker.cpp.

◆ isAdjacentToParallelDomainBoundary() [1/2]

bool peano4::datamanagement::VertexMarker::isAdjacentToParallelDomainBoundary ( ) const

Is currently selected/analysed vertex adjacent to parallel domain boundary.

Definition at line 243 of file VertexMarker.cpp.

◆ isAdjacentToParallelDomainBoundary() [2/2]

bool peano4::datamanagement::VertexMarker::isAdjacentToParallelDomainBoundary ( int i) const

Is one vertex of cell adjacent to parallel domain boundary.

Peano runs through the mesh cell by cell. Within a cell, you can ask if the ith vertex actually is adjacent to a parallel domain boundary.

Definition at line 248 of file VertexMarker.cpp.

References assertion1, and toString().

Here is the call graph for this function:

◆ isContainedInAdjacentCells()

bool peano4::datamanagement::VertexMarker::isContainedInAdjacentCells ( const tarch::la::Vector< Dimensions, double > & x,
double scaleAdjacentCells = 1.0,
double tolerance = tarch::la::NUMERICAL_ZERO_DIFFERENCE ) const

Will return true if x is contained within the adjacent cells.

You can use shrink those cells via the additional parameter if you want.

The geometric operation is defined over the closed interval, i.e. we look into the adjacent cubes to the vertex and their faces still count as "inside". If x is exactly on the face of a cube adjacent to the vertex, we will get back a true. Indeed, the cubes are even slightly bigger due to machine precision.

Definition at line 215 of file VertexMarker.cpp.

References std::abs(), and tarch::la::smallerEquals().

Here is the call graph for this function:

◆ isHanging() [1/2]

bool peano4::datamanagement::VertexMarker::isHanging ( ) const

Definition at line 233 of file VertexMarker.cpp.

◆ isHanging() [2/2]

bool peano4::datamanagement::VertexMarker::isHanging ( int i) const

Definition at line 238 of file VertexMarker.cpp.

◆ isLocal() [1/2]

bool peano4::datamanagement::VertexMarker::isLocal ( ) const
See also
isLocal(int) for currently selected/represented vertex

Definition at line 186 of file VertexMarker.cpp.

◆ isLocal() [2/2]

bool peano4::datamanagement::VertexMarker::isLocal ( int i) const

Is a vertex local, i.e.

not adjacent to any boundary or remote

Definition at line 196 of file VertexMarker.cpp.

◆ isParentCellLocal()

bool peano4::datamanagement::VertexMarker::isParentCellLocal ( ) const

Whenever we touch a vertex the first or the last time, we touch it from a cell: If we touch a vertex the first time, the traversal is just about to enter a cell and sees that one of its vertices is not loaded yet.

When we issue a touchVertexLastTime() event, the traversal is just about to leave a cell.

So there's a cell state associated with any vertex event, and, therefore, we know if the corresponding cell is local and whether its parent cell is local.

See also
isParentVertexLocal()

Definition at line 191 of file VertexMarker.cpp.

◆ isParentLocal()

bool peano4::datamanagement::VertexMarker::isParentLocal ( ) const
private

◆ isParentOfSubtree() [1/2]

bool peano4::datamanagement::VertexMarker::isParentOfSubtree ( ) const

Definition at line 74 of file VertexMarker.cpp.

◆ isParentOfSubtree() [2/2]

bool peano4::datamanagement::VertexMarker::isParentOfSubtree ( int i) const

Definition at line 69 of file VertexMarker.cpp.

◆ isParentVertexLocal()

bool peano4::datamanagement::VertexMarker::isParentVertexLocal ( int i) const

Is the parent vertex local.

Is a parent vertex local, i.e. not adjacent to any boundary or remote. Peano traverses the tree in a strict octant-wise (multiscale-wise) order. That is, whenever you receive a touchVertexFirstTime() or touchVertexLastTime() event, the Peano core has actually entered a cell and recognised "whoops, I haven't used that vertex yet" or "this will be the last time this vertex is available". See the generic event description on an overview of all of these events.

As a logical consequence, there are always \( 2^d \) parent vertices when you encounter a vertex for the first or last time. But you never know which parent cell it will be. The code could have stepped down from A into a or from B into b. So the parent vertices could be the green or the blue ones.

This routine allows you to find out if these vertices are local. It will always return if isParentCellLocal() does not hold.

Definition at line 94 of file VertexMarker.cpp.

References assertion, and TwoPowerD.

◆ select()

peano4::datamanagement::VertexMarker & peano4::datamanagement::VertexMarker::select ( int number)

Picks a vertex within a cell.

After that, the routine returns.

This routine is only called by Peano's internal observer, i.e. the class constructing VertexMarker objects. Users never call this routine.

Definition at line 153 of file VertexMarker.cpp.

References assertion2, toString(), and TwoPowerD.

Here is the call graph for this function:

◆ toString()

std::string peano4::datamanagement::VertexMarker::toString ( ) const

Definition at line 128 of file VertexMarker.cpp.

Referenced by toolbox::particles::tests::TestHelpers::testParticleAssignedToVertexWillBeLocal().

Here is the caller graph for this function:

◆ willBeRefined() [1/2]

bool peano4::datamanagement::VertexMarker::willBeRefined ( ) const

Definition at line 176 of file VertexMarker.cpp.

◆ willBeRefined() [2/2]

bool peano4::datamanagement::VertexMarker::willBeRefined ( int i) const

Definition at line 181 of file VertexMarker.cpp.

◆ x() [1/2]

tarch::la::Vector< Dimensions, double > peano4::datamanagement::VertexMarker::x ( ) const
Returns
Position in space of currently selected vertex.

Definition at line 123 of file VertexMarker.cpp.

◆ x() [2/2]

tarch::la::Vector< Dimensions, double > peano4::datamanagement::VertexMarker::x ( int i) const

We do enumerate the vertices in a lexicographic way, i.e.

we start with the bottom left vertex. Then we run along the first Cartesian axis, then the second, and so forth. This yields a z-pattern for the enumeration.

Returns
Position of ith vertex

Definition at line 112 of file VertexMarker.cpp.

Referenced by toolbox::particles::tests::TestHelpers::testParticleAssignedToVertexWillBeLocal().

Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ toolbox::particles::tests::MultiscaleTransitionsTest

For unit tests.

Definition at line 95 of file VertexMarker.h.

◆ toolbox::particles::tests::TestHelpers

Definition at line 96 of file VertexMarker.h.

Field Documentation

◆ _cellCentre

tarch::la::Vector<Dimensions, double> peano4::datamanagement::VertexMarker::_cellCentre
private

Centre of the underlying cell.

Definition at line 101 of file VertexMarker.h.

Referenced by toolbox::particles::tests::TestHelpers::testParticleAssignedToVertexWillBeLocal().

◆ _h

tarch::la::Vector<Dimensions, double> peano4::datamanagement::VertexMarker::_h
private

Size of the underlying cell.

Definition at line 106 of file VertexMarker.h.

Referenced by toolbox::particles::tests::TestHelpers::testParticleAssignedToVertexWillBeLocal().

◆ _hasBeenRefined

std::bitset<TwoPowerD> peano4::datamanagement::VertexMarker::_hasBeenRefined
private

◆ _isAdjacentCellLocal

std::bitset<ThreePowerD> peano4::datamanagement::VertexMarker::_isAdjacentCellLocal
private

◆ _isAdjacentToParallelDomainBoundary

std::bitset<TwoPowerD> peano4::datamanagement::VertexMarker::_isAdjacentToParallelDomainBoundary
private

Definition at line 122 of file VertexMarker.h.

◆ _isHanging

std::bitset<TwoPowerD> peano4::datamanagement::VertexMarker::_isHanging
private

◆ _isLocal

std::bitset<TwoPowerD> peano4::datamanagement::VertexMarker::_isLocal
private

◆ _isParentCellLocal

bool peano4::datamanagement::VertexMarker::_isParentCellLocal
private

Definition at line 118 of file VertexMarker.h.

◆ _isParentOfSubtree

std::bitset<TwoPowerD> peano4::datamanagement::VertexMarker::_isParentOfSubtree
private

Definition at line 116 of file VertexMarker.h.

◆ _isParentVertexLocal

std::bitset<TwoPowerD> peano4::datamanagement::VertexMarker::_isParentVertexLocal
private

Definition at line 114 of file VertexMarker.h.

◆ _numberOfAdjacentTrees

tarch::la::Vector<TwoPowerD,int> peano4::datamanagement::VertexMarker::_numberOfAdjacentTrees
private

Number of adjacent trees per vertex.

Obviously only relevant/valid if the vertex is local.

Definition at line 133 of file VertexMarker.h.

◆ _relativePositionOfCellWithinFatherCell

tarch::la::Vector<Dimensions, int> peano4::datamanagement::VertexMarker::_relativePositionOfCellWithinFatherCell
private

Entries from (0,1,2).

(0,0) or (0,0,0) is the left, bottom cell.

Definition at line 127 of file VertexMarker.h.

◆ _select

int peano4::datamanagement::VertexMarker::_select
private

◆ _willBeRefined

std::bitset<TwoPowerD> peano4::datamanagement::VertexMarker::_willBeRefined
private

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