Repository navigation
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3129 +/- ##
==========================================
+ Coverage 83.96% 84.00% +0.04%
==========================================
Files 261 261
Lines 60017 60036 +19
Branches 5065 5067 +2
==========================================
+ Hits 50393 50435 +42
+ Misses 8780 8757 -23
Partials 844 844
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
mloubout
force-pushed
the
safe-harmonic-contact
branch
2 times, most recently
from
December 1, 2026 03:28
0bf32b4 to
f8349b5
Compare
The safe harmonic mean drops a zero point instead of dividing by it, then guarded its final inversion by the reference point alone, so it was zero only when that point was. Next to a zero elsewhere in the stencil it came out at 4/3 or 2 times the nonzero value, e.g., a shear modulus on faces touching a fluid on one side of every fluid-solid contact. Guard it by the smallest of the points the mean reads instead: zero wherever it reads a zero, as the harmonic mean is, and still no division by zero.
mloubout
force-pushed
the
safe-harmonic-contact
branch
from
December 1, 2026 16:30
f8349b5 to
0ffee9a
Compare
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.
safe_harmonicaveraging returned a nonzero value next to a zero point unless that point was the reference one, the point the off-grid location is indexed from.The mean drops a zero point instead of dividing by it:
SafeInv(f, f)is 0 there. The final inversion was then guarded by the reference point alone,SafeInv(avg, f(x, y)). So a zero elsewhere in the stencil just left the mean over the other points, inflated by the missing term. With one zero cell in a field of ones, three of the four staggered corners around it come out at 4/3 instead of 0:The harmonic mean is zero next to any zero, and that is what the averaging is used for: the shear modulus of an elastic model with a fluid in it, which must vanish on every face that touches the fluid. With the reference-point guard it vanished only on faces whose reference node is the fluid one, so one side of every fluid–solid step carried a spurious shear modulus. On a stepped seafloor in an elastic model this changed the recorded gather by about 20% against SOFI2D, which zeroes all four (
av_mue.c). With this change the two agree to 0.3–0.7% at three grid spacings.Change. The final inversion of the safe mean is now guarded by the smallest of the points the mean reads:
Minover the function accesses of the interpolated expression, instead of the reference point. The per-pointSafeInvguard is unchanged, so nothing is ever divided by zero and no NaN can appear, whatever the interpolation weights. Plainharmonicis untouched. At higher interpolation orders the mean is now zero wherever its stencil reads a zero, which is also where plainharmonicreturns zero.Tests.
test_safe_harmonic_zero_neighbour, 2D and 3D, interpolation orders 2 and 4: one zero point must give zero at every staggered point whose mean reads it, no NaN, and the plain value elsewhere. It fails onmainand passes here.test_avg_modenow checks that the guard covers every point the mean reads.tests/test_differentiable.pyand the elastic and viscoelastic seismic examples pass. Their reference norms are unchanged: the example models have no zero shear modulus.