Skip to content

Allow a-posteriori corrections for du#2953

Draft
bennibolm wants to merge 4 commits into
trixi-framework:mainfrom
bennibolm:corrections-du
Draft

Allow a-posteriori corrections for du#2953
bennibolm wants to merge 4 commits into
trixi-framework:mainfrom
bennibolm:corrections-du

Conversation

@bennibolm

@bennibolm bennibolm commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

See #2948.
To fix this, I added a SubcellLimiterIDPCorrection function which corrects du accordingly.
Additionally, I added a check whether SubcellLimiterIDPCorrection is the first stage callback in the custom SSP time integration method. It doesn't make sense if it's not.

@bennibolm bennibolm added the bug Something isn't working label Apr 23, 2026
@github-actions

Copy link
Copy Markdown
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 with its PR number.

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.

@bennibolm

Copy link
Copy Markdown
Contributor Author

I tested the resulting numbers of entropy_timederivative and got the correct results: Without any limiting I get the same numbers as the pure DG simulation; Also, I get the same numbers as the pure LGL FV simulation without enabled correction stage.

@bennibolm

bennibolm commented Apr 23, 2026

Copy link
Copy Markdown
Contributor Author

Problem: The amount of limiting depends on the time step. We don't have a fully semidiscrete scheme.

@codecov

codecov Bot commented Apr 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.12%. Comparing base (bc7858a) to head (8da8fd7).

Files with missing lines Patch % Lines
src/time_integration/methods_SSP.jl 60.00% 2 Missing ⚠️
src/callbacks_step/analysis.jl 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2953      +/-   ##
==========================================
- Coverage   97.11%   92.12%   -5.00%     
==========================================
  Files         622      622              
  Lines       48235    48249      +14     
==========================================
- Hits        46843    44446    -2397     
- Misses       1392     3803    +2411     
Flag Coverage Δ
unittests 92.12% <83.33%> (-5.00%) ⬇️

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

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@amrueda amrueda left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, @bennibolm... And sorry for the delay!
This is a nice and elegant fix to the problem.
LGTM... But there are some tests failing.

Comment on lines +71 to +73
# Apply `perform_idp_correction!` to `du` instead of `u`:
# Pass `du` and `1.0` instead of `u` and `dt`
perform_idp_correction!(du, 1.0, mesh, equations, solver, cache)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
# Apply `perform_idp_correction!` to `du` instead of `u`:
# Pass `du` and `1.0` instead of `u` and `dt`
perform_idp_correction!(du, 1.0, mesh, equations, solver, cache)
# Apply `perform_idp_correction!` to `du` instead of `u`:
# Pass `du` and `1.0` instead of `u` and `dt`. This returns the correct
# semi-discrete correction: du_i = du_i^(FV) + \sum_j f^(antidiffusive)_ij
perform_idp_correction!(du, 1.0, mesh, equations, solver, cache)

@amrueda amrueda left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

On a second pass, I realized the following:
At each analysis callback, du is computed and subsequently "corrected" with the IDP routines using the bounds that were computed for the explicit Euler step of the previous RK stage. This is a bit weird because there is no guarantee that those are meaningful bounds for the solution at the time of the analysis callback. Also, there is no guarantee that the low-order method can fulfill those bounds. I'd suggest computing the bounds before du_correction_subcell_limiting!.

return nothing
end

# `SubcellLimiterIDPCorrection` is the first entry in the tuple of stage callbacks.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this always the case? if not, we'll have to do something different here or force it to be the first.

Comment on lines 349 to +352
@notimeit timer() integrator.f(du_ode, u_ode, semi, t)
# Update `du` with corrections from `SubcellLimiterIDPCorrection` for a-posteriori subcell limiting
du_correction_subcell_limiting!(du_ode, u_ode, integrator,
integrator.p.solver.volume_integral)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think that we have to re-compute the bounds before the call to du_correction_subcell_limiting!. The most consistent way to do this is, probably, to force the call of the analysis callback to be after the call to the time-step callback...

@bennibolm

bennibolm commented May 27, 2026

Copy link
Copy Markdown
Contributor Author

At each analysis callback, du is computed and subsequently "corrected" with the IDP routines using the bounds that were computed for the explicit Euler step of the previous RK stage

Oh yeah, you are right. In that case, I actually would prefer to close this PR and don't add additional computations. As we discussed back then, the IDP limiting is simply not a pure semi-discrete method and the entropy analysis doesn't make full sense.
What do you say? @amrueda

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants