From 7a2e882a58706f865f4ef7b4b6a53b26c289d76e Mon Sep 17 00:00:00 2001
From: JM Etancelin <jean-matthieu.etancelin@univ-pau.fr>
Date: Mon, 3 Aug 2020 08:38:00 +0200
Subject: [PATCH] updaet cusom ghosts. simulation write parameters with freq

---
 hysop/backend/host/python/operator/custom.py |  2 ++
 hysop/simulation.py                          | 21 ++++++++++----------
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/hysop/backend/host/python/operator/custom.py b/hysop/backend/host/python/operator/custom.py
index 25f8f48fb..7c756e89a 100644
--- a/hysop/backend/host/python/operator/custom.py
+++ b/hysop/backend/host/python/operator/custom.py
@@ -57,7 +57,9 @@ class PythonCustomOperator(HostOperator):
                 if not it[1] is None:
                     is_input, (field, td, req) = it
                     min_ghosts = (max(g, self._ghosts) for g in req.min_ghosts.copy())
+                    max_ghosts = (min(g, self._ghosts) for g in req.max_ghosts.copy())
                     req.min_ghosts = min_ghosts
+                    req.max_ghosts = max_ghosts
         return requirements
 
     @debug
diff --git a/hysop/simulation.py b/hysop/simulation.py
index 817b72e41..9c5eb491b 100644
--- a/hysop/simulation.py
+++ b/hysop/simulation.py
@@ -224,16 +224,17 @@ class Simulation(object):
         for (io_params, params, kwds) in self._parameters_to_write:
             if self.mpi_params.rank == io_params.io_leader:
                 if (io_params.fileformat is IO.ASCII):
-                    kwds = kwds.copy()
-                    f = kwds.pop('file')
-                    formatter = kwds.pop('formatter')
-                    values = npw.asarray(tuple(map(lambda x: x.item() if x.size == 1 else x,
-                                                   (p() for p in params))))
-                    values = npw.array2string(values, max_line_width=npw.inf,
-                                              formatter=formatter, legacy='1.13', **kwds)
-                    values = '\n'+values[1:-1]
-                    f.write(values)
-                    f.flush()
+                    if ((self.current_iteration % io_params.frequency) == 0):
+                        kwds = kwds.copy()
+                        f = kwds.pop('file')
+                        formatter = kwds.pop('formatter')
+                        values = npw.asarray(tuple(map(lambda x: x.item() if x.size == 1 else x,
+                                                       (p() for p in params))))
+                        values = npw.array2string(values, max_line_width=npw.inf,
+                                                  formatter=formatter, legacy='1.13', **kwds)
+                        values = '\n'+values[1:-1]
+                        f.write(values)
+                        f.flush()
                 else:
                     msg = 'Unknown format {}.'.format(fileformat)
                     raise ValueError(msg)
-- 
GitLab