diff --git a/HySoP/hysop/problem/problem.py b/HySoP/hysop/problem/problem.py index a622b07c97bce36fc38488cfd3cbf96cdd731603..566130b38ffa551f8027b18d95378e412ec729a2 100644 --- a/HySoP/hysop/problem/problem.py +++ b/HySoP/hysop/problem/problem.py @@ -31,7 +31,8 @@ class Problem(object): return object.__new__(cls, *args, **kw) @debug - def __init__(self, operators, simulation, monitors=[], name=None): + def __init__(self, operators, simulation, monitors=[], + dumpFreq=100, name=None): """ Create a transport problem instance. @@ -40,6 +41,8 @@ class Problem(object): to describe simulation parameters. @param monitors : list of monitors. @param name : an id for the problem + @param dumpFreq : frequency of dump (i.e. saving to a file) + for the problem; set dumpFreq = -1 for no dumps. Default = 100. """ ## Problem operators self.operators = operators @@ -58,8 +61,15 @@ class Problem(object): ## A list of variables that must be initialized before ## any call to op.apply() self.input = [] - ## call to problem.dump frequency during apply. 0 means never. - self.dumpFreq = 0 + ## call to problem.dump frequency during apply. + if dumpFreq >= 0: + ## dump problem every self.dumpFreq iter + self.dumpFreq = dumpFreq + self._doDump = True + else: + self._doDump = False + self.dumpFreq = 100000 + ## Id for the problem. Used for dump file name. if name is None: self.name = 'parmesPb' @@ -136,7 +146,8 @@ class Problem(object): for op in self.operators: op.apply(self.simulation) self.simulation.advance() - if self.simulation.currentIteration % self.dumpFreq is 0: + testdump = self.simulation.currentIteration % self.dumpFreq + if self._doDump and testdump: self.dump() @debug @@ -212,6 +223,8 @@ class Problem(object): @param rate : the frequency of output """ self.dumpFreq = freq + if freq < 0: + self._doDump = False if __name__ == "__main__": print __doc__