Skip to content

Add opt-in annulus pressure, wall and traction recovery - #857

Open
gthyagi wants to merge 11 commits into
underworldcode:developmentfrom
gthyagi:feature/cylindrical-geometry-correction
Open

gthyagi wants to merge 11 commits into
underworldcode:developmentfrom
gthyagi:feature/cylindrical-geometry-correction

Conversation

@gthyagi

@gthyagi gthyagi commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Straight-sided annulus meshes approximate circular density interfaces and walls. These opt-in Stokes methods separate pressure-jump extraction, numerical circular-wall conditions and boundary-traction recovery, so benchmark drivers can call solver-owned algorithms and retain the original FE fields.

The supported scope is a nondimensional, origin-centred, isoviscous 2-D annulus with affine triangles, continuous P2 velocity/P1 regular pressure, and the pressure nullspace enabled. Both rotated strong free slip and fully prescribed zero-slip walls are covered. Existing defaults are unchanged.

Changes

  • Extract the prescribed circular pressure jump as physical pressure p=q+p_J, with the corresponding regular force and free-slip outer-chord natural datum.
  • Transfer free-slip or full-vector zero-slip conditions to polygonal walls using numerical one-sided Taylor data. Record the iteration history and flux compatibility; four updates are a benchmark schedule, not a universal convergence guarantee.
  • Retain circular CBF and separate weighted spatial reconstructions. The zero-slip method recovers full Cartesian reactions before a rotating normal/tangent trace solve, without removing the pressure mean.
  • Preserve transferred means/resultants while explicitly changing fine-scale CBF moments. A boundary pressure estimate -sigma_nn remains separate from the solved FE pressure.
  • Repair cached-pressure gauge consistency and guard null PETSc index-set wrappers on empty wall ranks.

Docstrings and the advanced guide distinguish the published pressure-extraction, boundary-correction and CBF principles from these adaptations. No inherited stability theorem, universal superconvergence, spherical support or unrestricted short-wave accuracy is claimed.

Validation

The narrow review branch at 1e2d0a5e96a72c8628d912f4a06d817838836308 was rebuilt into a fresh Mac Linux ARM64 installation against the pinned PETSc 3.25.4 int32 image. Package/native origins and parallel HDF5 pass. Native contracts pass 64 tests plus one MPI-only skip in serial/on each MPI2 rank, and 65 tests on every MPI4 rank. The six private numerical modules have identical executable ASTs to consolidation 9b9422a8; one file differs only by a trailing blank line. These gates cover exact moments, constant pressure, affine stress and source-pressure lifts, gauges, source immutability and actual empty boundary owners.

The separate consolidation runtime passes 80 native tests plus one MPI-only skip in serial/MPI2, 81 on every Mac MPI4/Gadi MPI16 rank, and 327 annulus components with assess disabled. Gadi build 182213891.gadi-pbs exits zero. The integration campaign has completed 18 spatial-recovery models and eight zero-slip refinement/backward controls; the twelve-state native traction audit and working-report update are complete. Full-circle normal/shear errors improve at both walls while adverse direct FE-pressure and small harmonic changes remain explicit. Focused case3/case4 serial versus MPI16 replay fields agree within 5.6e-16. The final current annulus component suite passes 352 tests; this is separate from the original 327-test build snapshot. The debugging record and source-pinned evidence retain adverse FE-pressure results and the analytical-wall cancellation diagnosis. The boundary-accuracy report includes before/after figures and the measured recovery limits. Integration-branch evidence does not replace the narrow-branch gates above.

Review scope

The FE-valued datum collective-ordering prerequisite also proposed in #855 remains included with its regressions. Unrelated submesh ownership and potential-evaluation changes used by the integration benchmark are excluded from this PR.

Boundary traces are replicated and small SciPy sparse line systems are solved on each rank; scaling beyond the tested annulus is not claimed. The reconstruction has a measured bandwidth limitation. The analytical-wall oracle diagnoses remaining FE-pressure error and is never used by the numerical recovery algorithm.

The retained gravity comparisons, source budgets and buffer studies are in the separate gravity-comparison report. The split changes no numerical evidence or solver validation.

Underworld development team with AI support from Claude Code

Review follow-up (29 October 2026)

  • Fix collective evaluation of prescribed rotated wall data #855 owns the generic rotated-datum fix and must merge first. This branch now contains its actual commit history (1d2297b8), resolving the add/add conflict once in merge bf5e33bc; its rotated helper and regression file match Fix collective evaluation of prescribed rotated wall data #855 exactly. After Fix collective evaluation of prescribed rotated wall data #855 lands, this shared change is no longer a separate delta against development.
  • Kept 1089 for geometry; renamed the four other cylindrical test files to 1901-1904 without changing their contents. Updated CI globs; all 359 test files remain reachable and shell syntax checks pass.
  • Existing solver defaults and numerical settings remain unchanged by this follow-up.
  • The maintainer's scope caveat remains: the annulus algorithms and recovery mathematics require their own mathematical review. These structural fixes do not claim that review has occurred. Keep this PR in draft pending that review.

Underworld development team with AI support from Claude Code

Schedule FE-valued normal data in globally registered boundary order, including empty (0,dim) coordinate batches on ranks without constrained nodes. Local node/spec grouping could enter mesh local-vector collectives in different orders and hang before Stokes iteration. Preserve boundary attribution and SVD signs for each owned datum row.

Validation: two focused annulus component checks pass serial and on both MPI2 ranks, covering ranks with missing local boundary groups and FE evaluation of empty batches. No native or mathematical discretization change. Next: validate a fresh Gadi int32 installation on MPI16 and rerun the case2 h32 reproducer before primary-workflow acceptance.
Expose solver-owned pressure extraction, numerical Taylor wall updates, circular CBF topography recovery and modal trace integration for affine isoviscous P2/continuous-P1 annuli. Keep five public methods backed by private lazy helpers, explicit configuration and numerical failure histories. Document technical sources and the required projected pressure gauge.

Include the registered-boundary collective datum scheduling prerequisite from open PR underworldcode#855; no analytical, geoid, Poisson, spherical or child-submesh changes are included. Add independent mathematical regressions and one explicit CI entry.

Validation: executable kernel/method/test ASTs match d2c0527 tested on the integration branch (14 serial UW3, 189 annulus components and 14 tests on 16 MPI ranks). Four standalone h32 migrations reproduce calibrated fields and signed coefficients within 1e-14. Coverage and style checks pass. A matching upstream-base native installation and focused serial/MPI gates are next before opening the review PR.

Underworld development team with AI support from Claude Code
Constrain the public examples and helper docstrings to nondimensional inputs; mark prerequisite datum tests level_1/tier_b. No numerical implementation or test-body changes.

Validation: Gadi182128805 built bf81ed9 against the existing int32 image, verified native/Python origins and passed all 12 tests serially and on every one of 16 MPI ranks. Executable ASTs remain identical after these documentation/selection changes; coverage355, style and diff gates pass. No native/model reruns are affected. Next: narrow upstream review, retaining separate integration-campaign provenance.

Underworld development team with AI support from Claude Code
…stency

Recover a separate circular P2 trace using endpoint-weighted local polynomial
convolution, exact breakpoint-resolved circular projection, and constraints
on the physical mean and Cartesian radial resultant. Keep the original CBF
trace and cache unchanged; replicate only boundary data. Explicit support and
degree control accuracy; do not claim spline/DG SIAC superconvergence.

Align transfer pressure with the cached reaction gauge after constant pressure
calibration. Distributed pressure-subvector differences must be uniform;
nonuniform stale pressure changes are rejected. Constant pressure regression
proves the original defect before the fix; its actual benchmark effect is
small compared with the combined FE pressure/velocity moment error.

