Coverage for pySDC/projects/Monodomain/hooks/HookClass_post_iter_info.py: 100%
10 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
1import time
2from pySDC.core.hooks import Hooks
5class post_iter_info_hook(Hooks):
6 """
7 Hook class to write additional iteration information to the command line.
8 It is used to print the final residual, after u[0] has been updated with the new value from the previous step.
9 This residual is the one used to check the convergence of the iteration and when running in parallel is different from
10 the one printed at IT_FINE.
11 """
13 def __init__(self):
14 super(post_iter_info_hook, self).__init__()
16 def post_iteration(self, step, level_number):
17 """
18 Overwrite default routine called after each iteration.
19 It calls the default routine and then writes the residual to the command line.
20 We call this the residual at IT_END.
21 """
22 super().post_iteration(step, level_number)
23 self.__t1_iteration = time.perf_counter()
25 L = step.levels[level_number]
27 self.logger.info(
28 "Process %2i on time %8.6f at stage %15s: ----------- Iteration: %2i --------------- " "residual: %12.8e",
29 step.status.slot,
30 L.time,
31 "IT_END",
32 step.status.iter,
33 L.status.residual,
34 )