diff --git a/lbmpy_walberla/boundary.py b/lbmpy_walberla/boundary.py index 865ec33bac01d1234e0c40a098582c7f7a823b9f..5f2dc6fd1f2228687eddc1af3c27f471ad06b1b3 100644 --- a/lbmpy_walberla/boundary.py +++ b/lbmpy_walberla/boundary.py @@ -32,7 +32,16 @@ def generate_boundary(generation_context, class_name, boundary_object, lb_method openmp=generation_context.openmp) kernel.function_name = "boundary_" + boundary_object.name - stencil_info = [(i, ", ".join([str(e) for e in d])) for i, d in enumerate(lb_method.stencil)] + # waLBerla is a 3D framework. Therefore, a zero for the z index has to be added if we work in 2D + if lb_method.dim == 2: + stencil = () + for d in lb_method.stencil: + d = d + (0,) + stencil = stencil + (d,) + else: + stencil = lb_method.stencil + + stencil_info = [(i, ", ".join([str(e) for e in d])) for i, d in enumerate(stencil)] context = { 'class_name': boundary_object.name, diff --git a/lbmpy_walberla_tests/test_walberla_codegen.py b/lbmpy_walberla_tests/test_walberla_codegen.py index 9ec5724556013dda4353afc6a4be53a824a65602..cde21c58aa6b13835a8a97091e6ab576e7e8a293 100644 --- a/lbmpy_walberla_tests/test_walberla_codegen.py +++ b/lbmpy_walberla_tests/test_walberla_codegen.py @@ -91,7 +91,13 @@ class WalberlaLbmpyCodegenTest(unittest.TestCase): generate_lattice_model(ctx, 'FluctuatingMRT', collision_rule) @staticmethod - def test_boundary(): + def test_boundary_3D(): with ManualCodeGenerationContext(openmp=True, double_accuracy=True) as ctx: lb_method = create_lb_method(stencil='D3Q19', method='srt') - generate_boundary(ctx, 'Boundary', NoSlip(), lb_method, target='gpu') \ No newline at end of file + generate_boundary(ctx, 'Boundary', NoSlip(), lb_method, target='gpu') + + @staticmethod + def test_boundary_2D(): + with ManualCodeGenerationContext(openmp=True, double_accuracy=True) as ctx: + lb_method = create_lb_method(stencil='D2Q9', method='srt') + generate_boundary(ctx, 'Boundary', NoSlip(), lb_method, target='gpu')