scheme_layout module, providing the scheme_layout datatype and the functionality to read the lua files and to set the predefined stencils.
# Scheme Layout
The layout includes all information about the stencil, the inverse directions, the prevailing directions and the weights.
In MUSUBI one can choose among the following predefined layouts:
In MUSUBI it is also possible to define a new layout in the lua file. This feature is implemented to test new layouts. In case one wants to run multiple simulations using this layout, it is highly recommended to implement a new kernel (the following files have to be extended: mus_flow_module and related modules in source/compute.
Defining a new Layout
To define a new layout one has to set layout = 'new_stencil'
. To define the
stencil the following information has to be provided:
The following example shows how to define the standard D3Q19 as a new layout:
-- Scheme
scheme = {
label = 'test',
layout = 'new_stencil',
-- Initial condition
initial_condition = {
density = 1.0,
velocityX = 0.0,
velocityY = 0.0,
velocityZ = 0.0 },
-- Boundary conditions
boundary_condition = {
{ label = 'wall',
kind = 'velocity_bounceback',
velocityX = 0.03, velocityY = 0.0, velocityZ = 0.0 },
{ label = 'wall',
kind = 'wall',
velocityX = 0.0, velocityY = 0.0, velocityZ = 0.0 }
},
fluid = { relaxation_scheme = 'BGK',
omega = 1.8,
rho0 = 1.0 },
-- Defining the new Stencil
stencil = {
QQ = 19,
disc_vel = {
{-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}
},
weight = {
(1.0/18.0),(1.0/18.0),(1.0/18.0),(1.0/18.0),(1.0/18.0),(1.0/18.0),(1.0/36.0),(1.0/36.0),(1.0/36.0),
(1.0/36.0),(1.0/36.0),(1.0/36.0),(1.0/36.0),(1.0/36.0),(1.0/36.0),(1.0/36.0),(1.0/36.0),(1.0/36.0),
(1.0/3.0)
},
inv_dir = {
4, 5, 6, 1, 2, 3, 10, 9, 8,
7, 14, 13, 12, 11, 18, 17, 16, 15,
19
},
prev_dir = {
{1.,0.,0.},{0.,1.,0.},{0.,0.,1.},{1.,0.,0.},{0.,1.,0.},{0.,0.,1.},
{0.,0.5*math.sqrt(2.),0.5*math.sqrt(2.)},{0.,0.5*math.sqrt(2.),0.5*math.sqrt(2.)},
{0.,0.5*math.sqrt(2.),0.5*math.sqrt(2.)},{0.,0.5*math.sqrt(2.),0.5*math.sqrt(2.)},
{0.5*math.sqrt(2.),0.,0.5*math.sqrt(2.)},{0.5*math.sqrt(2.),0.,0.5*math.sqrt(2.)},
{0.5*math.sqrt(2.),0.,0.5*math.sqrt(2.)},{0.5*math.sqrt(2.),0.,0.5*math.sqrt(2.)},
{0.5*math.sqrt(2.),0.5*math.sqrt(2.),0.},{0.5*math.sqrt(2.),0.5*math.sqrt(2.),0.},
{0.5*math.sqrt(2.),0.5*math.sqrt(2.),0.},{0.5*math.sqrt(2.),0.5*math.sqrt(2.),0.}
}
}
}
data structure containing all information related to the compute stencil. Several stencils can be defined. mus_moments_module Moments are directly related to the stencil layout and are therefore defined here
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
type(tem_stencilHeader_type), | public | :: | fStencil |
fluid stencil same as stencil(1) |
|||
integer, | public | :: | nStencils |
number of stencils used in this scheme |
|||
type(grw_stencilheaderarray_type), | public | :: | grwStencil |
Temporary growing array of stencil It is copied to stencil(:) and destroyed, where this is destroyed? |
|||
type(tem_stencilHeader_type), | public, | allocatable | :: | stencil(:) |
The list of stencil types, the stencils for the individual schemes is ordered as follows: |
||
type(dyn_labelarray_type), | public | :: | stencil_labels |
dynamic array of labels created from stencil directions to create unique growing array of grwStencil |
|||
integer, | public | :: | fStencil_pos |
position of fluid stencil in grwStencil |
|||
real(kind=rk), | public, | allocatable | :: | weight(:) |
The weights for the different discrete velocities |
||
real(kind=rk), | public | :: | cs |
Lattice speed of sound for fStencil $\sum_i (weight_icx_icx_i) = c_s^2 I |
|||
real(kind=rk), | public, | allocatable | :: | prevailDir(:,:) |
Prevailing directions |
||
type(mus_moment_type), | public | :: | moment |
Moment space definition |
|||
logical, | public | :: | new_stencil | = | .false. |
New stencil definition loaded from config |
|
type(mus_scheme_derived_quantities_type), | public | :: | quantities |
derive quantities that depends on the layout such as velocity, pdf_eq, etc.. |
Calculate lattice speed of sound for given stencil
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(mus_scheme_layout_type), | intent(inout) | :: | layout |
scheme layout for pdf state |
load a new stencil definition from the lua file
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(mus_scheme_layout_type) | :: | me | ||||
integer, | intent(in), | optional | :: | parent_handle | ||
type(flu_State) | :: | conf |
Dump the weights in lua format.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rk), | intent(in) | :: | me(:) |
weights |
||
type(aot_out_type) | :: | conf |
Initialize growing array of stencils
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(mus_scheme_layout_type), | intent(inout) | :: | layout |
musubi schemes layout type |
This routine finialize grwStencil by truncating stencil elem arrays and set stencil%nElems
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(mus_scheme_layout_type), | intent(inout) | :: | layout |
scheme layout |
||
integer, | intent(in) | :: | nElemsInTree |
fluid tree from mesh |
||
integer, | intent(in) | :: | minLevel |
min and max level |
||
integer, | intent(in) | :: | maxLevel |
min and max level |
||
type(tem_comm_env_type), | intent(in) | :: | proc |
mpi communication type |
Destroy the stencil
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_stencilHeader_type), | intent(out), | allocatable | :: | stencil(:) |
musubi schemes stencil type |
This routine defines layout for predefined stencils
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(mus_scheme_layout_type), | intent(inout) | :: | layout |
scheme layout for pdf state |
||
character(len=*), | intent(in) | :: | stencilName |
Name of the stencil to create |
||
integer, | intent(in) | :: | nElems |
number of elements use this layout |
This subroutine sets the parameters for the predefined d3q19 stencil.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(mus_scheme_layout_type), | intent(inout) | :: | layout |
scheme layout for pdf state |
||
integer, | intent(in) | :: | nElems |
number of elements use this layout |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rk) | :: | weights(19) |
This subroutine sets the parameters for the predefined d3q27 stencil.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(mus_scheme_layout_type), | intent(inout) | :: | layout |
scheme layout for pdf state |
||
integer, | intent(in) | :: | nElems |
number of elements use this layout |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rk) | :: | weights(27) |
This subroutine sets the parameters for the predefined d3q7 stencil.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(mus_scheme_layout_type), | intent(inout) | :: | layout |
scheme layout for pdf state |
||
integer, | intent(in) | :: | nElems |
number of elements use this layout |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rk) | :: | weights(7) |
This subroutine sets the parameters for the predefined d3q6 layout%fStencil, used by the Flekkoy model of passive scalar transport.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(mus_scheme_layout_type), | intent(inout) | :: | layout |
scheme layout for pdf state |
||
integer, | intent(in) | :: | nElems |
number of elements use this layout |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rk) | :: | weights(6) |
This subroutine sets the parameters for the predefined d2q9 stencil.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(mus_scheme_layout_type), | intent(inout) | :: | layout |
scheme layout for pdf state |
||
integer, | intent(in) | :: | nElems |
number of elements use this layout |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rk) | :: | weights(9) |
This subroutine sets the parameters for the predefined d2q9 stencil.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(mus_scheme_layout_type), | intent(inout) | :: | layout |
scheme layout for pdf state |
||
integer, | intent(in) | :: | nElems |
number of elements use this layout |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rk) | :: | weights(3) |
This subroutine sets the parameters for the predefined d3q13 stencil.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(mus_scheme_layout_type), | intent(inout) | :: | layout |
scheme layout for pdf state |
||
integer, | intent(in) | :: | nElems |
number of elements use this layout |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rk) | :: | weights(13) |
This subroutine sets the parameters for the predefined d2q5 stencil.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(mus_scheme_layout_type), | intent(inout) | :: | layout |
scheme layout for pdf state |
||
integer, | intent(in) | :: | nElems |
number of elements use this layout |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rk) | :: | weights(5) |