Make initial conditions with random numbers invariant wrt the order of AMR/analysis callbacks
#342 opened on Nov 17, 2020
Description
Thus the order of AMR and analysis seems to matter - why, however, is currently beyond me. If the analysis happens before AMR, there are a total of 111 time steps for the test (with
tspan=(0.0, 0.2)). If it happens afterwards, it increases to114time steps. Thus, somehow the analysis step affects the solution in such a way that a subsequent AMR procedure is affected. Does it have to do with the analysis callback executingrhs!? As I said: I don't get it. Any ideas, @ranocha?
The analysis callback computes "error" norms by comparing to the initial condition - in particular when the analysis callback is initialized. Similarly, the AMR callback will call the initial condition when it's initialized to perform initial AMR. Since the initial condition uses random numbers, a different order of these callbacks will of course lead to different results.
Possible adaptations allowing us to move the callbacks around while still keeping the current order of initial AMR and analysis are
- to disable initial calculation of error norms (which would be weird, I think)
- to allow calling an AMR callback directly on an ODE to perform initial refinement
Other than that, I still think it's often not really appropriate to rely on a fixed stream of random numbers. It might be better here to just check some statistical errors etc. - or to disable initial AMR and load the corresponding data from a file.
Originally posted by @ranocha in https://github.com/trixi-framework/Trixi.jl/issues/338#issuecomment-728699593