Add ProblemInitPackageData callback and update souce callbacks
Add ProblemInitPackageData
to allow modification/additions to the "Hydro" package from a problem generator.
This also changes the logic on how to enroll source functions, but I'm not sure which way I prefer.
Originally, a problem related source function (so no physics source function that will/should be generally be used across problems) would be enrolled by adding the function pointer to the package, e.g., via
hydro_pkg->UpdateParam<Hydro::SourceFirstOrderFun_t>(
Hydro::source_first_order_param_key, RandomBlasts);
which, with this MR, could be called in the ProblemInitPackageData
function.
The new version now has a global callback function ProblemSourceFirstOrder
so that each package that wants to enroll that function needs to override it in the problem related conditional in main.cpp
.
I made the change as I felt that the original variant used the Params
interface in an unnecessary way because for problem specific functions there's only ever one version called for a given simulation.
Thus the flexibility through Params
is not required and a "standard" function callback looks like a cleaner interface.
The "drawback" is that adding a source function now also requires to add the declaration to pgen.hpp
so that it can be enrolled in main.cpp
(though all is namespace protected) whereas in the original version all the enroll logic could be fully contained in the problem generator source file (within the ProblemInitPackageData
call -- though, in turn, that call would need to be added as a callback in main.cpp
).
What do you think, @forrestglines ?
I'll add documentation when we decide which way to go.
PS: I wonder if we could get cmake to automatically create all the problem-related callback logic currently in main.cpp
, e.g., based on list of source files in the pgen
directory. Just a quality of life improvement (which would also allow to reduce the binary size if that ever becomes a problem).