Independent pure-helper/adapter contracts pass serially and on two ranks:
polynomial moments, closed P6 kernel, direct nested integration, conservation,
rotation/scale/permutation, graded meshes, empty boundary ranks and duplicated
ghost values. Native wrapper and fresh-install gates are pending the batched
container build; no model results from this commit are yet accepted.
Next: build immutable versioned Mac/Gadi installs, run full serial/MPI gates
and matched annulus refinement before production acceptance.

Underworld development team with AI support from Claude Code

(cherry picked from commit a882c34)
Extend one-sided affine P2 velocity polynomials to true circles and register distinct essential vector fields once. Enforce one joint polygon flux constraint with the minimum-L2 normal midpoint-bubble correction, retaining vertex and tangential data. Replicate only owned boundary-cell traces, including empty-rank/ghost-safe label extraction; report physical-circle residuals and actual standard-solver verdicts at every fixed-point step.

Cite the exact Taylor-Hood trial/test precedent in Ruas 2019 alongside shifted-boundary foundations, while documenting symmetric-stress and flux-projection differences. Clarify that pressure-lift natural data are omitted where full velocity test traces vanish. Seventeen independent polynomial, flux, geometry and adapter tests pass serially and on each MPI2 rank as development helper checks. Fresh compiled/native gates and model acceptance remain pending; no all-case accuracy claim yet. Next: versioned Mac/Gadi builds and separate smooth-wall/delta-pressure pilots.

Underworld development team with AI support from Claude Code
The first16-rank zero-slip installation gate exposed a real null-handle dereference in labelled edge extraction: PETSc may return a false IS wrapper rather than PythonNone for an absent local stratum. Use the established PETSc truthiness guard before indices/destroy. Existing stratum consumers already use this contract; no generic boundary-flux behavior or numerical wall data changes.

Add real-null, safe false-sentinel and valid zero-length index-set regressions. The exact prior commit fails the safe sentinel at the same indices access; corrected20-test helper suite passes serially and on every MPI2/MPI16 rank through explicit development overlays. Preserve failed Gadi build182210837 with no validated-install marker and no model submissions. Next: fresh versioned single-revision builds and complete native gates before MPI model use.

Underworld development team with AI support from Claude Code
Transfer freshly assembled Cartesian regular-pressure reactions using physical-circle and polygon stress moments, then solve a rotating normal/tangent P2 trace system. Retain circular and weighted-reconstructed fields separately, without wall pressure shifts. Add exact constant pressure, affine stress/lift, conservation, gauge, and real empty-owner contracts. Python helper gates pass serial/MPI2/MPI4 and saved-state prototype parity; fresh native wrapper builds and full refinement acceptance remain pending.

Underworld development team with AI support from Claude Code
@gthyagi gthyagi changed the title Add opt-in cylindrical source, wall and reaction corrections Add opt-in annulus pressure, wall and traction recovery Oct 25, 2026
Widen the cylindrical CI batch from the single geometry file to test_1089_cylindrical_*.py, including Dirichlet transfer, full traction, pressure gauge and reconstruction contracts. The existing coverage guard reproduces the original four-file omission and passes after the change: all 359 root test files are reachable, with no new deferrals.

Validation: bash -n scripts/test.sh; coverage guard; diff check; complete selected five-file batch against the verified narrow-branch install with CI's not-tier_c selection: 62 passed, 1 expected skip requiring at least four MPI ranks. UW3 implementation and test bodies are unchanged. Next: the automatic GitHub CI rerun on PR 857.

Underworld development team with AI support from Claude Code
@lmoresi

lmoresi commented Oct 28, 2026

Copy link
Copy Markdown
Member

Adversarial review

Scope of this review. We reviewed structure, CI reach, the overlap with
#855, and whether the opt-in claim holds. We did not review the ~1,400 lines
of new _cylindrical_* algorithm or the recovery mathematics; that half wants a
reviewer with the annulus benchmark in hand, and we say so rather than imply
coverage we do not have.

