diff --git a/lbmpy_tests/test_walberla_codegen.py b/lbmpy_tests/test_walberla_codegen.py new file mode 100644 index 0000000000000000000000000000000000000000..64ef1d08c105223ba976400ce532d08fa83be702 --- /dev/null +++ b/lbmpy_tests/test_walberla_codegen.py @@ -0,0 +1,33 @@ +import unittest +import sympy as sp +from lbmpy.boundaries import NoSlip, UBB +from lbmpy_walberla import Field, RefinementScaling, generateLatticeModel +from lbmpy.creationfunctions import createLatticeBoltzmannMethod +from lbmpy_walberla.boundary import createBoundaryClass + + +class TestWalberlaCodeGen(unittest.TestCase): + + def test_latticeModel(self): + forceField = Field.createGeneric('force', spatialDimensions=3, indexDimensions=1, layout='fzyx') + force = [forceField(0), forceField(1), forceField(2)] + + omega = sp.Symbol("omega") + + scaling = RefinementScaling() + scaling.addStandardRelaxationRateScaling(omega) + scaling.addForceScaling(forceField) + header, sources, _ = generateLatticeModel(latticeModelName="TestModel", method='srt', stencil='D3Q19', + forceModel='guo', + force=force, relaxationRates=[omega], refinementScaling=scaling) + + def test_ubb(self): + boundary = UBB([0.05, 0, 0], dim=3, name="MyUBB") + method = createLatticeBoltzmannMethod(stencil='D3Q19', method='srt') + createBoundaryClass(boundary, method) + + def test_noSlip(self): + boundary = NoSlip(name='MyNoSlip') + method = createLatticeBoltzmannMethod(stencil='D3Q19', method='srt') + createBoundaryClass(boundary, method) + diff --git a/lbmpy_walberla/boundary.py b/lbmpy_walberla/boundary.py index c82c045ea2b09296066461b5c6145fc385511586..855c81b0b2c59e3fbcb4280944c38cac61fd3b85 100644 --- a/lbmpy_walberla/boundary.py +++ b/lbmpy_walberla/boundary.py @@ -1,7 +1,7 @@ import numpy as np from jinja2 import Environment, PackageLoader -from pystencils import Field +from pystencils import Field, FieldType from pystencils.data_types import createType, TypedSymbol from pystencils_walberla.jinja_filters import addPystencilsFiltersToJinjaEnv @@ -44,7 +44,7 @@ def createBoundaryClass(boundaryObject, lbMethod, doublePrecision=True, target=' pdfField = Field.createGeneric('pdfs', lbMethod.dim, np.float64 if doublePrecision else np.float32, indexDimensions=1, layout='fzyx', indexShape=[len(lbMethod.stencil)]) - indexField = Field('indexVector', indexStructDtype, layout=[0], + indexField = Field('indexVector', FieldType.INDEXED, indexStructDtype, layout=[0], shape=(TypedSymbol("indexVectorSize", createType(np.int64)), 1), strides=(1, 1)) kernel = generateIndexBoundaryKernelGeneric(pdfField, indexField, indexStructDtype, lbMethod, boundaryObject,