From 61e21b159fe5cc117f8b0c38e85c961c52e1e59f Mon Sep 17 00:00:00 2001
From: Jean-Baptiste Keck <Jean-Baptiste.Keck@imag.fr>
Date: Tue, 14 Apr 2020 16:25:47 +0200
Subject: [PATCH] this simple patch should resolve #42

---
 .../backend/host/python/operator/diffusion.py |  6 ++++--
 hysop/fields/discrete_field.py                |  2 ++
 hysop/fields/tests/test_fields.py             | 19 +++++++++++++++++--
 hysop/operator/tests/test_diffusion.py        |  6 ++----
 4 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/hysop/backend/host/python/operator/diffusion.py b/hysop/backend/host/python/operator/diffusion.py
index d40c8e1de..ec36df387 100644
--- a/hysop/backend/host/python/operator/diffusion.py
+++ b/hysop/backend/host/python/operator/diffusion.py
@@ -75,7 +75,9 @@ class PythonDiffusion(DiffusionOperatorBase, OpenClMappable, HostOperator):
     def setup(self, work):
         super(PythonDiffusion, self).setup(work=work)
         diffusion_filters = ()
-        for (Fo,Ft,Kd) in zip(self.dFout.dfields, self.forward_transforms, self.all_dkds): 
+        for (Fo,Ft,Kd) in zip(self.dFout.dfields, 
+                              self.forward_transforms, 
+                              self.all_dkds): 
             args = (Ft.full_output_buffer,) + tuple(Kd)
             F = self.build_diffusion_filter(Fo.dim, *args)
             diffusion_filters += (F,)
@@ -94,7 +96,7 @@ class PythonDiffusion(DiffusionOperatorBase, OpenClMappable, HostOperator):
                                                 self.backward_transforms,
                                                 self.diffusion_filters):
                 Ft(simulation=simulation)
-                filter_diffusion(nu_dt, Ft.output_buffer)
+                filter_diffusion(nu_dt, Ft.full_output_buffer)
                 Bt(simulation=simulation)
 
         for Fo in self.dFout.dfields:
diff --git a/hysop/fields/discrete_field.py b/hysop/fields/discrete_field.py
index fa0402d15..1490a15a8 100644
--- a/hysop/fields/discrete_field.py
+++ b/hysop/fields/discrete_field.py
@@ -634,6 +634,8 @@ class DiscreteScalarField(NamedScalarContainerI, TaggedObject):
             The continuous field that is dicrerized.
         topology: :class:`~hysop.topology.topology.Topology`
             The topology where to allocate the discrete field.
+        register_discrete_field: bool, defaults to True
+            If set register input topology to input continuous field.
         name : string, optional
             A name for the field.
         pretty_name: string or unicode, optional.
diff --git a/hysop/fields/tests/test_fields.py b/hysop/fields/tests/test_fields.py
index c024291ab..76ad49e45 100644
--- a/hysop/fields/tests/test_fields.py
+++ b/hysop/fields/tests/test_fields.py
@@ -191,9 +191,24 @@ def test_tensor_field():
                                            shape=(2, 2))
     DT9 = DT0[:2, :2]
     DT10 = DT9.clone()
-    DT11, requests = DT10.tmp_dfield_like(name='DT11')
-    work = requests().allocate(True)
+    DT11, requests11 = DT10.tmp_dfield_like(name='DT11')
+    DT12, requests12 = DT10.tmp_dfield_like(name='DT11')
+
+    work = requests11().allocate(True)
     DT11.honor_memory_request(work)
+    
+    work = requests12().allocate(True)
+    DT12.honor_memory_request(work)
+    
+    for df in DT11.data:
+        df[...] = 11
+    for df in DT12.data:
+        df[...] = 12
+    for df in DT11.data:
+        assert np.all(df == 11)
+    for df in DT12.data:
+        assert np.all(df == 12)
+    
 
     str(DT0)
     DT0.short_description()
diff --git a/hysop/operator/tests/test_diffusion.py b/hysop/operator/tests/test_diffusion.py
index 773801b8b..d399f128e 100644
--- a/hysop/operator/tests/test_diffusion.py
+++ b/hysop/operator/tests/test_diffusion.py
@@ -37,10 +37,8 @@ class TestDiffusionOperator(object):
             size_min=None, size_max=None):
         assert dim > 0
 
-        # periodic boundaries removes one computational point
-        # so we add one here.
-        size_min = first_not_None(size_min, self.size_min) + 1
-        size_max = first_not_None(size_max, self.size_max) + 1
+        size_min = first_not_None(size_min, self.size_min)
+        size_max = first_not_None(size_max, self.size_max)
 
         shape = tuple(npw.random.randint(low=size_min, high=size_max, size=dim).tolist())
 
-- 
GitLab