From dec028aea7ac93a59e2a6bccd681a090c89f24b6 Mon Sep 17 00:00:00 2001
From: Martin Bauer <martin.bauer@fau.de>
Date: Fri, 19 Jan 2018 14:28:51 +0100
Subject: [PATCH] Bugfix in lbmpy waLBerla interface

- added rudimentary test to prevent these kind of problems
---
 lbmpy_tests/test_walberla_codegen.py | 33 ++++++++++++++++++++++++++++
 lbmpy_walberla/boundary.py           |  4 ++--
 2 files changed, 35 insertions(+), 2 deletions(-)
 create mode 100644 lbmpy_tests/test_walberla_codegen.py

diff --git a/lbmpy_tests/test_walberla_codegen.py b/lbmpy_tests/test_walberla_codegen.py
new file mode 100644
index 00000000..64ef1d08
--- /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 c82c045e..855c81b0 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,
-- 
GitLab