walberla::stencil::internal::$name< Dummy > Struct Template Reference

Detailed Description

template<typename Dummy = int>
struct walberla::stencil::internal::$name< Dummy >

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] ];
}

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();
}

#include <Stencil.in.h>

Member Variables

static const char * NAME = "$name"
 
static const uint_t D = $D
 
static const uint_t Q = $Q
 
static const uint_t POS_Q = $Q / 2
 
static const uint_t Dimension = $D
 
static const uint_t Size = $Q
 
static const bool containsCenter = $containsCenter
 
static const uint_t noCenterFirstIdx = $noCenterFirstIndex
 
static const Direction dir [$Q] = { $dirs }
 Subset of directions. Defines the stencil. More...
 
static const Direction dir_pos [POS_Q] = { $dir_pos }
 Contains only half of the directions ( the positive ones ) More...
 
static const uint_t idx [NR_OF_DIRECTIONS] = { $indexFromDir }
 Maps direction enums, to an index. More...
 
static const Direction d_per_d [NR_OF_DIRECTIONS][$Q/2] = { $d_per_d }
 Maps a direction to a set of sub-directions. More...
 
static const uint_t d_per_d_length [NR_OF_DIRECTIONS] = { $d_per_d_length }
 Length of the d_per_d array For usage see documentation of d_per_d. More...
 
static const Direction dir_neighbors [NR_OF_DIRECTIONS][NR_OF_DIRECTIONS] = { $dir_neighbors }
 Views directions as cells in a 3x3x3 grid. More...
 
static const uint_t dir_neighbors_length [NR_OF_DIRECTIONS] = { $dir_neighbors_length }
 Length of the dir_neighbors array For usage see documentation of dir_neighbors. More...
 
static bool containsDir (Direction d)
 
static uint_t invDirIdx (Direction d)
 

Iteration

typedef stencil::Iterator< $name > iterator
 
static iterator begin ()
 
static iterator beginNoCenter ()
 
static iterator end ()
 

Member Typedef Documentation

◆ iterator

template<typename Dummy = int>
typedef stencil::Iterator<$name> walberla::stencil::internal::$name< Dummy >::iterator

Member Function Documentation

◆ begin()

template<typename Dummy = int>
static iterator walberla::stencil::internal::$name< Dummy >::begin ( )
inlinestatic

◆ beginNoCenter()

template<typename Dummy = int>
static iterator walberla::stencil::internal::$name< Dummy >::beginNoCenter ( )
inlinestatic

◆ containsDir()

template<typename Dummy = int>
static bool walberla::stencil::internal::$name< Dummy >::containsDir ( Direction  d)
inlinestatic

◆ end()

template<typename Dummy = int>
static iterator walberla::stencil::internal::$name< Dummy >::end ( )
inlinestatic

◆ invDirIdx()

template<typename Dummy = int>
static uint_t walberla::stencil::internal::$name< Dummy >::invDirIdx ( Direction  d)
inlinestatic

Member Data Documentation

◆ containsCenter

template<typename Dummy >
const bool walberla::stencil::internal::$name< Dummy >::containsCenter = $containsCenter
static

◆ D

template<typename Dummy >
const uint_t walberla::stencil::internal::$name< Dummy >::D = $D
static

◆ d_per_d

template<typename Dummy >
const Direction walberla::stencil::internal::$name< Dummy >::d_per_d = { $d_per_d }
static

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];

◆ d_per_d_length

template<typename Dummy >
const uint_t walberla::stencil::internal::$name< Dummy >::d_per_d_length = { $d_per_d_length }
static

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

◆ Dimension

template<typename Dummy >
const uint_t walberla::stencil::internal::$name< Dummy >::Dimension = $D
static

◆ dir

template<typename Dummy >
const Direction walberla::stencil::internal::$name< Dummy >::dir = { $dirs }
static

Subset of directions. Defines the stencil.

◆ dir_neighbors

template<typename Dummy >
const Direction walberla::stencil::internal::$name< Dummy >::dir_neighbors = { $dir_neighbors }
static

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

template<typename Dummy >
const uint_t walberla::stencil::internal::$name< Dummy >::dir_neighbors_length = { $dir_neighbors_length }
static

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

◆ dir_pos

template<typename Dummy >
const Direction walberla::stencil::internal::$name< Dummy >::dir_pos = { $dir_pos }
static

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

template<typename Dummy >
const uint_t walberla::stencil::internal::$name< Dummy >::idx = { $indexFromDir }
static

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

template<typename Dummy >
const char * walberla::stencil::internal::$name< Dummy >::NAME = "$name"
static

◆ noCenterFirstIdx

template<typename Dummy >
const uint_t walberla::stencil::internal::$name< Dummy >::noCenterFirstIdx = $noCenterFirstIndex
static

◆ POS_Q

template<typename Dummy >
const uint_t walberla::stencil::internal::$name< Dummy >::POS_Q = $Q / 2
static

◆ Q

template<typename Dummy >
const uint_t walberla::stencil::internal::$name< Dummy >::Q = $Q
static

◆ Size

template<typename Dummy >
const uint_t walberla::stencil::internal::$name< Dummy >::Size = $Q
static

The documentation for this struct was generated from the following file:
const Direction inverseDir[NR_OF_DIRECTIONS]
Inverse directions.
Definition: Directions.h:180
const int cx[NR_OF_DIRECTIONS]
The x component for each direction.
Definition: Directions.h:107
static const Direction dir[$Q]
Subset of directions. Defines the stencil.
Definition: Stencil.in.h:67
static iterator end()
Definition: Stencil.in.h:90
Direction
Definition: Directions.h:35
std::size_t uint_t
Definition: DataTypes.h:133
@ W
West.
Definition: Directions.h:47
static const uint_t Size
Definition: Stencil.in.h:62
static iterator begin()
Definition: Stencil.in.h:88