Skip to content

feat(distributed): compact diffusion leaf on partition slabs #57

Closed

Description

@kylebeggs

Stage 2 of #56. Extend the compact flux-form Diffusion leaf (landed in #48, CartesianGrid only) to partition_grid slabs so prepare_distributed accepts it.

Why this is the cheap stage

A face-averaged coefficient needs κ on both sides of every face, including the faces that fall on a partition cut. There the neighbour cell lives in the slab's ghost layer, and _slab_field (src/distributed.jl:266-277) deliberately leaves coefficient ghosts zero — its docstring makes that a stated invariant: "every field-valued parameter in the whitelist is read pointwise at the cell being written … that is what lets a coefficient be partitioned with no exchange of its own."

The pleasant surprise is that this needs no communication at all. _slab_op (src/distributed.jl:242-247) runs on the host with the global κ field in hand and slices it per slab. Filling a slab's κ ghosts is therefore just widening that slice by the halo wherever a neighbour exists — a setup-time indexing change, not an exchange. No new machinery, no exchange adjoint to write, and no per-apply cost, so #56's "one halo exchange per application" invariant holds trivially.

The _slab_field invariant is narrowed, not broken: it still holds verbatim for ScalingOp and Advection, which do read their coefficients pointwise. Diffusion opts into a widened variant instead.

Scope

  • Add _slab_coeff_field(κ, lg) beside _slab_field — same slicing, but also copies the neighbouring interior cells into the ghost layer at Interface faces. Physical-boundary ghosts stay zero and are never read; the leaf's own even-mirror extension already covers them.
  • _distributable(D::Diffusion) = _partitionable_coeff(D.κ) (src/distributed.jl:24-38), and _slab_op(D, lg) = Diffusion(lg, _slab_coeff_field(D.κ, lg), D.avg).
  • Drop _undistributable_reason(::Diffusion) and add Diffusion to the "Supported:" string in _check_distributable (src/distributed.jl:143-147).
  • The public diffusion(g, κ) constructor keeps rejecting Interface faces — _slab_op uses the inner constructor, which is exactly the seam it was documented for. Nothing about the user-facing entry point changes.
  • Docs: the hand-written distributable-operator lists in docs/pages/distributed.qmd:172,286.

Watch out for

  • The distributability guards run once on the global operator tree, before _slab_op localizes anything. Re-checking a localized tree rejects it. Do not add a post-localization check.
  • A slab keeps the global extent; only local_range says which part it owns. Do not "fix" a slab's extent to describe its own span.
  • Corner ghosts are dimension-order dependent, but a compact flux stencil stays ±1 per axis, so it is unaffected — unlike a diagonal or wider stencil.

Acceptance

  • Dense parity: dist_materialize of the distributed prepared operator equals materialize(prepare(...)) on the equivalent single grid, for both averaging policies, at ≥2 partitions and with a cut in each dimension.
  • Adjoint identity and boundary_rhs parity across the partition, including a spatially varying κ whose values differ across the cut (a constant κ would hide a zeroed ghost entirely — make the test able to fail).
  • test/partitioning.jl: extend the _scaling_leaves walker; test/mdla.jl / test/mdla_gpu.jl for the extension path.
  • No new per-apply exchange: the exchange count for a distributed mul! is unchanged from the Laplacian baseline.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions