From 2504216ec91606257df4a49de145c2d17f0ad78b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrique=20Gonz=C3=A1lez=20Paredes?= Date: Thu, 1 Oct 2026 09:48:45 +0200 Subject: [PATCH 01/19] =?UTF-8?q?personal/egparedes:=20connectivities=20as?= =?UTF-8?q?=20types=20=E2=80=94=20Cartesian=20axis=20dimensions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add two levels below `DimensionIndex` — `AnyCartesianAxisIndex` (either cell class of a Cartesian axis) and `CartesianAxisIndex` (a declared axis) — and bound `Staggered[D: CartesianAxisIndex]` on the declared one. Doubly staggered dimensions, staggered local dimensions and staggered mesh locations become static `[type-var]` errors instead of runtime `TypeError`s, and because the levels sit below the root no `type[DimensionIndex]` annotation widens and `LocalDimensionIndex` keeps its position. Verified in `staggered_probe.py` with mypy 2.3.1 and pyright 1.1.414. Motivate the levels as a domain concept rather than a typing trick: a declared axis and its `Staggered[.]` are the two cell classes of a 1-dimensional CW complex, `Staggered` is the involution that swaps them, and in more than one dimension `Dims[...]` is the per-axis bit vector of the product complex. Record that this is finer than a form degree, that the absence of orientation data follows from the product structure, and that mesh locations are separate classes because the complex does not factor. Also decided: extents are declared and never derived (absolute `UnitRange`s already carry the degree assignment and the periodic case; the interleaving invariant belongs to the grid); the alignment convention is antisymmetric, so both conventions are reachable by choosing which member of the pair to declare; `DimensionKind.LOCAL` leaves the enum in PR B, derived from the class. Rejected in the note: a sibling root above `DimensionIndex`, a `Protocol` + `Literal` discriminator, a second partner constructor (`StaggeredAbove[D]` makes `flip_staggered` partial), declaring both members of a pair, and a static cell `degree` for now. Open questions added for parameterizing the alignment, `kind`'s remaining two jobs, and a `degree` conditioned on an exterior-calculus consumer. Reserve `dual`/`Dual` for the full Hodge dual; the per-axis swap keeps `flip_staggered`. Cross-links both ways with the surface-syntax note. --- content/index.md | 4 +- .../connectivities-as-types.md | 353 ++++++++++++++++-- .../staggered_probe.py | 145 +++++++ .../discretization-independent-fd-syntax.md | 4 +- 4 files changed, 473 insertions(+), 33 deletions(-) create mode 100644 content/personal/egparedes/connectivities-as-types/staggered_probe.py diff --git a/content/index.md b/content/index.md index cf9d353..7689cd8 100644 --- a/content/index.md +++ b/content/index.md @@ -44,8 +44,8 @@ Work-in-progress proposals, organized by contributor. - [[personal/egparedes/layered-architecture|A layered architecture for gt4py with enforced public/internal decoupling]] — keywords: architecture, layering, tach, modularity, public-api, semi-public, internal, packaging, dependencies, refactoring, infrastructure, over-engineering, otf, workflow, dsl, config, allocators, caching, fingerprint, compiled-program, process-pool, factory-boy, instrumentation, adr, jax, decoupling, migration, tech-debt - [[personal/egparedes/otf-toolchain-split|Dissolving gt4py.next.otf into a toolchain core and DSL-agnostic build infrastructure]] — keywords: otf, toolchain, workflow, pipeline, refactoring, architecture, layering, modularity, backend, bindings, build-system, caching, runners, compiled-program, factory-boy, naming, observability, stage-inspection, adr, tach, tech-debt -- [[personal/egparedes/connectivities-as-types/connectivities-as-types|Connectivities as types: one declaration for offset, local dimension and provider key]] — keywords: type-system, type-checking, dimensions, local-dimensions, connectivities, offset-provider, unstructured, neighbor-sum, reduction, frontend, foast, gtir, embedded, gtfn, dace, nominal-types, dependent-types, metaclass, serialization, fingerprint, staggering, migration, adr, tech-debt, shared-local-dimensions, implemented -- [[personal/egparedes/discretization-independent-fd-syntax|A discretization-independent surface syntax for finite-difference computations]] — keywords: finite-difference, finite-volume, mesh-invariant, structured, unstructured, exterior-calculus, dec, mimetic, de-rham, location-typing, stencil, weight-generation, rbf-fd, gfdm, moment-matching, conservation, field-operators, icon, pace, pmap, fv3, ifs-fvm, arakawa-staggering, c-grid, d-grid, a-grid, dynamical-core, hevi, vertical-solve, elliptic-solve, mpdata, semi-implicit, miura, atlas, prior-art, dsl-design +- [[personal/egparedes/connectivities-as-types/connectivities-as-types|Connectivities as types: one declaration for offset, local dimension and provider key]] — keywords: type-system, type-checking, dimensions, local-dimensions, connectivities, offset-provider, unstructured, neighbor-sum, reduction, frontend, foast, gtir, embedded, gtfn, dace, nominal-types, dependent-types, metaclass, serialization, fingerprint, staggering, axis-dimensions, cw-complex, exterior-calculus, domain, dimension-kind, migration, adr, tech-debt, shared-local-dimensions, implemented +- [[personal/egparedes/discretization-independent-fd-syntax|A discretization-independent surface syntax for finite-difference computations]] — keywords: finite-difference, finite-volume, mesh-invariant, structured, unstructured, exterior-calculus, dec, mimetic, de-rham, cw-complex, location-typing, stencil, weight-generation, rbf-fd, gfdm, moment-matching, conservation, field-operators, icon, pace, pmap, fv3, ifs-fvm, arakawa-staggering, c-grid, d-grid, a-grid, dynamical-core, hevi, vertical-solve, elliptic-solve, mpdata, semi-implicit, miura, atlas, prior-art, dsl-design