Skip to content

CBF boundary_flux: _assemble_volume_reaction is wrong on inhomogeneous Dirichlet boundaries (2D and 3D) #407

Description

@lmoresi

Found by the adversarial review of PR #404 (2026-07-24) — pre-existing, dimension-independent, NOT introduced by that PR.

_assemble_volume_reaction (the residual-based reaction used by boundary_flux) is exact on g=0 Dirichlet boundaries but produces garbage when the boundary value is non-zero:

  • P1 tet box, unit conduction: Top (g=0) boundary reaction sums to −1.000000 (exact); Bottom (g=1) sums to −4.41 (P1) / −11.59 (P2) against a true flux of ±1.
  • 2D box, Bottom g=1: sumR = −27.27, recovered 'flux' ≈ −29.5 for a true value of 1.
  • Shell case: interior residual is O(1) even though the KSP converged to rnorm 1e-13 — the Dirichlet boundary VALUES are evidently not inserted into the residual evaluation state before DMPlexSNESComputeResidualFEM.

Existing regressions (test_1019 etc.) pass only because they measure homogeneous boundaries. Every published CBF heat-flux / Nusselt recipe that reads the flux on a non-zero-temperature boundary is affected.

Likely fix: scatter the constrained boundary values into the local state vector (boundary-FEM-correct scatter, the same class as the SNES-callback scatter fix in #? — see test_1016's driven-boundary machinery) before computing the residual-based reaction.

Underworld development team with AI support from Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions