Coverage for pySDC/implementations/convergence_controller_classes/store_uold.py: 100%
14 statements
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-20 14:51 +0000
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-20 14:51 +0000
1from pySDC.core.convergence_controller import ConvergenceController
4class StoreUOld(ConvergenceController):
5 """
6 Class to store the solution of the last iteration in a variable called 'uold' of the levels.
8 Default control order is 90.
9 """
11 def setup(self, controller, params, description, **kwargs):
12 """
13 Define parameters here
15 Args:
16 controller (pySDC.Controller): The controller
17 params (dict): The params passed for this specific convergence controller
18 description (dict): The description object used to instantiate the controller
20 Returns:
21 (dict): The updated params dictionary
22 """
23 return {"control_order": +90, **super().setup(controller, params, description, **kwargs)}
25 def post_iteration_processing(self, controller, S, **kwargs):
26 """
27 Store the solution at the current iteration
29 Args:
30 controller (pySDC.Controller): The controller
31 S (pySDC.Step): The current step
33 Return:
34 None
35 """
36 for L in S.levels:
37 for i in range(len(L.u)):
38 if L.u[i] is not None:
39 L.uold[i] = L.prob.dtype_u(L.u[i])
40 else:
41 L.uold[i] = None
43 return None
45 def post_spread_processing(self, controller, S, **kwargs):
46 """
47 Store the initial conditions in u_old in the spread phase.
49 Args:
50 controller (pySDC.Controller): The controller
51 S (pySDC.Step): The current step
53 Return:
54 None
55 """
56 self.post_iteration_processing(controller, S, **kwargs)
57 return None