From 6777bbe64e9ffcd15623b604a9bf803eefe28cb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franck=20P=C3=A9rignon?= <franck.perignon@imag.fr> Date: Fri, 7 Mar 2014 15:21:34 +0000 Subject: [PATCH] fix bug in method setting for operators --- HySoP/hysop/operator/diffusion.py | 6 ++++-- HySoP/hysop/operator/discrete/differential.py | 5 +++-- HySoP/hysop/operator/discrete/discrete.py | 3 +++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/HySoP/hysop/operator/diffusion.py b/HySoP/hysop/operator/diffusion.py index 80f52a89c..c1eb3ab8e 100644 --- a/HySoP/hysop/operator/diffusion.py +++ b/HySoP/hysop/operator/diffusion.py @@ -9,6 +9,7 @@ from parmepy.operator.continuous import Operator from parmepy.f2py import fftw2py from parmepy.operator.discrete.diffusion_fft import DiffusionFFT from parmepy.constants import debug +from parmepy.methods_keys import SpaceDiscretisation, GhostUpdate import numpy as np @@ -35,7 +36,8 @@ class Diffusion(Operator): """ # The only available method at the time is fftw if method is None: - method = 'fftw' + method = {SpaceDiscretisation: 'fftw', GhostUpdate: True} + ## input/output field, solution of the problem self.vorticity = vorticity ## Global resolution for vorticity @@ -50,7 +52,7 @@ class Diffusion(Operator): def discretize(self): # The only available solver is fftw - if self.method is not 'fftw': + if self.method[SpaceDiscretisation] is not 'fftw': print self.method raise AttributeError("Method not yet implemented.") diff --git a/HySoP/hysop/operator/discrete/differential.py b/HySoP/hysop/operator/discrete/differential.py index 514a3d807..52a16ddee 100644 --- a/HySoP/hysop/operator/discrete/differential.py +++ b/HySoP/hysop/operator/discrete/differential.py @@ -24,8 +24,7 @@ class Differential(DiscreteOperator): ## return object.__new__(cls, *args, **kw) @debug - def __init__(self, invar, outvar, - method={SpaceDiscretisation: FD_C_4, GhostUpdate: True}): + def __init__(self, invar, outvar, method=None): """ @param[in] invar : input field @param[in,out] outvar : Grad of the input field. @@ -36,6 +35,8 @@ class Differential(DiscreteOperator): """ self.invar = invar self.outvar = outvar + if method is None: + method = {SpaceDiscretisation: FD_C_4, GhostUpdate: True} DiscreteOperator.__init__(self, [self.invar, self.outvar], method=method) self.input = [self.invar] diff --git a/HySoP/hysop/operator/discrete/discrete.py b/HySoP/hysop/operator/discrete/discrete.py index a752db902..96fe01654 100644 --- a/HySoP/hysop/operator/discrete/discrete.py +++ b/HySoP/hysop/operator/discrete/discrete.py @@ -5,6 +5,7 @@ Abstract interface for discrete operators. from abc import ABCMeta, abstractmethod from parmepy.constants import debug from parmepy.tools.timers import Timer, ManualFunctionTimer +from parmepy.methods_keys import GhostUpdate class DiscreteOperator(object): @@ -40,6 +41,8 @@ class DiscreteOperator(object): if method is None: method = {} self.method = method + if not GhostUpdate in method: + method[GhostUpdate] = True self.name = self.__class__.__name__ ## Object to store computational times of lower level functions self.timer = Timer(self) -- GitLab