parthenon-hpc-lab / parthenon

Parthenon AMR infrastructure
https://parthenon-hpc-lab.github.io/parthenon/
Other
112 stars 33 forks source link

Make AMR and sparse restarts bitwise exact #1073

Closed lroberts36 closed 4 months ago

lroberts36 commented 4 months ago

PR Summary

This PR saves the derefinement count for each meshblock and the deallocation count for each sparse variable in the restart output (as well as in regular HDF5 output). This should ensure that restarted simulations give bitwise exact results to simulations that were run from start to finish.

Previously, AMR simulations that were restarted had the deallocation count of all meshblocks reset to zero. This meant that after restart, a block could be deallocated a few steps after it would have been deallocated if there was no restart. This resulted in differences in simulation results with and without restarts many orders of magnitude larger than machine precision, although still relatively small compared to characteristic scales of the problem. An example of this difference is in issue #1072 (the problem detailed there is fixed by this PR).

Similarly, the deallocation count of sparse variables was not stored and was reset to zero on restart. This was a known issue, and the restart regression test set the global deallocation count large enough that variables were never deallocated. This PR also stores the deallocation count of variables in the restart file and sets them to the correct values on restart. The restart test now works with a deallocation count of 5.

Also, MeshRefinement::DereferenceCount is renamed to MeshRefinement::DeallocationCount since dereference count doesn't really make sense.

WARNING: This PR does not solve the edge case described in issue #1077

PR Checklist