Skip to content
Snippets Groups Projects
Commit 44fd76fa authored by Frederik Hennig's avatar Frederik Hennig
Browse files

small fix: retrieve codegen target earlier

parent 16c96838
No related merge requests found
......@@ -9,65 +9,70 @@ from pystencils_walberla import CodeGeneration, generate_sweep, generate_pack_in
from lbmpy_walberla import generate_boundary
# ========================
# General Parameters
# ========================
with CodeGeneration() as ctx:
stencil = 'D2Q9'
omega = sp.Symbol('omega')
layout = 'fzyx'
# ========================
# Target Selection
# ========================
# PDF Fields
pdfs, pdfs_tmp = ps.fields('pdfs(9), pdfs_tmp(9): [2D]', layout=layout)
if ctx.cuda:
target = 'gpu'
else:
target = 'cpu'
# Velocity Output Field
velocity = ps.fields("velocity(2): [2D]", layout=layout)
output = {'velocity': velocity}
# ========================
# General Parameters
# ========================
# Optimization
optimization = {'target': 'cpu',
'cse_global': True,
'symbolic_field': pdfs,
'symbolic_temporary_field': pdfs_tmp,
'field_layout': layout}
stencil = 'D2Q9'
omega = sp.Symbol('omega')
layout = 'fzyx'
# PDF Fields
pdfs, pdfs_tmp = ps.fields('pdfs(9), pdfs_tmp(9): [2D]', layout=layout)
# ==================
# Method Setup
# ==================
# Velocity Output Field
velocity = ps.fields("velocity(2): [2D]", layout=layout)
output = {'velocity': velocity}
lbm_params = {'stencil': stencil,
'method': 'mrt_raw',
'relaxation_rates': [0, 0, 0, omega, omega, omega, 1, 1, 1],
'cumulant': True,
'compressible': True}
# Optimization
optimization = {'target': target,
'cse_global': True,
'symbolic_field': pdfs,
'symbolic_temporary_field': pdfs_tmp,
'field_layout': layout}
lbm_update_rule = create_lb_update_rule(optimization=optimization,
output=output,
**lbm_params)
lbm_method = lbm_update_rule.method
# ==================
# Method Setup
# ==================
# ========================
# PDF Initialization
# ========================
lbm_params = {'stencil': stencil,
'method': 'mrt_raw',
'relaxation_rates': [0, 0, 0, omega, omega, omega, 1, 1, 1],
'cumulant': True,
'compressible': True}
initial_rho = sp.Symbol('rho_0')
lbm_update_rule = create_lb_update_rule(optimization=optimization,
output=output,
**lbm_params)
pdfs_setter = macroscopic_values_setter(lbm_method,
initial_rho,
velocity.center_vector,
pdfs.center_vector)
lbm_method = lbm_update_rule.method
# =====================
# Code Generation
# =====================
# ========================
# PDF Initialization
# ========================
with CodeGeneration() as ctx:
if ctx.cuda:
target = 'gpu'
else:
target = 'cpu'
initial_rho = sp.Symbol('rho_0')
pdfs_setter = macroscopic_values_setter(lbm_method,
initial_rho,
velocity.center_vector,
pdfs.center_vector)
# =====================
# Code Generation
# =====================
# LBM Sweep
generate_sweep(ctx, "CumulantMRTSweep", lbm_update_rule, field_swaps=[(pdfs, pdfs_tmp)], target=target)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment