Repository navigation
Plan: finite-difference data, samples, reconstruction and staggered components (#321) - #513
berkgeveci wants to merge 1 commit into
Conversation
| | `(0, ½, ½)` | x-faces (MAC's `u`) | `nx × (ny-1) × (nz-1)` | | ||
| | `(½, 0, 0)` | x-edges (Yee's `Ex`) | `(nx-1) × ny × nz` | | ||
|
|
||
| These are PETSc `DMStag`'s locations. An axis offset by `½` has one sample |
There was a problem hiding this comment.
AMReX's IndexType (cell or node per axis) is the same offset, and its face-centred MultiFabs are where much of this data will come from. Worth naming beside DMStag, so a Catalyst AMReX adaptor can map IndexType and nGrow straight onto offset and ghosts.
| lay them out, so a native array is taken as it is (zero-copy for a contiguous | ||
| NumPy or device array). | ||
|
|
||
| **On a mapped grid** the offset is in index space: a sample's position is the |
There was a problem hiding this comment.
On a curvilinear grid, the position at a half index is itself a reconstruction of the geometry (trilinear in the cell, presumably). Please say which.
| average-preserving reconstruction of higher order (a conservative one) is a | ||
| later method, not this plan's. | ||
| - **`boundary`:** what a location gets where its stencil reaches past the valid | ||
| samples (D6). `"nearest"` (the default) uses the samples there are, as VTK's |
There was a problem hiding this comment.
What does "nearest" mean for "multilinear" at a point outside the centres' hull: clamp to the nearest sample, or extrapolate from the nearest cell? The guide's cell-centre example shows that this strip is where the choice is visible.
| ### D6. Ghost layers in the native array, and the valid region | ||
|
|
||
| A solver's array often includes its halo. `ghosts=g` (a number, or one per axis) | ||
| says the array holds `g` extra samples on each side of each axis; the valid |
There was a problem hiding this comment.
ghosts per axis and per side, (lo, hi). Some solvers pad only one side, or pad faces differently from cells.
| `Samples` too, `kind="point"`. Its stencils stay those of #415. It gains a | ||
| `boundary` argument for samples: | ||
|
|
||
| - `"one-sided"` (today's behaviour, and the default): the stencils narrow at the |
There was a problem hiding this comment.
A "periodic" rule. Periodic boxes are common in finite-difference output, and the stencil wraps the index with no halo.
| stored normal points down its axis. It is an implicit array over the native | ||
| buffers, not a copy. `divergence`, `perot` and `upwind_flux` then take MAC | ||
| velocities directly, and the divergence of a MAC field at the cell centres is | ||
| the solver's own compact stencil. (`kind="average"` face samples times the face |
There was a problem hiding this comment.
MAC solvers store point samples of normal velocity at face centres, and their compact divergence is sum(u A) / V with those point samples (the midpoint rule). So "point samples are not [fluxes]" contradicts "the solver's own compact stencil" on the line above. Since divergence takes fluxes, face_values needs to multiply by face area (an option, or a fluxes=True) for the MAC case to work as stated.
|
Separating samples, reconstruction and operators is right, and Samples with no implicit basis makes the choice visible without changing existing results. One inconsistency in D7 on MAC fluxes, and a few gaps. |
The plan for #321, finite-difference data, as
docs/design/plans/finite-difference-data.md. It turns the proposal of 2026-11-01 into decisions;finite_differences(#415) already did most of its operator stage.The core:
td.Samples(data, offset=..., kind=..., ghosts=...), values on a structured grid's lattice (each axis at 0 or ½ a cell: points, cell centres, faces, edges, PETSc DMStag's locations), point samples or averages, with no basis. A filter that needs a function between the values refuses it and names the remedy, so the reconstruction becomes an explicit choice (td.reconstruct), and the solver's difference operators stay distinct from differentiating a reconstruction (finite_differencesonSamples, with a declared boundary rule).Values,H1,Constantand today's results do not change.Decisions D1-D9, each with a recommendation; reply per decision. Of note:
Samples;_with_basisstays forValues, and the guide says what it chooses.td.collocate, with no composite type.td.face_valuesmaps MAC face components onto Tack's face numbering without a copy, sodivergence,perotandupwind_fluxtake them.The guide (step 1, docs only) follows in its own PR.
Docs only:
mkdocs build --strictis clean.This plan will be merged (accepted) after the 0.8 release.
🤖 Generated with Claude Code