tem_stencil_module Module

Stencil definitions for the elements

A stencil is basically a set of element-offsets $(s_x, s_y, s_z)$, describing the relative positions of all required elements for a given element.

There is an example in the Documentation named 'Example for the stencil construction'.

Variables

TypeVisibilityAttributesNameInitial
integer, public, parameter:: d3q19_cxDir(3,19) =reshape([-1, 0, 0, 0, -1, 0, 0, 0, -1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, -1, 0, -1, 1, 0, 1, -1, 0, 1, 1, -1, 0, -1, 1, 0, -1, -1, 0, 1, 1, 0, 1, -1, -1, 0, -1, 1, 0, 1, -1, 0, 1, 1, 0, 0, 0, 0], [3, 19])
integer, public, parameter:: d3q27_cxDir(3,27) =reshape([-1, 0, 0, 0, -1, 0, 0, 0, -1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, -1, 0, -1, 1, 0, 1, -1, 0, 1, 1, -1, 0, -1, 1, 0, -1, -1, 0, 1, 1, 0, 1, -1, -1, 0, -1, 1, 0, 1, -1, 0, 1, 1, 0, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 0, 0, 0], [3, 27])
integer, public, parameter:: d3q7_cxDir(3,7) =reshape([-1, 0, 0, 0, -1, 0, 0, 0, -1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0], [3, 7])
integer, public, parameter:: d3q6_cxDir(3,6) =reshape([-1, 0, 0, 0, -1, 0, 0, 0, -1, 1, 0, 0, 0, 1, 0, 0, 0, 1], [3, 6])
integer, public, parameter:: d2q9_cxDir(3,9) =reshape([-1, 0, 0, 0, -1, 0, 1, 0, 0, 0, 1, 0, -1, -1, 0, -1, 1, 0, 1, -1, 0, 1, 1, 0, 0, 0, 0], [3, 9])
integer, public, parameter:: d2q5_cxDir(3,5) =reshape([-1, 0, 0, 0, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0], [3, 5])
integer, public, parameter:: d2q4_cxDir(3,4) =reshape([-1, 0, 0, 0, -1, 0, 1, 0, 0, 0, 1, 0], [3, 4])
integer, public, parameter:: d1q3_cxDir(3,3) =reshape([-1, 0, 0, 1, 0, 0, 0, 0, 0], [3, 3])
integer, public, parameter:: d1q2_cxDir(3,2) =reshape([-1, 0, 0, 1, 0, 0], [3, 2])
integer, private, parameter:: d3q13_cxDir(3,13) =reshape([0, -1, -1, 0, -1, 1, 0, 1, -1, 0, 1, 1, -1, 0, -1, 1, 0, -1, -1, 0, 1, 1, 0, 1, -1, -1, 0, -1, 1, 0, 1, -1, 0, 1, 1, 0, 0, 0, 0], [3, 13])

Interfaces

public interface init

initialize the dynamic array

• private subroutine init_ga_stencilelement(me, length)

Include the subroutines for the growing array.

Arguments

TypeIntentOptionalAttributesName
type(grw_stencilelementarray_type), intent(out) :: me
integer, intent(in), optional :: length

public interface truncate

truncate the array, meaning cut off the trailing empty entries

• private subroutine truncate_ga_stencilelement(me)

Arguments

TypeIntentOptionalAttributesName
type(grw_stencilelementarray_type) :: me

public interface empty

empty the entries without changing arrays

• private subroutine empty_ga_stencilelement(me)

Arguments

TypeIntentOptionalAttributesName
type(grw_stencilelementarray_type) :: me

public interface destroy

destroy the dynamic array

• private subroutine destroy_ga_stencilelement(me)

Arguments

TypeIntentOptionalAttributesName
type(grw_stencilelementarray_type), intent(inout) :: me

public interface placeat

insert an element at a given position

• private subroutine placeat_ga_stencilelement(me, val, pos, length)

adds the value to a given position inside the growing array.

Arguments

TypeIntentOptionalAttributesName
type(grw_stencilelementarray_type) :: me
type(tem_stencilElement_type), intent(in) :: val
integer, intent(in) :: pos
integer, intent(in), optional :: length

optional length to expand the array

• private subroutine placeat_ga_stencilelement_vec(me, val, pos, length)

adds the values starting from a given position inside the growing array.

