From 0d4436a3530b25fe016cdabb960ea07e16213664 Mon Sep 17 00:00:00 2001
From: Martin Bauer <martin.bauer@fau.de>
Date: Tue, 7 Nov 2017 13:16:11 +0100
Subject: [PATCH] Fixes in periodicity handling

---
 boundaries/boundaryhandling.py    | 2 +-
 boundaries/periodicityhandling.py | 7 ++++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/boundaries/boundaryhandling.py b/boundaries/boundaryhandling.py
index 569a098a..5897cd17 100644
--- a/boundaries/boundaryhandling.py
+++ b/boundaries/boundaryhandling.py
@@ -12,7 +12,7 @@ class BoundaryHandling(PeriodicityHandling, GenericBoundaryHandling):  # importa
         flagInterface = NumpyFlagFieldInterface(shapeWithGl, flagDtype)
 
         GenericBoundaryHandling.__init__(self, flagInterface, pdfField, lbMethod, None, ghostLayers, target, openMP)
-        PeriodicityHandling.__init__(self, list(domainShape) + [len(lbMethod.stencil)])
+        PeriodicityHandling.__init__(self, list(domainShape) + [len(lbMethod.stencil)], target=target)
 
     def __call__(self, *args, **kwargs):
         for cls in BoundaryHandling.__bases__:
diff --git a/boundaries/periodicityhandling.py b/boundaries/periodicityhandling.py
index d5b86ed8..428afcae 100644
--- a/boundaries/periodicityhandling.py
+++ b/boundaries/periodicityhandling.py
@@ -2,12 +2,13 @@ from lbmpy.stencils import getStencil
 
 
 class PeriodicityHandling(object):
-    def __init__(self, fieldShape, periodicity=(False, False, False)):
+    def __init__(self, fieldShape, periodicity=(False, False, False), target='cpu'):
         self._spatialShape = fieldShape[:-1]
         self._indexShape = fieldShape[-1]
         self._periodicity = list(periodicity)
-        self._periodicityDirty = False
+        self._periodicityDirty = True
         self._periodicityKernels = []
+        self._target = target
 
     @property
     def periodicity(self):
@@ -33,7 +34,7 @@ class PeriodicityHandling(object):
             return
 
         self._periodicityKernels = []
-        dim = len(self.flagField.shape)
+        dim = len(self._spatialShape)
         if dim == 2:
             stencil = getStencil("D2Q9")
         elif dim == 3:
-- 
GitLab