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

AMR-Compat SurfaceIntegrals #1959

Closed DanielDoehring closed 1 day ago

DanielDoehring commented 1 month ago

This fixes https://github.com/trixi-framework/Trixi.jl/issues/1955 by re-computing the boundary indices every time the surface integral is computed.

As the boundary indices need to be specified as a Tuple and no longer simply a Symbol or Vector of Symbols, this is breaking.

github-actions[bot] commented 1 month 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 1 month ago

Codecov Report

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

Project coverage is 96.16%. Comparing base (def208b) to head (cdd1bc7). Report is 4 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1959 +/- ## ======================================= Coverage 96.16% 96.16% ======================================= Files 460 460 Lines 36980 36984 +4 ======================================= + Hits 35560 35564 +4 Misses 1420 1420 ``` | [Flag](https://app.codecov.io/gh/trixi-framework/Trixi.jl/pull/1959/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/1959/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=trixi-framework) | `96.16% <100.00%> (+<0.01%)` | :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.

DanielDoehring commented 1 month ago

Thanks for tackling this. How urgent is the fix for you? I'm asking since this is a hotfix with a breaking change. An alternative would be to implement a notification by the AMR callback as mentioned in #215. Thus, we may discuss whether this could be a more general approach that helps us in the long run

I plan to show/use this for the JuliaCon talk (this is also where I realized that this is buggy).

I absolutely agree that #215 makes a hell lot of sense, but this also seems to me like a very-long range project. Until then, I suggest that we get the callback working also with AMR.

ranocha commented 1 month ago

Ok. How much overhead do we get by this for non-AMR cases?

DanielDoehring commented 1 month ago

How much overhead do we get by this for non-AMR cases?

I added some timings:

 analyze solution                    27    175ms    1.2%  6.48ms    564KiB    5.9%  20.9KiB
   ~analyze solution~                27    174ms    1.2%  6.44ms    361KiB    3.8%  13.4KiB
   AnalysisSurfaceIntegral          108    998μs    0.0%  9.24μs    203KiB    2.1%  1.88KiB
     ~AnalysisSurfaceIntegral~      108    851μs    0.0%  7.88μs      752B    0.0%    6.96B
     inidices                       108    147μs    0.0%  1.36μs    202KiB    2.1%  1.88KiB

for this elixir: https://github.com/trixi-framework/Trixi.jl/blob/main/examples/p4est_2d_dgsem/elixir_navierstokes_NACA0012airfoil_mach08.jl So there are some allocations due to the reconstruction of the indices vector.

Note that the callback gets in this case called every 10th timestep, much more than in an actual case. But this allowed me to reduce the total runtime and the analysis interval.

Arpit-Babbar commented 2 weeks ago

I see that this PR is mentioned in v0.8. Does it mean that it will be merged eventually? There is no urgency from my side, but it will be good to know. If this PR is going to be merged, we can make this nearly final (i.e., ready to merge whenever v0.8 is released) and rebase https://github.com/trixi-framework/Trixi.jl/pull/1920 on top of this.

ranocha commented 2 weeks ago

Yes, I think it would be good to merge this somewhat soon and release v0.8. What's your take on this, @DanielDoehring?

DanielDoehring commented 1 week ago

I added this to v0.8 as this is a breaking change, which we typically handle by increasing the first version decimal. From my side this is good to go, so you are kindly invited to review this (again). :)

ranocha commented 1 week ago

Thanks!

@Arpit-Babbar Any suggestions from your side to improve this PR? Otherwise, I would like to proceed as you suggested above

If this PR is going to be merged, we can make this nearly final (i.e., ready to merge whenever v0.8 is released) and rebase #1920 on top of this.

ranocha commented 1 week ago

@Arpit-Babbar Are there further breaking changes that you need for https://github.com/trixi-framework/Trixi.jl/pull/1920?

ranocha commented 5 days ago

@sloede How's your review going? Do you have a rough estimate when you will have some time for it?

sloede commented 4 days ago

As the boundary indices need to be specified as a Tuple and no longer simply a Symbol or Vector of Symbols, this is breaking.

Why again is this change needed and couldn't remain a Vector of symbols?

DanielDoehring commented 4 days ago

I wonder, however, whether this is really a breaking change. From what I can see, this is really a bugfix, since the surface integral computation was already used for AMR simulations but just produced the wrong output. I thus think this shouldn't require a minor version bump, but only a patch release.

The reason why this is breaking is that the boundary symbols have now to be supplied as a NTuple, not just a Symbol or a Vector of Symbols. Thus, even in the non-AMR case the user interface changes.