UniformGridGPU.py 1.56 KB
Newer Older
Martin Bauer's avatar
Martin Bauer committed
1
2
3
4
5
6
7
8
import sympy as sp
from lbmpy.creationfunctions import create_lb_method, create_lb_update_rule
from lbmpy.boundaries import NoSlip, UBB
from pystencils_walberla import generate_pack_info_from_kernel
from lbmpy_walberla import generate_lattice_model, generate_boundary
from pystencils_walberla import CodeGeneration, generate_sweep


Martin Bauer's avatar
Martin Bauer committed
9
10
11
12
sweep_block_size = (128, 1, 1)
sweep_params = {'block_size': sweep_block_size}


Martin Bauer's avatar
Martin Bauer committed
13
14
15
16
17
18
19
20
21
22
with CodeGeneration() as ctx:
    # LB options
    options = {
        'method': 'srt',
        'stencil': 'D3Q19',
        'relaxation_rate': sp.Symbol("omega"),
        'field_name': 'pdfs',
        'compressible': False,
        'temporary_field_name': 'pdfs_tmp',
        'optimization': {'cse_global': True,
Martin Bauer's avatar
Martin Bauer committed
23
24
                         'cse_pdfs': False,
                         }
Martin Bauer's avatar
Martin Bauer committed
25
26
27
28
29
30
31
32
33
    }
    lb_method = create_lb_method(**options)
    update_rule = create_lb_update_rule(lb_method=lb_method, **options)

    # CPU lattice model - required for macroscopic value computation, VTK output etc.
    generate_lattice_model(ctx, 'UniformGridGPU_LatticeModel', lb_method)

    # gpu LB sweep & boundaries
    generate_sweep(ctx, 'UniformGridGPU_LbKernel', update_rule, field_swaps=[('pdfs', 'pdfs_tmp')],
Martin Bauer's avatar
Martin Bauer committed
34
                   inner_outer_split=True, target='gpu', gpu_indexing_params=sweep_params)
Martin Bauer's avatar
Martin Bauer committed
35
36
37
38
39
    generate_boundary(ctx, 'UniformGridGPU_NoSlip', NoSlip(), lb_method, target='gpu')
    generate_boundary(ctx, 'UniformGridGPU_UBB', UBB([0.05, 0, 0]), lb_method, target='gpu')

    # communication
    generate_pack_info_from_kernel(ctx, 'UniformGridGPU_PackInfo', update_rule, target='gpu')