Repository navigation
fix: make StructuredGrid3DGeometry agree with the structured support it duplicates - #366
Merged
lachlangrose merged 1 commit intoNov 1, 2026
Conversation
This was referenced Oct 29, 2026
lachlangrose
force-pushed
the
refactor/repair-structured-grid-geometry
branch
from
November 1, 2026 05:51
e8f3fd8 to
0a8dfa4
Compare
lachlangrose
changed the base branch from
master
to
test/scalar-field-grid-registration
November 1, 2026 05:51
lachlangrose
force-pushed
the
refactor/repair-structured-grid-geometry
branch
from
November 1, 2026 06:08
0a8dfa4 to
ea4bed7
Compare
…it duplicates StructuredGrid3DGeometry is a copy of the geometry half of BaseStructuredSupport and had drifted: - global_node_indices was a stub returning its input, so elements was (n, 8, 3) ijk triples instead of (n, 8) flat node indexes - position_to_cell_index did not floor, clip or flag points outside the grid (a point past the maximum got an out-of-range cell index) and ran inside() before validating - inside() excluded the boundary and had no tolerance - global_index_to_node_index only handled 1-D input; global_cell_indices was missing Bring those in line with the support and add tests that compare the two on the same inputs (unit, offset/anisotropic and minimal grids), plus explicit boundary and outside-point cases. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
lachlangrose
force-pushed
the
refactor/repair-structured-grid-geometry
branch
from
November 1, 2026 06:54
ea4bed7 to
3bdbb08
Compare
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.
Step 1 of consolidating the structured-grid geometry code. No behaviour change for the interpolation path.
Background
StructuredGrid3DGeometryis a copy of the geometry half ofBaseStructuredSupport(24 of its ~25 members are shared). It has drifted. The only in-library user is theaabb_gridof theUnstructuredMesh*Geometryclasses, and it had no tests. Before it can be used as the single geometry type (a later step), it has to agree with the support. This PR makes it agree and pins that with tests.What was different
Found by running both classes on the same inputs (unit cube, offset anisotropic box, 30-degree rotated box):
global_node_indiceselementswas(n, 8, 3)ijk tripleselementsis(n, 8)position_to_cell_index(0,0,0)andinside=Falseinside>/<, boundary excluded, no tolerance, no input validationglobal_index_to_node_indexglobal_cell_indicesglobal_index_to_cell_indexalso dropped a modulo on the k index. It gives the same result for valid indices.Tests
packages/loop_common/tests/test_structured_grid_geometry.py(22 tests) compares the geometry class withloop_common.supports.StructuredGridon three grids, and covers the maximum boundary, outside points, single points and bad shapes. 19 of the 22 fail on the old code; the other 3 were already correct.packages/loop_common/tests: 178 passedpackages/loop_interpolation/tests: 606 passed, 46 skipped, 2 xfailedtests: 730 passed, 6 skippedNotes
inside()andposition_to_cell_indexonStructuredGrid3DGeometrynow include boundary points. I found no callers outside the library besides theaabb_griduse, but I have not checked the QGIS plugin or map2loop.rotation_xyinposition_to_cell_indexorinside; points must already be in the grid's own frame. The docstring now says so.position_to_cell_corners,node_indexes_to_position,element_size,vtk), and makingBaseStructuredSupportextend this class.🤖 Generated with Claude Code