Conversation
The position in Region::distance_complex is recomputed from the accumulated distance. When a candidate step is smaller than the resolution of that distance, the position does not move. Two coincident surfaces in one region then make the search alternate between them forever. This occurs after about 100 m of flight inside one cell, when leaving a union and when entering an intersection. Take the smallest representable step when the accumulated distance does not change. Add a unit test with two coincident planes that covers both cases.
The position change in Region::distance_complex moves track end points by roundoff. Only the spherical mesh tallies of this test change, because SphericalMesh::find_theta_crossing detects the crossing of the theta = pi/2 grid surface depending on roundoff. All other regression results are unchanged. Generated with GCC and OPENMC_ENABLE_STRICT_FP=on.
Assert the returned distance, state that the test coordinates are deliberate, and scope the comment in Region::distance_complex to the position at the true boundary.
yrrepy
marked this pull request as ready for review
September 17, 2026 22:44
GuySten
approved these changes
Sep 18, 2026
GuySten
left a comment
Contributor
There was a problem hiding this comment.
Except from one small suggestion,
LGTM.
Co-authored-by: GuySten <62616591+GuySten@users.noreply.github.com>
yrrepy
force-pushed
the
fix-complex-region-distance-position
branch
from
September 18, 2026 07:54
51ef78e to
f240a12
Compare
paulromano
requested changes
Sep 18, 2026
paulromano
left a comment
Contributor
There was a problem hiding this comment.
I'm planning on reviewing this
This reverts commit f240a12.
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.
Description
This fixes a lost-particle failure that can occur at complex CSG boundaries. The issue was exposed by weight-window surface checkpoints.
I have a large model, in it, when weight window surface checkpoints are on, I would get the following failures:
WARNING: Could not find the cell containing particle 2488140WARNING: Could not find the cell containing particle 2771912This was previously working in 0.15.4, but these errors appear with 0.16.1-dev.
I narrowed it down to PR #3934
Issue #4140 documents the problem and provides a MWE to reproduce it.
per Codex:
During a complex-region distance search, the candidate position was previously advanced incrementally across virtual surface crossings. The particle was later transported by applying the returned total distance to its original position. Roundoff could therefore make the position used to identify the boundary differ from the particle's actual transported position. In affected cases, the returned surface was inconsistent with the final position and the subsequent cell search failed.
per Codex
Checklist