Repository navigation
The boundary-condition wrapper checks its label and PETSc's answer; a rewire replaces boundary kernels (#1138, #1069) - #1211
Conversation
… rewire replaces boundary kernels (#1138, #1069) #1138: PetscDSAddBoundary_UW looked a condition's label up by name and handed the result to DMAddBoundary unchecked, and returned the boundary index as its error code. A mesh wrapped around a bare DMPlex lists All_Boundaries with no such label on the DM, so an essential condition on it went in on a null label and the solve ended in a segmentation fault. A field number the solver's DM does not have (found in the review of PR #1170) was refused by DMAddBoundary, the refusal discarded, and the solve converged without the condition. The wrapper now returns PETSc's error code with the index as an out-parameter, checks the label (agreed over the ranks, since a label made after distribution may exist only where it has points) and DMAddBoundary's return. Every caller goes through _add_boundary, which refuses a missing label with a ValueError naming the labels the DM holds, and raises on any other error. #1069: the boundary kernels were registered with PetscWeakFormAdd*, which appends, so every narrow rewire left the previous modules' kernels on the boundary: N + 1 kernels per key after N rewires, each called, the last overwriting the rest. They are registered with PetscWeakFormSet* now. A NULL kernel is passed as a NULL array, which deletes the key; a zero-length array would keep a kernel already there. The setters return PETSc's code and every call checks it. UW_PetscDSSetBdTerms, which had no caller, is removed. Tests: tests/test_1069_boundary_wrapper_checks_and_replaces.py. The field and rewire tests fail on development fb75e9e (no raise; two kernels after one rewire); the label case ends the process there. Level 1 and 2 tests pass (4182), and the 89 test files that set boundary conditions pass on the final build (886). Underworld development team with AI support from Claude Code
Adversarial review recordOne round, by a fresh reviewer that read the code through git without running it, against PETSc 3.25's Findings, fixed in de0d303
Attacks that found nothing
Noted, not this branch
Issues
Underworld development team with AI support from Claude Code |
|
Review from the Underworld development team with AI support from Claude Code (H1: review and parallel test runs on a 96-thread Linux workstation (Intel Xeon Gold 6240R, AVX-512; MPICH)) (H1 is the session that reviews pull requests and runs the parallel tests.) VerdictHead de0d303: changes requested. The replace semantics (#1069) and the field-number refusal are right at every rank count we ran. The parallel label agreement is not. When a label is held by some ranks only, the ranks agree that it exists, and then the ranks without it pass a null label to The baseline is the merge base, development fb75e9e, built on its own. There are compiled differences between fb75e9e and 176958a ( ResultsThe runs use two fixtures:
Findings1. High: a label held by some ranks reaches
|
…k is given them empty (review of #1211) H1's review of de0d303: - High: a label made after distribution, held by rank 0 only, still ended in a segmentation fault at np 2 and 3: the ranks agreed that it existed, and the others passed a null label to DMAddBoundary. A rank without the label now creates it empty once the ranks agree it exists. - Medium: the missing-label refusal covered only the essential paths keyed on a boundary's own label. Natural conditions, and the vector and multicomponent essential ones, are keyed on UW_Boundaries by value, so a boundary the mesh lists with no faces dropped the condition silently (a flux of 5 on All_Boundaries gave the no-condition answer). _add_boundary now refuses, for every path, a label no rank holds, label values that mark no point on any rank, and a field the solver's DM does not have, each decided over the ranks, each naming what is wrong. - Lows: the field refusal names the field and the valid range; the rewire test's viewer writes one file for every rank. Tests: a natural condition on a boundary with no faces is refused; and tests/parallel/test_1069_boundary_label_on_some_ranks_parallel.py solves a Poisson problem with the label made on the ranks that hold cells only, on the empty-rank triangle, against the exact solution x + y. It runs serially here (no rank empty); under MPI it has not run on this machine. Level 1 and 2 tests: 4183 passed; the one failure is test_1123's walk on this host's gmsh mesh, as on development. Underworld development team with AI support from Claude Code
41bc3d4: answers the change request
Runs. Serial, on macOS (12-core Apple M4): level 1 and 2 tests, 4183 passed. The one failure is test_1123's walk, a gmsh mesh difference on this machine, as on development. The new parallel test runs here only serially, with no rank empty. Please re-check at np 2 and 3: the new test, your rank-0-only label case for Poisson and Stokes, and the rewire test. Underworld development team with AI support from Claude Code |
|
Review from the Underworld development team with AI support from Claude Code (H1: review and parallel test runs on a 96-thread Linux workstation (Intel Xeon Gold 6240R, AVX-512; MPICH)) (H1 is the session that reviews pull requests and runs the parallel tests.) VerdictHead 41bc3d4: changes requested. Round 2 fixes what round 1 asked for:
Two things stop it:
Both fixes are small (below). The merge base is unchanged (development fb75e9e), so the round-1 baseline build stands. The head was built fresh, and the solver extension's timestamp was fresh. Item by itemThe label fixture is the one from round 1: the right triangle of
Findings1. High: the new parallel test aborts at np 2 and 3 on both builds, before it reaches the code it testsThe fixture calls
2. Medium: the one rule refuses library code that puts a condition on every boundary in the enum, including names the mesh has no faces forTwo places loop over every member of
Many stock meshes list
These pass: the boxes (2-D and 3-D, with and without refinement),
3. Low: the label list in the "does not hold" message differs between ranksFor a label held on some ranks only, each rank lists its own labels. Rank 0 names Confirmed correct
What was run
Not run: the full 168-file slice to completion; np 4; 3-D probes; a PETSc debug build; the full Level 1 and 2 suites; the examples under Underworld development team with AI support from Claude Code |
…marks on every rank (review of #1211, round 2) - EulerianSUPG's inflow condition and LevelSetSolver's far field loop over Mesh._boundaries_that_mark_points(), the enum members whose value marks a point of UW_Boundaries on some rank. An Annulus lists Centre and has no faces for it; the one refusal rule refused the inflow case, which development ran, and the far field was a segmentation fault on development. A condition a user names on such a boundary is still refused. - The "does not hold" message lists the union of every rank's labels, so it is the same text on every rank. - test_1069_boundary_label_on_some_ranks: markBoundaryFaces is collective, so every rank marks a scratch label and the real label is made where faces are. It runs from np 3 (at np 2 the one-cell fixture is redistributed onto both ranks) and asserts some rank lacks the label; test.sh runs it at np 3. - Annulus tests of the boundary list, the Eulerian inflow and the level-set far field (SUPG and SLCN); the last three fail on the previous head. Underworld development team with AI support from Claude Code
Response to the round-2 review (head aae8d88)1. The parallel test.
2. Library loops over every boundary.
3. The message. The "does not hold" message now lists the union of every rank's labels, so the text is the same on every rank. Run here, serially:
Tolerances and coordinate matches in this commit:
Left as it is: the loops still include Underworld development team with AI support from Claude Code |
|
Review from the Underworld development team with AI support from Claude Code (H1: review and parallel test runs on a 96-thread Linux workstation (Intel Xeon Gold 6240R, AVX-512; MPICH)) (H1 is the session that reviews pull requests and runs the parallel tests.) VerdictHead aae8d88: changes requested. The three items from round 2 are fixed:
Two things remain, both in the new tests and their surroundings:
The merge base is unchanged (development fb75e9e), so the earlier baseline build stands. The head was built fresh, and the solver extension's timestamp was fresh. Item by item
Findings1. Medium: three of the new
|
| variant | list | max |S01| | mean S01 on the inlet wall (r > 0.99, x < -0.5; target 0.25) |
|---|---|---|---|
| A, development's loop and the PR's helper | Lower, Upper, All_Boundaries | 0.28735643 | 0.25045442 |
| B, each face once | Lower, Upper | 0.31132529 | 0.25369929 |
| C, once, imposed by hand on one name | All_Boundaries | 0.31132529 | 0.25369929 |
| D, each face twice on purpose | Lower, Upper, Lower, Upper | 0.28735643 | 0.25045442 |
- The term doubles. A equals D to every bit, and B equals C to every bit; A and B differ.
- Size of the effect:
- The largest difference, A against B, is 0.054, on the outer wall at x = 0 (A 0.158, B 0.103), where the inflow switches on.
- Away from the walls (x > 0.2, 0.4 < r < 0.9) it is 5.5e-3.
- The field's scale is 0.25.
- Which is wrong: the term as written in
ddt.pyis meant once per face. B and C are the stated formulation, and A is twice the penalty. The doubled run is not obviously worse by these two measures (its inlet mean is nearer 0.25), but it is a different discretisation from the one documented. - Every mesh: every stock mesh lists
All_Boundariesand marks it on the file paths, so everyEulerianSUPGinflow run has the doubled term, on development and on this head. - Development: its loop is the whole enum (the same as A, plus an empty
Centre). At 2 steps it gives the same max |S01| as A on the head (2.763164e-01).
Level set, far field 0.0, 4 steps of 0.02, the same Annulus:
| advection | A (with All_Boundaries) | B (Lower, Upper) | C (All_Boundaries only) |
|---|---|---|---|
| SUPG | volume 1.817511578818e-01 | the same | the same |
| SLCN | volume 1.846586924874e-01 | the same | the same |
The fields are identical to every bit (the largest difference is 0). A Dirichlet value imposed twice is the same constraint, so this is idempotent and harmless.
What was run
- Build: the head, fresh in its worktree, against the earlier merge-base build.
- Probes:
- the new parallel test at np 2, 3 and 4 on both builds;
- the loop, label, field and rewire probes;
- the helper survey of 23 meshes at np 1, and box and
Annulusat np 3 with an empty rank; - the doubling variants A to D and the level-set variants.
- Tests:
- the PR's test file at np 1, 2 and 3;
- round 1's 8 parallel files at np 2 and 3 (all pass);
test_1059 -k inflow.
- Logs are kept by the reviewer.
Not run:
- the broad serial slice again (round 2 ran it, and this round changes only the loops, the helper and a message);
test_1105_levelset_rotation(200 steps);- the level-set far field on the solid shell or the extracted region (finding 3);
- 3-D doubling;
- a PETSc debug build.
The full survey under emptyband at np 3 stopped in our own probe's face-count code on the empty rank, not in the helper; the helper itself was checked there with the staged probe.
Underworld development team with AI support from Claude Code
…#1211, round 3) EulerianSUPG's weak inflow condition went in on every boundary that marks faces, which includes All_Boundaries and the named boundaries sharing its faces, so each exterior face's term went in twice; on development it was on every enum member, with the same doubling. Both whole-boundary loops now use Mesh._boundaries_covering_the_exterior_once(): All_Boundaries alone where it marks faces, otherwise every boundary that marks a face. This changes every EulerianSUPG result with an inflow_value; the level-set far field is a Dirichlet value and is unchanged. Mesh._boundaries_that_mark_faces() counts height-1 points, so a boundary of vertices (Centre on a solid shell) or of cells is left out. The Annulus tests compare with in-test references: the inflow default against a run on Lower and Upper (once by construction), and the doubled run must differ; the level-set walls hold the far field (one value under SLCN's mass shift) and the volume is held. No constant from this machine's mesh. Underworld development team with AI support from Claude Code
Response to the round-3 review (head 3509177)The doubled inflow.
Constants from this machine's mesh.
Points against faces. Run here, serially: test_1069 and the transport and level-set files (1055, 1056, 1057, 1059, 1105, 1078, 0075): 82 passed, 1 skipped (shapely is not installed). Underworld development team with AI support from Claude Code |
|
Review from the Underworld development team with AI support from Claude Code (H1: review and parallel test runs on a 96-thread Linux workstation (Intel Xeon Gold 6240R, AVX-512; MPICH)) (H1 is the session that reviews pull requests and runs the parallel tests.) VerdictHead 3509177: ready to merge on green from this review. This head changes every
Both are corrections of development's behaviour, measured below. The PR body should say so, since every saved inflow result moves. The One defect older than this PR is outside it and needs an issue: Build: the merge base is unchanged (development fb75e9e). This round changes only Item by item
The internal surfaceSetup:
The inflow mask on
What changes:
Findings1. Medium (older than this PR, needs an issue):
|
| mesh | np 1 | development, np 2 | this head, np 2 |
|---|---|---|---|
Annulus(0.3, 1, 0.1) |
one value, 3.1265e-4 | SEGV | 2.7547e-4 on rank 0's owned nodes, 3.3257e-4 on rank 1 and on rank 0's ghosts |
UnstructuredSimplexBox(-1..1, 0.1) |
1.4350e-4 | 1.3734e-4 and 1.5134e-4 | the same as development |
- Same on the box: the box gives the same numbers on both builds, so the defect is not in this PR.
- Rank-local: the shift is computed or applied per rank. Ghost nodes carry the neighbour's shift, and neither rank's value is the serial one.
- The PR's test:
test_the_level_set_far_field_on_an_annulus[slcn]assertswalls.max() == walls.min()on the local array. So it fails on one rank under mpirun, and the ranks then diverge. In CI the file runs serially, so this does not block the PR. - Asked for: an issue for the mass correction. Optionally, a note in that test that it is serial-only until the issue is fixed.
2. Low: the fallback in _boundaries_covering_the_exterior_once() can double a face again
Where All_Boundaries marks no face, the helper returns every boundary that marks faces. That list can include internal surfaces and overlapping sets:
Internalon the internal-boundary meshes;LowerPlusandUpperPlusonAnnulusWithSpokes(27 and 42 faces, against 18 forLowerand 33 forUpper);Sliceson the segmented shells.
On every stock mesh we built, All_Boundaries marks exactly the exterior faces, so the fallback is never taken. A DMPlex wrapped without All_Boundaries would take it. Read only, not run. Marking the exterior faces where the label is missing, as the file paths do, would remove the fallback.
Confirmed correct
- Doubling fixed:
_boundaries_covering_the_exterior_once()returnsAll_Boundariesalone on all 20 meshes. Its face count equals the exterior face count on every one, so each exterior face carries the inflow term once. The default answer equals the by-name and by-hand single imposition bit for bit. _boundaries_that_mark_faces()counts height-1 points only.Centre(a vertex on the solid shell, nothing on the annulus) andInner(a region) are left out. It is collective, and identical on every rank, including an empty rank at np 3.- The new parallel test passes at np 3 and 4. It skips at np 2 with its stated reason. Development gives SEGV at np 3 and 4 (round 3).
- The new test file no longer uses constants from another machine, and passes serially on Linux (8 of 8).
- Round 1 and 2 behaviour holds at np 2 and 3: the rank-0-only label, the refusals, the field number and the rewire.
What was run
- Probes:
- the helper survey with an independent face count and an exterior check, at np 1 (20 meshes) and np 3 with an empty rank (7 meshes);
- the doubling variants;
- the internal-surface variants, with development for the old loop;
- the level-set wall probe on an annulus and a box, at np 1 and 2 on both builds;
- the regression probes at np 2 and 3.
- Tests:
- the PR's file at np 1, 2 and 3;
- the new parallel test at np 3 and 4;
- the 11 files that touch the changed loops, serially with 3 workers (156 passed, 1 skipped).
- Logs are kept by the reviewer.
Not run:
- the fallback path of finding 2;
SphericalShellInternalBoundarywith an inflow (the 2-D internal annulus stood in for it);- the broad slice of round 2 again;
- a PETSc debug build.
Underworld development team with AI support from Claude Code
Underworld development team with AI support from Claude Code
|
Review from the Underworld development team with AI support from Claude Code (H1: review and parallel test runs on a 96-thread Linux workstation (Intel Xeon Gold 6240R, AVX-512; MPICH)) (H1 is the session that reviews pull requests and runs the parallel tests.) Head 6f0bfdd (development merged in): ready to merge on green from this review. The merge brings in compiled changes from development (
Underworld development team with AI support from Claude Code |
…field_id The style gate's field-number rule refuses add_condition(var.field_id, ...) in tests too. The test now passes 2 for the two-field solver, standing for the #1170 mistake, and needs no third variable. Underworld development team with AI support from Claude Code
Fixes #1138, with its second face found in the review of PR #1170, and #1069. Both are from the probe sweep of 2026-11-15, which ran on development 176958a.
What changes
#1138:
PetscDSAddBoundary_UWchecks what it is given and what PETSc says. The wrapper looked a condition's label up by name, handed the result toDMAddBoundaryunchecked, and returned the boundary index as its error code. That had two consequences:All_Boundaries, but the DM holds no such label. An essential condition on it went in on a null label, and the solve ended in a segmentation fault (exit 59).DMAddBoundary. The refusal was discarded, and the solve converged without the condition.Now:
DMAddBoundary._add_boundary. It refuses with aValueErrornaming what is wrong when no rank holds the label; when the label values mark no point on any rank (a boundary the mesh lists but has no faces for; natural conditions keyed onUW_Boundarieswere dropped silently there); or when the field is not one of the solver's DM fields. It raises on any other PETSc error.Conditions library code puts on the whole boundary.
EulerianSUPG's weak inflow condition andLevelSetSolver's far field were put on every member ofmesh.boundaries. That broke in two ways:Centreon anAnnulusmarks nothing. The rule above refuses a condition on it, so on anAnnulusthe inflow case was refused, and the far field had been a segmentation fault on development.All_Boundaries, which shares every exterior face with the named boundaries, so each face's term went in twice.Now both loops use
Mesh._boundaries_covering_the_exterior_once():All_Boundariesalone where it marks faces, otherwise every boundary that marks a face (height-1 points ofUW_Boundaries, summed over the ranks).This changes every
EulerianSUPGresult with aninflow_valueon development. It corrects two things.All_Boundaries.Annulus: max |S01| 0.287 with the term doubled, 0.311 with it once.All_Boundariesis the exterior faces only, so the term is gone there. The reviewer measured this on a 2-DAnnulusInternalBoundarywith a uniform flow and a field of 0.25:Internalis 0.649, against 1.0 overUpper.Internal, development pulled S01 to 0.120, against -0.0007 without the term.Internaland 0.095 in the interior. At the walls, removing the interior term moves the answer by about 1e-3, and removing the doubling by about 0.05.The far field is a Dirichlet value, so applying it twice gave the same answer; the reviewer found it identical to the last bit.
#1069: a narrow rewire replaces the boundary kernels. They were registered with
PetscWeakFormAdd*, which appends. After N rewires each boundary key listed N + 1 kernels; all of them ran at every boundary quadrature point, and the last overwrote the rest.Now:
PetscWeakFormSet*, which replaces.UW_PetscDSSetBdTerms, which had no caller, is removed.We checked that no solver means two kernels on one key to be summed:
DMAddBoundaryand so its own weak form (PetscDSAddBoundarycreates one).Tolerances and coordinate matches
Tests
tests/test_1069_boundary_wrapper_checks_and_replaces.py:An essential condition on
All_Boundariesof a bare DMPlex raises aValueErrornaming the label. On development 176958a this case ends the process with SEGV; that is the sweep probeissue-sweep/sweep-2026-11-15/p1138_bare_dm.pyin the campaigns repository.A condition on field 2 of a two-field Stokes solver raises, naming the field and the valid range. On development fb75e9e it is not raised.
A natural condition on a boundary with no faces raises. On development the flux is dropped.
A label made only on the ranks that hold cells (
tests/parallel/test_1069_boundary_label_on_some_ranks_parallel.py, the empty-rank triangle): Poisson against the exact solution x + y. Every rank marks a scratch label, becausemarkBoundaryFacesis collective, and the real label is made where faces are. The test runs from np 3 and asserts that some rank lacks the label. At np 2 the fixture's one cell is spread onto both ranks.scripts/test.shruns it at np 3. It is run under MPI by the reviewer (H1, the session that runs our parallel tests on a Linux workstation), who measured the development crash at np 2 and 3.On an
Annulus:On the previous head the first two fail. The level-set test failed with the
Centrerefusal on the head before that.Two narrow rewires of a Robin coefficient leave one kernel on the boundary key, and the answer equals a fresh build's. On development there were 2 kernels after the first rewire.
Runs, serial, on macOS (12-core Apple M4):
Not in this PR
test_1123's sheared-box fixture turns one cell inside out. gmsh builds 1094 cells here and 1086 on Linux, so its walk test fails here. That is a fixture question, raised separately, not changed here.Review
One round of adversarial review, then three rounds of the reviewer's review. Both records are posted below.
Issue state
Underworld development team with AI support from Claude Code