feat[next]: staggered fields#2667
Draft
tehrengruber wants to merge 7 commits into
Draft
Conversation
tehrengruber
commented
Jun 19, 2026
d40bb43 to
38714de
Compare
Add support for staggered cartesian fields (GridTools#2339), where half-grid dimensions sit half a cell offset from the full grid. - `Dimension +/- 0.5` lowers to a `CartesianConnectivity` relocation onto the flipped staggered dimension (`is_staggered`/`flip_staggered`, `connectivity_for_cartesian_shift`); integer shifts stay translations. - Embedded field path (`nd_array_field`) handles the relocation domain remap; iterator embedded `execute_shift` moves the position from the connectivity's `domain_dim` to its `codomain` (translation is the degenerate equal-dim case), replacing the previous relocation assert. - type_deduction: the `Dimension + offset` cartesian-shift branch is gated on `op in {ADD, SUB}` so e.g. `TDim % 2.0` reports an unsupported operand. - Tests for plus/minus/back/half2center half-shifts across embedded and roundtrip. Rebased on top of GridTools#2411 (cartesian shift as self-describing CartesianOffset node, gather-only offset providers).
38714de to
8dd276b
Compare
Cartesian offsets are self-describing CartesianOffset IR nodes and no longer appear in the offset provider, so 'common.get_offset(...)' for a FieldOffset can only return a (neighbor) Connectivity, never a Dimension. Drop the dead 'isinstance(offset_definition, common.Dimension)' branch (flagged with a '# TODO: dead-code remove' comment), leaving the Connectivity path as in the sibling 'as_connectivity_field' method.
Restore Connectivity to a @runtime_checkable Protocol (as on main) instead of a Generic abc. Field is already a runtime_checkable Protocol, so abstractmethod enforcement is unchanged; this re-enables structural isinstance checks (relied on by is_neighbor_table) and matches the 'Connectivity Protocol' workaround comment in CartesianConnectivity.
Two defects from the staggered-fields restructuring of LambdaToDataflow._visit_shift: - ~20 lines of unreachable dead code after the if/else (both branches already return), including a stale call to '_make_cartesian_shift' with its old 'Dimension' signature (it now takes a 'CartesianConnectivityType'). Removed. - An over-strict 'assert isinstance(offset_value_arg, gtir.OffsetLiteral)' in the unstructured branch that broke dynamic neighbor offsets: the offset value may be a dynamic expression (the pre-existing code and '_make_unstructured_shift' both handle this via '_make_dynamic_neighbor_offset'). Removed; the offset *provider* asserts (it must be a named string OffsetLiteral) are kept.
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.
Add support for staggered fields (replaces #2339), where half-grid dimensions sit half a cell offset from the full grid.