Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add implementation of subcell bounds check #1672

Merged
merged 20 commits into from
Oct 20, 2023

Conversation

bennibolm
Copy link
Contributor

@bennibolm bennibolm commented Oct 16, 2023

This PR adds the implementation of a subcell local bounds check. Rn, now it only contains the check for positivity bounds since it's the only feature merged to main.

It is implemented as a stage callback. Therefore, the solution before the convex combination in the SSPRK method is checked. This is sufficient since it is a convex combination and the previous solution is already checked.
BUT: The stage callback has to be called after SubcellLimiterIDPCorrection to obtain a meaningful test.

At the end of the simulation, the following output is added:

────────────────────────────────────────────────────────────────────────────────────────────────────
Maximum deviation from bounds:
────────────────────────────────────────────────────────────────────────────────────────────────────
rho1:
- positivity: 2.220446049250313e-16
rho2:
- positivity: 3.122502256758253e-17
────────────────────────────────────────────────────────────────────────────────────────────────────

If save_errors=true the deviations of the last stage in every time step is saved into a text file.

I just found an error in a note in the docstring of SubcellLimiterIDP. If the correction stage callback is no enabled, we do not get a DGSEM but a FV scheme. I fixed it in this PR.

@github-actions
Copy link
Contributor

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

  • The PR has a single goal that is clear from the PR title and/or description.
  • All code changes represent a single set of modifications that logically belong together.
  • No more than 500 lines of code are changed or there is no obvious way to split the PR into multiple PRs.

Code quality

  • The code can be understood easily.
  • Newly introduced names for variables etc. are self-descriptive and consistent with existing naming conventions.
  • There are no redundancies that can be removed by simple modularization/refactoring.
  • There are no leftover debug statements or commented code sections.
  • The code adheres to our conventions and style guide, and to the Julia guidelines.

Documentation

  • New functions and types are documented with a docstring or top-level comment.
  • Relevant publications are referenced in docstrings (see example for formatting).
  • Inline comments are used to document longer or unusual code sections.
  • Comments describe intent ("why?") and not just functionality ("what?").
  • If the PR introduces a significant change or new feature, it is documented in NEWS.md.

Testing

  • The PR passes all tests.
  • New or modified lines of code are covered by tests.
  • New or modified tests run in less then 10 seconds.

Performance

  • There are no type instabilities or memory allocations in performance-critical parts.
  • If the PR intent is to improve performance, before/after time measurements are posted in the PR.

Verification

  • The correctness of the code was verified using appropriate tests.
  • If new equations/methods are added, a convergence test has been run and the results
    are posted in the PR.

Created with ❤️ by the Trixi.jl community.

@codecov
Copy link

codecov bot commented Oct 17, 2023

Codecov Report

Attention: 84 lines in your changes are missing coverage. Please review.

Comparison is base (bb60b5d) 86.47% compared to head (f4f4146) 87.21%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1672      +/-   ##
==========================================
+ Coverage   86.47%   87.21%   +0.73%     
==========================================
  Files         423      425       +2     
  Lines       34312    34379      +67     
==========================================
+ Hits        29671    29981     +310     
+ Misses       4641     4398     -243     
Flag Coverage Δ
unittests 87.21% <0.00%> (+0.73%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...ee_2d_dgsem/elixir_euler_shockcapturing_subcell.jl 0.00% <ø> (-100.00%) ⬇️
..._shock_bubble_shockcapturing_subcell_positivity.jl 0.00% <ø> (-100.00%) ⬇️
src/Trixi.jl 43.48% <ø> (ø)
src/solvers/dgsem_tree/subcell_limiters.jl 29.41% <0.00%> (-55.88%) ⬇️
src/solvers/dgsem_tree/subcell_limiters_2d.jl 0.00% <0.00%> (-94.34%) ⬇️
src/callbacks_stage/subcell_bounds_check_2d.jl 0.00% <0.00%> (ø)
src/callbacks_stage/subcell_bounds_check.jl 0.00% <0.00%> (ø)

... and 107 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bennibolm
Copy link
Contributor Author

The implementation for exporting the deviations when save_errors=true is not tested right now. Should I activate it in one elixir to change this?
More general: Is this feature even wanted in main? For me, it was very helpful to have more information than the final maximum deviations, which is printed in the console at the end of a simulation.

@sloede
Copy link
Member

sloede commented Oct 17, 2023

The implementation for exporting the deviations when save_errors=true is not tested right now. Should I activate it in one elixir to change this? More general: Is this feature even wanted in main? For me, it was very helpful to have more information than the final maximum deviations, which is printed in the console at the end of a simulation.

I think everything that is useful for a future scientist/developer/debugger would make sense to keep. And yes, if you want to keep it, you should at least use it and check that a file was actually created.

@bennibolm
Copy link
Contributor Author

The implementation for exporting the deviations when save_errors=true is not tested right now. Should I activate it in one elixir to change this? More general: Is this feature even wanted in main? For me, it was very helpful to have more information than the final maximum deviations, which is printed in the console at the end of a simulation.

I think everything that is useful for a future scientist/developer/debugger would make sense to keep. And yes, if you want to keep it, you should at least use it and check that a file was actually created.

I added a test to check the output file. Is that okay like this or am I missing something? @sloede
Unfortunately, both existing tests have maximum deviations of 0.0. I think I will change the tested elixir in the future. But at least, it is tested, that the file exists and the time steps and final time match.

@bennibolm bennibolm marked this pull request as ready for review October 18, 2023 08:39
@bennibolm bennibolm requested a review from efaulhaber October 18, 2023 09:03
Copy link
Member

@efaulhaber efaulhaber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idk, I can't really say much about this PR. I would have to spend more time to really work myself through the details.

src/callbacks_stage/subcell_bounds_check.jl Outdated Show resolved Hide resolved
@bennibolm bennibolm requested review from amrueda and sloede and removed request for amrueda October 18, 2023 10:17
test/test_tree_2d_eulermulti.jl Outdated Show resolved Hide resolved
src/solvers/dgsem_tree/subcell_limiters_2d.jl Outdated Show resolved Hide resolved
src/callbacks_stage/subcell_bounds_check.jl Outdated Show resolved Hide resolved
src/callbacks_stage/subcell_bounds_check.jl Outdated Show resolved Hide resolved
src/callbacks_stage/subcell_bounds_check_2d.jl Outdated Show resolved Hide resolved
src/callbacks_stage/subcell_bounds_check.jl Outdated Show resolved Hide resolved
@bennibolm bennibolm marked this pull request as draft October 19, 2023 10:42
@bennibolm bennibolm requested a review from sloede October 20, 2023 12:14
@bennibolm bennibolm marked this pull request as ready for review October 20, 2023 12:15
src/callbacks_stage/subcell_bounds_check.jl Outdated Show resolved Hide resolved
src/callbacks_stage/subcell_bounds_check.jl Outdated Show resolved Hide resolved
src/callbacks_stage/subcell_bounds_check.jl Outdated Show resolved Hide resolved
src/callbacks_stage/subcell_bounds_check.jl Outdated Show resolved Hide resolved
@sloede sloede enabled auto-merge (squash) October 20, 2023 12:44
@sloede sloede merged commit fc00ac1 into trixi-framework:main Oct 20, 2023
30 of 31 checks passed
@bennibolm bennibolm deleted the subcell-limiting-bounds-check branch October 20, 2023 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants