11from pySDC .core .sweeper import Sweeper , _Pars
2+ from pySDC .core .level import Level
23
34
45class Cache (object ):
@@ -55,7 +56,7 @@ class MultiStep(Sweeper):
5556 alpha = None
5657 beta = None
5758
58- def __init__ (self , params ):
59+ def __init__ (self , params , level ):
5960 """
6061 Initialization routine for the base sweeper.
6162
@@ -71,6 +72,7 @@ def __init__(self, params):
7172
7273 Args:
7374 params (dict): parameter object
75+ level (pySDC.Level.level): the level that uses this sweeper
7476 """
7577 import logging
7678 from pySDC .core .collocation import CollBase
@@ -88,15 +90,36 @@ def __init__(self, params):
8890 # we need a dummy collocation object to instantiate the levels.
8991 self .coll = CollBase (num_nodes = 1 , quad_type = 'RADAU-RIGHT' )
9092
91- # This will be set as soon as the sweeper is instantiated at the level
92- self .__level = None
93+ self .__level = level
9394
9495 self .parallelizable = False
9596
9697 # proprietary variables for the multistep methods
9798 self .steps = len (self .alpha )
9899 self .cache = Cache (self .steps )
99100
101+ @property
102+ def level (self ):
103+ """
104+ Returns the current level
105+
106+ Returns:
107+ pySDC.Level.level: Current level
108+ """
109+ return self .__level
110+
111+ @level .setter
112+ def level (self , lvl ):
113+ """
114+ Sets a reference to the current level (done in the initialization of the level)
115+
116+ Args:
117+ lvl (pySDC.Level.level): Current level
118+ """
119+ assert isinstance (lvl , Level ), f"You tried to set the sweeper's level with an instance of { type (lvl )} !"
120+
121+ self .__level = lvl
122+
100123 def predict (self ):
101124 """
102125 Add the initial conditions to the cache if needed.
0 commit comments