trixi-framework / Trixi.jl

Trixi.jl: Adaptive high-order numerical simulations of conservation laws in Julia
https://trixi-framework.github.io/Trixi.jl
MIT License
505 stars 98 forks source link

Save and load user_data for p4est #1915

Closed benegee closed 4 weeks ago

benegee commented 2 months ago

This fixes restating when using AMR. Resolves #1914

github-actions[bot] commented 2 months ago

Review checklist

This checklist is meant to assist creators of PRs (to let them know what reviewers will typically look for) and reviewers (to guide them in a structured review process). Items do not need to be checked explicitly for a PR to be eligible for merging.

Purpose and scope

Code quality

Documentation

Testing

Performance

Verification

Created with :heart: by the Trixi.jl community.

codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 96.13%. Comparing base (8665300) to head (7b11b29).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1915 +/- ## ========================================== + Coverage 95.93% 96.13% +0.19% ========================================== Files 460 460 Lines 36952 36956 +4 ========================================== + Hits 35449 35524 +75 + Misses 1503 1432 -71 ``` | [Flag](https://app.codecov.io/gh/trixi-framework/Trixi.jl/pull/1915/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=trixi-framework) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/trixi-framework/Trixi.jl/pull/1915/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=trixi-framework) | `96.13% <100.00%> (+0.19%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=trixi-framework#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

ranocha commented 2 months ago

Can we have a CI test for this?

benegee commented 2 months ago

I am still unhappy with this fix. While new_p4est allows to just allocate user data, load_p4est requires to also provide the data. So in the end I am only saving the data to have memory allocated upon restart.

I also do not know if there was a good reason for not saving user data in the first place.

benegee commented 1 month ago

The solution is to use p4est_reset_data! https://github.com/cburstedde/p4est/issues/308

DanielDoehring commented 1 month ago

So with this, is it possible to restart a simulation and refine the initial condition?

benegee commented 1 month ago

So with this, is it possible to restart a simulation and refine the initial condition?

Just checked with this example here and it seems to work.

DanielDoehring commented 1 month ago

Just checked with this example here and it seems to work.

Cool, thanks for picking this up!

ranocha commented 1 month ago

So with this, is it possible to restart a simulation and refine the initial condition?

Just checked with this example here and it seems to work.

Do we have a test for this? Or is it covered by the tests we already have?

DanielDoehring commented 4 weeks ago

Do we have a test for this? Or is it covered by the tests we already have?

So the newly introduced test does exactly this. So in some sense we "test for crash".

benegee commented 4 weeks ago

Thanks for your feedback!

Following @JoshuaLampert 's comment above and https://github.com/trixi-framework/Trixi.jl/pull/1384#issuecomment-1505878188 I removed ode_default_options() in elixir_advection_{extended,restart,restart_amr}.jl for p4est_2d_dgsem and tree_2d_dgsem.

In the new elixir_advection_restart_amr.jl for p4est_2d_dgsem and tree_2d_dgsem I set adapt_initial_condition = true. This still tests the restarting capability in general.

ranocha commented 4 weeks ago

Thanks! However, some test tolerances are not satisfied right now: https://github.com/trixi-framework/Trixi.jl/actions/runs/9398803634/job/25884924262?pr=1915#step:7:2874

benegee commented 4 weeks ago

Thanks! However, some test tolerances are not satisfied right now: https://github.com/trixi-framework/Trixi.jl/actions/runs/9398803634/job/25884924262?pr=1915#step:7:2874

Yes! I wanted to update them, but it seems I also introduced some issue in the MPI test. I'm on it.

benegee commented 4 weeks ago

It seems to work now!