Skip to content

Fix distance threshold bug ScalarInterp#2010

Open
dragos-ana wants to merge 1 commit into4C-multiphysics:mainfrom
dragos-ana:fix-scalar-interpolation-distance-threshold
Open

Fix distance threshold bug ScalarInterp#2010
dragos-ana wants to merge 1 commit into4C-multiphysics:mainfrom
dragos-ana:fix-scalar-interpolation-distance-threshold

Conversation

@dragos-ana
Copy link
Copy Markdown
Contributor

@dragos-ana dragos-ana commented Apr 29, 2026

Fixed calculation of normalized weights within the scalar interpolation framework, if the interpolation location is within a distance threshold wrt a reference location.
In that case, the weight of that specific reference point is directly set to 1.0 AND the other weights are reset to 0.0. The previous approach also enabled multiple 1.0 weights, and only the first detected 1.0 was kept.
Unit tests were added to test the bugfix; these tests would have previously failed because the weights would have always been {1.0, 0.0} regardless of the interpolation location 0.0 or 1.0.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes scalar interpolation weight normalization when the interpolation location is (nearly) coincident with a reference location by ensuring a single reference gets weight 1.0 and all others are reset to 0.0.

Changes:

  • Update calculate_normalized_weights() to reset all weights to 0.0 and stop processing as soon as a reference point is within distance_threshold.
  • Remove the post-pass that tried to detect weight == 1.0 after the fact.
  • Add unit tests covering the “at reference location” behavior for inverse-distance and exponential weighting.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/core/linalg/tests/4C_linalg_utils_scalar_interpolation_test.cpp Adds new tests that assert exactly one unit weight when interpolating at reference locations.
src/core/linalg/src/dense/4C_linalg_utils_scalar_interpolation.hpp Clarifies the intended semantics of distance_threshold in the parameter struct.
src/core/linalg/src/dense/4C_linalg_utils_scalar_interpolation.cpp Implements the corrected “coincident point => one-hot weights” logic inside the weighting loops.

Comment thread src/core/linalg/src/dense/4C_linalg_utils_scalar_interpolation.cpp
Comment thread src/core/linalg/src/dense/4C_linalg_utils_scalar_interpolation.cpp
Fixed calculation of normalized weights within the
scalar interpolation framework, if the interpolation
location is within a distance threshold wrt a reference
location.
In that case, the weight at the specific location is directly
set to 1.0 AND the other weights are reset to 0.0.
The previous approach also enabled multiple 1.0 weights, and
only the first detected 1.0 was kept.
Unit tests were added to test the bugfix; these tests would have
previously failed.
@dragos-ana dragos-ana force-pushed the fix-scalar-interpolation-distance-threshold branch from b23648c to c631e0b Compare April 29, 2026 18: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.

2 participants