waLBerla 7.3
Loading...
Searching...
No Matches
walberla::stencil::$name Struct Reference

Detailed Description

Defines a D-dimensional stencil info with Q directions.

A stencil is defined by picking a subset of all possible directions. These directions are listed in the dir array. So when iterating a stencil, one iterates the dir array which contains the directions. To get the properties for these directions, the global arrays of Directions.h can be used:

using namespace stencil;
for( uint_t i = 0; i < $name::Size; ++i )
{
int cx = cx[ $name::dir[i] ];
Direction inverse = inverseDir[ $name::dir[i] ];
}
Definition AABBQuadrant.h:29
constexpr std::array< int, NR_OF_DIRECTIONS > cx
The x component for each direction.
Definition Directions.h:110
Direction
Definition Directions.h:39
constexpr std::array< Direction, NR_OF_DIRECTIONS > inverseDir
Inverse directions.
Definition Directions.h:216
std::size_t uint_t
Definition DataTypes.h:161
static constexpr std::array< Direction, $Q > dir
Set of directions.
Definition Stencil.in.h:68
static constexpr uint_t Size
Definition Stencil.in.h:60

Since all these arrays are constant, the lookup can be resolved at compile time and no performance overhead should be generated.

For more convenient iteration, use the provided iterator. The following code is equivalent to the code example above:

using namespace stencil;
for( auto dir = $name::begin(); dir != $name::end(); ++dir )
{
int cx = dir.cx();
Direction inverse = dir.inverseDir();
}
static constexpr iterator end()
Definition Stencil.in.h:147
static constexpr iterator begin()
Definition Stencil.in.h:145

#include <Stencil.in.h>

Iteration

using iterator = stencil::Iterator< $name >
static constexpr iterator begin ()
static constexpr iterator beginNoCenter ()
static constexpr iterator end ()

Member Variables

static constexpr std::string_view NAME = "$name"
static constexpr uint_t D = $D
static constexpr uint_t Q = $Q
static constexpr uint_t POS_Q = $Q / 2
static constexpr uint_t Dimension = $D
static constexpr uint_t Size = $Q
static constexpr bool containsCenter = $containsCenter
static constexpr uint_t noCenterFirstIdx = $noCenterFirstIndex
static constexpr std::array< Direction, $Qdir = { $dirs }
 Set of directions.
static constexpr std::array< Direction, POS_Qdir_pos = { $dir_pos }
 Contains only half of the directions ( the positive ones ).
static constexpr std::array< uint_t, NR_OF_DIRECTIONSidx = { $indexFromDir }
 Maps direction enums, to an index.
static constexpr std::array< std::array< Direction, $Q/2 >, NR_OF_DIRECTIONSd_per_d { { $d_per_d } }
 Maps a direction to a set of sub-directions.
static constexpr std::array< uint_t, NR_OF_DIRECTIONSd_per_d_length { $d_per_d_length }
 Length of the d_per_d array For usage see documentation of d_per_d.
static constexpr size_t subdirsLength { $subdirs_length }
static constexpr std::array< Direction, $subdirs_length > subdirs { $subdirs }
static constexpr std::array< size_t, NR_OF_DIRECTIONS+1 > subdirsPtr { $subdirsPtr }
static constexpr std::array< std::array< Direction, NR_OF_DIRECTIONS >, NR_OF_DIRECTIONSdir_neighbors { { $dir_neighbors } }
 Views directions as cells in a 3x3x3 grid.
static constexpr std::array< uint_t, NR_OF_DIRECTIONSdir_neighbors_length { $dir_neighbors_length }
 Length of the dir_neighbors array For usage see documentation of dir_neighbors.
static constexpr bool containsDir (Direction d)
static constexpr uint_t invDirIdx (Direction d)

Member Typedef Documentation

◆ iterator

Member Function Documentation

◆ begin()

constexpr iterator walberla::stencil::$name::begin ( )
inlinestaticconstexpr

◆ beginNoCenter()

constexpr iterator walberla::stencil::$name::beginNoCenter ( )
inlinestaticconstexpr

◆ containsDir()

constexpr bool walberla::stencil::$name::containsDir ( Direction d)
inlinestaticconstexpr

◆ end()

constexpr iterator walberla::stencil::$name::end ( )
inlinestaticconstexpr