Arguments

TypeIntentOptionalAttributesName
type(grw_stencilelementarray_type) :: me
type(tem_stencilElement_type), intent(in) :: val(:)
integer, intent(in) :: pos
integer, intent(in), optional :: length

optional length to expand the array

public interface append

append a value to the dynamic array and return its position.

• private subroutine append_ga_stencilelement(me, val, length)

Arguments

TypeIntentOptionalAttributesName
type(grw_stencilelementarray_type) :: me
type(tem_stencilElement_type), intent(in) :: val
integer, intent(in), optional :: length

optional length to expand the array

• private subroutine append_ga_stencilelement_vec(me, val, length)

Arguments

TypeIntentOptionalAttributesName
type(grw_stencilelementarray_type) :: me
type(tem_stencilElement_type), intent(in) :: val(:)
integer, intent(in), optional :: length

optional length to expand the array

public interface expand

increase the size of the container for the array.

• private subroutine expand_ga_stencilelement(me, pos, length)

Arguments

TypeIntentOptionalAttributesName
type(grw_stencilelementarray_type) :: me
integer, intent(in), optional :: pos
integer, intent(in), optional :: length

optional length to expand the array

public interface tem_stencil_dump

Write element information to disk

Arguments

TypeIntentOptionalAttributesName

integer, intent(in), optional :: nUnit
• private subroutine tem_stencilElement_dump(me, nUnit, neighID, tIDonly)

Write element information to disk

Arguments

TypeIntentOptionalAttributesName
type(tem_stencilElement_type), intent(in) :: me

stencil element to be dumped

integer, intent(in) :: nUnit

unit to dump to

integer(kind=long_k), intent(in), optional allocatable:: neighID(:)

neighbor ID

logical, intent(in), optional :: tIDonly

only use tree IDs

private interface init

initialize the dynamic array

Arguments

TypeIntentOptionalAttributesName
integer, intent(in), optional :: length

private interface truncate

truncate the array, meaning cut off the trailing empty entries

Arguments

TypeIntentOptionalAttributesName

private interface empty

empty the entries without changing arrays

Arguments

TypeIntentOptionalAttributesName

private interface destroy

destroy the dynamic array

Arguments

TypeIntentOptionalAttributesName

private interface placeat

insert an element at a given position

• private subroutine placeat_ga_stencilheader(me, val, pos, length)

adds the value to a given position inside the growing array.

Arguments

TypeIntentOptionalAttributesName
integer, intent(in) :: pos
integer, intent(in), optional :: length

optional length to expand the array

• private subroutine placeat_ga_stencilheader_vec(me, val, pos, length)

adds the values starting from a given position inside the growing array.

Arguments

TypeIntentOptionalAttributesName
integer, intent(in) :: pos
integer, intent(in), optional :: length

optional length to expand the array

private interface append

append a value to the dynamic array and return its position.

• private subroutine append_ga_stencilheader(me, val, length)

Arguments

TypeIntentOptionalAttributesName
integer, intent(in), optional :: length

optional length to expand the array

• private subroutine append_ga_stencilheader_vec(me, val, length)

Arguments

TypeIntentOptionalAttributesName
integer, intent(in), optional :: length

optional length to expand the array

private interface expand

increase the size of the container for the array.

• private subroutine expand_ga_stencilheader(me, pos, length)

Arguments

TypeIntentOptionalAttributesName
integer, intent(in), optional :: pos
integer, intent(in), optional :: length

optional length to expand the array

• private subroutine init_stencilHeader(me, QQN, QQ, nElems, useAll, nDims, label, cxDir)

initialize stencil

Arguments

TypeIntentOptionalAttributesName

integer, intent(in) :: QQN

number of discrete velocities in the model (without the center one)

integer, intent(in), optional :: QQ

number of discrete velocities in the model (incl. the center one)

integer, intent(in), optional :: nElems

The number of elements to use this stencil for

logical, intent(in), optional :: useAll

use this stencil for all elements?

integer, intent(in), optional :: nDims
character(len=*), intent(in), optional :: label
integer, intent(in), optional :: cxDir(:,:)
• private subroutine init_stencilElement(me, QQN, headerPos, tIDpos)

initialize stencil

Arguments

TypeIntentOptionalAttributesName
type(tem_stencilElement_type), intent(out) :: me

