← Explainer · Markdown · Source on GitHub

# Algorithms and numerical review

**Review companion, 2026-09-26; performance-first GPU execution boundaries updated
2026-09-26; pressure qualification and staged transport/composite review updated
against commit `5c4984eef691d593a1082072ba12344f0478f6bc`. A concrete regular-grid MAC candidate
is now specified below; its implementation and CUDA qualification remain pending.** Current formulas were checked against the
linked source. Proposed formulas describe TRN-01/S2/S3 design obligations, not
implemented or scientifically validated capabilities. The scalar example is an
illustration, not the selected production momentum algorithm. Start with the
[algorithm explainer](/algorithms.html) or [transport plan](/docs/amrex-alignment/SINGLE_LEVEL_TRANSPORT).
Current status belongs on the [work board](/docs/WORKBOARD).

## Reading map

Read the physical model, then the current update, then the proposed flux balance.
The distinction matters: choosing a conservative transport operator changes one
part of a coupled incompressible solver, not its whole accuracy or conservation story.

| Question | Detail |
| --- | --- |
| What physical problem is solved? | [Governing equations](#governing-equations) and [MAC locations](#mac-grid-and-control-volumes) |
| What does today's code calculate? | [Sampling and correction](#current-semi-lagrangian-and-maccormack), then [full step](#current-time-step-and-projection) |
| What does pressure convergence establish? | [Pressure solver qualification](#pressure-solver-qualification): current fixes, assumptions, true residual and final continuity |
| How do physical boundaries become numerical stencils? | [Boundary conditions](#boundary-conditions), the [implemented guide](/docs/BOUNDARY_CONDITIONS_HALOS) and [BC-01/BC-02 plan](/docs/plans/boundary-condition-alignment) |
| Why does a flux update conserve? | [Signs, units and cancellation](#proposed-shared-flux-update) |
| What could a concrete algorithm look like? | [Illustrative scalar method](#illustrative-regular-grid-scalar-algorithm) |
| How will the first MAC candidate work? | [Selected regular-grid formulation](#first-regular-grid-mac-candidate): volumes, carriers, fluxes, complete stages and CFL proof |
| What remains to derive? | [Staggered momentum and geometry](#mac-momentum-and-cut-cell-derivation), [S2/S3](#s2-and-s3-coupling) |
| What would establish correctness? | [Review and validation gates](#review-and-validation-gates), with [source map](#source-map) |

Method selection and support rules are defined in [TRN-01](/docs/amrex-alignment/SINGLE_LEVEL_TRANSPORT).
Use one resolved method per run; preserve useful current methods while evaluating
one conservative candidate. A method must state its timestep, stencil, geometry,
boundary and integration requirements. A shared interface must expose required
stages instead of assuming every algorithm is an interchangeable `Advect()` call.
Neither data-model alignment nor a method name establishes numerical compatibility.

## Required execution architecture

**Approved target; not fully implemented:** the
[GPU execution plan](/docs/plans/gpu-resident-processing) keeps simulation fields
and repeated numerical processing on one GPU, including transport/ghost kernels,
geometry updates, pressure topology, complete reductions, solver coefficients,
convergence evaluation, CFL limits and coarse/fine transfers. Do not download
simulation fields or reduction partials for CPU numerical completion. Keep the
authoritative solver and timestep values resident for their next device consumer.
There is no silent CPU fallback.

Host setup, static asset preparation, allocation, layout management, kernel
scheduling and requested output remain available. Explicitly bounded compact
status/control/layout metadata may cross the device boundary; record its purpose,
bytes/count, cadence and synchronization cost. For example, the GPU evaluates
convergence and an occasional completion readback can stop host scheduling; the
host does not recompute dot products or PCG coefficients. Device-only launch gating
must earn its complexity and inactive-work cost through measurement. Requested
field captures and completed diagnostic products are accounted for separately;
terminal formatting/unit conversion does not become simulation feedback.

Apply this boundary to each new AMR-02/TRN-01/S2/S3 scope. Full closure of unrelated
GPU-01 backlog is not an alignment prerequisite. Current source is evidence of
behavior, not proof that every target already passes:
[CflGpu](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/src/PolyCfd.Gpu/Diagnostics/CflGpu.cs) currently computes final limits
from host-returned reductions, the shared
[PcgIteration](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/src/PolyCfd.Gpu/PcgIteration.cs) uses host scalar
coefficients/decisions for both pressure solvers, and
[PressureComponentsGpu](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/src/PolyCfd.Gpu/Projection/PressureComponentsGpu.cs)
still downloads rebuild metadata and compatibility measurements, with whole-array
downloads for host classification when there are more than 16 regions. Its per-region mean subtraction already
completes on-device. Diffusion's Chebyshev recurrence and audit finalization also
use host calculations ([implemented contract](/src/PolyCfd.Gpu/Diffusion/README)).
Prioritize repeated coefficient/reduction round trips and field-scale downloads.
Bounded status or allocation metadata is assessed under the control boundary;
its mere presence is not a numerical-processing defect. Existing gaps keep their
own migration and numerical/performance evidence rather than blocking an unrelated
structural change.

Use [AMR-02's semantic split](/docs/amrex-alignment/DATA_MODEL_ALIGNMENT): `MeshPatch` identifies a mesh
partition; `BoundaryRegion` entries in `DomainBoundaryConditions` describe physical
boundaries, with `DeviceBoundaryRegion`/`DeviceDomainBoundaryConditions` device bindings.
`IEmbeddedBoundarySource`/`SdfEmbeddedBoundarySource` supply geometry inputs;
`EmbeddedBoundaryData`/`DeviceEmbeddedBoundaryData` hold derived metrics. Kernels
borrow `EmbeddedBoundaryMetricsView` plus a compact derived `PatchKernelDescriptor`.
`IndexType`, `Box`, `DomainGeometry`, `LevelLayout` and `LevelFields` retain
their separate roles. Those target names do not rename current source by documentation.
The level coordinator schedules method stages; patch kernels execute the numerical
operations. Field/geometry views identify layout and geometry revisions, time and
stage; ghost validity is refreshed after its producer changes. Retained storage
or an old completed-frame identity does not certify stage freshness.

## Governing equations

**Current physical model:** constant-density incompressible Newtonian flow.
Velocity is `u = (u,v,w)`, density is constant `rho`, kinematic viscosity is `nu`,
body acceleration is `f`, and kinematic pressure is `p = P/rho`:

```text
partial_t u + (u dot grad)u = -grad p + nu Laplacian(u) + f
div u = 0
```

The stored pressure has units `length^2/time^2`, not pascals. For component `a`,
the continuum identity is

```text
div(u_a u) = (u dot grad)u_a + u_a div u.
```

Therefore advective and conservative momentum forms agree when `div u = 0`.
Their discrete versions need not agree: interpolation, discrete divergence,
limiting, boundaries and stage timing affect the identity. Projection does not
automatically turn a nonconservative remap into a shared-flux momentum update.
The [physics guide](/docs/PHYSICS_GUIDE) defines the supported physical scope.

For a scalar concentration `q`, `partial_t q + div(q u) = s` describes a conserved
amount with source density `s`. For momentum take `q = rho u_a`; pressure and
viscosity then enter as forces. Using `q = u_a` instead tracks momentum divided
by the constant density. State which convention a diagnostic uses.

## MAC grid and control volumes

**Current storage:** pressure at cell centers; each velocity component at its
normal face center. With origin zero and spacings `(dx,dy,dz)`:

```text
p(i,j,k): ((i+1/2)dx, (j+1/2)dy, (k+1/2)dz)
u(i,j,k): (i dx,     (j+1/2)dy, (k+1/2)dz)
v(i,j,k): ((i+1/2)dx, j dy,     (k+1/2)dz)
w(i,j,k): ((i+1/2)dx,(j+1/2)dy, k dz)
```

See [MAC conventions](/docs/MAC_GRID_CONVENTIONS). A stored face sample is not
automatically an average over a derived momentum control volume. On a regular
interior grid, the natural dual volume around an `u` sample is shifted half a
cell in X relative to a pressure cell. Its transport surfaces differ from the
pressure cell's surfaces. V/W have corresponding shifts. Physical boundary
dual volumes, periodic duplicate endpoints and cut dual volumes require explicit
weights; summing every stored face with full cell volume double-counts periodic
endpoints. Existing [exact periodic diagnostics](/docs/PERIODIC_EXACT_VALIDATION)
use half endpoint weights, which do not by themselves define cut-cell momentum.

Device velocities currently have dense interior buffers and inline boundary
stencils; pressure also has packed face halos. There are no general GPU velocity
edge/corner ghost arrays. [Halo layout](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/docs/halo-layout.md) describes actual storage.
TRN-01 must specify its stencil before S2 chooses exchange/storage requirements.

## Current semi-Lagrangian and MacCormack

**Implemented:** [AdvectionGpu](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/src/PolyCfd.Gpu/Advection/AdvectionGpu.cs),
methods `Advect`, `AdvectKernelImpl`, `Sample` and `CorrectKernelImpl`.
Let `I_c` be trilinear interpolation of component `c` on its native staggered
lattice, and `I_u` the resulting vector interpolation. The original velocity
`u^n` carries every component. At output location `x`:

```text
x_mid = x - (dt/2) I_u[u^n](x)
x_dep = x - dt I_u[u^n](x_mid)
S_dt[u^n](q)(x) = I_c[q](x_dep)
```

The geometry-aware path additionally projects both `x_mid` and `x_dep` out of
the solid using the SDF. It excludes blocked interpolation samples and renormalizes
the remaining weights. A face classified Closed or with aperture below `0.01`
is treated as blocked and keeps its input value; an entirely rejected interpolation
stencil returns zero. Nonperiodic samples clamp to the domain; periodic samples
wrap. These existing rules are geometry handling, not a finite-volume balance.

`SemiLagrangian` uses `q_forward = S_dt[u^n](q^n)`. `MacCormack` uses:

```text
q_forward  = S_dt[u^n](q^n)
q_backward = S_-dt[u^n](q_forward)       # SAME original carrying velocity
q_trial    = q_forward + (q^n - q_backward)/2
q_new      = clamp(q_trial, q_min, q_max)
```

`q_min/q_max` are the eligible original samples in the forward interpolation
stencil. This clamp bounds the output against that stencil; it does not impose
an equal/opposite transfer between neighboring control volumes. The method
corrects a round-trip interpolation error, with lineage in
[Selle et al., An Unconditionally Stable MacCormack Method](https://physbam.stanford.edu/papers/stanford2006-09.pdf).
That paper's formal results do not prove the order of our geometry-limited,
split pressure/diffusion solver. The word MacCormack also names conservative
schemes elsewhere; the nonconservation statement here concerns this implementation.

The [advection tests](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/test/PolyCfd.Gpu.Tests/Advection/AdvectionSchemeTests.cs)
check uniform fields and Gaussian transport/overshoot. They do not prove general
momentum conservation, cut-cell accuracy or full-solver convergence order.

## Boundary conditions

**Implemented formulas and review gaps; proposed work is labeled below.** The
[boundary guide](/docs/BOUNDARY_CONDITIONS_HALOS) owns the current contracts and
source/test links. Treat a physical choice, its component-specific mathematical
condition, its sampling location and its application stage as separate decisions.
For example, a stationary slip wall fixes normal velocity to zero but gives
tangential diffusion a zero-normal-gradient condition. AMReX's `BCRec` describes
component low/high boundary types; linear operators use their own `LinOpBCType`
conditions. Use corresponding names where these responsibilities match, preserving
our compact descriptors, inline velocity stencils and pressure halos.
[AMReX boundary conventions](https://amrex-codes.github.io/amrex/docs_html/Basics.html#boundary-conditions)
and [linear-solver BCs](https://amrex-codes.github.io/amrex/docs_html/LinearSolvers.html#boundary-conditions)
are references, not a requirement to reproduce their complete API or allocate BC fields.

### Boundary location and pressure correction

With a cell-centered pressure sample `pI` half a cell inside a flat domain face,
and a ghost `pG` half a cell outside, the current centered boundary construction is:

```text
fixed boundary pressure pB: (pI + pG)/2 = pB  => pG = 2 pB - pI
zero normal derivative:    (pG - pI)/h = 0   => pG = pI
constant physical pB in incremental projection:
    phiB = 0, phiG = -phiI, p^(n+1) = p^n + phi
```

Setting the pressure ghost directly to `pB` would move the discrete boundary
condition to a different location. Keep the physical pressure used by the static
predictor/final halo distinct from the homogeneous increment used by its linear
solve. Moving geometry currently uses full-pressure projection; do not apply the
static increment rule indiscriminately. Likewise, tangential wall diffusion uses
the reflected sample `uG = 2 uWall - uI`, while a normal MAC velocity already lies
on the wall and is prescribed there. These placement distinctions must survive
renaming and future ghost/exchange interfaces.

### Transport stages and AMReX-Hydro correspondence

Current semi-Lagrangian/MacCormack sampling wraps periodic coordinates and clamps
nonperiodic ones. Normal boundary enforcement and diffusion wall stencils do not
by themselves establish correct exterior tangential samples, outlet reversal or
MacCormack forward/reverse/limiter-stage boundary semantics. BC-02 must derive and
qualify these behaviors on one grid with nonuniform data, including the forward
scratch consumed by the reverse stage. A post-advection boundary application alone
is not evidence that earlier samples used the correct conditions.

AMReX-Hydro documents Godunov pre-/post-MAC edge-state rules for prescribed inflow,
reflection, extrapolation and backflow control. Its direction-dependent condition
switches behavior with inflow/outflow direction. Those rules act on reconstructed
states before upwinding, so copying them into our interpolating sampler is not a
numerical derivation. TRN-01 should use them as a reference for its conservative
candidate and qualify the complete projection/transport coupling.
[AMReX-Hydro boundary details](https://amrex-fluids.github.io/amrex-hydro/docs_html/bcs.html)

### Validation and delivery

**Planned:** [BC-01](/docs/plans/boundary-condition-alignment) closes the scenario/general
typed-API consistency gap: periodic velocity and pressure must describe the same
topology, with coordinate-corresponding opposite samples. The AMR-02 target puts
periodicity in canonical domain geometry and keeps physical fills separate from
neighbor exchange and later coarse/fine fills. BC-02 then qualifies each supported
method/BC subset before S2 transport acceptance, alongside TRN-01. Keep numerical
corrections separate from AMR-02's behavior-preserving structural acceptance.

Current partial normal-velocity masks still have whole-face pressure conditions;
they do not implement spatially mixed BCs. AMReX-Hydro's mixed projection support
uses additional spatial data and Robin/overset treatment, with documented limits
on tested configurations. Defer that feature until needed; it is not a prerequisite
for AMR-02, basic S2 or S3. New boundary numerical work and final diagnostics remain
on-device under the [GPU policy](/docs/plans/gpu-resident-processing); bounded setup
descriptors do not require repeated field transfers or extra velocity halo storage.

## Current time step and projection

**Implemented static geometry:** the integrator applies advection, body increments,
the old pressure force, backward-Euler diffusion, immersed-face constraints and
incremental projection. Boundary operations occur between these stages. Denote
the constrained preprojection velocity by `u_star`:

```text
u_adv = Advect(u^n, dt)
u_rhs = u_adv + dt f - dt G(p^n)
(I - dt nu L) u_diff = u_rhs
u_star = ApplyImmersedConstraints(u_diff)
A phi = b,       A = -D_alpha G,       b = -D_alpha(u_star)/dt
u^(n+1) = u_star - dt G(phi)
p^(n+1) = p^n + phi                    # restore gauge and physical pressure BCs
```

`D_alpha` is outward open-area flux divided by effective fluid volume, `G` the
effective staggered correction gradient including solid-face masks and correction
boundary treatment, `L` the viscous discrete Laplacian, and `phi` a pressure
increment. The applied correction skips solid-adjacent faces; cancellation requires
the pressure operator to match that correction, not merely an unmasked gradient
kernel. The signed residual/continuity identity and its assumptions are in
[pressure solver qualification](#pressure-solver-qualification). Reapplied constraints,
compatibility projections and finite precision require checking actual final divergence.
Under GPU-01 the residual, complete norms, compatibility/gauge corrections,
coefficients and convergence evaluation remain on device. A bounded compact status
readback may stop host scheduling or report failure; it does not require downloading
partials or recomputing the numerical decision. Compare its measured synchronization
cost with inactive device-gated launches while preserving tolerances and checks.

The pressure operator limits effective small volumes and masks solid rows;
its weights are not a derivation of conservative momentum volumes. Pressure
inner products use double-accumulated volume weights with float fields and Half
geometry. Constant prescribed physical pressure gives zero prescribed pressure
increment. Closed/periodic pressure components have constant null modes; fixed
pressure anchors only components connected to that boundary. Both pressure solvers
now share a PCG loop that projects every unanchored region's constant mode and
gauges each region, including static disconnected domains. Moving projection also
balances its geometric-source right-hand side per region. Preserve this existing
component compatibility, gauge and imbalance-refusal behavior as topology changes;
do not replace several null modes by one global mean. The
[projection guide](/src/PolyCfd.Gpu/Projection/README) owns these implemented contracts.

**Implemented moving geometry differs:** it rebuilds geometry at `t+dt`, initializes
changed cells, advects, adds sources, diffuses and imposes wall velocity, then uses
full-pressure projection with a geometric source. It does not use the static
old-pressure predictor/increment accumulation. For rigid rotation:

```text
u_wall(x) = omega cross (x - center)
S_raw = D_alpha(u_wall)
b_raw = -(D_alpha(u_star) - S_raw)/dt
b_compatible = component-compatible RHS
S_compatible = D_alpha(u_star) + dt b_compatible
continuity error = D_alpha(u_new) - S_compatible
```

Other motion uses the existing limited old/current-volume source. A small moving
continuity error does not prove exact geometric conservation or momentum balance.
See [moving design](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/docs/MOVING_GEOMETRY_DESIGN.md) and
[moving fan qualification](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/docs/MOVING_FAN_VALIDATION.md). Backward-Euler diffusion
and splitting remain accuracy limitations even if new advection is second order.
AMReX-Hydro's [projection overview](https://amrex-fluids.github.io/amrex-hydro/docs_html/Projections.html)
is useful context; its other velocity/pressure arrangements are not our current solver.

For the implemented linear-solver algorithms behind these equations, continue to
the [shared pressure iteration](/src/PolyCfd.Gpu/Projection/README#one-pcg-loop),
[multigrid preconditioner](/src/PolyCfd.Gpu/Multigrid/README),
[diffusion method and residual definition](/src/PolyCfd.Gpu/Diffusion/README)
and [boundary stencils](/docs/BOUNDARY_CONDITIONS_HALOS). Diffusion currently uses
Chebyshev semi-iteration on undamped Jacobi followed, when needed, by a bounded
colored Gauss-Seidel phase. The [pressure multigrid design](/docs/GPU_MULTIGRID_DESIGN),
[cut-cell multigrid design](/docs/CUT_CELL_MULTIGRID_DESIGN) and
[diffusion history](/docs/ADAPTIVE_DIFFUSION_RELATIVE_TOLERANCE) retain rationale and
labeled historical algorithms. Solver coarsening is not physical AMR, and convergence
of an algebraic solve is separate from the accuracy of its discretization.

## Pressure solver qualification

**Current implementation, pinned review:** [commit `5c4984e`](https://github.com/hankbeasley/polycfd/commit/5c4984eef691d593a1082072ba12344f0478f6bc)
completed SOL-02. Its [V-cycle](https://github.com/hankbeasley/polycfd/blob/5c4984eef691d593a1082072ba12344f0478f6bc/src/PolyCfd.Gpu/Multigrid/MultigridCycle.cs#L54)
keeps a separate coarse RHS, and its
[restriction](https://github.com/hankbeasley/polycfd/blob/5c4984eef691d593a1082072ba12344f0478f6bc/src/PolyCfd.Gpu/Multigrid/MultigridKernels.cs#L169)
is the volume-weighted adjoint of injection, `R = V_c^-1 P^T V_f`, on the stated
active spaces. The same Chebyshev polynomial is used before and after the coarse
correction. Earlier aliased-RHS and nonadjoint-transfer findings describe superseded
code. The [multigrid guide](/src/PolyCfd.Gpu/Multigrid/README#v-cycle)
owns the current construction argument, schedules, buffer roles, test scope and limits;
this review does not create another implementation contract or a new test-run claim.

**Planned PRJ-01:** qualify the remaining pressure-solver and final-continuity
contracts below. Status and owner live on the [work board](/docs/WORKBOARD).
This follow-up does not reopen completed SOL-02 or replace its retained evidence.

PCG requires a fixed linear preconditioner, self-adjoint and positive on the relevant
volume-weighted compatible subspace. The current construction argument depends on
symmetric positive-semidefinite flux operators on every participating level, consistent positive weights,
homogeneous correction BCs, and zero correction in excluded coarse cells. Rediscretized
coarse geometry need not be Galerkin for that argument, but can degrade convergence.
Geometry crossing a periodic seam can give independently built opposite apertures and
a nonsymmetric operator; the [seam guards and limits](/src/PolyCfd.Gpu/Multigrid/README#limits)
are bounded empirical evidence, not a general SPD guarantee. Positivity sampled on a
few vectors is useful regression evidence alongside the derivation, not its replacement.

Retain and extend the existing [pressure solver contract tests](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/test/PolyCfd.Gpu.Tests/Numerics/Pcg/PressureSolverContractTests.cs),
[symmetry tests](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/test/PolyCfd.Gpu.Tests/Multigrid/MultigridSymmetryTests.cs) and
[transfer tests](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/test/PolyCfd.Gpu.Tests/Multigrid/MultigridTransferTests.cs)
when changing a smoother, transfer, geometry or boundary treatment. Qualification
must exercise the **whole applied preconditioner**, including its finest-level
entry and coarse solve:

- Check weighted symmetry and positive action on the declared active/compatible
  space, including anchored systems and each unanchored connected component; retain
  independent operator residuals and the matching nullspace/gauge checks.
- Check linearity, repeated-call independence, ignored incoming correction values,
  unchanged input RHS and retained coarse RHS after pre/post smoothing. Keep scratch
  ownership and nonaliasing checks; do not validate only the isolated smoother.
- Check transfer adjointness at every level pair, including odd extents, rebuilt cut
  geometry and zero-volume coarse cells. Retain the host-double V-cycle comparison;
  add independent small-system checks for newly supported cases rather than rewriting
  already useful coverage.
- State which configurations satisfy the construction assumptions and which are
  guarded limitations. A finite or honestly unconverged seam test cannot qualify an
  arbitrary nonsymmetric system for PCG. Measure allocations, synchronization and
  complete device reductions alongside numerical acceptance.

### True residual and final continuity

The [shared iteration](/src/PolyCfd.Gpu/Projection/README#one-pcg-loop)
currently declares success from the recursively updated, compatibility-projected
residual. Its [failure summary](/src/PolyCfd.Gpu/Projection/README#pressure-failure-summary)
recomputes the physical operator residual only at a nonconverged exit; independent
tests also audit successful solves. A success flag therefore does not by itself
certify the true residual of the returned pressure or the final velocity continuity.
PRJ-01 acceptance must measure both. A runtime true-residual confirmation at
candidate success is proposed qualification work, with device reduction and measured
cost; it is not already provided by this documentation or SOL-02.

For the simple static regular periodic case, use identical discrete operators,
homogeneous correction BCs, a compatible RHS and no subsequent velocity modification.
With `A=-D G`, `b=-D(u_star)/dt`, true residual `r=b-A phi` and
`u_projected=u_star-dt G(phi)`, exact arithmetic gives:

```text
D(u_projected) = D(u_star) + dt A phi = -dt r.
```

The minus sign follows from the negative-Laplacian convention. To separate other
effects, define a raw continuity target `S_raw`,
`b_raw=-(D(u_star)-S_raw)/dt`, `delta_b=b_solve-b_raw`, and the net velocity change
`delta_u` applied after projection. When the same operator identity holds:

```text
r_true = b_solve - A phi
D(u_final) - S_raw = -dt r_true + dt delta_b + D(delta_u)
S_compatible = S_raw + dt delta_b
D(u_final) - S_compatible = -dt r_true + D(delta_u).
```

Finite precision and any operator/geometry mismatch add a separate defect to these
identities. Report the raw compatibility adjustment, the true residual in the
declared solved space, and continuity after the **last** domain/immersed constraint
application separately. A small error relative to `S_compatible` does not show that
the raw physical source was compatible or that boundary momentum was preserved.
The [projection](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/src/PolyCfd.Gpu/Projection/ProjectionGpu.cs) and
[integrator](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/src/PolyCfd.Gpu/Integration/TimeIntegratorGpu.cs) still have separate
static and moving stage orders; final-constraint qualification must cover the claimed
path. Keep current component compatibility/refusal behavior and scientific limits;
do not introduce a universal runtime guarantee by interpreting this derivation alone.
PRJ-01 closure requires the applicable CUDA operator/solver and scientific suites,
independent post-constraint continuity evidence and measured transfer/memory/timing
costs on its declared supported configurations. Retained tests are extended where
the claim grows; no limits or references are weakened to obtain acceptance.

## Proposed shared-flux update

**Proposed contract:** choose a fixed orientation for each transport interface
`f`, from volume `L` to `R`, with normal `n_f`. `Q_i = V_i q_i` is the integrated
quantity, and `s_if` is `+1` for the L volume and `-1` for R. Define the signed
amount transported over a step, already including physical open area and time:

```text
I_f = integral_[t_n,t_(n+1)] integral_[open face f] q (u dot n_f) dA dt
Q_i^(n+1) = Q_i^n - sum_f(s_if I_f) + B_i
```

`B_i` is the integrated source/boundary-force contribution appropriate to `q`.
For a scalar concentration, `I_f` has units of scalar amount. For physical momentum
`q=rho u_a`, it has units `mass*length/time`; for `q=u_a`, units `length^4/time`.
If storing flux density instead, specify its units and apply `alpha*A*dt` exactly
once. This fixed-volume equation needs the moving-volume extension below for motion.

Each internal interface contributes `-I_f` to L and `+I_f` to R, so summing all
volumes cancels internal transfers algebraically. Example: initially `Q_L=4`,
`Q_R=1`, with `I_f=+0.3` and no other transfers gives `3.7,1.3`; the total remains
5. A negative `I_f` reverses the transfer. Independently using outgoing `0.3` and
incoming `0.25` would lose `0.05`. Finite precision still requires roundoff-aware
budget tolerances; identical flux data do not guarantee bitwise invariant sums.
Compute the shared transfers, their update and full double-accumulated budget
reduction on GPU. Returning partial sums for CPU finalization violates GPU-01 even
if the main update is device resident.

Constant preservation is an additional condition: for constant `q`, its update
vanishes only when the transporting volume fluxes satisfy the required discrete
continuity and sources/BCs agree. Shared-flux cancellation alone does not prove
this, boundedness, physical energy evolution or accuracy.

## Illustrative regular-grid scalar algorithm

**Illustrative only:** a fully specified small building block for discussion.
It solves `q_t + a q_x = 0` for constant speed `a`, periodic uniform 1D cells of
width `h`, unit cross section, fixed volumes, and cell averages `q_i`. It is not
a 3D momentum, cut-cell, thermal or selected production algorithm.

Use a limited piecewise-linear reconstruction (slopes here have units of `q`):

```text
sigma_i = minmod(q_i - q_(i-1), q_(i+1) - q_i)
minmod(x,y) = sign(x) min(|x|,|y|) if x*y > 0; otherwise 0
q_i^L = q_i - sigma_i/2;    q_i^R = q_i + sigma_i/2
F_(i+1/2)(q) = a q_i^R       if a >= 0
             = a q_(i+1)^L   if a < 0
L_i(q) = -(F_(i+1/2)(q) - F_(i-1/2)(q))/h
```

Advance with the two-stage, second-order strong-stability-preserving Runge-Kutta
formula, reconstructing and filling periodic neighbors separately at each stage:

```text
q_stage = q^n + dt L(q^n)
q^(n+1) = (q^n + q_stage + dt L(q_stage))/2
I_(i+1/2) = (dt/2) [F_(i+1/2)(q^n) + F_(i+1/2)(q_stage)]
```

The last line is the actual integrated flux of this update; storing only its
second-stage flux would give the wrong diagnostic/register balance. For `a>0`,
a forward-Euler substep can be written using `C=a dt/h` as

```text
q_i + dt L_i(q) = (1/2)q_i^L + (1/2-C)q_i^R + C q_(i-1)^R.
```

For `0 <= C <= 1/2`, the coefficients are nonnegative and sum to one; minmod
endpoints stay within their neighboring cell range. Thus each such substep is
bounded by the input's global range, and the two-stage convex combination retains
that bound. Negative `a` gives the symmetric argument. This is a sufficient bound
for this example, not a universal CFL rule. Conservation follows separately from
flux telescoping. Smooth-region spatial reconstruction and time integration are
nominally second order; limiter activation can reduce local order near extrema.

The two-stage form has the SSP Runge-Kutta basis described by
[Gottlieb, Shu and Tadmor (2001)](https://www.math.umd.edu/~tadmor/pub/linear-stability/Gottlieb-Shu-Tadmor.SIREV-01.pdf).
Our explicit boundedness calculation above is for these particular scalar assumptions.
Multidimensional varying velocity, staggered momentum, boundary reconstruction and
small cut cells require new derivations and timestep limits. AMReX-Hydro's
[reconstruction helpers](https://amrex-fluids.github.io/amrex-hydro/docs_html/Utilities.html)
illustrate further choices; this example does not reproduce its Godunov algorithms.

## First regular-grid MAC candidate

**Selected design candidate, not implemented or accepted:** limited piecewise-linear
MUSCL reconstruction with minmod slopes, two SSPRK2 transport evaluations using the
**same accepted velocity as carrier**, then the existing source/old-pressure predictor,
backward-Euler diffusion and one incremental projection. The complete nonlinear
method is **first order in time**. Its reconstruction is nominally second order in
smooth space; SSPRK2 is second order in time for a prescribed steady carrier, not
for the full evolving momentum problem. This choice retains the current pressure
solve count and avoids introducing velocity history or an unqualified midpoint predictor.
The [TRN-01 plan](/docs/amrex-alignment/SINGLE_LEVEL_TRANSPORT) still requires measured benefit before
production adoption; current methods/defaults are unchanged.

### Scope, unknowns and periodic ownership

Use one fixed all-fluid Cartesian patch, periodic in every direction, constant
density $\rho>0$ and constant kinematic viscosity $\nu\ge0$. Spacings $h_x,h_y,h_z$
are constant but need not be equal; the initial 3D prototype uses at least four
cells on each axis. Forces are zero or prescribed smooth accelerations sampled at
$t^n$; state-dependent feedback, physical walls/inlets/outlets, cuts and motion are
outside this first candidate. The 2D example below is a slice per unit depth.

Each velocity component $q$ approximates the mean over its own shifted rectangular
momentum volume, with $V=h_xh_yh_z$ in 3D. Thus $\rho Vq$ is **discrete physical
momentum**; $Vq$ is momentum per density. A current point sample is only a midpoint
quadrature approximation to that mean, with $O(h^2)$ error for smooth data. Initialize
and compare analytic cases using declared dual-volume averages or explicitly stated
midpoint quadrature; do not silently compare exact averages with point-sample references.
The same locations/arrays remain useful, but location alone did not select this meaning.

In mathematical subscripts let $p_{i,j,k}$ denote the pressure-cell center, as in
AMReX-Hydro notation. The mapping to our zero-based arrays is:

| Mathematical quantity | Current array entry | Independent periodic indices |
| --- | --- | --- |
| $p_{i,j,k}$ | PInterior[i,j,k] | All pressure cells |
| $u_{i+1/2,j,k}$ | UInterior[i+1,j,k] | Store U[0..Nx-1,j,k] once; U[Nx,j,k]=U[0,j,k] |
| $v_{i,j+1/2,k}$ | VInterior[i,j+1,k] | V[i,0..Ny-1,k]; final Y endpoint is a copy |
| $w_{i,j,k+1/2}$ | WInterior[i,j,k+1] | W[i,j,0..Nz-1]; final Z endpoint is a copy |

There are $N=N_xN_yN_z$ independent full volumes per component. Wrap all stencil
indices through those independent ranges; copy endpoint storage after producing
a complete field. Never count both endpoint copies as independent momentum.
See [MacComponent](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/src/PolyCfd.Gpu/Core/MacComponent.cs).

### One worked U momentum volume

The volume centered on $q_0=u_{i+1/2,j}$ lies between pressure centers $x_i,x_{i+1}$
and between $y_{j-1/2},y_{j+1/2}$. Let $q_W,q_E,q_S,q_N$ be the neighboring U values
on this shifted grid. At this stage, lower-case $u,v$ in the carrier column are
read from the **unchanged accepted** velocity $\mathbf U^n$. Slopes in the last
column come from the transported field for the current evaluation, which can
differ from that carrier.

| Face / positive coordinate orientation | Flux location | Carrying velocity $a_f$ | Reconstructed transported pair $(q_L,q_R)$ |
| --- | --- | --- | --- |
| West / +X | $(x_i,y_j)$ | $(u_{i-1/2,j}+u_{i+1/2,j})/2$ | $(q_W+\sigma_{W,x}/2,\ q_0-\sigma_{0,x}/2)$ |
| East / +X | $(x_{i+1},y_j)$ | $(u_{i+1/2,j}+u_{i+3/2,j})/2$ | $(q_0+\sigma_{0,x}/2,\ q_E-\sigma_{E,x}/2)$ |
| South / +Y | $(x_{i+1/2},y_{j-1/2})$ | $(v_{i,j-1/2}+v_{i+1,j-1/2})/2$ | $(q_S+\sigma_{S,y}/2,\ q_0-\sigma_{0,y}/2)$ |
| North / +Y | $(x_{i+1/2},y_{j+1/2})$ | $(v_{i,j+1/2}+v_{i+1,j+1/2})/2$ | $(q_0+\sigma_{0,y}/2,\ q_N-\sigma_{N,y}/2)$ |

All listed orientations are +X or +Y, **not** four outward normals. Consequently
the U update subtracts East minus West and North minus South transfers.
For unit depth, X faces have area $h_y$ and Y faces area $h_x$.

Define the pressure-cell and U-volume divergences:

$$
D_{i,j}\mathbf U =
\frac{u_{i+1/2,j}-u_{i-1/2,j}}{h_x}
+\frac{v_{i,j+1/2}-v_{i,j-1/2}}{h_y},
\qquad
D_Ua=\frac{a_E-a_W}{h_x}+\frac{a_N-a_S}{h_y}.
$$

Substituting the four carrier averages gives, without approximation,

$$
D_Ua=\frac12\left(D_{i,j}\mathbf U^n+D_{i+1,j}\mathbf U^n\right).
$$

The terms at $u_{i+1/2,j}$ cancel between the two pressure-cell differences; the
two V differences are precisely their average. This proves carrier continuity
when the accepted native MAC field is discretely solenoidal. For finite divergence,
the dual divergence is exactly that average, not necessarily zero.

In 3D add bottom/top carriers

$$
a_{z,\pm}=\frac12\left(w_{i,j,k\pm1/2}+w_{i+1,j,k\pm1/2}\right).
$$

The six-face U-volume divergence equals the same neighboring average of the **3D**
pressure-cell divergences. V and W follow by permuting axes. In array notation,
U[I,j,k] has south/north carriers averaging V[I-1,j,k], V[I,j,k] and
V[I-1,j+1,k], V[I,j+1,k], respectively. Its adjacent pressure cells are
P[I-1,j,k] and P[I,j,k]. Off-diagonal momentum fluxes are at corners in the 2D
drawing and **edge centers in 3D**; diagonal fluxes are at pressure-cell centers.
[Basilisk's MAC source](https://basilisk.fr/src/navier-stokes/mac.h) provides a useful
2D location check. Its centered tensor averages are not this limited reconstruction.

### Reconstruction and the actual shared transfers

For component $q$, dual-cell index $K$ and coordinate direction $r$, choose

$$
\sigma_{K,r}=\operatorname{minmod}(q_K-q_{K-e_r},q_{K+e_r}-q_K),
\qquad q_{K,r}^{\pm}=q_K\pm\frac12\sigma_{K,r}.
$$

Minmod returns the smaller magnitude with the common sign, or zero when signs
differ. At a shared face oriented from $L$ to $R$, use one flux per area,
one area-integrated flow rate and one stage-integrated transfer:

$$
\begin{aligned}
\widehat f_f(a,q)&=\max(a_f,0)q_{L,r}^{+}+\min(a_f,0)q_{R,r}^{-},\\
\mathcal F_f(a,q)&=A_f\widehat f_f(a,q),\qquad A_f=V/h_r,\\
\mathcal L_a(q)_K&=-\frac1V\sum_{f\in\partial K}s_{Kf}\mathcal F_f(a,q).
\end{aligned}
$$

$s_{Kf}=+1$ on a positive-coordinate face and $-1$ on a negative-coordinate
face. Both neighbors consume the same oriented $\mathcal F_f$.
In 3D, for velocity, $\widehat f$ has units $\mathrm{m^2/s^2}$, $\mathcal F$ has
$\mathrm{m^4/s^2}$ and $I_f=\int\mathcal F_f\,dt$ has $\mathrm{m^4/s}$.
Multiplication by $\rho$ gives momentum flow rate (newtons) and transferred
momentum ($\mathrm{kg\,m/s}$). The 2D slice uses rates and transfers per unit
out-of-plane depth. Area and time occur once each.

Let $a=C(\mathbf U^n)$ be the carrier averages above. Keep them fixed for both
transport evaluations; reconstruct the transported states afresh:

$$
\begin{aligned}
q^{(1)}&=q^n+\Delta t\,\mathcal L_a(q^n),\\
q^{\mathrm{adv}}&=\frac12q^n+
 \frac12\left(q^{(1)}+\Delta t\,\mathcal L_a(q^{(1)})\right),\\
I_f&=\frac{\Delta t}{2}
 \left(\mathcal F_f(a,q^n)+\mathcal F_f(a,q^{(1)})\right).
\end{aligned}
$$

Thus, exactly in algebra,

$$
q_K^{\mathrm{adv}}=q_K^n-\frac1V\sum_f s_{Kf}I_f,\qquad
q_0^{\mathrm{adv}}=q_0^n-\frac{I_E-I_W+I_N-I_S}{V}
$$

for the 2D worked volume. Add top minus bottom in 3D. The second-stage field
$q^{(1)}$ need not be divergence-free: it supplies **transported values only**.
It must never replace $\mathbf U^n$ when constructing the carrier. Only storing
the second-stage flux would fail to reproduce this update. Reductions or selected
interface audits can consume both weighted contributions while their scratch is live;
a permanently stored full flux register is unnecessary on this single patch.

### Complete timestep and array lifetimes

Start from an accepted $\mathbf U^n,p^n$ with consistent periodic endpoints and
a checked native continuity residual. Project initial data once during setup if
needed, record that change/cost, and choose a zero-mean initial kinematic pressure
(analytic when known, otherwise declared zero). No previous-velocity history is
needed. A step outside the declared CFL or initial continuity acceptance is rejected
before transport changes the accepted state.

With $\Delta_h$ the current periodic component Laplacian and $G,D$ the current
compatible MAC gradient/divergence, use exactly this sequence:

$$
\begin{aligned}
\mathbf U^{\mathrm{adv}}&=\operatorname{SSPRK2}_{C(\mathbf U^n)}
                                      (\mathbf U^n,\Delta t),\\
R&=\mathbf U^{\mathrm{adv}}+\Delta t f^n-\Delta t Gp^n,\\
(I-\Delta t\nu\Delta_h)\mathbf U^\star&=R,\\
A\phi&=-D\mathbf U^\star/\Delta t,\qquad A=-DG,\\
\mathbf U^{n+1}&=\mathbf U^\star-\Delta t G\phi,\\
p^{n+1}&=p^n+\phi,\qquad \sum_{\mathrm{cells}}Vp^{n+1}=0 .
\end{aligned}
$$

Here $f^n$ is the declared dual-volume approximation of prescribed acceleration;
sources are applied once, after transport, at $t^n$. Skip diffusion when $\nu=0$.
The correction has periodic BCs and a zero initial guess. Disable optional residual
projection for this first candidate so an ordinary step has **one primary Poisson
solve**, plus three component diffusion solves when viscous. Setup projection is
separate. A future refinement pass would be an explicit measured configuration.

| Stage | Values read / carrying velocity | Produced data and boundary action |
| --- | --- | --- |
| 0. Preconditions | Accepted U/V/W and p; $\mathbf U^n$ is the sole carrier source | Check continuity, device CFL and finite values; canonicalize periodic duplicates; pressure halo represents $p^n$ |
| 1. First flux evaluation | $a=C(\mathbf U^n)$ and transported $q^n$ | Shared $\mathcal F^0$; construct all directional contributions to $q^{(1)}$; wrap unique indices |
| 2. Second flux evaluation | Same $a$, transported $q^{(1)}$ | Recompute slopes/fluxes; form $q^{\rm adv}$ and weighted transfers; never read a partially updated $q^{(1)}$ |
| 3. Complete all components | Original U/V/W remain read-only through the last carrier consumer | Only then copy/swap complete Uadv into state and refresh periodic duplicates |
| 4. Force and old pressure | Prescribed $f(t^n)$, retained $p^n$ with periodic halo | Form $R$; no transport-stage pressure solve or source repetition |
| 5. Diffusion | $R$, constant $\nu$, periodic component operator | Solve for Ustar; enforce periodic duplicate equality |
| 6. Projection | Ustar, homogeneous periodic correction operator | Zero-initialized $\phi$, correct U/V/W, accumulate/gauge p and refresh pressure halo |
| 7. Acceptance | Final canonical U/V/W, pressure and retained stage budgets | Check true residual and final continuity after duplicate refresh; finish momentum/energy reductions on GPU |

These stages map to the existing
[integrator](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/src/PolyCfd.Gpu/Integration/TimeIntegratorGpu.cs),
[diffusion](/src/PolyCfd.Gpu/Diffusion/README) and
[incremental projection](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/src/PolyCfd.Gpu/Projection/ProjectionGpu.cs);
the conservative advection implementation is new work. The frozen carrier adds
no solve solely for flux-location interpolation. This differs from AMReX-Hydro's
cell-centered pre/post-MAC prediction stages; retain its separation of carrier and
transported states, not its complete timestep by name.

Ordered prototype pseudocode, with each loop body scheduled on the GPU:

~~~text
validate fixed all-fluid periodic layout and accepted state
compute global admissible dt from Uold; reject before mutation if exceeded
for component q in U, V, W:
    q1 = qold
    for direction r:
        F = shared_flux(qold, carrier=Uold, direction=r)
        q1 -= dt * divergence_r(F)
        audit contribution (dt/2)*F while F is live
    qadv = (qold + q1)/2
    for direction r:
        F = shared_flux(q1, carrier=Uold, direction=r)
        qadv -= (dt/2) * divergence_r(F)
        audit contribution (dt/2)*F while F is live
commit all qadv components together; refresh periodic duplicates
add dt*f(t_n); apply old-pressure predictor
solve backward-Euler diffusion if nu>0
solve one pressure increment; correct velocity; accumulate/gauge pressure
refresh duplicates/pressure halo; check final continuity and stage budgets
~~~

Each slope reads immediate neighbors, but divergence uses neighbors' reconstructed
states: the component stencil reaches **two samples in each direction**. Carriers
read adjacent native faces. No new full velocity halo is required on this periodic
patch; later S2 exchanges must supply this reach at both complete stages.

One concrete low-storage schedule uses: borrowed immutable old state; a complete
MAC output set of $S$ stored samples; one component-stage buffer of capacity $M$,
the largest stored component; and one oriented flux buffer of $N$ unique faces.
Reuse that flux buffer only after both adjacent divergence consumers and audit
reductions complete. Reuse component-stage scratch after its second-stage consumers.
No slope array or stored carrier array is required. Added float storage is
$4(S+M+N)$ bytes, about $20N$ for large grids, **in addition to** existing solver
workspaces, device reduction scratch and requested output. At $128^3$ this schedule
is 40.25 MiB with the existing duplicated-endpoint extents. It entails 18 directional
flux constructions and 18 divergence accumulations for three components/two stages,
plus initializations, final copies and checks; kernel fusion can change launch count,
not dependencies. Measure these costs rather than equating one pressure solve with
unchanged total runtime. All reductions, CFL decisions and numerical checks finish
on device; only permitted bounded status metadata reaches the host.

### Multidimensional transport CFL and proof

For every component volume $K$, let $a_{r,+},a_{r,-}$ be its positive- and
negative-side carriers, both signed in the **positive coordinate direction**.
Choose the following sufficient bound, enforced using the actual accepted carrier:

$$
\lambda_K=\sum_r
\frac{\max(\max(a_{r,+},0),\max(-a_{r,-},0))}{h_r},
\qquad
\Delta t\max_{\mathrm{components},K}\lambda_K\le\frac12.
$$

If the maximum is zero, transport imposes no timestep limit; the configured
maximum step/final-time bound still applies. A simpler, possibly more restrictive
cross-check is

$$
\Delta t\left(\|U^n\|_\infty/h_x+\|V^n\|_\infty/h_y+
\|W^n\|_\infty/h_z\right)\le1/2.
$$

Do not apply the 1D CFL independently on each axis.
The local bound is a sufficient transport restriction, not a proven sharp limit
or an accuracy guarantee for the full forced/projected step.

To prove it, define outgoing rates $c_{r,+}=\max(a_{r,+},0)/h_r$,
$c_{r,-}=\max(-a_{r,-},0)/h_r$ and $m_r=\max(c_{r,+},c_{r,-})$.
For $d$ active dimensions choose

$$
\beta_r=2\Delta t\,m_r+
\frac{1-2\Delta t\sum_s m_s}{d},\qquad
q_K=\sum_r\frac{\beta_r}{2}(q_{K,r}^{+}+q_{K,r}^{-}).
$$

The weights $\beta_r$ are nonnegative and sum to one. In a forward-Euler flux
update the coefficients of local outgoing endpoint states become
$\beta_r/2-\Delta t c_{r,+}$ and $\beta_r/2-\Delta t c_{r,-}$, both nonnegative.
Incoming upwind endpoint coefficients are also nonnegative. Their total weight is
$1-\Delta t D_Ka$. If $D_Ka=0$, this is a convex combination of minmod endpoints,
which lie in the previous global component range. Each Euler map therefore preserves
constants and that range. SSPRK2 is a composition of two such maps followed by a
convex average with $q^n$, so the same transport bound applies at both stages.
The $\beta_r$ are proof devices, not extra runtime state or numerical flux weights.

With finite carrier divergence $\delta_K$, a constant field's **first Euler stage**
is $q_0(1-\Delta t\delta_K)$; exact constant preservation and an unscaled maximum
principle no longer follow. The second stage consumes that nonconstant result.
Report this defect against the measured native/dual divergence and roundoff.
Pressure correction and sources can change component extrema; the proof above
does not establish bounds or energy stability for the complete velocity timestep.

### Accuracy, momentum and energy of the complete update

Freezing $\mathbf U^n$ is deliberate. Two SSP stages integrate the frozen-carrier
semidiscrete transport problem to second order in smooth regimes, but omit the
evolving carrier's time derivative. Pressure and forces are also outside the
transport stages, and diffusion is backward Euler. The candidate therefore makes
only a **first-order temporal claim for evolving flow, even when inviscid**.
A later second-order coupled method requires a separately derived stage treatment;
neither changing the label nor substituting $q^{(1)}$ as carrier supplies it.

Shared periodic transfers cancel exactly in the discrete component momentum sum.
On the regular periodic grid, the pressure gradient and component Laplacian also
telescope over the unique volumes. Consequently, with exact solves,

$$
M_\alpha^{n+1}-M_\alpha^n
=\rho V\Delta t\sum_K f_{\alpha,K}^n,\qquad
M_\alpha=\rho V\sum_K q_{\alpha,K}.
$$

For diffusion residual $d=R-(I-\Delta t\nu\Delta_h)\mathbf U^\star$, the
corresponding momentum defect is $-\rho V\sum_K d_{\alpha,K}$, plus storage and
reduction roundoff. Separately check the projection identity
$D\mathbf U^{n+1}=-\Delta t\,r_{\rm true}$ with the compatible RHS and constraints
described in [PRJ-01](#pressure-solver-qualification).

Define discrete kinetic energy by $K(\mathbf U)=\rho V\sum_{\alpha,K}q_{\alpha,K}^2/2$,
counting unique periodic component samples. For regular periodic operators
$G=-D^\ast$ in matching volume-weighted inner products, the projection's
kinetic-energy change obeys

$$
K(\mathbf U^{n+1})-K(\mathbf U^\star)
=-\frac{\rho}{2}\|\Delta t G\phi\|_f^2
+\rho\Delta t\langle D\mathbf U^{n+1},\phi\rangle_c .
$$

It is nonpositive for an exact divergence-free correction. There is no claim here
that limited transport is an energy contraction or that projection makes its energy
error physically correct. Measure transport, forcing, pressure and viscous energy
changes separately, then solution error and total cost at frozen targets.

The [exact-arithmetic design checker](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/tools/check_mac_transport_design.py)
checks finite carrier/flux identities, bounds and stage-transfer accounting on tiny
periodic examples. It is an offline mathematical oracle, not a CPU simulation
backend, production fallback, CUDA test or accuracy/performance qualification.
The checker uses physical transfers $F_{\rm check}=\rho\mathcal F$ and
$I_{\rm check}=\rho I$, divides their divergence by $\rho V$, and uses
$\rho=3/2$ to exercise nonunit density. This is algebraically identical to the
density-normalized equations above. Its tiny 3×4×3 fixture checks algebra, not
the prototype's minimum grid extent.
Reproduce this bounded derivation check with:

```text
py -3.12 tools/check_mac_transport_design.py --output output/amrex-mac-formulation/exact-arithmetic.json
```

The next implementation evidence is CUDA agreement with these equations, native
final continuity, refinement studies and single-grid benefit under
[the existing acceptance gates](/docs/amrex-alignment/SINGLE_LEVEL_TRANSPORT#single-grid-acceptance-matrix).

## MAC momentum and cut-cell derivation

For the existing embedded-boundary implementation and the bounded readiness checks
before same-level cut interfaces, see the [2026-09-27 source review](/docs/amrex-alignment/EMBEDDED_BOUNDARIES)
and [illustrated explanation](/algorithms.html#geometry). That review keeps
AMR-02/BC-01 representation/setup work separate from numerical EB qualification.

The [regular periodic candidate](#first-regular-grid-mac-candidate) now supplies the
initial momentum formulation. The following **extensions remain unresolved** and
do not block review of that bounded design. Physical boundaries follow BC-02, then
stationary cuts and separately motion:

- Derive boundary/cut dual volumes and their carrier-continuity relation; the
  regular-grid arithmetic-average identity cannot simply be reused there.
- Define pressure and viscous tractions on physical/immersed boundaries and the
  work they do. On an impermeable stationary wall the advective normal transfer
  is zero, but pressure and viscous forces can change total fluid momentum.
- Derive cut dual geometry and physical aperture areas consistently, including
  centroid/normal information needed by reconstruction. Existing pressure-cell
  fractions or arbitrary cell-to-face averages are not a sufficient derivation.
- Choose a small-cell treatment and prove that its redistribution/merging preserves
  the declared balance without crossing a solid. Small volumes can impose severe
  explicit restrictions. [AMReX's embedded-boundary discussion](https://amrex-codes.github.io/amrex/docs_html/EB.html#small-cell-problem-and-redistribution)
  explains the issue; adoption requires MAC-specific validation here.
- Qualify motion separately, including newly exposed/covered fluid and each stage's
  geometry. Do not equate an SDF rebuild, pressure compatibility correction or
  copied neighbor value with a conservative transfer through moving geometry.

For reference, the moving-control-volume momentum balance uses boundary velocity
`w_b`, outward normal `n`, and physical stress `T = -P I + rho nu (grad u + grad u^T)`:

```text
d/dt integral_C(t) rho u dV
  = -integral_boundary rho u [(u-w_b) dot n] dA
    + integral_boundary T n dA + integral_C(t) rho f dV
dV/dt = integral_boundary w_b dot n dA.
```

The second identity is the geometric conservation obligation. A discrete method
must reconcile volume changes with swept geometry and relative fluxes, and preserve
constant states where the physical BCs permit them. At an impermeable moving wall,
`(u-w_b) dot n=0`, yet traction and wall work remain. Pressure-solver coarsening,
physical AMR coarsening, and previous/current motion geometry are distinct objects.

## S2 and S3 coupling

**Planned S2:** for a conservative method, neighboring same-resolution patches must
use the same interface transfer with opposite signs, including all temporal stages, limiter inputs and
periodic ownership. Patch edges are not physical walls. Native field/flux ownership,
ghost updates and boundary stencils must preserve the accepted single-grid method.
Retained interpolation methods instead require equivalent departure-point sampling,
including forward/reverse/limiting stages; they do not acquire a conservative-flux
guarantee. Test partition independence separately for each supported method and geometry.
`DomainBoundaryConditions` applies at the physical domain, while `MeshPatch`
interfaces use device exchange coordinated at the level. Refresh stage-valid
ghosts before each dependent kernel; field-scale component connectivity and final
reductions stay on GPU. Host layout metadata may specify duplicate ownership;
device kernels apply that rule to the numerical samples.

**Planned S3:** covered coarse values are replaced by appropriately weighted fine
values (average-down); the composite total counts uncovered coarse plus fine data
once. For a scalar, `V_C q_C = sum_children V_f q_f` requires consistent volumes.
MAC velocity restriction requires its own face/dual-volume and divergence contracts.

Average-down does not correct coarse/fine interface transfers. Orient the interface
outward from an uncovered coarse cell toward fine coverage. If that cell used
`I_C` while the neighboring fine cells received net `I_F` over the same area/time,
the correction to its integrated quantity is

```text
Q_C <- Q_C - (I_F - I_C),
I_F = sum_fine_faces sum_fine_substeps I_f.
```

This replaces its coarse loss by the actual fine transfer. When `I_C=0.3` and
`I_F=0.35`, it must lose another `0.05`. If storing an average, divide the correction
by the appropriate coarse volume. The opposite orientation reverses the signs.
Initially equal level timesteps remove substeps, not spatial flux mismatch.
[AMReX's flux-register example](https://amrex-codes.github.io/amrex/docs_html/AmrCore.html#fluxregisters)
provides the scalar model for this synchronization. Staggered momentum and cut
interfaces still need their derived geometry and transfer accounting.

Refluxing does not enforce composite incompressibility, pressure continuity,
viscous coupling or accuracy. S3 must coordinate it with composite pressure and
diffusion so later corrections respect the final budgets. First deliver the bounded
[S3-01 two-level pressure example](/docs/amrex-alignment/S2_S3_PLAN#first-two-level-pressure-example):
explicit active pressure/normal-flux unknowns, ownership, interface rows, BCs and
gauges, followed by a solved reference and final normal-flux/divergence checks.
Its elliptic residual reflux corrects operator-flux mismatch during the pressure
solve; it does not qualify time-integrated transport reflux or a full flow step.
Later complete fixed-layout flow qualification must combine transport reflux,
average-down, diffusion and composite projection, then check the final momentum
budget and continuity after all corrections. A flux-register sketch alone does not
derive that coupling. Mesh adaptation also
requires conservative remapping and rebuilt connectivity/coverage. See the
[S2/S3 plan](/docs/amrex-alignment/S2_S3_PLAN); AMReX alignment alone implements none of these operations.
Error indicators, tagging, compaction and numerical state transfers stay on GPU.
The host may cluster compact tags, build layout metadata and size allocations at
defined regrid points, with declared transfer and synchronization budgets. Compact
tags can become large: measure their bytes/count/cadence and old/new layout memory
peaks rather than treating them as automatically inexpensive. Fully device-driven
clustering is a later measured optimization, not an AMReX alignment prerequisite.
Do not download solution fields or reduction partials for CPU numerical work.

## Review and validation gates

The review has two parts: **check the equations and assumptions**, then **measure
the implementation against independent references**. Documentation and algebra are
necessary design evidence; they are not a numerical validation run.

| Claim | Mathematical/design check | Required computational evidence |
| --- | --- | --- |
| Linear solve converges | Operator, BCs, compatible RHS, null modes and residual norm | Convergence plus true operator residual; appropriate component gauges |
| PCG preconditioner is admissible | Fixed linear map; volume-weighted symmetry/positivity on the declared compatible space; whole-cycle argument and limits | Existing cycle/transfer/solver tests, unchanged buffers and RHS, independent small-system/reference checks for added scope |
| Continuity holds | Consistent discrete D/G and actual target, including motion | Native final divergence or moving-target error, after constraints |
| Transport conserves | Shared signed integrated transfers; complete control-volume/source definition | Stagewise double-reduced budgets, physical boundary exchange, roundoff-aware tolerance |
| Constants/bounds survive | Compatible transporting fluxes; stated limiter/stability assumptions | Constant and sharp-profile tests in all supported geometries/BCs |
| Energy is physically correct | Viscous dissipation, boundary work and force work; consistent quadrature | Correct decay/input and numerical dissipation, separate from momentum totals |
| Solution is accurate | Consistency and full integration order, including boundary treatment | Native-face field/phase/amplitude/force errors, independent grid and dt refinement |
| S2/S3 coupling is correct | Unique coverage, flux orientation, restriction, composite operators | Partition equivalence, interface budgets and multilevel/reference convergence |
| Execution preserves GPU performance | Fields/repeated numerical kernels and complete reductions stay resident; explicit compact control/layout boundary | No field/partial-result downloads for CPU numerics in qualified paths; measured control bytes/count/cadence, synchronization, launches and memory; requested output counted separately; no hidden fallback |
| Device reductions preserve numerical checks | Double accumulation, complete device finalization, declared ordering/error behavior, proper weights and nullspaces | Independent reference comparisons for norms, coefficients, CFL and diagnostics; unchanged convergence, conservation and physical acceptance gates |
| Stage data is current | Layout/geometry/time-stage validity, producer dependencies and ghost invalidation | Failure/rebind/regrid cases cannot consume stale fields, metrics or ghosts; owned/borrowed lifetimes remain valid |
| Cost is acceptable | Memory/stage/timestep requirements explicitly stated | Idle-GPU cost to declared error target, retained memory and required output cost |

Freeze cases, error measures, tolerances, observation windows and reference/build
identities before comparing methods. Each review claim needs a chain from a pinned
source/research reference and stated assumptions to discrete equations, implemented
stages and executable evidence. Record actual commands, build identity, receipts,
coverage and qualified failures; a plan checkbox or mathematical derivation does not
replace a run. Regular periodic scalar evidence precedes a complete periodic MAC
time-step reference; then physical boundaries, stationary cuts and separately motion.
The worked two-level composite example precedes general S3 coupling claims.
Use traveling shear, planar Taylor-Green, Beltrami, qualified nonlinear references,
backward step and cylinder according to [TRN-01 acceptance](/docs/amrex-alignment/SINGLE_LEVEL_TRANSPORT#single-grid-acceptance-matrix).
Do not infer full order from an advection order label or one small divergence value.
GPU reductions may change summation order; analyze the resulting error and compare
against independent references while retaining double accumulation. A readback
removal passes only when the complete device computation preserves the scientific
checks, including nonfinite detection, convergence/failure handling and physical
diagnostics. Do not disable checks, relax tolerances or replace reference results
to satisfy a transfer audit. Current field-scale CPU processing and host reduction
completion remain migration gaps until replacements satisfy those gates; permitted
host setup and bounded control metadata need their own cost evidence. Fewer copies
alone do not establish better performance.

Keep qualified failures visible. The [exact periodic report](/docs/PERIODIC_EXACT_VALIDATION)
records that the diffusion correction removed the large original Beltrami velocity
plateau, while high-wave traveling shear still fails its accuracy gate. The
[physics guide](/docs/PHYSICS_GUIDE#2-one-time-step) retains the original channel
steady temporal-ratio failure and pending full enclosure qualification. New
transport must not silently relabel those studies as passing or replace their references.

For runtime work, follow [CUDA verification and suite selection](/docs/COMPLETE_VALIDATION#choose-coverage-for-the-change)
and [test instructions](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/test/README.md). Focused operator tests do not replace
the relevant `verify-all` suite or full coverage for broad acceptance. Report actual
receipts and unrun checks; CPU backend not run (user directive). This documentation
change itself has no new runtime/scientific validation result.

## Source map

| Area | Implemented source and focused checks |
| --- | --- |
| Transport | [AdvectionGpu](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/src/PolyCfd.Gpu/Advection/AdvectionGpu.cs); [scheme tests](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/test/PolyCfd.Gpu.Tests/Advection/AdvectionSchemeTests.cs) |
| Stage order | [TimeIntegratorGpu](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/src/PolyCfd.Gpu/Integration/TimeIntegratorGpu.cs); [stage diagnostics tests](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/test/PolyCfd.Gpu.Tests/Diagnostics/StepStageDiagnosticsTests.cs) |
| Discrete projection | [DivGradGpu](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/src/PolyCfd.Gpu/DivGradGpu.cs), [ProjectionGpu](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/src/PolyCfd.Gpu/Projection/ProjectionGpu.cs); [incremental tests](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/test/PolyCfd.Gpu.Tests/Projection/IncrementalProjectionTests.cs), [operator tests](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/test/PolyCfd.Gpu.Tests/Numerics/Pressure/PressureOperatorGpuTests.cs) |
| Pressure iteration and preconditioning | [Shared PcgIteration](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/src/PolyCfd.Gpu/PcgIteration.cs), [Jacobi solver](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/src/PolyCfd.Gpu/PcgSolverGpu.cs), [multigrid solver](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/src/PolyCfd.Gpu/Multigrid/PcgMgSolverGpu.cs); [projection contract and tests](/src/PolyCfd.Gpu/Projection/README), [multigrid contract and tests](/src/PolyCfd.Gpu/Multigrid/README) |
| Whole-preconditioner qualification | [Review and pinned source account](#pressure-solver-qualification); [symmetry/linearity guards](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/test/PolyCfd.Gpu.Tests/Multigrid/MultigridSymmetryTests.cs), [adjoint/RHS/reference-cycle checks](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/test/PolyCfd.Gpu.Tests/Multigrid/MultigridTransferTests.cs), [shared solver contracts](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/test/PolyCfd.Gpu.Tests/Numerics/Pcg/PressureSolverContractTests.cs) |
| Motion and gauges | [PressureComponentsGpu](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/src/PolyCfd.Gpu/Projection/PressureComponentsGpu.cs); [component tests](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/test/PolyCfd.Gpu.Tests/Projection/PressureComponentsTests.cs), [geometric source tests](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/test/PolyCfd.Gpu.Tests/Projection/GeometricSourceProjectionTests.cs) |
| Viscosity and walls | [DiffusionGpu](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/src/PolyCfd.Gpu/Diffusion/DiffusionGpu.cs), [immersed coefficients](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/src/PolyCfd.Gpu/Diffusion/ImmersedWallCoefficientsGpu.cs); [independent residual tests](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/test/PolyCfd.Gpu.Tests/Diffusion/DiffusionResidualAccuracyTests.cs) |
| Geometry | [CutCellBuilderGpu](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/src/PolyCfd.Gpu/Geometry/CutCellBuilderGpu.cs), [DeviceCellGeometry](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/src/PolyCfd.Gpu/Core/DeviceCellGeometry.cs); [geometry contract tests](https://github.com/hankbeasley/polycfd/blob/b7f5b9ba6f52355d9b196b586e4a6c8719d8feea/test/PolyCfd.Gpu.Tests/Projection/GeometryContractTests.cs) |

The links identify review entry points, not a claim that these tests were run for
this page. Preserve the device ownership, selective capture, completed-frame and
stage-observer contracts in [runtime contracts](/docs/RUNTIME_CONTRACTS).