Repository navigation
Description
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 atInterfacefaces. 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 addDiffusionto the "Supported:" string in_check_distributable(src/distributed.jl:143-147). - The public
diffusion(g, κ)constructor keeps rejectingInterfacefaces —_slab_opuses 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_oplocalizes anything. Re-checking a localized tree rejects it. Do not add a post-localization check. - A slab keeps the global
extent; onlylocal_rangesays 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
±1per axis, so it is unaffected — unlike a diagonal or wider stencil.
Acceptance
- Dense parity:
dist_materializeof the distributed prepared operator equalsmaterialize(prepare(...))on the equivalent single grid, for both averaging policies, at ≥2 partitions and with a cut in each dimension. - Adjoint identity and
boundary_rhsparity 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_leaveswalker;test/mdla.jl/test/mdla_gpu.jlfor the extension path.- No new per-apply exchange: the exchange count for a distributed
mul!is unchanged from theLaplacianbaseline.
Activity
feat(distributed): compact diffusion leaf on partition slabs
docs(amr): record the conservative coarse-fine flux decision
docs(design): fix the §8 scope note and one term
docs(amr): record the conservative coarse-fine flux decision