Repository navigation
Restore the slope sign in the SUPERBEE limiter - #2049
Open
aliencaocao wants to merge 2 commits into
Open
aliencaocao wants to merge 2 commits into
aliencaocao wants to merge 2 commits into
Conversation
SUPERBEE built the limited slope from absolute values and never restored the sign of the slope differences, unlike minmod and MC. equations.md gains the matching sign(a) factor. All six SUPERBEE goldens change. Fixes MFlowCode#1819.
|
Claude Code Review Head SHA: a91eb2b Files changed:
Findings:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2049 +/- ##
==========================================
- Coverage 61.90% 61.89% -0.01%
==========================================
Files 86 86
Lines 22885 22886 +1
Branches 3369 3370 +1
==========================================
Hits 14166 14166
Misses 6220 6220
- Partials 2499 2500 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Collaborator
|
@sbryngelson I am confident this change is correct and an improvement to the code. It is ready to merge once the runners finish. It's a one line source change + golden file regeneration for affected numerics, so it should pass. |
wilfonba
approved these changes
Oct 14, 2026
sbryngelson
approved these changes
Oct 14, 2026
Lines of Code
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1819.
Change
In
src/simulation/m_muscl.fppthe SUPERBEE branch computesmax(min(2|a|,|b|), min(|a|,2|b|)), which is always positive. This PR adds the same sign restoration the minmod and MC branches already use:It also adds the missing
sign(a)factor to the SUPERBEE line ofdocs/documentation/equations.md. The documented formula then matches minmod, MC, and the literature.Why this is the correct slope
The limiter follows the SUPERBEE slope of Roe (1986), written with its sign factor in De Vuyst et al. (2016), Section 2.1 as
S(a, b) = sgn(a) · 1(ab ≥ 0) · max[min(|a|, 2|b|), min(2|a|, |b|)]. With a = qᵢ₊₁ − qᵢ and b = qᵢ − qᵢ₋₁, it isInside the
if, both differences share one sign.sign(slopeL)is therefore the sign of the slope, and the magnitude line already matches the formula. The only missing piece was the sign. For increasing data, the result is bit for bit identical to the original code's result.Before and after
The case is the same as in the issue: a smooth density bump that a uniform wind carries once around a periodic box. The exact answer after one lap is the starting shape.
Tests and goldens
The suite already contains SUPERBEE cases. Their goldens were generated with the sign error and change with this PR. The goldens were regenerated on CPU with GCC 16.2 in double precision without case optimization (
./mfc.sh test --generate --only ...):01DC02513D -> muscl_order=2 -> muscl_eps=0 -> muscl_lim=5347964C32D -> muscl_order=2 -> muscl_eps=0 -> muscl_lim=53EE4302C1D -> muscl_order=2 -> muscl_lim=56B227FF52D -> muscl_order=2 -> muscl_lim=5712581751D -> muscl_order=2 -> muscl_eps=0 -> muscl_lim=5A7C19B7B3D -> muscl_order=2 -> muscl_lim=5Every other test in the suite passes unchanged against its existing golden (from a full suite run with the same compiler and flags).
Contribution Policy
All contributions are expected to demonstrate:
If these expectations are not met, we would prefer to implement the changes ourselves rather than spend time reviewing low-effort submissions.
Acknowledgement
PR template credit: junegunn