stencil element type to be initialized

integer, intent(in) :: QQN

number of discrete velocities in the model (without the center one)

integer, intent(in), optional :: tIDpos(:)

• private subroutine empty_stencil(me)

Delete all entries in the stencil

Arguments

TypeIntentOptionalAttributesName

• private subroutine destroy_stencilElement(me)

destroy stencil

Arguments

TypeIntentOptionalAttributesName
type(tem_stencilElement_type), intent(out) :: me

stencil element type to be destroyed

• private subroutine empty_stencil(me)

Delete all entries in the stencil

Arguments

TypeIntentOptionalAttributesName

• private subroutine copy_stencilElement(left, right)

This function provides copy assigment for tem_stencilElement_type

Arguments

TypeIntentOptionalAttributesName
type(tem_stencilElement_type), intent(out) :: left

tem_stencilElement to copy to

type(tem_stencilElement_type), intent(in) :: right

tem_stencilElement to copy from

This function provides copy assigment for tem_stencilHeader_type

Arguments

TypeIntentOptionalAttributesName

Derived Types

Stencil definitions

Components

TypeVisibilityAttributesNameInitial
character(len=labelLen), private :: label

a stencil label

integer, private :: QQ

number of directions

integer, private :: QQN

integer, private :: nDims =0
integer, private, allocatable:: cxDir(:,:)

cartesian directions of discrete velocities. Integer number version. Size is (3,nDir)

real(kind=rk), private, allocatable:: cxDirRK(:,:)

Cartesian directions of discrete velocities. Real number version. Size is (3,nDir)

integer, private, allocatable:: cxDirInv(:)

inverted cartesian direction indices. this is well defined for symmetric stencils only.

real(kind=rk), private, allocatable:: cxcx(:,:)

2nd order tensor of discrete velocities Size is (6,QQ) for 3D: xx, yy, zz, xy, yz, xz (3,QQ) for 2D: xx, yy, xy (1,QQ) for 1D: xx

integer, private, allocatable:: map(:)

mapping of stencil entries to treelm definition, if possible entry is zero if nothing defined,

integer, private, allocatable:: map2treeDef(:)

mapping of treelm definition to stencil entries, if possible entry is zero if nothing defined

integer, private :: restPosition

Rest-density position in stencil

integer, private :: depStencil

the stencil on which the current one depends this is required for boundary stencils which elements actually require the neighbors of the compute stencil

logical, private :: useAll

use this stencil for all elements

logical, private :: requireNeighNeigh =.false.

requires valid neighbors of the stencil neighbors

logical, private :: requireAll =.false.

requires valid neighbors of the stencil neighbors

integer, private :: nElems

the number of elements using this stencil

type(grw_intarray_type), private, allocatable:: elemLvl(:)

list of elements on which this stencil should be applied Both elemLvl and elem array are used for stencil other than fluid stencil

type(grw_intarray_type), private :: elem

list of elements on which this stencil should be applied In build_BCstencil they point to original treeID list and used in tem_initelemLevels. Later this position is updated such that they point to the level wise total list in update_elemPosToTotalPos.

type, public :: tem_stencilElement_type

Element stencil definition

Components

TypeVisibilityAttributesNameInitial
integer, private :: QQN

number of entries in pos

integer, private, allocatable:: tIDpos(:)

position in the tem_element_type::neighID%val( elemPos ) Array size: QQN

the stencil on which the current one depends this is required for boundary stencils which elements actually require the neighbors of the compute stencil

integer, private, allocatable:: totalPos(:)

pointer to tem_element_type::tID( ) For neighbor of an element in every stencil direction. It also inclues neighbor which is either fluid/halo/ghost. Array size: QQN Set in routine: build_levelElements, identify_stencilNeigh, identify_additionalNeigh

type, public :: grw_stencilelementarray_type

growing array type for type(tem_stencilelement_type)

Components

TypeVisibilityAttributesNameInitial
integer, private :: nvals =0
integer, private :: containersize =0
type(tem_stencilElement_type), private, allocatable:: val(:)

Components

TypeVisibilityAttributesNameInitial
integer, private :: nvals =0
integer, private :: containersize =0

Functions

public pure function tem_stencil_findIndexOfDir(findDir, cxDir) result(idx)

Find the index of the given direction in the list of all directions. -1 if not found.

Arguments

TypeIntentOptionalAttributesName
integer, intent(in) :: findDir(3)

vector index to find in cxDir

integer, intent(in) :: cxDir(:,:)

array of vectors

public pure function d3q125_cxDir() result(cxDir)

Definition of the d3q125 neighborhood

None

public pure function d3q81_cxDir() result(cxDir)

Definition of the d3q81 neighborhood.

None

public function tem_stencil_zeroPos(me) result(pos)

Identify the zero-position in the stencil Return -1 if not found in stencil

Arguments

TypeIntentOptionalAttributesName

stencil to map

Return Value integer

Position of zero-entry in the stencil

find position stencil

Arguments

TypeIntentOptionalAttributesName
type(grw_stencilelementarray_type), intent(in) :: me

List of element stencil definitions

integer, intent(in) :: val

Stencil to search for

public function tem_stencil_getLabelForcxDir(me, prevailDir) result(uLabel)

This function returns a unique label for given stencil cxDir

Arguments

TypeIntentOptionalAttributesName

stencil

real(kind=rk), intent(in) :: prevailDir(:,:)

prevail directions

Return Value character(len=labelLen)

return unique label

Subroutines

Load the stencil configuration from the lua file

Arguments

TypeIntentOptionalAttributesName

stencil type to fill

integer, intent(in) :: parent_handle

handle of the parent table

type(flu_State) :: conf

lua state type

public subroutine tem_identify_inverseDirections(me, cxDir)

This subroutine fills the array of inverse directions according to the given array of directions.

Arguments

TypeIntentOptionalAttributesName
integer, intent(out) :: me(:)

array of positions of the inverse offsets in cxDir

integer, intent(in) :: cxDir(:,:)

array of given offsets

public subroutine tem_identify_prevailDirections(me, cxDir)

This subroutine fills the array of prevailing directions according to the given array of directions.

Arguments

TypeIntentOptionalAttributesName
real(kind=rk), intent(out), allocatable:: me(:,:)

growing array of prevailing directions

integer, intent(in) :: cxDir(:,:)

array of given offsets

public subroutine tem_stencil_map_toTreelmDef(me)

Map the stencil offsets to the internally defined treelm offsets.

Arguments

TypeIntentOptionalAttributesName

stencil to map

public subroutine tem_treelmDef_map_toStencil(me)

Map the internally defined treelm offsets to the stencil offsets.

Arguments

TypeIntentOptionalAttributesName

stencil to map

public subroutine tem_create_stencil(stencil, stencilKind)

This subroutine creates the required stencil.

Arguments

TypeIntentOptionalAttributesName

stencil type to be defined

character(len=*) :: stencilKind

stencil kind to decide which create function to call

private subroutine init_ga_stencilelement(me, length)

Include the subroutines for the growing array.

Arguments

TypeIntentOptionalAttributesName
type(grw_stencilelementarray_type), intent(out) :: me
integer, intent(in), optional :: length

private subroutine destroy_ga_stencilelement(me)

Arguments

TypeIntentOptionalAttributesName
type(grw_stencilelementarray_type), intent(inout) :: me

private subroutine truncate_ga_stencilelement(me)

Arguments

TypeIntentOptionalAttributesName
type(grw_stencilelementarray_type) :: me

private subroutine empty_ga_stencilelement(me)

Arguments

TypeIntentOptionalAttributesName
type(grw_stencilelementarray_type) :: me

private subroutine placeat_ga_stencilelement(me, val, pos, length)

adds the value to a given position inside the growing array.

Arguments

TypeIntentOptionalAttributesName
type(grw_stencilelementarray_type) :: me
type(tem_stencilElement_type), intent(in) :: val
integer, intent(in) :: pos
integer, intent(in), optional :: length

optional length to expand the array

private subroutine placeat_ga_stencilelement_vec(me, val, pos, length)

adds the values starting from a given position inside the growing array.

Arguments

TypeIntentOptionalAttributesName
type(grw_stencilelementarray_type) :: me
type(tem_stencilElement_type), intent(in) :: val(:)
integer, intent(in) :: pos
integer, intent(in), optional :: length

optional length to expand the array

private subroutine append_ga_stencilelement(me, val, length)

Arguments

TypeIntentOptionalAttributesName
type(grw_stencilelementarray_type) :: me
type(tem_stencilElement_type), intent(in) :: val
integer, intent(in), optional :: length

optional length to expand the array

private subroutine append_ga_stencilelement_vec(me, val, length)

Arguments

TypeIntentOptionalAttributesName
type(grw_stencilelementarray_type) :: me
type(tem_stencilElement_type), intent(in) :: val(:)
integer, intent(in), optional :: length

optional length to expand the array

private subroutine expand_ga_stencilelement(me, pos, length)

Arguments

TypeIntentOptionalAttributesName
type(grw_stencilelementarray_type) :: me
integer, intent(in), optional :: pos
integer, intent(in), optional :: length

optional length to expand the array

Arguments

TypeIntentOptionalAttributesName
integer, intent(in), optional :: length

Arguments

TypeIntentOptionalAttributesName

Arguments

TypeIntentOptionalAttributesName

Arguments

TypeIntentOptionalAttributesName

private subroutine placeat_ga_stencilheader(me, val, pos, length)

adds the value to a given position inside the growing array.

Arguments

TypeIntentOptionalAttributesName
integer, intent(in) :: pos
integer, intent(in), optional :: length

optional length to expand the array

private subroutine placeat_ga_stencilheader_vec(me, val, pos, length)

adds the values starting from a given position inside the growing array.

Arguments

TypeIntentOptionalAttributesName
integer, intent(in) :: pos
integer, intent(in), optional :: length

optional length to expand the array

Arguments

TypeIntentOptionalAttributesName
integer, intent(in), optional :: length

optional length to expand the array

Arguments

TypeIntentOptionalAttributesName
integer, intent(in), optional :: length

optional length to expand the array

Arguments

TypeIntentOptionalAttributesName
integer, intent(in), optional :: pos
integer, intent(in), optional :: length

optional length to expand the array

private subroutine empty_stencil(me)

Delete all entries in the stencil

Arguments

TypeIntentOptionalAttributesName

Write element information to disk

Arguments

TypeIntentOptionalAttributesName

integer, intent(in), optional :: nUnit

private subroutine tem_stencilElement_dump(me, nUnit, neighID, tIDonly)

Write element information to disk

Arguments

TypeIntentOptionalAttributesName
type(tem_stencilElement_type), intent(in) :: me

stencil element to be dumped

integer, intent(in) :: nUnit

unit to dump to

integer(kind=long_k), intent(in), optional allocatable:: neighID(:)

neighbor ID

logical, intent(in), optional :: tIDonly

only use tree IDs

private subroutine init_stencilHeader(me, QQN, QQ, nElems, useAll, nDims, label, cxDir)

initialize stencil

Arguments

TypeIntentOptionalAttributesName

integer, intent(in) :: QQN

number of discrete velocities in the model (without the center one)

integer, intent(in), optional :: QQ

number of discrete velocities in the model (incl. the center one)

integer, intent(in), optional :: nElems

The number of elements to use this stencil for

logical, intent(in), optional :: useAll

use this stencil for all elements?

integer, intent(in), optional :: nDims
character(len=*), intent(in), optional :: label
integer, intent(in), optional :: cxDir(:,:)

private subroutine init_stencilElement(me, QQN, headerPos, tIDpos)

initialize stencil

Arguments

TypeIntentOptionalAttributesName
type(tem_stencilElement_type), intent(out) :: me

stencil element type to be initialized

integer, intent(in) :: QQN

number of discrete velocities in the model (without the center one)

integer, intent(in), optional :: tIDpos(:)

private subroutine destroy_stencilElement(me)

destroy stencil

Arguments

TypeIntentOptionalAttributesName
type(tem_stencilElement_type), intent(out) :: me

stencil element type to be destroyed

private subroutine tem_stencil_createCxcx(me)

Create cxcx for a given stencil

Arguments

TypeIntentOptionalAttributesName

stencil

This function provides copy assigment for tem_stencilHeader_type

Arguments

TypeIntentOptionalAttributesName

private subroutine copy_stencilElement(left, right)

This function provides copy assigment for tem_stencilElement_type

Arguments

TypeIntentOptionalAttributesName
type(tem_stencilElement_type), intent(out) :: left

tem_stencilElement to copy to

type(tem_stencilElement_type), intent(in) :: right

tem_stencilElement to copy from