Skip to content

An internal boundary's seam facet assembles no normal (#1135) - #1212

Merged
lmoresi merged 3 commits into
developmentfrom
bugfix/facet-slip-junction-1135
Nov 16, 2026
Merged

lmoresi merged 3 commits into
developmentfrom
bugfix/facet-slip-junction-1135

Conversation

@lmoresi

@lmoresi lmoresi commented Nov 16, 2026

Copy link
Copy Markdown
Member

Fixes #1135. Review: H1 (review and parallel test runs on a 96-thread Linux workstation).

The defect

Mesh._assemble_boundary_normal skips a facet that is not exterior, meaning one with two cells. So an internal boundary assembles no normal in serial: its facets have a cell on each side.

In parallel, a facet of an internal boundary that lies on a partition seam has only one local cell, and it passed as exterior. On that rank, Internal assembled a normal at the vertices of those facets.

The facet-slip normal (smoothing._slip_normals) refuses a vertex that more than one boundary claims. Where Internal meets a side of a 3-D BoxInternalBoundary, the vertex was therefore refused its slide normal on some partitions and slid in serial.

Measured at (0.25, 0, 0.5):

  • the assembled Internal normal is 0 in serial and (0, 0, -1) on the owning rank at rand3, np 3;
  • the slide normal is (0, -1, 0) in serial, and is refused in 3 of the rank's 4 projector builds.

The issue's guess, that a vertex's set of incident labels comes from the rank's local facets, was close. It is the internal label's normal assembly, not the label sets: those were already combined over the sharing ranks.

The fix