◆ invDirIdx()

constexpr uint_t walberla::stencil::$name::invDirIdx ( Direction d)
inlinestaticconstexpr

Member Data Documentation

◆ containsCenter

bool walberla::stencil::$name::containsCenter = $containsCenter
staticconstexpr

◆ D

uint_t walberla::stencil::$name::D = $D
staticconstexpr

◆ d_per_d

std::array< std::array< Direction, $Q / 2 >, NR_OF_DIRECTIONS > walberla::stencil::$name::d_per_d { { $d_per_d } }
staticconstexpr

Maps a direction to a set of sub-directions.

A sub-direction is defined as a direction that contains the letters of the original direction i.e. SW is a sub-direction of S and W. the following code shows how to iterate over all sub-directions, that are contained in the stencil of W

template<typename Stencil>
//...
for (int i=0; i < Stencil::d_per_d_length[dir]; ++i)
stencil::Direction subDirection = Stencil::d_per_d[dir][i];
@ W
West.
Definition Directions.h:43

◆ d_per_d_length

std::array< uint_t, NR_OF_DIRECTIONS > walberla::stencil::$name::d_per_d_length { $d_per_d_length }
staticconstexpr

Length of the d_per_d array For usage see documentation of d_per_d.

◆ Dimension

uint_t walberla::stencil::$name::Dimension = $D
staticconstexpr

◆ dir

std::array< Direction, $Q > walberla::stencil::$name::dir = { $dirs }
staticconstexpr

Set of directions.

◆ dir_neighbors

std::array< std::array< Direction, NR_OF_DIRECTIONS >, NR_OF_DIRECTIONS > walberla::stencil::$name::dir_neighbors { { $dir_neighbors } }
staticconstexpr

Views directions as cells in a 3x3x3 grid.

Describes neighborhood between cells/directions.

Basis a 3x3x3 grid where every cell corresponds to a direction. The following array provides answer to the question: What are the neighboring cells of a given cell using the current stencil. If a neighbor is not in this 3x3x3 grid it can not be described by a direction and is not returned. Therefore N , for example, has more neighbors that NW. By definition, the neighbors of C are identical to the dir[] array without C itself.

◆ dir_neighbors_length

std::array< uint_t, NR_OF_DIRECTIONS > walberla::stencil::$name::dir_neighbors_length { $dir_neighbors_length }
staticconstexpr

Length of the dir_neighbors array For usage see documentation of dir_neighbors.

◆ dir_pos

std::array< Direction, POS_Q > walberla::stencil::$name::dir_pos = { $dir_pos }
staticconstexpr

Contains only half of the directions ( the positive ones ).

Use this f.e. in situations where direction have to be handled pairwise, the direction together with its inverse direction.

◆ idx

std::array< uint_t, NR_OF_DIRECTIONS > walberla::stencil::$name::idx = { $indexFromDir }
staticconstexpr

Maps direction enums, to an index.

Use this when working with fields: The direction enum cannot be used as field index directly. Consider having a D2Q4 stencil, then the fourth field index f ranges from 0 to 3, but the direction enums are S=1,N=2,E=3,W=4 start at 1. So a stencil class is needed to map back from direction to field index

◆ NAME

std::string_view walberla::stencil::$name::NAME = "$name"
staticconstexpr

◆ noCenterFirstIdx

uint_t walberla::stencil::$name::noCenterFirstIdx = $noCenterFirstIndex
staticconstexpr

◆ POS_Q

uint_t walberla::stencil::$name::POS_Q = $Q / 2
staticconstexpr

◆ Q

uint_t walberla::stencil::$name::Q = $Q
staticconstexpr

◆ Size

uint_t walberla::stencil::$name::Size = $Q
staticconstexpr

◆ subdirs

std::array< Direction, $subdirs_length > walberla::stencil::$name::subdirs { $subdirs }
staticconstexpr

◆ subdirsLength

size_t walberla::stencil::$name::subdirsLength { $subdirs_length }
staticconstexpr

◆ subdirsPtr

std::array< size_t, NR_OF_DIRECTIONS + 1 > walberla::stencil::$name::subdirsPtr { $subdirsPtr }
staticconstexpr

The documentation for this struct was generated from the following file:
  • /builds/administration/walberla-website/walberla/src/stencil/Stencil.in.h