Skip to content

refactor: PropertyGrid takes its geometry from StructuredGrid3DGeometry - #368

Merged
lachlangrose merged 1 commit into
prototype/support-extends-geometryfrom
refactor/property-grid-geometry
Nov 1, 2026
Merged

lachlangrose merged 1 commit into
prototype/support-extends-geometryfrom
refactor/property-grid-geometry

Conversation

@lachlangrose

Copy link
Copy Markdown
Member

Draft, stacked. This branch is built on #367, #366, #364 and #363 (it contains their commits), so its diff against master shows all of them until they merge. The change in this PR is the last commit, refactor: PropertyGrid takes its geometry from StructuredGrid3DGeometry and adds cell lookup. Merge order: #363, #366, #364, #367, then this.

Step 3 of consolidating the structured-grid geometry code: the results container reuses the shared geometry class instead of carrying its own copy.

Change

PropertyGrid (the results container renamed in #363) re-implemented maximum, nodes and cell_centres with its own linspace / meshgrid code. It now builds a StructuredGrid3DGeometry from its origin, step_vector and nsteps (the number of nodes) and delegates to it. The dataclass fields are unchanged, so constructor calls, pickles and to_dict are unaffected. The geometry is rebuilt on access rather than stored, so it can never go out of sync with the fields.

New, all from the shared geometry:

  • geometry, nsteps_cells, n_nodes, n_cells
  • inside(points)
  • cell_index_at(points): flat index of the cell each point falls in, in the same order as cell_properties and cell_centres (x fastest); -1 for points outside; points on the maximum boundary belong to the last cell
  • cell_value_at(name, points): the cell property in that cell, NaN outside; works for scalar and vector cell data

Points are in the grid's own frame. PropertyGrid has no rotation, and neither lookup applies one.

Tests

packages/loop_common/tests/test_property_grid.py (30 tests, three grids: integer unit grid, offset anisotropic, minimal):

  • nodes and cell_centres equal independent meshgrid constructions (so delegating did not change them)

  • every cell centre is in its own cell; cell_value_at returns the right values for random points; boundary and outside points; vector-valued cell data

  • Mutation check: indexing cell data with node strides instead of cell strides fails 8 of the 30

  • packages/loop_common/tests: 213 passed

  • packages/loop_interpolation/tests: 606 passed, 46 skipped, 2 xfailed

  • tests: 737 passed, 6 skipped

  • ruff: no new findings

Not in this PR

  • BoundingBox.structured_grid() still returns the interpolation support, not a PropertyGrid.
  • Interpolating a node property at a point (trilinear) is not added: it needs the local-coordinate helper, which still lives in the support class.
  • The 2D equivalents.

🤖 Generated with Claude Code

@lachlangrose
lachlangrose force-pushed the refactor/property-grid-geometry branch from 5bfb9b1 to 196fcb0 Compare November 1, 2026 05:51
@lachlangrose
lachlangrose changed the base branch from master to prototype/support-extends-geometry November 1, 2026 05:51
@lachlangrose
lachlangrose added this pull request to stack #385 November 1, 2026 05:52
@lachlangrose
lachlangrose force-pushed the refactor/property-grid-geometry branch from 196fcb0 to 8234298 Compare November 1, 2026 06:08
@lachlangrose
lachlangrose marked this pull request as ready for review November 1, 2026 06:12
…ry and adds cell lookup

PropertyGrid re-implemented maximum, nodes and cell_centres with its own linspace/meshgrid
code. It now builds a StructuredGrid3DGeometry from its origin, step_vector and nsteps (the
number of nodes) and delegates to it, so the node/cell convention is defined in one place.
The public fields are unchanged.

New: geometry, nsteps_cells, n_nodes, n_cells, inside(points), cell_index_at(points) (flat
cell index in cell_properties order, -1 outside) and cell_value_at(name, points) (NaN outside).
Points are in the grid's own frame; the grid is not rotated.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@lachlangrose
lachlangrose force-pushed the refactor/property-grid-geometry branch from 8234298 to 16c2409 Compare November 1, 2026 06:54
@lachlangrose
lachlangrose merged commit 79e9b36 into master Nov 1, 2026
37 checks passed
@lachlangrose
lachlangrose deleted the refactor/property-grid-geometry branch November 1, 2026 06:54
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.

1 participant