Fix get_index_in_direction for regular meshes#3948
Open
JoffreyDorville wants to merge 6 commits into
Open
Conversation
GuySten
reviewed
May 29, 2026
paulromano
requested changes
May 30, 2026
Contributor
paulromano
left a comment
There was a problem hiding this comment.
I'm not sure I agree with the change. When the position being tested is on the boundary between two mesh elements, it is ambiguous as to whether it should be considered as being in the mesh element to the left or to the right. To me it seems more consistent to always pick one direction.
We have other ways of handling this ambiguity elsewhere in the code such as 1) pushing the position forward by TINY_BIT to move it off the boundary, or 2) Looking at the dot product of u and the surface normal to decide which one to choose.
Contributor
|
I think using the particle direction is a good solution. |
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.
Description
For regular meshes, the function
get_index_in_directionis returning 0 instead of 1 when the tested coordinate is coincident with the lower boundary. This results in points being incorrectly seen outside the mesh when they lie on surfaces corresponding to the lower boundaries of the mesh.For rectilinear meshes, the function
get_index_in_directionworks as expected.I added a cpp unit test to illustrate the problem and to show that this PR fixes it.
This fix also corrected the results of the
weightwindows/survival_biasingregression tests which have been updated. I cross-checked that using an equivalent rectilinear mesh instead of the regular mesh in tests/regression_tests/weightwindows/survival_biasing/test.py produces the same results as the updated ones with the fix.Rectilinear mesh used:
Checklist