diff --git a/pySDC/core/level.py b/pySDC/core/level.py index 66d3d3083e..68634a04f4 100644 --- a/pySDC/core/level.py +++ b/pySDC/core/level.py @@ -67,14 +67,14 @@ def __init__(self, problem_class, problem_params, sweeper_class, sweeper_params, level_index (int): custom name for this level """ - # instantiate sweeper, problem and hooks - self.__sweep = sweeper_class(sweeper_params) - self.__prob = problem_class(**problem_params) - # set level parameters and status self.params = _Pars(level_params) self.status = _Status() + # instantiate sweeper, problem and hooks + self.__sweep = sweeper_class(sweeper_params, self) + self.__prob = problem_class(**problem_params) + # set name self.level_index = level_index @@ -87,9 +87,6 @@ def __init__(self, problem_class, problem_params, sweeper_class, sweeper_params, self.tau = [None] * self.sweep.coll.num_nodes - # pass this level to the sweeper for easy access - self.sweep.level = self - self.__tag = None # freeze class, no further attributes allowed from this point diff --git a/pySDC/core/sweeper.py b/pySDC/core/sweeper.py index ff8fe29c8c..e23f1c1749 100644 --- a/pySDC/core/sweeper.py +++ b/pySDC/core/sweeper.py @@ -44,16 +44,15 @@ class Sweeper(object): coll (pySDC.Collocation.CollBase): collocation object """ - def __init__(self, params): + def __init__(self, params, level): """ Initialization routine for the base sweeper Args: params (dict): parameter object - + level (pySDC.Level.level): the level that uses this sweeper """ - # set up logger self.logger = logging.getLogger('sweeper') essential_keys = ['num_nodes'] @@ -81,9 +80,7 @@ def __init__(self, params): ) self.params.do_coll_update = True - # This will be set as soon as the sweeper is instantiated at the level - self.__level = None - + self.__level = level self.parallelizable = False def setupGenerator(self, qd_type): diff --git a/pySDC/helpers/setup_helper.py b/pySDC/helpers/setup_helper.py index a0290eb8e4..2071bb11a7 100644 --- a/pySDC/helpers/setup_helper.py +++ b/pySDC/helpers/setup_helper.py @@ -24,7 +24,9 @@ def generate_description(problem_class, **kwargs): problem_keys = problem_class.__init__.__code__.co_varnames level_keys = level_params({}).__dict__.keys() - sweeper_keys = description['sweeper_class']({'num_nodes': 1, 'quad_type': 'RADAU-RIGHT'}).params.__dict__.keys() + sweeper_keys = description['sweeper_class']( + {'num_nodes': 1, 'quad_type': 'RADAU-RIGHT'}, None + ).params.__dict__.keys() step_keys = step_params({}).__dict__.keys() # TODO: add convergence controllers diff --git a/pySDC/implementations/convergence_controller_classes/adaptive_collocation.py b/pySDC/implementations/convergence_controller_classes/adaptive_collocation.py index 2e7580332c..65ce0280b6 100644 --- a/pySDC/implementations/convergence_controller_classes/adaptive_collocation.py +++ b/pySDC/implementations/convergence_controller_classes/adaptive_collocation.py @@ -142,8 +142,7 @@ def switch_sweeper(self, S): nodes_old = L.sweep.coll.nodes.copy() # change sweeper - L.sweep.__init__(update_params_sweeper) - L.sweep.level = L + L.sweep.__init__(update_params_sweeper, L) # reset level to tell it the new structure of the solution L.params.__dict__.update(new_params_level) diff --git a/pySDC/implementations/sweeper_classes/Multistep.py b/pySDC/implementations/sweeper_classes/Multistep.py index 1a4de3f6ec..08220c2a96 100644 --- a/pySDC/implementations/sweeper_classes/Multistep.py +++ b/pySDC/implementations/sweeper_classes/Multistep.py @@ -1,4 +1,5 @@ from pySDC.core.sweeper import Sweeper, _Pars +from pySDC.core.level import Level class Cache(object): @@ -55,7 +56,7 @@ class MultiStep(Sweeper): alpha = None beta = None - def __init__(self, params): + def __init__(self, params, level): """ Initialization routine for the base sweeper. @@ -71,6 +72,7 @@ def __init__(self, params): Args: params (dict): parameter object + level (pySDC.Level.level): the level that uses this sweeper """ import logging from pySDC.core.collocation import CollBase @@ -88,8 +90,7 @@ def __init__(self, params): # we need a dummy collocation object to instantiate the levels. self.coll = CollBase(num_nodes=1, quad_type='RADAU-RIGHT') - # This will be set as soon as the sweeper is instantiated at the level - self.__level = None + self.__level = level self.parallelizable = False @@ -97,6 +98,28 @@ def __init__(self, params): self.steps = len(self.alpha) self.cache = Cache(self.steps) + @property + def level(self): + """ + Returns the current level + + Returns: + pySDC.Level.level: Current level + """ + return self.__level + + @level.setter + def level(self, lvl): + """ + Sets a reference to the current level (done in the initialization of the level) + + Args: + lvl (pySDC.Level.level): Current level + """ + assert isinstance(lvl, Level), f"You tried to set the sweeper's level with an instance of {type(lvl)}!" + + self.__level = lvl + def predict(self): """ Add the initial conditions to the cache if needed. diff --git a/pySDC/implementations/sweeper_classes/Runge_Kutta.py b/pySDC/implementations/sweeper_classes/Runge_Kutta.py index 1ec9d58e32..6c6c07641e 100644 --- a/pySDC/implementations/sweeper_classes/Runge_Kutta.py +++ b/pySDC/implementations/sweeper_classes/Runge_Kutta.py @@ -125,12 +125,13 @@ class RungeKutta(Sweeper): The entries of the Butcher tableau are stored as class attributes. """ - def __init__(self, params): + def __init__(self, params, level): """ Initialization routine for the custom sweeper Args: params: parameters for the sweeper + level (pySDC.Level.level): the level that uses this sweeper """ # set up logger self.logger = logging.getLogger('sweeper') @@ -156,8 +157,9 @@ def __init__(self, params): self.params = _Pars(params) - # This will be set as soon as the sweeper is instantiated at the level + # set level using the setter in order to adapt residual tolerance if needed self.__level = None + self.level = level self.parallelizable = False self.QI = self.coll.Qmat @@ -343,14 +345,15 @@ class RungeKuttaIMEX(RungeKutta): weights_explicit = None ButcherTableauClass_explicit = ButcherTableau - def __init__(self, params): + def __init__(self, params, level): """ Initialization routine Args: params: parameters for the sweeper + level (pySDC.Level.level): the level that uses this sweeper """ - super().__init__(params) + super().__init__(params, level) type(self).weights_explicit = self.weights if self.weights_explicit is None else self.weights_explicit self.coll_explicit = self.get_Butcher_tableau_explicit() self.QE = self.coll_explicit.Qmat diff --git a/pySDC/implementations/sweeper_classes/Runge_Kutta_Nystrom.py b/pySDC/implementations/sweeper_classes/Runge_Kutta_Nystrom.py index ce3910ef02..ed7550ae65 100644 --- a/pySDC/implementations/sweeper_classes/Runge_Kutta_Nystrom.py +++ b/pySDC/implementations/sweeper_classes/Runge_Kutta_Nystrom.py @@ -104,14 +104,15 @@ class RungeKuttaNystrom(RungeKutta): weights_bar = None matrix_bar = None - def __init__(self, params): + def __init__(self, params, level): """ Initialization routine for the custom sweeper Args: params: parameters for the sweeper + level (pySDC.Level.level): the level that uses this sweeper """ - super().__init__(params) + super().__init__(params, level) self.coll_bar = self.get_Butcher_tableau_bar() self.Qx = self.coll_bar.Qmat diff --git a/pySDC/implementations/sweeper_classes/boris_2nd_order.py b/pySDC/implementations/sweeper_classes/boris_2nd_order.py index 1ff5c2471c..fb395a9f3f 100644 --- a/pySDC/implementations/sweeper_classes/boris_2nd_order.py +++ b/pySDC/implementations/sweeper_classes/boris_2nd_order.py @@ -16,22 +16,21 @@ class boris_2nd_order(Sweeper): Sx: node-to-node Euler half-step for position update """ - def __init__(self, params): + def __init__(self, params, level): """ Initialization routine for the custom sweeper Args: params: parameters for the sweeper + level (pySDC.Level.level): the level that uses this sweeper """ - # call parent's initialization routine - if "QI" not in params: params["QI"] = "IE" if "QE" not in params: params["QE"] = "EE" - super(boris_2nd_order, self).__init__(params) + super(boris_2nd_order, self).__init__(params, level) # S- and SQ-matrices (derived from Q) and Sx- and ST-matrices for the integrator [ diff --git a/pySDC/implementations/sweeper_classes/explicit.py b/pySDC/implementations/sweeper_classes/explicit.py index a69910d8c5..4ecc35536b 100644 --- a/pySDC/implementations/sweeper_classes/explicit.py +++ b/pySDC/implementations/sweeper_classes/explicit.py @@ -9,19 +9,19 @@ class explicit(Sweeper): QE: explicit Euler integration matrix """ - def __init__(self, params): + def __init__(self, params, level): """ Initialization routine for the custom sweeper Args: params: parameters for the sweeper + level (pySDC.Level.level): the level that uses this sweeper """ if 'QE' not in params: params['QE'] = 'EE' - # call parent's initialization routine - super(explicit, self).__init__(params) + super(explicit, self).__init__(params, level) # integration matrix self.QE = self.get_Qdelta_explicit(qd_type=self.params.QE) diff --git a/pySDC/implementations/sweeper_classes/generic_implicit.py b/pySDC/implementations/sweeper_classes/generic_implicit.py index a70b1045c4..cf33d5bd35 100644 --- a/pySDC/implementations/sweeper_classes/generic_implicit.py +++ b/pySDC/implementations/sweeper_classes/generic_implicit.py @@ -9,19 +9,19 @@ class generic_implicit(Sweeper): QI: lower triangular matrix """ - def __init__(self, params): + def __init__(self, params, level): """ Initialization routine for the custom sweeper Args: params: parameters for the sweeper + level (pySDC.Level.level): the level that uses this sweeper """ if 'QI' not in params: params['QI'] = 'IE' - # call parent's initialization routine - super().__init__(params) + super().__init__(params, level) # get QI matrix self.QI = self.get_Qdelta_implicit(qd_type=self.params.QI) diff --git a/pySDC/implementations/sweeper_classes/generic_implicit_MPI.py b/pySDC/implementations/sweeper_classes/generic_implicit_MPI.py index 4df14c346d..cf3cba2087 100644 --- a/pySDC/implementations/sweeper_classes/generic_implicit_MPI.py +++ b/pySDC/implementations/sweeper_classes/generic_implicit_MPI.py @@ -22,13 +22,20 @@ class adds a communicator and nothing else. The `generic_implicit` implicit clas `generic_implicit`. """ - def __init__(self, params): + def __init__(self, params, level): + """ + Initialization routine for the sweeper + + Args: + params: parameters for the sweeper + level (pySDC.Level.level): the level that uses this sweeper + """ self.logger = logging.getLogger('sweeper') if 'comm' not in params.keys(): params['comm'] = MPI.COMM_WORLD self.logger.debug('Using MPI.COMM_WORLD for the communicator because none was supplied in the params.') - super().__init__(params) + super().__init__(params, level) if self.params.comm.size != self.coll.num_nodes: raise NotImplementedError( diff --git a/pySDC/implementations/sweeper_classes/imex_1st_order.py b/pySDC/implementations/sweeper_classes/imex_1st_order.py index 181776b635..bd20e19953 100644 --- a/pySDC/implementations/sweeper_classes/imex_1st_order.py +++ b/pySDC/implementations/sweeper_classes/imex_1st_order.py @@ -14,12 +14,13 @@ class imex_1st_order(Sweeper): QE: explicit Euler integration matrix """ - def __init__(self, params): + def __init__(self, params, level): """ Initialization routine for the custom sweeper Args: params: parameters for the sweeper + level (pySDC.Level.level): the level that uses this sweeper """ if 'QI' not in params: @@ -27,8 +28,7 @@ def __init__(self, params): if 'QE' not in params: params['QE'] = 'EE' - # call parent's initialization routine - super().__init__(params) + super().__init__(params, level) # IMEX integration matrices self.QI = self.get_Qdelta_implicit(qd_type=self.params.QI) diff --git a/pySDC/implementations/sweeper_classes/imex_1st_order_MPI.py b/pySDC/implementations/sweeper_classes/imex_1st_order_MPI.py index cdadd721f5..4c16ca8b61 100644 --- a/pySDC/implementations/sweeper_classes/imex_1st_order_MPI.py +++ b/pySDC/implementations/sweeper_classes/imex_1st_order_MPI.py @@ -4,11 +4,11 @@ class imex_1st_order_MPI(SweeperMPI, imex_1st_order): - def __init__(self, params): - super().__init__(params) + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) assert ( self.params.QE == 'PIC' - ), f"Only Picard is implemented for explicit precondioner so far in {type(self).__name__}! You chose \"{self.params.QE}\"" + ), f"Only Picard is implemented for explicit preconditioner so far in {type(self).__name__}! You chose \"{self.params.QE}\"" def integrate(self, last_only=False): """ diff --git a/pySDC/implementations/sweeper_classes/multi_implicit.py b/pySDC/implementations/sweeper_classes/multi_implicit.py index 807e34425c..b11276ce6b 100644 --- a/pySDC/implementations/sweeper_classes/multi_implicit.py +++ b/pySDC/implementations/sweeper_classes/multi_implicit.py @@ -12,12 +12,13 @@ class multi_implicit(Sweeper): Q2: implicit integration matrix for the second component """ - def __init__(self, params): + def __init__(self, params, level): """ Initialization routine for the custom sweeper Args: params: parameters for the sweeper + level (pySDC.Level.level): the level that uses this sweeper """ # Default choice: implicit Euler @@ -27,7 +28,7 @@ def __init__(self, params): params['Q2'] = 'IE' # call parent's initialization routine - super(multi_implicit, self).__init__(params) + super(multi_implicit, self).__init__(params, level) # Integration matrices self.Q1 = self.get_Qdelta_implicit(qd_type=self.params.Q1) diff --git a/pySDC/implementations/sweeper_classes/verlet.py b/pySDC/implementations/sweeper_classes/verlet.py index da014dbb9a..01343d0fa5 100644 --- a/pySDC/implementations/sweeper_classes/verlet.py +++ b/pySDC/implementations/sweeper_classes/verlet.py @@ -16,12 +16,13 @@ class verlet(Sweeper): qQ: update rule for final value (if needed) """ - def __init__(self, params): + def __init__(self, params, level): """ Initialization routine for the custom sweeper Args: params: parameters for the sweeper + level (pySDC.Level.level): the level that uses this sweeper """ if 'QI' not in params: @@ -29,8 +30,7 @@ def __init__(self, params): if 'QE' not in params: params['QE'] = 'EE' - # call parent's initialization routine - super(verlet, self).__init__(params) + super(verlet, self).__init__(params, level) # Trapezoidal rule, Qx and Double-Q as in the Boris-paper [self.QT, self.Qx, self.QQ] = self.__get_Qd() diff --git a/pySDC/projects/DAE/sweepers/fullyImplicitDAE.py b/pySDC/projects/DAE/sweepers/fullyImplicitDAE.py index a879300699..32ffd1684b 100644 --- a/pySDC/projects/DAE/sweepers/fullyImplicitDAE.py +++ b/pySDC/projects/DAE/sweepers/fullyImplicitDAE.py @@ -45,14 +45,13 @@ class FullyImplicitDAE(generic_implicit): J. Comput. Phys. Vol. 221 No. 2 (2007). """ - def __init__(self, params): + def __init__(self, params, level): """Initialization routine""" if 'QI' not in params: params['QI'] = 'IE' - # call parent's initialization routine - super().__init__(params) + super().__init__(params, level) msg = f"Quadrature type {self.params.quad_type} is not implemented yet. Use 'RADAU-RIGHT' instead!" if self.coll.left_is_node: diff --git a/pySDC/projects/DAE/sweepers/rungeKuttaDAE.py b/pySDC/projects/DAE/sweepers/rungeKuttaDAE.py index 8f7fb5361d..917f08a007 100644 --- a/pySDC/projects/DAE/sweepers/rungeKuttaDAE.py +++ b/pySDC/projects/DAE/sweepers/rungeKuttaDAE.py @@ -76,8 +76,8 @@ class RungeKuttaDAE(RungeKutta): More details can be found [here](https://github.com/Parallel-in-Time/pySDC/blob/master/pySDC/implementations/sweeper_classes/Runge_Kutta.py). """ - def __init__(self, params): - super().__init__(params) + def __init__(self, params, level): + super().__init__(params, level) self.du_init = None self.fully_initialized = False diff --git a/pySDC/projects/DAE/sweepers/semiImplicitDAE.py b/pySDC/projects/DAE/sweepers/semiImplicitDAE.py index 141fca506e..a918e48879 100644 --- a/pySDC/projects/DAE/sweepers/semiImplicitDAE.py +++ b/pySDC/projects/DAE/sweepers/semiImplicitDAE.py @@ -83,14 +83,13 @@ class SemiImplicitDAE(FullyImplicitDAE): :math:`F_{new}(\vec{x}, \vec{x}')`. """ - def __init__(self, params): + def __init__(self, params, level): """Initialization routine""" if 'QI' not in params: params['QI'] = 'IE' - # call parent's initialization routine - super().__init__(params) + super().__init__(params, level) msg = f"Quadrature type {self.params.quad_type} is not implemented yet. Use 'RADAU-RIGHT' instead!" if self.coll.left_is_node: diff --git a/pySDC/projects/Monodomain/sweeper_classes/exponential_runge_kutta/imexexp_1st_order.py b/pySDC/projects/Monodomain/sweeper_classes/exponential_runge_kutta/imexexp_1st_order.py index 1805131a02..b7f1032c30 100644 --- a/pySDC/projects/Monodomain/sweeper_classes/exponential_runge_kutta/imexexp_1st_order.py +++ b/pySDC/projects/Monodomain/sweeper_classes/exponential_runge_kutta/imexexp_1st_order.py @@ -17,19 +17,19 @@ class imexexp_1st_order(Sweeper): The underlying intergrator is exponential Runge-Kutta, leading to exponential SDC (ESDC). """ - def __init__(self, params): + def __init__(self, params, level): """ Initialization routine for the custom sweeper Args: params: parameters for the sweeper + level (pySDC.Level.level): the level that uses this sweeper """ if "QI" not in params: params["QI"] = "IE" - # call parent's initialization routine - super(imexexp_1st_order, self).__init__(params) + super().__init__(params, level) # IMEX integration matrices self.QI = self.get_Qdelta_implicit(qd_type=self.params.QI) diff --git a/pySDC/projects/Monodomain/sweeper_classes/runge_kutta/imexexp_1st_order.py b/pySDC/projects/Monodomain/sweeper_classes/runge_kutta/imexexp_1st_order.py index 1217509d92..476ebbdd9e 100644 --- a/pySDC/projects/Monodomain/sweeper_classes/runge_kutta/imexexp_1st_order.py +++ b/pySDC/projects/Monodomain/sweeper_classes/runge_kutta/imexexp_1st_order.py @@ -13,19 +13,19 @@ class imexexp_1st_order(Sweeper): """ - def __init__(self, params): + def __init__(self, params, level): """ Initialization routine for the custom sweeper Args: params: parameters for the sweeper + level (pySDC.Level.level): the level that uses this sweeper """ if "QI" not in params: params["QI"] = "IE" - # call parent's initialization routine - super(imexexp_1st_order, self).__init__(params) + super().__init__(params, level) # IMEX integration matrices self.QI = self.get_Qdelta_implicit(qd_type=self.params.QI) diff --git a/pySDC/projects/parallelSDC/linearized_implicit_fixed_parallel.py b/pySDC/projects/parallelSDC/linearized_implicit_fixed_parallel.py index bb27c15912..2a3c19bc93 100644 --- a/pySDC/projects/parallelSDC/linearized_implicit_fixed_parallel.py +++ b/pySDC/projects/parallelSDC/linearized_implicit_fixed_parallel.py @@ -13,19 +13,19 @@ class linearized_implicit_fixed_parallel(linearized_implicit_parallel): D: eigenvalues of the QI """ - def __init__(self, params): + def __init__(self, params, level): """ Initialization routine for the custom sweeper Args: params: parameters for the sweeper + level (pySDC.Level.level): the level that uses this sweeper """ if 'fixed_time_in_jacobian' not in params: params['fixed_time_in_jacobian'] = 0 - # call parent's initialization routine - super(linearized_implicit_fixed_parallel, self).__init__(params) + super().__init__(params, level) assert self.params.fixed_time_in_jacobian in range(self.coll.num_nodes + 1), ( "ERROR: fixed_time_in_jacobian is too small or too large, got %s" % self.params.fixed_time_in_jacobian diff --git a/pySDC/projects/parallelSDC/linearized_implicit_fixed_parallel_prec.py b/pySDC/projects/parallelSDC/linearized_implicit_fixed_parallel_prec.py index b2285e53f3..7efce21758 100644 --- a/pySDC/projects/parallelSDC/linearized_implicit_fixed_parallel_prec.py +++ b/pySDC/projects/parallelSDC/linearized_implicit_fixed_parallel_prec.py @@ -11,19 +11,19 @@ class linearized_implicit_fixed_parallel_prec(linearized_implicit_fixed_parallel D: eigenvalues of the QI """ - def __init__(self, params): + def __init__(self, params, level): """ Initialization routine for the custom sweeper Args: params: parameters for the sweeper + level (pySDC.Level.level): the level that uses this sweeper """ if 'fixed_time_in_jacobian' not in params: params['fixed_time_in_jacobian'] = 0 - # call parent's initialization routine - super(linearized_implicit_fixed_parallel, self).__init__(params) + super().__init__(params, level) assert self.params.fixed_time_in_jacobian in range(self.coll.num_nodes + 1), ( "ERROR: fixed_time_in_jacobian is too small or too large, got %s" % self.params.fixed_time_in_jacobian diff --git a/pySDC/projects/parallelSDC/linearized_implicit_parallel.py b/pySDC/projects/parallelSDC/linearized_implicit_parallel.py index 766d3a4c88..90e540516c 100644 --- a/pySDC/projects/parallelSDC/linearized_implicit_parallel.py +++ b/pySDC/projects/parallelSDC/linearized_implicit_parallel.py @@ -8,19 +8,19 @@ class linearized_implicit_parallel(generic_implicit): Parallel sweeper using Newton for linearization """ - def __init__(self, params): + def __init__(self, params, level): """ Initialization routine for the custom sweeper Args: params: parameters for the sweeper + level (pySDC.Level.level): the level that uses this sweeper """ if 'fixed_time_in_jacobian' not in params: params['fixed_time_in_jacobian'] = 0 - # call parent's initialization routine - super(linearized_implicit_parallel, self).__init__(params) + super().__init__(params, level) self.D, self.V = np.linalg.eig(self.QI[1:, 1:]) self.Vi = np.linalg.inv(self.V) diff --git a/pySDC/projects/parallelSDC_reloaded/nilpotency.py b/pySDC/projects/parallelSDC_reloaded/nilpotency.py index d0852d3588..d79c2297f7 100644 --- a/pySDC/projects/parallelSDC_reloaded/nilpotency.py +++ b/pySDC/projects/parallelSDC_reloaded/nilpotency.py @@ -3,7 +3,7 @@ """ Created on Fri Dec 22 17:17:14 2023 -Evaluate the nilpotency of diagonal preconditionners MIN-SR-S and MIN-SR-NS +Evaluate the nilpotency of diagonal preconditioners MIN-SR-S and MIN-SR-NS with increasing number of nodes. """ import numpy as np @@ -36,7 +36,7 @@ def nilpotencyNS(d, Q): nil_MIN_SR_NS = [] nNodes = range(2, 20) for m in nNodes: - s = Sweeper({"num_nodes": m, "quad_type": quadType, "node_type": nodeType}) + s = Sweeper({"num_nodes": m, "quad_type": quadType, "node_type": nodeType}, None) Q = s.coll.Qmat[1:, 1:] nodes = s.coll.nodes diff --git a/pySDC/projects/soft_failure/implicit_sweeper_faults.py b/pySDC/projects/soft_failure/implicit_sweeper_faults.py index 17ee24b286..b623523fd0 100755 --- a/pySDC/projects/soft_failure/implicit_sweeper_faults.py +++ b/pySDC/projects/soft_failure/implicit_sweeper_faults.py @@ -28,12 +28,13 @@ class implicit_sweeper_faults(generic_implicit): """ - def __init__(self, params): + def __init__(self, params, level): """ Initialization routine for the custom sweeper Args: params: parameters for the sweeper + level (pySDC.Level.level): the level that uses this sweeper """ if 'allow_fault_correction' not in params: @@ -45,8 +46,7 @@ def __init__(self, params): if 'dump_injections_filehandle' not in params: params['dump_injections_filehandle'] = None - # call parent's initialization routine - super(implicit_sweeper_faults, self).__init__(params) + super().__init__(params, level) self.fault_stats = _fault_stats() diff --git a/pySDC/tests/test_sweepers/test_preconditioners.py b/pySDC/tests/test_sweepers/test_preconditioners.py index dab7575fee..a313a0ad56 100644 --- a/pySDC/tests/test_sweepers/test_preconditioners.py +++ b/pySDC/tests/test_sweepers/test_preconditioners.py @@ -14,7 +14,7 @@ @pytest.mark.parametrize("M", num_nodes) def test_MIN_SR(node_type, quad_type, M): params = {'num_nodes': M, 'quad_type': quad_type, 'node_type': node_type} - sweeper = Sweeper(params) + sweeper = Sweeper(params, None) Q = sweeper.coll.Qmat[1:, 1:] # Check non-stiff limit @@ -47,7 +47,7 @@ def test_MIN_SR(node_type, quad_type, M): @pytest.mark.parametrize("M", num_nodes) def test_MIN_SR_FLEX(node_type, quad_type, M): params = {'num_nodes': M, 'quad_type': quad_type, 'node_type': node_type} - sweeper = Sweeper(params) + sweeper = Sweeper(params, None) start_idx = 1 for i in range(M): @@ -138,7 +138,7 @@ def test_LU(node_type, quad_type, M): return params = {'num_nodes': M, 'quad_type': quad_type, 'node_type': node_type} - sweeper = Sweeper(params) + sweeper = Sweeper(params, None) Q = sweeper.coll.Qmat[1:, 1:] # Check nilpotency @@ -160,7 +160,7 @@ def test_LU(node_type, quad_type, M): @pytest.mark.parametrize("M", num_nodes) def test_Qpar(node_type, quad_type, M): params = {'num_nodes': M, 'quad_type': quad_type, 'node_type': node_type} - sweeper = Sweeper(params) + sweeper = Sweeper(params, None) Q = sweeper.coll.Qmat[1:, 1:] QDelta = sweeper.get_Qdelta_implicit('Qpar')[1:, 1:] @@ -174,7 +174,7 @@ def test_Qpar(node_type, quad_type, M): @pytest.mark.parametrize("M", num_nodes) def test_IE(node_type, quad_type, M): params = {'num_nodes': M, 'quad_type': quad_type, 'node_type': node_type} - sweeper = Sweeper(params) + sweeper = Sweeper(params, None) QDelta = sweeper.get_Qdelta_implicit('IE')[1:, 1:] for i in range(M): @@ -188,7 +188,7 @@ def test_IE(node_type, quad_type, M): @pytest.mark.parametrize("M", num_nodes) def test_IEpar(node_type, quad_type, M): params = {'num_nodes': M, 'quad_type': quad_type, 'node_type': node_type} - sweeper = Sweeper(params) + sweeper = Sweeper(params, None) QDelta = sweeper.get_Qdelta_implicit('IEpar')[1:, 1:] assert np.all(np.diag(np.diag(QDelta)) == QDelta), "no diagonal QDelta" @@ -201,7 +201,7 @@ def test_IEpar(node_type, quad_type, M): @pytest.mark.parametrize("M", num_nodes) def test_PIC(node_type, quad_type, M): params = {'num_nodes': M, 'quad_type': quad_type, 'node_type': node_type} - sweeper = Sweeper(params) + sweeper = Sweeper(params, None) QDelta = sweeper.get_Qdelta_implicit('PIC')[1:, 1:] assert np.all(QDelta == 0), "not a null matrix"