mus_scheme_layout_module Module

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:

  • 'predefined_d3q19': The D3Q19 model. The advection relaxation kernel for this model is highly optimized.
  • 'predefined_d3q7': The more simple D3Q7 model. The advection relaxation kernel for this model is highly optimized.
  • 'Flekkoy': The Flekkoy model consists of a D3Q6 stencil and is used for passive scalar transport.

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 number of offsets (QQ)
  • the offsets (disc_vel)
  • the weights (weight)
  • the inverse directions (inv_dir) as integers pointing on the belonging offsets
  • the prevailing directions (prev_dir) as reals giving the distance in the different directions

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.}
             }
  }
 }

Uses

Used by


Contents


Derived Types

type, public :: mus_scheme_layout_type

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

Components

TypeVisibilityAttributesNameInitial
type(tem_stencilHeader_type), private :: fStencil

fluid stencil same as stencil(1)

integer, private :: nStencils

number of stencils used in this scheme

type(grw_stencilheaderarray_type), private :: grwStencil

Temporary growing array of stencil It is copied to stencil(:) and destroyed, where this is destroyed?

type(tem_stencilHeader_type), private, allocatable:: stencil(:)

The list of stencil types, the stencils for the individual schemes is ordered as follows:

Read more…
type(dyn_labelarray_type), private :: stencil_labels

dynamic array of labels created from stencil directions to create unique growing array of grwStencil

integer, private :: fStencil_pos

position of fluid stencil in grwStencil

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

The weights for the different discrete velocities

real(kind=rk), private :: cs

Lattice speed of sound for fStencil $\sum_i (weight_icx_icx_i) = c_s^2 I

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

Prevailing directions

type(mus_moment_type), private :: moment

Moment space definition

logical, private :: new_stencil =.false.

New stencil definition loaded from config


Functions

private function mus_calculate_speed_of_sound(layout) result(c_sound)

Calculate lattice speed of sound for given stencil

Arguments

TypeIntentOptionalAttributesName
type(mus_scheme_layout_type), intent(inout) :: layout

scheme layout for pdf state

Return Value real(kind=rk)


Subroutines

public subroutine mus_load_newLayout(me, parent_handle, conf)

load a new stencil definition from the lua file

Read more…

Arguments

TypeIntentOptionalAttributesName
type(mus_scheme_layout_type) :: me
integer, intent(in), optional :: parent_handle
type(flu_State) :: conf

public subroutine mus_weights_out(me, conf)

Dump the weights in lua format.

Read more…

Arguments

TypeIntentOptionalAttributesName
real(kind=rk), intent(in) :: me(:)

weights

type(aot_out_type) :: conf

public subroutine mus_init_layout(layout)

Initialize growing array of stencils

Arguments

TypeIntentOptionalAttributesName
type(mus_scheme_layout_type), intent(inout) :: layout

musubi schemes layout type

public subroutine mus_finalize_layout(layout, nElemsInTree, minLevel, maxLevel, proc)

This routine finialize grwStencil by truncating stencil elem arrays and set stencil%nElems

Arguments

TypeIntentOptionalAttributesName
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

public subroutine mus_destroy_stencil(stencil)

Destroy the stencil

Arguments

TypeIntentOptionalAttributesName
type(tem_stencilHeader_type), intent(out), allocatable:: stencil(:)

musubi schemes stencil type

public subroutine mus_define_layout(layout, stencilName, nElems)

This routine defines layout for predefined stencils

Arguments

TypeIntentOptionalAttributesName
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

public subroutine mus_define_d3q19(layout, nElems)

This subroutine sets the parameters for the predefined d3q19 stencil.

Arguments

TypeIntentOptionalAttributesName
type(mus_scheme_layout_type), intent(inout) :: layout

scheme layout for pdf state

integer, intent(in) :: nElems

number of elements use this layout

public subroutine mus_set_weights_d3q19(weights)

Arguments

TypeIntentOptionalAttributesName
real(kind=rk) :: weights(19)

public subroutine mus_define_d3q27(layout, nElems)

This subroutine sets the parameters for the predefined d3q27 stencil.

Arguments

TypeIntentOptionalAttributesName
type(mus_scheme_layout_type), intent(inout) :: layout

scheme layout for pdf state

integer, intent(in) :: nElems

number of elements use this layout

public subroutine mus_set_weights_d3q27(weights)

Arguments

TypeIntentOptionalAttributesName
real(kind=rk) :: weights(27)

public subroutine mus_define_d3q7(layout, nElems)

This subroutine sets the parameters for the predefined d3q7 stencil.

Arguments

TypeIntentOptionalAttributesName
type(mus_scheme_layout_type), intent(inout) :: layout

scheme layout for pdf state

integer, intent(in) :: nElems

number of elements use this layout

public subroutine mus_set_weights_d3q7(weights)

Arguments

TypeIntentOptionalAttributesName
real(kind=rk) :: weights(7)

public subroutine mus_define_d3q6(layout, nElems)

This subroutine sets the parameters for the predefined d3q6 layout%fStencil, used by the Flekkoy model of passive scalar transport.

Arguments

TypeIntentOptionalAttributesName
type(mus_scheme_layout_type), intent(inout) :: layout

scheme layout for pdf state

integer, intent(in) :: nElems

number of elements use this layout

public subroutine mus_set_weights_d3q6(weights)

Arguments

TypeIntentOptionalAttributesName
real(kind=rk) :: weights(6)

public subroutine mus_define_d2q9(layout, nElems)

This subroutine sets the parameters for the predefined d2q9 stencil.

Arguments

TypeIntentOptionalAttributesName
type(mus_scheme_layout_type), intent(inout) :: layout

scheme layout for pdf state

integer, intent(in) :: nElems

number of elements use this layout

public subroutine mus_set_weights_d2q9(weights)

Arguments

TypeIntentOptionalAttributesName
real(kind=rk) :: weights(9)

public subroutine mus_define_d1q3(layout, nElems)

This subroutine sets the parameters for the predefined d2q9 stencil.

Arguments

TypeIntentOptionalAttributesName
type(mus_scheme_layout_type), intent(inout) :: layout

scheme layout for pdf state

integer, intent(in) :: nElems

number of elements use this layout

public subroutine mus_set_weights_d1q3(weights)

Arguments

TypeIntentOptionalAttributesName
real(kind=rk) :: weights(3)

private subroutine mus_define_d3q13(layout, nElems)

This subroutine sets the parameters for the predefined d3q13 stencil.

Arguments

TypeIntentOptionalAttributesName
type(mus_scheme_layout_type), intent(inout) :: layout

scheme layout for pdf state

integer, intent(in) :: nElems

number of elements use this layout

private subroutine mus_set_weights_d3q13(weights)

Arguments

TypeIntentOptionalAttributesName
real(kind=rk) :: weights(13)

private subroutine mus_define_d2q5(layout, nElems)

This subroutine sets the parameters for the predefined d2q5 stencil.

Arguments

TypeIntentOptionalAttributesName
type(mus_scheme_layout_type), intent(inout) :: layout

scheme layout for pdf state

integer, intent(in) :: nElems

number of elements use this layout

private subroutine mus_set_weights_d2q5(weights)

Arguments

TypeIntentOptionalAttributesName
real(kind=rk) :: weights(5)