LatticeModel.py 1.05 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import sympy as sp

from lbmpy import LBMConfig, LBMOptimisation, LBStencil, Method, Stencil
from lbmpy.creationfunctions import create_lb_collision_rule, create_lb_update_rule

from pystencils_walberla import CodeGeneration, generate_pack_info_from_kernel
from lbmpy_walberla import generate_lattice_model

#   ========================
#      General Parameters
#   ========================

stencil = LBStencil(Stencil.D2Q9)
omega = sp.Symbol('omega')
layout = 'fzyx'

#   Optimizations for the LBM Method
lbm_opt = LBMOptimisation(cse_global=True, field_layout=layout)

#   ===========================
#      SRT Method Definition
#   ===========================

lbm_config = LBMConfig(stencil=stencil, method=Method.SRT, relaxation_rate=omega)

collision_rule = create_lb_collision_rule(lbm_config=lbm_config, lbm_optimisation=lbm_opt)

#   =====================
#      Code Generation
#   =====================

with CodeGeneration() as ctx:
    # generation of the lattice model ...
    generate_lattice_model(ctx, "LatticeModel", collision_rule, field_layout=layout)