1. This PR contains #855 in full. src/underworld3/utilities/rotated_bc.py
is blob 4fd412a9 on both branches — byte-identical, not merely overlapping.
Both PRs also add tests/parallel/test_1084_rotated_datum_collectives.py, so
whichever merges second hits an add/add conflict. The copy here is #855's plus
the level_1 / tier_b markers, so it is the one to keep. One of the two PRs
should own the datum fix: either drop it from here and let #855 land first, or
land this and close #855.

2. Four test files share the number 1089. test_1089_cylindrical_dirichlet,
_dirichlet_traction, _geometry, _pressure_gauge, _reconstruction. The
convention is one number per file, and test_1089 now identifies nothing. CI
reach itself is fine: the added glob tests/test_1089_cylindrical_*.py covers
all five, and tests/parallel/test_*.py already covers test_1084.

3. The opt-in claim checks out. The .pyx change is 421 insertions and
zero deletions, so no existing line of the solver path moves. That
substantiates "existing defaults are unchanged" in a way the description alone
does not.

4. Markers and documentation are in order. All five new files carry
level_1 and tier_b, which is right for proven tests. The capability guide
(guides/boundary-condition-rulings.md) is updated in the same change, which is
what the Charter asks when a boundary mechanism grows.

5. No test asserts the four-update schedule. The description is careful that
"four updates are a benchmark schedule, not a universal convergence guarantee",
and we checked that no test pins a magic iteration count against it. That is the
right call; a test that asserted 4 would break elsewhere and undiagnosably.

The open question is finding 1 — the duplication with #855 has to be resolved
before either can merge — and the algorithmic review this one still needs.

State boundary registration order explicitly, mark the MPI regressions, and correct the datum-node payload comment.

Underworld development team with AI support from Claude Code
Retain the reviewed generic fix and regression tests from its owning PR, preventing duplicate add/add conflicts after that prerequisite merges.

Underworld development team with AI support from Claude Code
Preserve all test bodies and CI reach while leaving 1089 for the geometry tests.

Underworld development team with AI support from Claude Code
@gthyagi

gthyagi commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @lmoresi. The structural findings are addressed:

The numerical algorithms and existing solver defaults were not changed by this follow-up. Your separate mathematical-review requirement remains open; this PR stays in draft, and I am not claiming that the structural checks validate the recovery mathematics.

@gthyagi
gthyagi marked this pull request as ready for review October 29, 2026 12:47
@gthyagi
gthyagi requested a review from lmoresi as a code owner October 29, 2026 12:47
@lmoresi

lmoresi commented Nov 6, 2026

Copy link
Copy Markdown
Member

Adversarial review of #857

Verdict: not ready. The numerics held against analytic cases on both walls, serial through np 8. Three things block: a merge that silently fails a passing development test, a conflict with a shadowing trap, and tests that cannot fail on most of the new behaviour. Reviewed at 23c11aa against development eddab70.

Merge state

Merge base 0dfb734: 11 PR commits, development 376 ahead. Real conflicts in 2 files, one hunk each. rotated_bc.py, boundary-condition-rulings.md and the rest merge clean.

  • petsc_generic_snes_solvers.pyx: a 760-line hunk, development side empty. 421 lines are the PR's 9 new methods; the other 339 are 7 old methods development moved to SolverBaseClass, so only the 421 stay.
  • scripts/test.sh: real but small. Development replaced "${PYTEST[@]}" with batch N, and the PR's line sits inside that hunk.

Findings

