Skip to content

Add MPI-complete direct scalar boundary-flux integrals - #709

Open
gthyagi wants to merge 1 commit into
underworldcode:developmentfrom
gthyagi:feature/scalar-boundary-flux-integral
Open

Add MPI-complete direct scalar boundary-flux integrals#709
gthyagi wants to merge 1 commit into
underworldcode:developmentfrom
gthyagi:feature/scalar-boundary-flux-integral

Conversation

@gthyagi

@gthyagi gthyagi commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Purpose

Add a collective scalar diagnostic:

total_flux = poisson.boundary_flux_integral("Top")

For integral quantities such as heat-flow/Nusselt diagnostics, recover the
integral directly from consistent nodal reactions rather than create a
pointwise flux field, recover its boundary mass, and integrate that field
again. The public solver method delegates to utilities.boundary_flux.

Mathematics and MPI

For an essential boundary whose trace basis forms a partition of unity,
summing its consistent nodal reactions gives the integrated CBF flux. Each
rank's volume assembly contains partial reactions, so all contributing
copies of a shared boundary point must participate exactly once.

The original mantle feature (6177be86) only selected points from locally
labelled facets. New tests exposed missing contributions when a rank shared
a boundary point but held no labelled boundary facet. This revision first
reduces boundary-membership flags to point owners and broadcasts them back
through the PETSc point SF, then reduces the local reaction sums. It does
not replicate global boundary coordinates or construct a flux MeshVariable.

Eight-rank exact-conduction case Original mantle integral Corrected integral Exact
Triangle P1, Bottom -2.187500 -2.500000 -2.500000
Tetrahedron P1, Bottom -2.389206 -2.500000 -2.500000
Triangle P2, Bottom -2.395833 -2.500000 -2.500000
Tetrahedron P2, Bottom -2.500000 -2.500000 -2.500000

All corrected Top integrals are +2.5. Assertions use absolute tolerance
1e-8, unchanged after the MPI fix. The existing nonuniform smooth-flux
serial/parallel reference is retained as an additional check.

Contract and Limitations

  • Call on all ranks after solving a continuous scalar problem, on an
    essential boundary. Vector fields are rejected before reaction assembly.
  • Return the raw CBF residual sign, matching boundary_flux().
  • No mean subtraction, area normalization, or Nusselt scaling. Users divide
    by the relevant area and reference conductive flux when required.
  • At intersections of driven walls, shared nodal reactions mix adjacent
    contributions; this is not a facet-separated integral at those corners.
  • This feature does not change existing pointwise boundary-flux recovery.

Validation

Clean branch built from development at 87091138 in an isolated install
using the existing Pixi dependencies; no other mantle changes are present.

Suite Result Elapsed
Full scalar boundary-flux file plus new integral tests, serial 20 passed 18.37 s
Existing parallel boundary-flux file plus new integral tests, 8 ranks 9 passed per rank 5.38 s

New exact tests cover P1/P2 triangles/tetrahedra, signed conservation,
unchanged mesh-variable registration, unknown boundaries and vector
rejection. No long coupled convection run is used as a correctness test.

@lmoresi please review the direct-reaction integral contract, especially the
point-SF membership propagation and the documented shared-corner limitation.

…ions

Expose boundary_flux_integral() as a collective raw scalar CBF reaction sum. Propagate boundary membership across the PETSc point SF before summing, so partial nodal reactions are retained on ranks without a labelled local boundary facet. Avoid pointwise recovery and temporary flux fields.

Document sign, normalization, essential-boundary and corner constraints. Include exact signed P1/P2 triangle/tetrahedron tests and existing smooth-flux references. The clean upstream-based build passes 20 serial tests and nine tests on eight MPI ranks. No unrelated mantle solver changes are included.
@gthyagi
gthyagi requested a review from lmoresi as a code owner September 9, 2026 01:33
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