Skip to content
Snippets Groups Projects
Commit 6fb3881b authored by Martin Bauer's avatar Martin Bauer
Browse files

Adapted codegen example file to changes in lbmpy

parent 4b74b16f
No related merge requests found
import sympy as sp import sympy as sp
from lbmpy.boundaries import NoSlip, UBB from lbmpy.boundaries import NoSlip, UBB
from lbmpy_walberla import Field, generateLatticeModelFiles, RefinementScaling from lbmpy_walberla import Field, generate_lattice_model_files, RefinementScaling
from lbmpy.creationfunctions import createLatticeBoltzmannMethod from lbmpy.creationfunctions import create_lb_method
from lbmpy_walberla.boundary import createBoundaryClass from lbmpy_walberla.boundary import create_boundary_class
from pystencils_walberla.cmake_integration import codegen from pystencils_walberla.cmake_integration import codegen
import pystencils as ps
# ------------- Lattice Model ------------------------------ # ------------- Lattice Model ------------------------------
forceField = Field.createGeneric('force', spatialDimensions=3, indexDimensions=1, layout='fzyx') force_field = ps.fields("force(3): [3D]", layout='fzyx')
force = [forceField(0), forceField(1), forceField(2)]
omega = sp.Symbol("omega") omega = sp.Symbol("omega")
scaling = RefinementScaling() scaling = RefinementScaling()
scaling.addStandardRelaxationRateScaling(omega) scaling.add_standard_relaxation_rate_scaling(omega)
scaling.addForceScaling(forceField) scaling.add_force_scaling(force_field)
generateLatticeModelFiles(className='SrtWithForceFieldModel', generate_lattice_model_files(class_name='SrtWithForceFieldModel',
method='srt', stencil='D3Q19', forceModel='guo', force=force, method='srt', stencil='D3Q19', force_model='guo', force=force_field.center_vector,
relaxationRates=[omega], refinementScaling=scaling) relaxation_rates=[omega], refinement_scaling=scaling)
def genBoundary(): def genBoundary():
boundary = UBB([0.05, 0, 0], dim=3, name="MyUBB") boundary = UBB([0.05, 0, 0], dim=3, name="MyUBB")
method = createLatticeBoltzmannMethod(stencil='D3Q19', method='srt') method = create_lb_method(stencil='D3Q19', method='srt')
return createBoundaryClass(boundary, method) return create_boundary_class(boundary, method)
def genNoSlip(): def genNoSlip():
boundary = NoSlip(name='MyNoSlip') boundary = NoSlip(name='MyNoSlip')
method = createLatticeBoltzmannMethod(stencil='D3Q19', method='srt') method = create_lb_method(stencil='D3Q19', method='srt')
return createBoundaryClass(boundary, method) return create_boundary_class(boundary, method)
codegen.register(['MyUBB.h', 'MyUBB.cpp'], genBoundary) codegen.register(['MyUBB.h', 'MyUBB.cpp'], genBoundary)
codegen.register(['MyNoSlip.h', 'MyNoSlip.cpp',], genNoSlip) codegen.register(['MyNoSlip.h', 'MyNoSlip.cpp',], genNoSlip)
......
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