High

  1. The clean merge of rotated_bc.py silently drops the sheet datum. _datum_batches filters boundary == name, and development appends (gp[2], q_plus, sheet_dspec, ...), so no sheet item matches. test_1092::test_fault_reaction_is_the_membrane_resultant fails merged (error 0.0474, limit 9.6e-4) and passes on development. This is the same code as Fix collective evaluation of prescribed rotated wall data #855 (identical rotated_bc.py diff). Tagging that append with SHEET_TANGENCY passes the three non-Maxwell 1092 tests.
  2. Taking the HEAD side of the pyx hunk keeps stale copies. boundary_normal_traction then appears at merged lines 5830 and 9589, and the Stokes-class copies would shadow development's SolverBaseClass versions with no conflict marker left.
  3. The tests cannot fail on the core (Charter section 8). No new test runs a Stokes solve; the 63 tests take about 15 s. Nothing calls cylindrical_pressure_lifting, add_cylindrical_wall_transfer, recover_cylindrical_topography or cylindrical_boundary_coefficient, or constructs _NumericalWall. 14 of 18 mutants survived the serial suite: free-slip wall wall_datum_sign, wall_natural_sign, wall_no_update_torque; lift lift_natural_sign, lift_jump_sign, lift_force doubled; recovery topo_sign, coeff_no_jacobian, traction_shear_sign; zero-slip loop zs_no_flux_projection, zs_no_update, zs_no_write; rotated datum rot_only_with_nodes (also survives test_1084 at np 3), rot_name_drop. Killed: zs_datum_sign, traction_jump_sign, traction_transfer_sign, recon_no_moments.

Medium
4. CI reach after the merge: test_190[1-4] matches no development batch glob, so taking development's side of the hunk drops them silently. test_1089 is reached by batch 3 tests/test_108*py.
5. CI reach now: test_1902::test_real_three_facet_wall_recovery_with_ranks_owning_no_boundary_cells needs np >= 4 but lives in tests/, which CI runs serially, so it always skips there. It passes when run by hand at np 4.
6. _NumericalWall lacks the guards _ZeroSlipWall has. boundary="Upper", radius=1.22 is accepted, and the second solve changes velocity by 1.7e-16, a silent no-op. An off-wall radius is accepted with 0 edges, sign=-1 on the outer wall is accepted, and viscosity=1 with a constitutive viscosity of 3 is accepted, as is a spatially variable viscosity. The mismatch had no visible effect at h=1/16.
7. Fixed MeshVariable names alias data between solvers and lifts (CircleRegularForce, ZeroSlipShift<b>, NormalShift<b>), with only a "Skipping" print. A second lift changed the first handle's force max from 4.77 to 9.54; re-solving Stokes 1 after Stokes 2's updates moved its velocity by 3.09e-3.
8. "A run records what it did": solve_cylindrical_wall_updates in model.step records ['solve','solve','solve']. Wall updates and projections leave no event, yet the solve event says adjoint: supported: True, so the run claims invertibility it does not have.
9. cylindrical_pressure_lifting accepts an unfitted sheet on a plain Annulus, reporting internal_chord_count=0 without refusing.

Low
10. On the smooth case the recover_cylindrical_topography transfer has rms 9-22% worse than raw boundary_normal_traction at every h and wall (h=1/32 Lower 5.91e-4 against 4.90e-4). On the sheet it is 23-51% better. The gains come from wall updates and reconstruction; the guide should say so.
11. Two "sigma_nn" signs: normal_field is +n.sigma.n, while topography follows boundary_normal_traction, which returns -n.sigma.n. Neither is documented, and feeding normal_field into h=-sigma_nn/(drho g) flips h.
12. datum_change_maximum compares raw data to the projected previous data, so it floors at the projection coefficient (3.489e-7 against 3.464e-7, while dv is 1.1e-8). It cannot show convergence.
13. A missing nullspace on the free-slip path gives AttributeError after a full solve. Zero-slip refuses up front with ValueError.
14. Charter section 5: the P2 line shape appears 7 times, edge-node edges.mean lines 9 times, coo_matrix line masses 5 times; the two wall constructors are near copies; boundary_flux.py already has _line_mass_1d/_desmear.
15. np.testing.assert_* is runtime checking at 9 library sites. Those at _cylindrical_wall.py:317,336 and the ValueError in _NumericalWall.__init__ are rank-local before collectives, the #961 class. We did not observe a hang.
16. Docs: the guide is missing from docs/advanced/index.md; docs/api/solvers.md and boundary-condition-rulings.md omit the zero-slip methods, and solvers.md omits reconstruct_cylindrical_trace; "case3", "DOI10.1016", "sections2/4"; "verified by benchmark evidence" points outside this repository.

Attacks that failed

  • Opt-in: pyx has 421 insertions and 0 deletions, and no _cylindrical module loads on import underworld3. Annulus FE datum energy matches at np 3, development and merged: 1.5340159191e-02.
  • The Fix collective evaluation of prescribed rotated wall data #855 hang: a box probe at np 3 hangs on development (exit 124), completes merged (3.1234315280e-03).
  • Zero-slip analytic, manufactured, updates=4: reconstructed Upper sigma_nn rms 1.80e-4, 4.25e-5, 1.08e-5 at h=1/8, 1/16, 1/32, rate 2. At h=1/32 Lower sigma_rtheta rms drops from 6.1e-2 (updates=0) to 3.07e-3, then 5.9e-5 reconstructed.
  • Free-slip analytic: at h=1/32 Lower, boundary_normal_traction rms drops from 1.32e-2 to 4.90e-4 with updates; cosine coefficient 0.366000 against exact 0.366.
  • Sheet analytic, h=1/16: lift velocity max error 1.59e-5 against 4.19e-3 for a natural load on the fitted boundary; Upper coefficient 0.773923 against 0.773929.
  • Rank consistency: free-slip and zero-slip printed digits match at np 1, 3, 8. No rank owned zero wall cells in these runs (min 14); only the np 4 test exercises that.
  • Own tests: 65 passed, 1 skipped at np 1, 2, 3; 66 passed on each rank at np 4.
  • Gauge: a +0.37 pressure shift changes topography by 1.1e-15; a nonuniform change is refused.
  • Radius-only selector: selected edges equal labelled facets on 9 meshes, both walls.
  • Other: quadrature_points=2 aborts at np 1 and 8, no hang; penalty=100 fails loudly at iteration 0; the style gate is clean; rotated parallel 1066 and 1140 give 11 passed, 3 skipped merged at np 3.

Issues

This PR closes no issue. #935, #936, #633: already fixed, labelled. #883, #884, #887, #787, #320, #939, #941, #637, #685: still live, untouched or not reached. #961: still live, and finding 15 adds sites of the same class.

Merge conditions

  • Fix the _datum_batches sheet drop in Fix collective evaluation of prescribed rotated wall data #855 and land that first. Add a test that drives build_rotation, and rerun test_1092 merged.
  • Rebase; keep only the 9 new methods in the pyx hunk and confirm boundary_normal_traction is defined once.
  • Put test_190[1-4] in a batch line, and move the empty-owner test to tests/parallel/ or a run that reaches np 4.
  • Add tier B end-to-end tests: one analytic solve per wall type, plus the lift and topography sign, that kill the surviving mutants. Our manufactured probes run in about a minute at h=1/8 under load.
  • Give _NumericalWall the label, radius and viscosity checks and a collective refusal; refuse an unfitted lift.
  • Make field names unique per solver and lift, or refuse a reuse.
  • Record wall updates in the transcript with an adjoint verdict.
  • State the two sigma_nn signs in the guide and link the guide from the index.

Could not test

np above 8, including the PR's Gadi np 16; a compiled merge (merged runs used development's build with the PR modules overlaid and the 9 methods attached at runtime); test_1092's Maxwell test, unfinished in 1500 s under load; stale wall handles after mesh deformation; accuracy under a nonzero penalty or variable viscosity; the external benchmark reports, not audited.

Underworld development team with AI support from Claude Code

This branch has not been deployed

No deployments
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.

2 participants