Skip to content

Add polynomial-interpolation cut-cell stencils (E2); harden devcontainer build#27

Merged
pbrady merged 1 commit into
lanl:mainfrom
pbrady:poly-interp-stencils
Jun 16, 2026
Merged

Add polynomial-interpolation cut-cell stencils (E2); harden devcontainer build#27
pbrady merged 1 commit into
lanl:mainfrom
pbrady:poly-interp-stencils

Conversation

@pbrady

@pbrady pbrady commented Jun 16, 2026

Copy link
Copy Markdown
Member

Summary

Migrates the project's Mathematica polynomial-interpolation cut-cell derivation into the SymPy stencil framework (scripts/stencil_gen/), and hardens the devcontainer's Spack build.

Poly-interpolation stencils (the new capability)

Define interpolation polynomials f[i+y] = Σ_j γ_ij(y, ψ, params)·f[node_j] (TEMO-style); the derivative stencil then falls out as (1/h)·d/dy γ|_{y=0}. This yields one consistent free-parameter setfa feeds both interp_wall and nbs_floating; ia is interpolation-only; da is the Dirichlet derivative.

  • stencil_gen/interp.py (new): derive_interior_interp, derivative_from_interp (the d/dy|0 core), cut-cell wall rows (two-variant zero+blend+average), derive_floating_coeffs via the interp↔derivative duality, and a derived Dirichlet closure (poly recipe + one conservation solve). The transcribed dirichlet_coeffs_symbolic is retained as a cross-check oracle.
  • taylor_system.py: _interp_rhs / build_interp_system (eval-at-y functional).
  • printer.py, codegen.py: emit real interp_interior / interp_wall / query_interp. Additive and gated on None-default StencilGenSpec fields, so existing stencils emit unchanged. __main__.py: generate polyE2_1.
  • tools/eval_poly.py: parse a polyE2_1.cpp's runtime methods for numeric comparison.
  • Tests (tests/test_interp.py, tests/test_codegen_poly.py): symbolic golden values, interp↔derivative duality, polynomial exactness, value/derivative decoupling, derived-vs-oracle Dirichlet, and a capstone asserting the regenerated polyE2_1.cpp is numerically equivalent (≤1e-12, all four runtime methods) to the committed src/stencils/polyE2_1.cpp.
  • docs/poly_interp_design.md, _proto_interp.py: design spec + a runnable validation demo.

Pure-Python and additive — src/stencils/polyE2_1.cpp is unchanged (the generator + capstone prove the codegen stays compatible). Scope is E2 only for now.

Devcontainer

  • .devcontainer/Dockerfile: spack install --fail-fast. The default best-effort install skips failed packages and their dependents yet exits 0 — which could produce a dependency-less image that still looked successfully built. --fail-fast aborts on the first failure. Pairs with the SPACK_MIRROR_URL build-arg for reliable source fetches behind a TLS-intercepting proxy.

Validation

  • t-polyE2_1 passes in a real C++ build (verified both in the CI dependency image and a native arm64 devcontainer build).
  • The capstone test confirms the regenerated codegen output matches the committed C++ to 1e-12 across all four runtime methods.
  • The new SymPy suite passes; existing stencil_gen tests are unaffected (additive, gated behind None-default fields).

Follow-ups (not in this PR)

  • Generalize beyond E2 (the Dirichlet closure's conservation step is currently the E2 specialization).
  • Optionally regenerate src/stencils/polyE2_1.cpp from the pipeline (numerically equivalent output; left as-is to avoid a noisy CSE diff).

…ner build

Migrate the project's Mathematica polynomial-interpolation derivation into the
sympy stencil framework, and make the devcontainer's Spack build fail loudly
instead of silently shipping a deps-less image.

Poly-interp migration (scripts/stencil_gen/) -- the novel idea: define
interpolation polynomials f[i+y] = sum_j gamma[i,j](y,psi,params)*f[node_j]
(TEMO-style) so the derivative stencil falls out as (1/h)*d/dy gamma|_{y=0},
giving one consistent free-parameter set (fa feeds interp_wall + nbs_floating;
ia is interp-only; da is the Dirichlet derivative):
- stencil_gen/interp.py (new): derive_interior_interp, derivative_from_interp
  (the d/dy|0 core), cut-cell wall rows (2-variant zero+blend+average),
  derive_floating_coeffs via interp<->derivative duality, and a DERIVED
  Dirichlet closure (poly recipe + one conservation solve); the transcribed
  dirichlet_coeffs_symbolic is kept as a cross-check oracle.
- taylor_system.py: _interp_rhs / build_interp_system (eval-at-y functional).
- printer.py, codegen.py: emit real interp_interior / interp_wall / query_interp
  (additive, gated on None-default StencilGenSpec fields, so existing stencils
  are unchanged). __main__.py: `generate polyE2_1`.
- tools/eval_poly.py: parse a polyE2_1.cpp's runtime methods for numeric checks.
- tests/test_interp.py, tests/test_codegen_poly.py: symbolic golden, duality,
  exactness, decoupling, Dirichlet-derived-vs-oracle, and a capstone proving the
  regenerated output is numerically equivalent (<=1e-12) to the committed
  src/stencils/polyE2_1.cpp across all four runtime methods.
- docs/poly_interp_design.md, _proto_interp.py: design spec + validated demo.
Pure-Python and additive; src/stencils/polyE2_1.cpp is unchanged.  Validated:
t-polyE2_1 passes in a real build and the regenerated codegen matches it.

Devcontainer (.devcontainer/Dockerfile): spack install --fail-fast.  The default
best-effort install skips failed packages and their dependents yet exits 0,
which let a fetch failure produce a deps-less image that looked built.
--fail-fast aborts on the first failure.  Pairs with the SPACK_MIRROR_URL
build-arg for reliable source fetches behind a TLS-intercepting proxy.
@pbrady
pbrady merged commit 68f9d0b into lanl:main Jun 16, 2026
4 checks passed
@pbrady
pbrady deleted the poly-interp-stencils branch June 16, 2026 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant