Skip to content

pull_vertex_onto: a target inside the mesh never takes a boundary vertex (#1089, partly) - #1128

Merged
lmoresi merged 9 commits into
developmentfrom
bugfix/pull-vertex-keeps-the-wall
Nov 13, 2026
Merged

lmoresi merged 9 commits into
developmentfrom
bugfix/pull-vertex-keeps-the-wall

Conversation

@lmoresi

@lmoresi lmoresi commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

What this does

pull_vertex_onto moves a mesh vertex onto each target it is given; Mesh.add_fault calls it for every control point of a fault before the cut. It took the nearest corner of the cell holding the target, with no test for the mesh boundary. A fault tip inside a boundary cell and nearest to its wall corner pulled that corner inward: the domain was dented (unit box area 0.99875), and the tip became a boundary vertex, which the split then refused as "touches the domain boundary".

With this change a target inside the mesh never takes a vertex of the mesh boundary.

  • A target on a boundary edge takes one of that edge's ends, as before. A target inside the mesh takes an interior corner of the cell holding it, however close a boundary corner is.
  • The boundary is every edge with one cell, so the two sides of a fault already split into the mesh count as boundary. A second fault ending beside an earlier one leaves the earlier fault's vertices where they are.
  • An interior corner taken in place of a nearer boundary corner is taken only if the cells around it stay above min_quality (0.1 by default, None disables). A corner that fails is passed over and the next nearest interior corner is tried.
  • When the cell has no interior corner, or none passes, the call raises ValueError on every rank. The message says what to do, and names the welded fault zone with a transverse-isotropic rheology as the route for a fault that has to end close under the boundary.
  • A pull that does not involve a boundary corner is unchanged: the nearest corner is taken with no test.
  • A mesh distributed with an overlap is refused, on every rank. Mesh.dm has no overlap, so add_fault is not affected.

This does not close #1089. The parts that stay are listed below.

The refusal is a geometric stand-in

A precise test would ask whether the move makes an element with inconsistent constraints, or one whose nodes are all constrained. That test is not built here. The rule above (no boundary vertex, and a quality floor on the cells around the vertex taken) stands in for it, and it refuses some placements a constraint test would allow. Where it refuses:

Cell holding the target Refused when
An edge on the boundary (one interior corner) closer to that edge than 0.043 to 0.068 of the cell's height (regular 1/12 box), 0.045 to 0.083 (irregular 1/12 box), 0.047 to 0.087 (annulus, cell size 0.1)
One corner on the boundary (two interior corners) within 0.16 of the shorter edge from that corner
Two boundary corners and no boundary edge (across a corner of the domain) close to the interior edge joining them, anywhere along it: 0.014 from it on a unit cell leaves a quality of 0.02
Every corner on the boundary always

Curved concave walls. The boundary is the mesh's own chords, so a point of the true curve on a concave wall is an interior target a sagitta from the boundary. On an annulus of inner radius 0.5 and cell size 0.1, a fault ending on the true inner circle between two wall vertices was refused in 96 of 96 cases. development placed all 96 by moving a wall vertex onto the tip, with the area changing by 9.4e-6 to 2.35e-4. At cell size 0.15 and finer every such point is refused; at 0.175 to 0.25 the point over the middle of a chord is placed and those over its quarter points are refused; at 0.3 the quarter points are placed too.

Tolerances and coordinate matches

Every tolerance and every match by coordinates in pull_vertex_onto after this change, what it bounds, and whether the mesh's own connectivity could have answered instead.

Where Value In this change What it decides Could connectivity or the point map answer?
The boundary: which vertices and edges are on it none added A face with one cell that no other rank holds, and the vertices in its closure, reconciled over the ranks. It does: read from the mesh's cones and supports and the point star forest. No coordinate is used. True only without overlap (below).
Whether the mesh has an overlap none added Any cell held by more than one rank, reduced over the ranks. Such a mesh is refused. It does: the point star forest.
Which cell, edge or vertex holds the target (_minimal_face_vertices) 1e-9, in barycentric coordinates of the cell (relative to the cell) kept A target is a point given by coordinates, not a mesh entity. The tolerance decides when it reads as on an edge or at a vertex and not inside the cell. It is why a target within 1e-9 of a cell's height of a boundary edge takes one of the edge's ends. No: the target is not in the mesh. Every cell is tested; there is no walk from a known start.
Which vertex a rank moves, given the winner of the reduction 1e-12 x the mesh extent, on the distance between coordinates kept The reduction over ranks carries the winner's coordinates, and each rank moves the vertex it finds there. Yes. A global vertex number from the point star forest would name the vertex with no tolerance. Not changed here.
Dropping a refused corner from the candidates on every rank 1e-12 x the mesh extent added The same identity by coordinates as the row above, for the corner the quality test refused. Yes, by the same global vertex number.
Whether the proposed corner is the nearest of its face (decides whether the quality test runs) 1e-12 x the mesh extent, on a difference of two distances added A tie between the candidate's distance and the nearest corner's. On one rank the two are the same number. Yes: by comparing which vertex it is, not how far. It is written on distances so that two ranks reading a face differently within the 1e-9 above reduce to "test it".
min_quality 0.1, an argument added The floor on the cells around a vertex taken in place of a nearer boundary vertex. Scale-free (1 equilateral, 0 flat). No. It is a threshold on shape and stands in for a constraint test, as the section above says.
The floor where a cell is already below min_quality the cell's present quality, compared strictly, no margin added A cell already worse than the floor is ruined only if the move makes it worse still, so a poor mesh is not refused for what it already is. A move that leaves such a cell exactly as it was passes; one that worsens it by a rounding error fails. No. It is the same threshold on shape.
A surface mesh in three dimensions: how far off a cell's plane a target may be and still be held by it half the square root of twice the cell's area (about the cell's own size) kept Which cells of a surface mesh are candidates to hold a target that is not exactly on the surface. Not reached on a plane mesh. No: the target is not in the mesh.
The winding of a cell, and whether the move inverted one sign of the signed area, no tolerance added Read once from the mesh as given, so a cell wound the other way is not read as inverted. Not a match or a search.

The choice among candidates is by distance to the target and has no tolerance; ties fall to coordinate order in the reduction, as before.

Three of these rows identify a vertex by where it is. One change would retire all three: reduce a vertex number in place of the coordinates. We have not made it here; it is a follow-up, with two things the cross-review found that it has to respect.

  • The number must carry the twin of a vertex on a split fault. The two sides of a fault share coordinates and are different mesh points, and today both copies move with the coordinates. A number that names one of them would open the fault.
  • At an exact tie in distance (a target at the midpoint of an edge) the vertex chosen depends on the partition: 52 of 10,686 targets in the cross-review's probe on 2 to 5 ranks, the same on development. A DMPlex global number depends on the partition too, so it would not settle a tie the same way at every rank count. We would break ties by coordinate order, lexicographically, which is what the reduction does now but applied to the same candidate set on every rank; a number from the mesh before it was distributed would also do, if the mesh carried one, and it does not today.

The cross-review also found that the three coordinate rows cannot pick different vertices on different ranks today (ghost coordinates were bitwise equal in 10,803 reductions), so the follow-up is not urgent.

Measurements

Serial, on macOS (12-core Apple M4).

add_fault with a tip under the top wall of an irregular 1/12 box (cell height about 0.072), nine tips at each depth:

Tip depth below the wall This branch development
0.002, 0.004 refused by the pull, 9 of 9 refused by the split ("touches the domain boundary"), 9 of 9
0.006 to 0.03 placed, 9 of 9, area 1 refused by the split, 9 of 9

The repro of the issue (tip at (0.504, 0.985), trace to (0.5, 0.6)) is placed with area 1, thirteen vertices on the top wall as before, and a worst cell quality of 0.252.

A second add_fault whose tip is beside an earlier split fault (irregular 1/12 box): at 0.25 and 0.1 of a cell height above the first fault it is placed with the first fault's vertices in place; at 0.03 the pull refuses it. development raised "adding ['Two'] would change the fault(s) already split into this mesh" at all three.

On a mesh with add-on levels the fault is also replayed onto each level of the multigrid tail, where the cells are larger. A level whose pull is refused is left welded with a warning, and the finest level is still split:

Tip depth This branch: tail levels split development
0.0006, 0.0012 finest split; top tail level split or none, warning names min_quality ValueError, nothing placed
0.0025 finest split; two tail levels split at one tip position, none (with the warning) at the other finest split; no tail level split, warning "touches the boundary"
0.005 finest split; two tail levels split finest split; no tail level split

What this does not fix

  • pull_vertex_onto moves a domain-boundary vertex onto a target inside the mesh #1089, the cut's snap. cut_along_lines with snap_frac=0.1 still moves a boundary vertex onto the line (unit box area 0.99952, the same as on development).
  • pull_vertex_onto moves a domain-boundary vertex onto a target inside the mesh #1089, a vertex where the boundary turns. A boundary vertex still slides along one boundary edge and off the other when it is the nearer end of the edge holding the target. A box corner does (area 0.99917 for a target at (0.02, 1.0)), and so does every vertex of a curved wall: a target on a chord of the annulus's inner wall moves the nearer end of the chord from radius 0.5 to 0.498, and the domain gains 2.8e-4 of area. A test holds this as it is.
  • A target outside the mesh takes the nearest vertex anywhere, as before.
  • pull_vertex_onto: two control points can claim the same vertex, silently unplacing the first #559, two targets of one call taking the same vertex. Still live, and easier to reach beside a boundary, since two targets in neighbouring boundary cells share their one interior corner. With four to six random targets a call beside the boundary of an irregular 1/12 box at one cell spacing, 14 to 25 of 150 calls left a target without a vertex, against 2 on development. Of 1375 calls whose targets were further apart than the longest edge of the cells holding them, none did. A test holds the present behaviour. A fix has to deal first with the replay onto coarse levels, which sees the fine trace at 0.25 to 0.5 of a cell spacing.
  • The quality floor covers a stand-in only. A target whose nearest corner is interior takes it untested, so the floor is not a floor on the mesh returned: of about 2800 accepted pulls of random targets in boundary cells of a regular 1/12 box, 10 to 14 left a cell below 0.1.
  • Tetrahedral meshes are not supported by pull_vertex_onto, before or after.

Parallel runs

By the cross-review (H1, a second session of ours on a 96-thread Linux workstation, MPICH), at 3584702; its record is in the comments.

  • tests/parallel/ptest_0844_line_cut_parallel.py: 20 of 20 pass on 2, 3, 4 and 5 ranks. The file is on development with 16 tests; this branch adds 4 for the boundary rule, and those 4 fail with development's line_cut.py.
  • With the not shared clause of the boundary-edge test removed in memory, only the seam test fails, on 2 and 4 ranks.
  • The last entry of the reduced tuple and the winding sign were probed on 2 to 5 ranks with 10,686 seam targets and 10,803 reductions: no hang, refusals on every rank. In 31 reductions two ranks read the face differently within the containment tolerance, with no disagreement in the outcome.
  • Overlap. On a mesh distributed with an overlap of one cell, on 2 ranks, 91 of 2,376 interior targets moved a boundary vertex at 3584702 (none on one rank): a boundary edge inside the overlap is held by two ranks and read as interior. The commit after the review refuses such a mesh on every rank, with a fifth new test in the parallel file (test_a_mesh_with_overlap_is_refused_on_every_rank). That test and the refusal have not been run on more than one rank by us; the cross-review reruns them.

Not run by the cross-review: the 42 serial files, test_0052, and anything in 3-D.

Issues

Tests

Serial, on macOS (12-core Apple M4).

  • tests/test_0844_line_cut.py and tests/test_0847_fault_api.py: 70 passed. Four tests are new in the last commit: the cell with two boundary corners and no boundary edge, two targets that choose one vertex (pull_vertex_onto: two control points can claim the same vertex, silently unplacing the first #559 as it is), a target on a chord of a curved wall, and a fault ending beside an earlier split fault.
  • tests/test_0052_collective_guard_scan.py passes with the new reductions.
  • 42 serial fault, placement and multigrid files: 412 passed, 1 skipped.
  • Mutants, in memory: the table is in the review record below. development's line_cut.py fails 19 of the 70; each of the four new tests is failed by at least one mutant; two clauses (after <= 0, the count restricted to the cells of the moved vertex) are killed by none.
  • scripts/check_test_coverage.py: all 446 files reachable. The docs page builds clean.
  • After the cross-review: the overlap refusal. The same 70 pass and test_0052 passes with its reduction; the new parallel test compiles and has not been run here.
  • tests/parallel/ptest_0844_line_cut_parallel.py is run by the cross-review; see "Parallel runs".

Underworld development team with AI support from Claude Code

pull_vertex_onto moved the nearest corner of the face holding a target,
with no test for the domain boundary. A target inside the mesh whose
nearest corner was a boundary vertex pulled that vertex inward: the
domain was dented, and a fault tip clear of the boundary became a
boundary vertex, which the split then refused as "touches the domain
boundary". Without a split the dent was accepted (unit box area 0.99875).

A boundary vertex now moves only along the boundary. A target on a
boundary edge or vertex takes that face's vertices as before; a target
inside the mesh takes an interior corner of its face; when the face has
no interior corner the refusal is a ValueError raised on every rank
(the flag leads the MIN reduction).

Tests: test_0844 (wall bitwise unchanged on a box and an annulus, the
boundary slide kept, the two refusals), test_0847 (a tip under a wall
vertex is placed and split), ptest_0844 (the same at any partition, and
the refusal collective; not run on the serial host).

Not fixed, marked TODO(BUG): a box corner still slides off one wall when
it is the nearer end of the boundary edge holding the target.

Underworld development team with AI support from Claude Code
Underworld development team with AI support from Claude Code
…on order

Review of the boundary rule (a target inside the mesh never takes a boundary
vertex) found that the interior corner it takes instead can be dragged up
against the boundary with nothing said: a target 1e-8 under a wall left a cell
of quality 2.5e-7, and a point of the true circle over a chord of a concave
wall left one at 0.057.

An interior corner that stands in for a strictly nearer boundary corner is now
taken only when the cells around it stay above min_quality (0.1 by default,
None disables), with the cut's own veto: refuse an inverted cell, or one below
min(min_quality, its present quality). The refusal is a collective ValueError.
The nearest corner itself is taken with no test, as before, so every pull that
does not involve the boundary rule is unchanged.

The reduction's flags are reordered so that a rank reading the target inside a
cell with an interior corner is believed over a rank reading it, within the
containment tolerance, on a face with none.

The docstring, the error text and the subsystem page now state what the rule
does not cover: a target outside the mesh, a box corner sliding along one
wall, the cut's snap (issue #1089 stays open for those two), and two targets
of one call taking the same vertex (issue #559, easier to reach beside a
boundary).

Tests: the refusal and its floor on the box and the annulus (fails before this
commit); a target outside the mesh. Parallel: the ten-target test collided on
shared corners and failed its own assertion, and is rebuilt on the regular box
with targets two cells apart; the quality refusal is collective; an interior
edge on a partition seam between two boundary vertices is not read as a
boundary edge.

Underworld development team with AI support from Claude Code
…uses (#1089)

An interior corner that stands in for a nearer boundary corner was refused
when it would leave a cell below min_quality, and only the nearest interior
corner was tried. A target close to an edge of its own cell and well clear
of the boundary was refused on that ground though the other interior corner
takes it soundly. The corners are now proposed in distance order, each
refusal reduced on every rank, and the call refuses only when none passes.
The refusal names the welded transverse-isotropic fault zone as the route
for a fault that has to end close under the boundary.

Docstring, documentation and tests for this follow in the next commits.

Underworld development team with AI support from Claude Code
Underworld development team with AI support from Claude Code
Underworld development team with AI support from Claude Code
… and the measured limits

Tests (tests/test_0844_line_cut.py), on a hand grid of 18 triangles with
one cell touching the wall at a single corner, listed both ways round:
the next interior corner takes a target the nearest would flatten; a
target no interior corner can take is refused with their count and the
worst quality; a cell already below the floor does not refuse a pull
that improves it; a later target is tested on the mesh the earlier ones
left; a target on a vertex moves nothing. The too-close test now checks
the quality the refusal reports against the mesh min_quality=None gives.
Each new test fails under an in-memory mutant of the clause it covers.

The retry loop's exit read names copied out of the reduced tuple, which
tests/test_0052_collective_guard_scan.py cannot follow, so the scan
failed on it. The reduction is now unpacked directly and the
min_quality=None exit stands on its own line; the behaviour is the same.

Docstring and docs carry numbers measured at this head: a cell with an
edge on the boundary refuses a target closer than 0.044 to 0.088 of its
height; a cell with one boundary corner refuses only within 0.16 of the
shorter edge from that corner; a concave-wall point of an annulus of
inner radius 0.5 is refused at cell size 0.15 and finer and placed at
0.2 and coarser. The floor applies to an interior corner standing in for
a nearer boundary corner and to nothing else: on a regular 1/12 box 14
of 2822 accepted pulls left a cell below 0.1, each by the nearest
corner. The docs page now covers two targets taking one vertex beside a
boundary (#559) and the welded transverse-isotropic zone where a split
is refused.

Serial, macOS (12-core Apple M4): 45 fault and placement files, 425
passed, 1 skipped. The parallel file has not been run at this head.

Underworld development team with AI support from Claude Code
The third review round found behaviour that was neither stated nor tested.

- A fault side already split into the mesh is boundary; the refusal now
  names it as the other possibility beside the domain boundary.
- The last entry of the reduced tuple says "this corner is the nearest of
  its face", so two ranks reading a face differently within the containment
  tolerance reduce to "test it". The same decision on one rank.
- The winding of each cell is read once from the mesh as given, so a cell
  an earlier target of the call inverted is not read as wound the other way.
- Docstring and docs: the cell with two boundary corners and no boundary
  edge, the 1e-9 containment tolerance under a boundary edge, curved concave
  walls (a point of the true curve is refused; a point on a chord moves the
  wall), the replay onto coarse levels, the untested tie, and the measured
  rate of two targets taking one vertex (#559, more frequent beside a
  boundary than before).
- Four tests: the corner cell, two targets that choose one vertex (#559 as
  it is), a target on a chord of a curved wall, a fault ending beside an
  earlier split fault.

Serial: test_0844 and test_0847 70 passed; 42 fault, placement and multigrid
files 412 passed, 1 skipped. Not run on more than one rank.

Underworld development team with AI support from Claude Code
Copilot AI balanced review requested due to automatic review settings November 13, 2026 04:05
@lmoresi

lmoresi commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

Review record (before the PR opened)

Three rounds of adversarial review by fresh agents, each on the head of the time, the third on f60a935 against development 01dec8d. Run on macOS (12-core Apple M4), serial only: nothing in any round was run on more than one rank. This is the third round's findings and what we did with each. 3584702 is the commit that answers it.

The main claim held in every serial probe of the review: over about 27 000 random single targets on a regular 1/12 box, an irregular 1/12 box and an annulus (inner radius 0.5, cell size 0.1), no accepted pull of a target inside the mesh moved a boundary vertex or inverted a cell.

Findings and outcome

# Finding Outcome
1 Two targets of one call taking the same vertex (#559) is 5 to 12 times more frequent beside a boundary than on development (14 to 25 of 150 calls against 2, six targets a cell apart on an irregular box), and still silent. No test covered a collision. Not fixed here; a refusal on a claimed vertex breaks the replay onto coarse levels, which sees the fine trace at 0.25 to 0.5 of a cell. Stated with the numbers in the docstring, the docs and the PR body. test_two_targets_that_choose_one_vertex_leave_the_earlier_without_one holds the present behaviour. #559 stays live.
2 A control point on the true curve of a concave wall is refused (96 of 96 on the annulus) where development placed it by denting the wall; the advice "put such a point on the chord" moves the wall too, since every vertex of a curved wall is a turning vertex. The statement about coarser meshes was right for the middle of a chord only. A known limit of the geometric rule; in the PR body under its own heading. Docstring and docs corrected (which points are placed at which cell size; the chord case and what it costs: radius 0.5 to 0.498, area +2.8e-4). test_a_target_on_a_chord_of_a_curved_wall_takes_an_end_of_the_chord holds it.
3 A cell with two boundary corners and no boundary edge (across a corner of the domain) refuses targets 0.20 to 0.25 of a cell from the wall; the depth figures did not cover it. Documented as the third cell case. test_a_target_beside_the_interior_edge_across_a_domain_corner_is_refused (three targets, the reported quality asserted).
4 The sides of a fault already split into the mesh count as boundary, and the refusal said "domain boundary". Not stated, not tested. Stated in the docstring and docs. The refusal now names "a side of a fault already split into the mesh" as the other possibility. test_a_fault_ending_beside_an_earlier_fault_leaves_its_vertices_alone (pull and add_fault; the first fault's vertices bitwise in place).
5 The replay onto coarse levels splits levels development left welded, and leaves a level welded with a warning where its pull is refused. Not mentioned anywhere. A paragraph in the docs and the table in the PR body. No new test: the mechanism is split_tail_levels' existing one and its tests pass.
6 The floor is applied to a stand-in only; a tie goes untested. By design (a pull that involves no boundary corner is unchanged). The docs now say a tie is not tested and give the measured rate (10 to 14 of about 2800).
7 Within 1e-11 of a wall an interior target takes a wall vertex. It is the containment tolerance (1e-9 in barycentric coordinates) reading the target as on the edge. Now stated in the docstring and docs.
8a The last entry of the reduced tuple: two ranks reading a face differently within the tolerance reduced to "no test". Changed. The entry now says "this corner is the nearest of its face", so the minimum over ranks is "test it". On one rank this is the same decision as before; no serial test separates it from f60a935.
8b The winding sign was read from the mesh after earlier targets of the same call, so a cell an earlier target inverted read as "wound the other way". Changed. The winding is read once from the mesh as given. Also a no-op unless an earlier target of the call inverts a cell, which the quality test prevents for a stand-in; not separated from f60a935 by a serial test.
8c On a DM with overlap, boundary edges in the overlap are shared and would read as interior. Not checked. add_fault works on a DM without overlap; we did not look for another route.
9 Clauses no serial test pins. See "What stays unpinned" below.
10 Depth figures and the "14 of 2822, worst 0.02" sentence differ from the review's draw. Per-mesh figures in the docstring, docs and PR body (0.043 to 0.068 regular box, 0.045 to 0.083 irregular, 0.047 to 0.087 annulus); the rate is given as a range over two samples, with both worst values.
11 A test docstring described an earlier commit of this branch (Charter §4); two private helpers of other modules are imported inside the function. The sentence is replaced by a statement of what the test guards. The imports are left: both helpers are the existing single definitions of "boundary vertex" and "shared point", and a second copy would be worse (§5).

8a and 8b are logic changes made after the review, so they have had no reviewer other than us. Both are for the cross-review to read: line_cut.py, the is_nearest entry and the exit test of the retry loop, and wound.

Mutants

In memory (one string of the installed line_cut.py replaced and executed into the module; no source edited), tests/test_0844_line_cut.py and tests/test_0847_fault_api.py, 70 tests:

Mutant Failed
none 0
development's line_cut.py 19
f60a935's line_cut.py 1 (the fault-side test, on the message)
interior target may take a boundary corner 19
no face is on the boundary 5
any edge between two boundary vertices is boundary 1
no quality test 11
last tuple entry read the wrong way 12
no retry 5
floor is min_quality alone 1
floor is the present quality alone 15
quality read on the mesh as given 1
no winding sign 2
every held corner tested 1
no corner tested 11
a tie is tested 1
message does not name the fault side 1
no inversion clause (after <= 0) 0
ruined cells counted over all cells 0

Each of the four new tests is failed by at least one mutant.

What stays unpinned

  • after <= 0 and the restriction of the count to the cells of the moved vertex: reachable only for a cell of zero area before the move or a non-positive min_quality. No test.
  • not shared in the boundary-edge test, the order of the flags in the MPI.MIN reduction, the sum of the ruined count and the minimum of the worst quality over ranks, and 8a: these can be pinned only on more than one rank. tests/parallel/ptest_0844_line_cut_parallel.py covers the seam and the refusals on every rank and has not been run at this head. It needs 2 to 5 ranks, with the not shared mutant for the seam test.

Runs at this head

  • tests/test_0844_line_cut.py and tests/test_0847_fault_api.py: 70 passed.
  • tests/test_0052_collective_guard_scan.py: passes.
  • 42 serial fault, placement and multigrid files: 412 passed, 1 skipped.
  • scripts/check_test_coverage.py: all 446 files reachable. The docs page builds clean.
  • Nothing on more than one rank.

Issue verdicts

Underworld development team with AI support from Claude Code

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 13, 2026

Copy link
Copy Markdown
Member Author

READY with conditions at 3584702. The new rule holds on 2 to 5 ranks, the seam clause is pinned by the parallel test, and no rank asymmetry was found in the two changes made after the third review round. The conditions are corrections to the PR text and one stated limit, listed at the end.

Parallel review of #1128

The runs were made by H1 (review and parallel test runs on a 96-thread Linux workstation: Intel Xeon Gold 6240R, AVX-512; MPICH). They use development 01dec8d with this branch's line_cut.py laid over it. The branch changes no other library file. Every MPI job ran under scripts/mpi_supervisor.py on 4 logical CPUs. np 5 is oversubscribed. Logs are kept by the reviewer.

1. The parallel test file, and the seam mutant

tests/parallel/ptest_0844_line_cut_parallel.py on this branch:

np Result
2 20 passed on every rank
3 20 passed
4 20 passed
5 20 passed

The PR body calls this file new. It is not. It exists on development with 16 tests, and this branch adds 4 to it. On development its 16 tests pass at np 2. Run against development's line_cut.py at np 2, the branch's file fails exactly its 4 new tests (16 passed), so each new test separates the branch from the base.

The seam case is exercised at every rank count. The test sends the corner cell to (across_rank + 1) % size and asserts that the two cells sit on different ranks.

The mutant was applied in memory by a pytest plugin that re-executes the module with and not shared[edge - pStart] removed from _face_is_on_the_domain_boundary. No file was edited.

np Failed with the mutant
2 test_a_seam_edge_between_two_boundary_vertices_is_not_the_boundary only (1 failed, 19 passed); every rank reports "no refusal"
4 the same test only (1 failed, 19 passed)

The seam clause is pinned, and nothing else in the file depends on it.

2. ptest_0844_reconnect_parallel.py

This is a different file. It tests reconnection repair (edge_split, reconnect) and does not call line_cut at all. Its text is byte-identical on the branch and on development.

At np 3 it gives the same result on both: 1 failed, 6 passed. The failure is test_adapt_with_repair_runs_in_parallel, on all three ranks, with the same assertion each time: "a parent-cell map survived a repair pass; a flipped cell spans two coarse cells and the transfer would read the wrong parent". This branch does not change the result. The failure belongs to development.

3. The two late logic changes: is_nearest and wound

Read. In the retry loop, every branch decision uses a reduced value or refused, and refused is built only from reduced values (where, n_ruined, worst). That covers both raises, the min_quality is None exit, the flag != 0 or is_nearest exit, and the not n_ruined exit. The branches that differ between ranks (candidates.size, held) only build local. Every rank reaches all three allreduce calls on every pass: the tuple, n_ruined, and worst after a reduced test. _face_is_on_the_domain_boundary runs on holding ranks only, and it uses only local queries (getJoin, getSupport). The two collective helpers, _true_wall_vertex_mask and _shared_points, are called unconditionally before the loop.

The loop terminates. The winning rank holds the refused corner at exactly the reduced coordinates, so each refused pass removes at least one candidate there.

[read] On the last tuple entry: distance and coordinates are functions of the vertex alone, so two ranks propose the same tuple prefix only when they propose the same vertex. MIN then returns note 0 ("test it"). When the ranks propose different vertices, the winner carries its own note. I found no reading in which a rank that would test is outvoted on the same vertex.

[read] On wound: it is read once from the input coordinates X, not from arr, so an earlier target cannot change it. On the DM that add_fault passes there is no overlap (measured below: the sum of local cells equals the global count at np 2 and 3), so each cell is on one rank. On an overlapped DM, a ghost cell has the same cone and bitwise-equal coordinates, so it gets the same sign. A cell whose input quality is exactly 0 gets wound = +1. That case sits under the after <= 0 clause, which the author already lists as unpinned.

[read] A pre-existing point, not in this diff: reconnect._shared_points returns early from a per-rank try/except around getGraph(), before its collective. A rank that raises there while its peers do not would hang them. This branch now reaches that helper from pull_vertex_onto. I did not reach the case.

Measured. An instrumented copy of the module, executed in memory, gathered each rank's proposal before every reduction. Targets were placed on and beside every partition-seam edge at np 2, 3, 4 and 5. Offsets were 0, ±3e-10, ±1e-9, ±2e-9, ±1e-6, ±0.02 and ±0.1 of the edge length, at 0.1, 0.3 and 0.5 along the edge. The meshes were a regular and an irregular 1/12 box and an annulus (inner radius 0.5, cell size 0.1). The same targets were then run serially.

  • 10 686 seam targets, 10 803 reductions. No hang. Every refusal was raised on every rank.
  • After every accepted pull, ghost and owner coordinates matched bitwise: the largest difference was 0.0.
  • 2 630 reductions had two or more ranks holding the target. In 31 of them the ranks read the face differently (an edge on one rank, a cell on another), which is the 8a case. In none did two ranks propose the same vertex with different notes. The note-tie path was therefore not reached in practice, but the differing reads were, and they gave no disagreement.
  • The retry path ran 117 times. It gave the same result at np > 1 as in serial.
  • A second sweep used 10 210 targets near interior edges of boundary cells, plus random points inside boundary cells, at np 1 to 5. Its outcomes were identical at every rank count: 0 differences from serial, and areas equal to 9e-16.
  • With every cell on rank 0 and the other ranks empty (np 2 and 3), five cases gave the serial results: a stand-in placement, the quality refusal, the no-interior-corner refusal, a target outside the mesh, and a deep interior target.

A pre-existing partition dependence. 52 of the 10 686 seam targets took a different vertex at np > 1 than in serial. Every one is on the perpendicular bisector of an edge (0.5 along it). There the two ends are at bit-identical distance, for example 0.0589255650989118 to both ends on the regular box. Within one rank, d.argmin() takes the first index in the cell's vertex order. Across ranks, MIN takes the lower coordinate. The two orders disagree, so the vertex chosen depends on the partition. All ranks still agree, so there is no hang and no torn mesh. development 01dec8d does the same (9 of 9 cases rechecked at np 2 and 3). The docstring calls such ties measure-zero. An edge midpoint is a natural control point, so they are not. Breaking the local tie on (distance, x, y), as the reduction does, would remove the dependence. That can be a follow-up.

4. The table of tolerances and coordinate matches

Checked against the diff. Every tolerance the diff adds or uses has a row, with two small gaps:

  • after < np.minimum(min_quality, before) also floors a cell at its present quality when that is below min_quality. The comparison is strict and has no tolerance, so a cell already below 0.1 that worsens by rounding counts as ruined. The docstring states this, but the table's min_quality row does not.
  • _minimal_face_vertices also has height < 0.5 * sqrt(area2) for surface meshes in three dimensions. This is kept, not added, but the "which face holds the target" row lists only the 1e-9.

The claim that the boundary is read from connectivity and the point SF, with no coordinate, is true. It holds only on a DM without overlap, which is the author's 8c and is now measured. On a DM with overlap 1 at np 2, wall faces in the overlap are shared, so _true_wall_vertex_mask and the edge test read them as interior. 91 of 2 376 targets on the regular box then moved a wall vertex for an interior target, for example a target at (0.025, 0.608) moved (0, 0.667). Serial on the same targets moved none. add_fault's DM has no overlap, so the fault path is not affected. pull_vertex_onto is a public function, though, and it gives no warning.

The three coordinate-identity rows. The follow-up can wait. Measured on every mesh and partition above:

  • Ghost and owner coordinates of shared vertices are bitwise equal, on input and after every pull: largest difference 0.0 at np 2 to 5.
  • The smallest distance between two distinct vertices, as a fraction of the extent, is 0.083 on the regular box, 0.063 on the irregular box and 0.033 on the annulus. That is about 10^10 times the 1e-12 tolerance.
  • The only vertices within 1e-12 of each other are the two copies of a split fault vertex, which are exactly coincident. Five such pairs exist after one fault in the regular box. The match hits both copies on every rank. Over 290 targets beside, on and past that fault, 10 accepted pulls moved both copies of a fault vertex (targets on the fault line). The results were identical at np 1, 2, 3 and 4, and a second fault beside the first was placed with area 1 at each.

So none of the three rows can pick a different vertex on different ranks today. One caution for the follow-up: if it swaps the coordinate match for one global vertex number, a target on a split fault will move one copy and open the fault. It has to carry the twin explicitly.

5. Serial counts

tests/test_0844_line_cut.py and tests/test_0847_fault_api.py on the branch: 70 passed. This matches the author's count. The 42-file serial sweep was not rerun.

Conditions

  1. Correct the PR body. ptest_0844_line_cut_parallel.py is extended (16 tests to 20), not new. "Nothing has been run on more than one rank" is out of date: the file passes at np 2 to 5, and the seam mutant fails exactly the seam test at np 2 and 4.
  2. State the overlap limit in the docstring, or refuse a DM with overlap. On an overlapped DM the boundary guarantee silently fails: 91 of 2 376 targets moved a wall vertex at np 2.
  3. Add to the table the floor at the present quality, and the surface-mesh height test, or say why they are left out.

Not blocking, for follow-ups: break exact distance ties locally on coordinates, so that the choice no longer depends on the partition (pre-existing); and when coordinates are retired for a global vertex number, carry the twin of a split vertex.

Not done

  • The 42-file serial sweep and test_0052_collective_guard_scan.py were not rerun.
  • No test in three dimensions or on a sphere surface.
  • The note-tie path of 8a (two ranks proposing the same vertex with different notes) was not reached by any probe, so it is pinned by reading only.

Underworld development team with AI support from Claude Code

The boundary is read from the edges that have one cell and are held by
one rank. In an overlap a boundary edge is held by two ranks and reads
as interior, so a target inside the mesh could take a boundary vertex:
on two ranks with an overlap of one cell, 91 of 2376 interior targets
did (cross-review of PR #1128), where none did on one rank.

The call now raises ValueError on every rank when any cell is held by
more than one rank. Mesh.dm has no overlap, so add_fault is unaffected.
One reduction is added, made on every rank before the first target.

tests/parallel/ptest_0844_line_cut_parallel.py gains
test_a_mesh_with_overlap_is_refused_on_every_rank. It has not been run
on more than one rank at this commit.

Underworld development team with AI support from Claude Code
@lmoresi

lmoresi commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

After the cross-review: b68e8eb

The cross-review at 3584702 (the comment above) cleared the branch with three conditions. What we did with each.

Condition Outcome
1. The PR body said the parallel file was new and had not been run. Corrected. The body now has a "Parallel runs" section with the cross-review's results: 20 of 20 on 2 to 5 ranks; 16 of the tests are on development, 4 are added here and fail with development's line_cut.py; the not shared mutant fails the seam test only, on 2 and 4 ranks.
2. The boundary read from connectivity is right only without overlap: with an overlap of one cell on 2 ranks, 91 of 2,376 interior targets moved a boundary vertex. Refused, not only stated. pull_vertex_onto now raises ValueError on every rank when any cell is held by more than one rank. The test is on the point star forest, with no tolerance, and adds one reduction made on every rank before the first target. Mesh.dm is distributed without overlap, so add_fault is unaffected. Docstring and docs say so. New test: test_a_mesh_with_overlap_is_refused_on_every_rank in tests/parallel/ptest_0844_line_cut_parallel.py.
3. Two rows missing from the tolerance table. Added: the floor where a cell is already below min_quality (its present quality, compared strictly), and the surface-mesh test of how far off a cell's plane a target may be (kept, not reached on a plane mesh). A row for the overlap test is added too.

The follow-up that replaces the three coordinate matches by a vertex number is described in the body with the cross-review's two findings: the number has to carry the twin of a vertex on a split fault, and an exact tie in distance is settled differently at different partitions today (52 of 10,686 targets, the same on development), which a DMPlex global number would not cure. We would break ties by coordinate order over the same candidate set on every rank.

Runs at b68e8eb

On macOS (12-core Apple M4), serial only.

  • tests/test_0844_line_cut.py, tests/test_0847_fault_api.py: 70 passed. tests/test_0052_collective_guard_scan.py passes with the new reduction.
  • scripts/check_test_coverage.py: all 446 files reachable.
  • Not run: anything on more than one rank. The refusal cannot be reached on one rank, so the new test and the 20 others in the parallel file need a rerun on 2 to 5 ranks, and the new test should be shown to report "no refusal" against 3584702's line_cut.py.
  • Not rebuilt: the docs page, after one added paragraph of plain text.

Review record row 8c ("overlap: not checked") is superseded by condition 2 above.

Underworld development team with AI support from Claude Code

@lmoresi

lmoresi commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

Re-check at b68e8eb: READY. All three conditions are met. The new overlap refusal is exercised in parallel and fires on every rank with the same message. It does not fire on a mesh without overlap. Measured by H1 (review and parallel test runs on a 96-thread Linux workstation (Intel Xeon Gold 6240R, AVX-512; MPICH)), on development 01dec8d with this branch's line_cut.py laid over it. Every MPI job ran under the supervisor.

ptest_0844_line_cut_parallel.py (now 21 tests):

np b68e8eb
2 21 passed
3 21 passed
4 21 passed
5 21 passed
  • The fixture assertion holds at every np: dm.distributeOverlap(1) gives ghost cells.
  • The seam test still passes, so the refusal does not touch the no-overlap mesh.

test_a_mesh_with_overlap_is_refused_on_every_rank against 3584702's line_cut.py: at np 2, 1 failed, with "ranks disagreed — ['no refusal', 'no refusal']". The test separates the two heads.

The refusal itself, probed directly on the same regular box at np 2 and 4:

  • On the overlap DM, every rank raises ValueError with one identical message: "pull_vertex_onto: the mesh is distributed with an overlap (some cell is held by more than one rank)…".
  • On the same mesh without overlap (Mesh.dm), the same target is accepted on every rank.
  • The process returns in both cases.

The fault path in parallel, at np 2, branch against 3584702:

test b68e8eb 3584702
test_1173 (add-on after a move) 7 passed 7 passed
test_1111 (cut of a moved child) 7 passed 7 passed
test_1135 (fac zone split, structural) 2 passed 2 passed

None of them is refused, which agrees with W1's reading that Mesh.dm and the fault meshes have no overlap.

Serial runs: test_0844 and test_0847 give 70 passed. test_0052_collective_guard_scan gives 5 passed with the new reduction. To run, it needs the source tree beside the tests: from a copy of tests/ alone it fails 2, which says nothing about the branch.

Conditions:

  1. The PR body now describes the parallel file as extended and gives the parallel results.
  2. The overlap limit is now a collective refusal, with a docstring paragraph and a test.
  3. The table has the floor at the present quality, the surface-mesh height test and the overlap test.

Attribution: every commit since 01dec8d ends with the repository line. There is no Co-Authored-By trailer, no model name and no emoji in the commits or the body.

The non-blocking follow-ups from the first review still stand: a local tie-break on coordinates at exact distance ties, and carrying the split-vertex twin if a global vertex number replaces the coordinate match.

Underworld development team with AI support from Claude Code

@lmoresi
lmoresi merged commit 70b240c into development Nov 13, 2026
10 checks passed
lmoresi pushed a commit that referenced this pull request Nov 13, 2026
line_cut.py met #1128's pull_vertex_onto, which reads each cell's winding
from the mesh as given and tests quality before and after each move. One
convention now serves both: the surface-mesh winding is voted once per call
over every rank (_global_flip) and passed to every _cell_quality reading,
in pull_vertex_onto as in the snapping loop; #1128's per-cell baseline is
read under it.

Underworld development team with AI support from Claude Code
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