Fix z-boundary backward FD stencil using fields(2) instead of fields(3)#1173
Fix z-boundary backward FD stencil using fields(2) instead of fields(3)#1173sbryngelson wants to merge 1 commit intoMFlowCode:masterfrom
Conversation
|
CodeAnt AI is reviewing your PR. Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Nitpicks 🔍
|
|
CodeAnt AI finished reviewing your PR. |
There was a problem hiding this comment.
Pull request overview
Fixes an incorrect component reference in the z-direction upper-boundary backward finite-difference stencil inside the shared finite-differences module, preventing corrupted divergence results at the z-boundary for 3D runs.
Changes:
- Correct z-upper boundary backward-difference term to use
fields(3)(z-component) rather thanfields(2)(y-component).
The z-direction upper-boundary backward difference at iz_s%end uses fields(2) (y-component) instead of fields(3) (z-component) in the third term, corrupting the divergence in all 3D simulations using this finite difference routine. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
e583f31 to
dc4ebd7
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1173 +/- ##
=======================================
Coverage 44.05% 44.05%
=======================================
Files 70 70
Lines 20498 20498
Branches 1990 1990
=======================================
Hits 9030 9030
Misses 10329 10329
Partials 1139 1139 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Superseded by #1242 (batched HPC-sensitive fixes) |
Summary
Severity: CRITICAL — produces wrong results in all 3D simulations using this routine.
File:
src/common/m_finite_differences.fpp, line 53The z-direction upper-boundary backward finite difference stencil at
iz_s%endusesfields(2)(the y-component) instead offields(3)(the z-component) in the third term of the second-order backward difference.Before
After
Why this went undetected
This is a copy-paste error in the x→y→z stencil chain where only the third term of the z-direction backward stencil is wrong — the first two terms correctly use
fields(3). The bug only activates at the exact upper z-boundary cells (iz_s%end) where the one-sided backward stencil is used; the interior central-difference stencil and the lower-boundary forward stencil are both correct. This makes the error localized to a thin boundary layer that is easily masked by the correct values everywhere else.Test plan
iz_s%endmatch the y-boundary analog🤖 Generated with Claude Code
Fixes #1194