A facet that the point star forest shares between ranks is now skipped in the normal assembly. Such a facet is a leaf on this rank, or a root with leaves elsewhere, so it lies between two ranks' cells and is interior.

  • The set comes from Mesh._seam_points(), factored out of _drop_seam_facets (Facet-surface slip restores onto the label's facets over all ranks (#1103) #1109), which uses the same test.
  • It is read on every rank before the rank-local facet walk, because computeDegree is collective.
  • The test is topological. No coordinates are matched and no tolerance is added.
  • Serial is unchanged: the seam set is empty there.

Test

tests/parallel/test_1135_internal_boundary_normal_on_a_seam_parallel.py (min_size 2) runs the issue's mesh, BoxInternalBoundary(simplex=True, cellSize=0.25) in 3-D, on a random cell partition with seed 3:

  • test_an_internal_boundary_assembles_no_normal: Internal's assembled normal is zero on every rank, and Front's is still a unit normal.
  • test_facet_slip_matches_serial_on_a_scattered_partition: facet slip with every label slipping (no declared surfaces, H1's probe configuration) matches serial vertex by vertex to 1e-10. The serial baseline is computed by serial_reference in the same environment.

The defect needs three ranks: no seed from 1 to 12 gives Internal a normal at np 2. So scripts/test.sh runs this file at np 3 on every run, as it does for test_1084 and test_0786, as well as in the np 2 batch.

Results on a 96-thread Linux workstation (single system image; Intel Xeon Gold 6240R, AVX-512; MPICH). This is the largest distance from serial with H1's probe (n_outer 5, serial move 4.104e-2):

layout development (H1's #1135 probe) this branch
natural, np 3 1.0e-12 1.1e-12
rand3, np 3 5.1e-3 9.2e-13
rand3, np 4 7.0e-3 1.1e-12
rand3, np 6 1.2e-2 1.0e-12
rand3, np 8 1.2e-2 1.4e-12

The new test:

  • development's discretisation_mesh.py: passes at np 2, where the defect doesn't show. Both tests fail at np 3 and np 4: Internal assembles a normal of size 1.0, and 205 of 468 coordinates are off serial by up to 5.1e-3.
  • this branch: 2 passed at np 2, 3, 4 and 5.

Neighbours:

  • Serial: 135 passed. Files: test_0056, test_0750, both test_0762 files, test_0763, test_0764, test_0765, test_0766, test_0768, test_0770, test_0855, test_1082, test_1086, test_1103_facet_slip_matches_serial, test_1188.
  • Parallel at np 2: 48 passed, 3 skipped. Files: both test_0766 files, test_0856, test_1063, test_1064, test_1069_boundary_normal, test_1086, test_1103_split_fault_slip, test_1103_facet_slip_against_serial, test_1135.
  • scripts/check_test_coverage.py: OK.

Side findings

  • A routine that wants an internal surface's normal still gets zero, on every partition now. That is unchanged, and is documented in the routine. rotated_bc keeps the raw PETSc normal for internal boundaries, separately.

Underworld development team with AI support from Claude Code

Mesh._assemble_boundary_normal skips a facet that is not exterior (two
cells), so an internal boundary assembles no normal in serial. In parallel
a facet of an internal boundary on a partition seam has one LOCAL cell and
passed as exterior: Internal took a normal on that rank, the facet-slip
normal (_slip_normals) saw two boundaries claim the vertices where Internal
meets a side, and refused their slide. On a 3-D BoxInternalBoundary under a
random cell partition the moved mesh was 5.1e-3 (np 3) to 1.2e-2 (np 6, 8)
off serial against a 4.1e-2 move.

A facet the point star forest shares between ranks is now skipped
(Mesh._seam_points, factored out of _drop_seam_facets, read on every rank
before the facet walk). Serial is unchanged.

Test: tests/parallel/test_1135_internal_boundary_normal_on_a_seam_parallel.py
(Internal assembles a zero normal on every rank; facet slip matches serial to
1e-10 on a random partition). The defect needs three ranks, so test.sh runs
the file at np 3 always.

Underworld development team with AI support from Claude Code
Copilot AI balanced review requested due to automatic review settings November 16, 2026 06:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@lmoresi

lmoresi commented Nov 16, 2026

Copy link
Copy Markdown
Member Author

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.)

Verdict on head fd52e63: ready to merge on green from this review.

The fix is correct, and the seam test cannot drop a real wall facet. With the issue's probe, the PR matches serial to about 1e-12 on every layout tried, including four that fail on development. No blocking or medium findings. There are two nits and one test suggestion below; none of them needs to hold the merge.

The probe is the issue's case: a 3-D BoxInternalBoundary(simplex=True, cellSize=0.25) on the unit cube, internal surface at z = 0.5. It runs redistribute_nodes with every label pinned and slipping (n_outer 5, metric_eval sympy) and matches vertices to serial by starting position. randN is a shell partition with each cell dealt to rank default_rng(N).integers(0, size).

The PR was built at fd52e63. The development column is the same build with the merge base's (0414d3d) discretisation_mesh.py laid over it. The compiled sources are identical between the merge base and the head, so the only difference between the columns is this PR.

Results

The facet-slip rows give max |x_np - x_serial|. The serial move is 4.104e-2 in 3-D, 3.644e-2 on the 2-D box and 2.885e-2 on the annulus. The PR's serial result is bit-identical to development's serial result.

case np layout development PR
3-D box facet slip 3 natural 1.02e-12 1.02e-12
3-D box facet slip 3 rand3 5.12e-3 6.52e-13
3-D box facet slip 3 rand7 1.53e-3 9.33e-13
3-D box facet slip 3 rand1 7.00e-3 7.66e-13
3-D box facet slip 3 rand5 4.56e-4 1.24e-12
3-D box facet slip 3 emptyband (rank 2 has no cells) 1.02e-12 1.02e-12
3-D box facet slip 3 wall (one cell layer on x = 0 to one rank) 9.37e-13 9.37e-13
3-D box facet slip 3 intseam (seam on the internal surface) 0 0
3-D box facet slip 4 natural 9.27e-13 9.27e-13
3-D box facet slip 4 rand3 7.00e-3 1.10e-12
3-D box facet slip 4 rand7 1.17e-3 7.81e-13
3-D box facet slip 4 rand1 1.22e-2 1.21e-12
3-D box facet slip 4 rand5 2.77e-3 1.04e-12
3-D box facet slip 4 emptyband 8.96e-13 8.96e-13
3-D box facet slip 4 wall 1.02e-12 1.02e-12
3-D box facet slip 4 intseam 1.55e-3 7.05e-13
2-D BoxInternalBoundary facet slip (cs 0.1) 3, 4 rand3, rand7 4.5e-13 to 6.6e-13 identical to development
AnnulusInternalBoundary facet slip (cs 0.1) 3, 4 rand3, rand7 3.2e-13 to 8.9e-13 identical to development
Internal assembled normal, max |n| (serial 0), 3-D box 3, 4 rand3, rand7; intseam at np 4 1.0 0
Internal assembled normal, max |n| (serial 0), annulus 3, 4 rand3, rand7 1.0 0
Internal assembled normal, max |n| (serial 0), all three meshes 3, 4 natural, band, emptyband, wall, corner 0 0
every exterior label's normal against serial, vertex by vertex (every local copy) 3, 4 all 8 layouts, all three meshes 0 (bitwise) 0 (bitwise)

The rand3 rows at np 3 and 4 reproduce the issue's values exactly.

Two cases give Internal a normal on development but leave the move alone:

  • On the annulus the internal circle never meets a wall, so there is no junction for _slip_normals to refuse.
  • On the 2-D box no seed gave Internal a normal.

Findings

No blocking or medium findings.

  1. Nit: the seam test assumes the solver DM has no cell overlap. That is true today, but the code doesn't say so.

    • Each facet's own point is tested for membership of the point star forest. With overlap 0 that is exactly "the facet has a cell on two ranks", so it is a facet-support test, not a vertex-sharing test (confirmed below).
    • On a DM that was distributed with an overlap of one cell, an outer facet of a ghost cell would be a leaf on one rank and a root with degree > 0 on its owner. That facet would then be skipped on both ranks, and the wall normal lost there.
    • No constructor builds the solver DM that way. The one-cell overlap for manifold meshes goes to the separate _nav_dm clone. But Mesh.__init__ takes an already-distributed DM as it is, so a caller could in principle hand in an overlapped one. FE assembly is already wrong on such a DM (the constructor's own comment says so), so this is not a new failure mode.
    • Suggestion: add one clause to the _seam_points docstring ("valid on the non-overlapped solver DM").
  2. Nit: cost.

    • _seam_points builds a Python set of every shared point: vertices, edges and facets. It rebuilds it on every _assemble_boundary_normal call, which means once per label, per _slip_normals call and per deform refresh.
    • Only height-1 points are ever looked up. Filtering to dm.getHeightStratum(1) would make the set several times smaller.
    • I did not measure this. On these meshes it is lost in the noise of the facet walk, which is per-facet Python anyway.
  3. Test suggestion. In test_an_internal_boundary_assembles_no_normal, the exterior check is that Front's largest component is about 1. The risk a seam-skip carries is a wall losing facets on some ranks, and the max over the field would not see a few missing wall vertices. A vertex-by-vertex comparison of one exterior label against serial would cover it. The review's normal probe did that comparison, and it is clean.

Confirmed correct

  • The seam test cannot catch an exterior facet.
    • On the non-overlapped DM, a point lives on a rank only if one of that rank's cells contains it. An exterior facet has one cell globally, so it exists on one rank and is never in the point SF.
    • What is tested is the facet point itself, not its vertices or edges. So a wall facet whose vertices are all shared (a thin partition along the wall, a corner, a one-layer rank) is still taken.
    • Measured by counting, on every rank, each label's facets that are in _seam_points. Layouts: rand3 at np 3 and 4, wall at np 4, corner at np 3, intseam at np 4, emptyband at np 3 on the 3-D box; rand3 at np 4 on the annulus; rand7 at np 3 on the 2-D box. The result:
      • 0 for every exterior label in every case;
      • for Internal, exactly the facets that have one local cell (on the 3-D box at rand3 np 3, 48 of 66 held, i.e. 24 seam facets, each held on two ranks).
  • Exterior normals are unchanged.
    • _assemble_boundary_normal and the public boundary_normal agree with serial bitwise, and in nonzero-vertex count, for every exterior label. This holds on the 3-D box, the 2-D box and the annulus at np 3 and 4, under natural, rand3, rand7, band, emptyband, wall, corner and intseam layouts.
    • In the wall layout, every cell with a facet on x = 0 goes to the last rank. That leaves a single layer whose wall facets have all their vertices shared. In the corner layout, the last rank holds only the cells around the minimum corner (4 cells in 3-D).
  • _drop_seam_facets is unchanged for its caller.
    • Its only caller is boundary_slip, which calls it under uw.mpi.size > 1 on every rank, including one with no cells.
    • The set is the same leaves-plus-roots-with-degree set.
    • computeDegree still runs before the early return on empty facets, so the collective order is the same.
    • The new serial short-circuit in _seam_points depends only on the communicator size, so it is the same on every rank.
    • test_1086_boundary_slip_classification_parallel, test_1103_facet_slip_against_serial_parallel and test_1103_split_fault_slip_parallel pass at np 2 and 3.
  • Collectives.
    • _seam_points() is called unconditionally on every rank, before createSubDM and before any rank-local branch. The only new rank-local branch is the continue inside the facet walk, and no collective follows it inside the loop.
    • Emptyband at np 3 and 4 (one rank with no cells) completed for the normal probe and for the full mover on all three meshes.
    • test_1082_mmpde_mover_empty_rank_parallel passes at np 3.
  • Public behaviour change. In parallel, mesh.boundary_normal("Internal") used to be nonzero at seam vertices on some partitions. It is now zero, which is what serial gives and what the docstring promises. The rotated-BC path keeps its own raw PETSc normal on internal surfaces and is not affected.
  • New test.
    • Development fails both cases at np 3 and np 4: "Internal assembled a normal of size 1.0", and a slip max error of 5.12e-3 with 205 of 468 entries off serial.
    • Development passes both at np 2. This is the np-2 blindness the PR describes.
    • The PR passes at np 2, 3 and 4.
  • test.sh. The new always-on np 3 line is in shard 4, next to the other always-on np 3 files. It runs under the supervisor, with the oversubscribe variable like its neighbours. The file is also picked up by the np 2 enumeration of tests/parallel/test_*.py.

What was run

  • Probe sweeps (above), base and PR:
    • 3-D facet slip: 8 layouts at np 3 and 4.
    • 2-D box and annulus facet slip: rand3 and rand7 at np 3 and 4.
    • Normal probe: 3 meshes, 8 layouts, np 3 and 4.
    • Seam-membership count: 8 runs.
    • Serial references for all of these.
  • New test test_1135_internal_boundary_normal_on_a_seam_parallel.py:
    • PR: 2/2 at np 2, 3 and 4;
    • development: 2/2 failed at np 3 and at np 4, 2/2 passed at np 2.
  • Parallel neighbours, PR, one batch of 16 files:
    • Files: the new test, 0765 internal-boundary integral, 0766 BoxInternalBoundary, 0766 mover refresh, 0855 mesh smoothing, 1064 rotated free slip, 1068 rotated nodal normal, 1069 boundary normal, 1082 empty-rank mover, 1086 boundary-slip classification, 1103 facet slip against serial, 1103 split-fault slip, 1140 rotated analytic normal, 1193 corner normal, 1152 FAC zone through a mover, 1084 rotated datum collectives.
    • np 2: 62 passed, 4 skipped.
    • np 3: 61 passed, 5 skipped. The skips are by design: two spherical anchor values not recorded for this host's gmsh, a serial-only assertion in 1069, and 1140 not measured at np 3.
  • Serial neighbours, PR, 18 files:
    • Files: 0056, 0062, 0595, 0763, 0764, 0766, 0855, 1018 rotated nodal normal, 1060 Nitsche, 1066, 1082, 1086 seam, 1103 facet slip, 1190, 1193, and tests/parallel 1069, 0765 and 0766 serially.
    • 120 passed, 5 skipped, 0 failed. Four of the skips are MPI-only internal-boundary cases that need --with-mpi; the fifth is a parallel-only stencil case in 1069.
    • test_1092_thin_sheet_prescribed_normal: the first 3 cases passed. I stopped the fourth (the level_3 Maxwell tide case) after 31 minutes without a result. In serial _seam_points returns an empty set, so the PR changes nothing on that path.

Not run

  • np 6 and 8: the core budget for this review was four processes.
  • np 5.
  • The full test.sh.
  • The last case of test_1092 (stopped; see above).
  • Neighbours on development (not needed; nothing failed on the PR).

Logs kept by the reviewer.

Underworld development team with AI support from Claude Code

@lmoresi
lmoresi merged commit 052e938 into development Nov 16, 2026
10 checks passed
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.

3 participants