-
Notifications
You must be signed in to change notification settings - Fork 37
Description
In the current implementation, you can supply one user-defined hook class, which has to inherit from the core hook class.
The problem I want to resolve is the following: I have written a hook class recording parameters to my specific problem, but now for one plot I want to record one additional parameter. In my case that is the error compared to some reference solution which is not cheap to obtain, thus I don't just want to add it to the hook I use all the time. Currently that means I have to copy paste the hook class or add a level of inheritance, which get's messy quickly.
I would like the hooks module to have a similar structure to the convergence controller module.
That is to say rather than doing sth like
self.hook.pre_run(...)
I want
for hook in self.hooks:
hook.pre_run(...)
and so on in the controller.
That way I can easily write a separate hook class recording only the error wrt a reference solution and supply both to the controller as an array like object.
In my projects I could save a bunch of lines of code. In addition to not repeating statements in different hook classes, I could also forgo calling the parent methods via super all the time. Currently, doing this is mandatory, since timing variables will otherwise be missing.
Also, we could add some default hooks in an implementation folder, for instance for recording the solution at the end of the step, or I could write a hook that records the embedded error estimate that could be added automatically when adding the respective convergence controller and so on.
The __stats dictionary would have to be moved from the hook class to the controller class such that all hooks add entries to the same dictionary. Additionally, I would pass in all methods of the core hook class and instead write a default hook class that records all the stuff the core module currently does.
What do you think, @pancetta ? Yes, no, maybe?