Coverage for pySDC/projects/Monodomain/hooks/HookClass_pde.py: 100%

16 statements  

« prev     ^ index     » next       coverage.py v7.6.9, created at 2024-12-20 14:51 +0000

1from pySDC.core.hooks import Hooks 

2 

3 

4class pde_hook(Hooks): 

5 """ 

6 Hook class to write the solution to file. 

7 """ 

8 

9 def __init__(self): 

10 super(pde_hook, self).__init__() 

11 

12 def pre_run(self, step, level_number): 

13 """ 

14 Overwrite default routine called before time-loop starts 

15 It calls the default routine and then writes the initial value to file. 

16 """ 

17 super(pde_hook, self).pre_run(step, level_number) 

18 

19 L = step.levels[level_number] 

20 P = L.prob 

21 if level_number == 0 and L.time == P.t0: 

22 P.write_solution(L.u[0], P.t0) 

23 

24 def post_step(self, step, level_number): 

25 """ 

26 Overwrite default routine called after each step. 

27 It calls the default routine and then writes the solution to file. 

28 """ 

29 super(pde_hook, self).post_step(step, level_number) 

30 

31 if level_number == 0: 

32 L = step.levels[level_number] 

33 P = L.prob 

34 P.write_solution(L.uend, L.time + L.dt)