Repository navigation
Exact point location on simplex meshes: barycentric coordinates and a face-crossing walk (#1123, register row 14) - #1175
Conversation
…ex meshes (#1123) [wip] On straight-sided simplex volume meshes, _robust_owning_cells finds the containing cell by barycentric coordinates and a walk across the face each point fails worst, from the cell of its nearest control point; a point still lost is walked again from its few nearest centroids. The only tolerance is SimplexLocator.ROUNDOFF, a guard on the dimensionless barycentric coordinates. A point several cells contain gets the lowest-numbered local cell in the star of the entity it lies on. The set of points a rank claims is unchanged: a point no local cell contains keeps today's face-tolerance claim, and points_in_domain, which the swarm's migration reads, keeps its boundary-sign test. Measured identical to development at np 2, 3 and 4 on random points, vertices and points 1e-9 to 1e-5 off vertices, 2-D and 3-D. Only evaluation classifies by the exact locator (exact_location=True), which fixes #1123: on its sheared 3-D mesh, points 1e-8 to 1e-4 from interior edges were wrong by up to 0.18 at 10 to 18 of about 1260; now every one is exact. Quadrilaterals, hexahedra and 2-manifolds keep the cell-wall test. Underworld development team with AI support from Claude Code
…960 item 3) The local evaluations inside global_evaluate_nd (the first pass and the containment round) run between collectives. A raise on one rank alone left the others waiting in the next one. _agreed_on_every_rank runs the step, reduces a failure flag, and raises on every rank: the failing rank its own error, the others a RuntimeError naming #960. A raise inside evaluate_nd before its own collectives (update_lvec, the locator) is not covered: that needs the collectives themselves to agree. tests/parallel/test_0960_global_evaluate_agrees_on_failure_parallel.py: rank 1 fails after its local evaluation; every rank raises. Development hangs (supervisor exit 124). Underworld development team with AI support from Claude Code
…in-star tie rule Underworld development team with AI support from Claude Code
…of reach or (serially) outside the mesh H1's timings found serial evaluation of mostly exterior points 50 to 65 % slower than development, although the walk itself was faster: every point the walk did not place went on to the 50-centroid face-tolerance search. - A point beyond every local cell's reach is not handed to it (it would reject it by the same reach test). - A lost point farther than twice the local cell reach from every local boundary face control point is not handed to it either (the tolerance cannot claim it). Rank-local. - For evaluation in serial, a lost point is tested with the face tolerance against the cell the walk left the mesh through only. In parallel the full pass decides, as for claims: near a partition seam another cell than the exit cell can meet the point (measured: up to 37 points per rank differ at np 2 to 4). Claims are unchanged (identical to development at np 2, 3, 4), and the evaluation mask equals the claim mask at np 2 and 4. 1e6 points, 7/8 outside a 3-D box, serial: evaluate 5.1 s against development's 6.5 to 7.1 s; _robust_owning_cells 5.1 s against 11.0 s. Underworld development team with AI support from Claude Code
|
Verdict: READY with conditions at d77bab4. The parallel review of #1175 is by H1 (review and parallel test runs on a 96-thread Linux workstation (Intel Xeon Gold 6240R, AVX-512; MPICH)). H3 reviews the general code and W1 reviews ownership and the swarm. This record covers parallel correctness only. Short version
The conditions are two small changes, items 2 and 3 below. Findings by severityMedium (already on development; not caused by this PR, but it limits what "exact" means in parallel)1. An interior point near a partition seam can be evaluated by a rank that does not contain it. Its value then depends on which rank asked.
Low2. The #1123 fix has no parallel test (condition 1).
3. The claim "points_in_domain identical to development" holds only on meshes without the #1123 problem (condition 2: correct the PR text and tell W1).
4. A test-side collective hazard in
5.
6. Empty rank.
7. In serial, the exit-cell shortcut and the full search disagree on 2 of 300 points 1e-6 outside the sheared box.
8. A degenerate cell disables the exact locator on that rank only.
For #1176 (not reviewed here)The locator answers "is this point in a local cell" exactly, and nothing more. A global in/out still needs a reduction over ranks on the same point set, at the same call on every rank. Union of exact containment works on this data:
The face-tolerance claim is not an in/out test. At np > 1, Partition independenceSetup
Main table, default partitioner. "extra claims (branch)" lists the points the branch claims and development does not, for strict, non-strict and
How to read it:
Other layouts: a shell partition that leaves the last rank empty, and random cell assignment with seeds 3 and 7. The other columns behave as in the main table.
How to read it:
Tests
#960 and its mutant
Existing parallel files, branch, np 2 and 4: all 18 files pass.
Collective audit
Rank-local
Lazy build and moversScript:
The errors before and after the moves are the same (3e-6 to 8e-6 at points 1e-6 from boundary vertices; exact elsewhere). What passed and what was not runPassed
Not run
Development arm
Scripts and logs are kept by the reviewer. Underworld development team with AI support from Claude Code |
…the tolerance comment) - tests/parallel/test_1123_exact_locator_parallel.py: on #1123's sheared mesh every inside point is owned by some rank at any rank count (development: 27, 6, 1, 1 inside points owned by no rank at np 1 to 4), exact serially. Also run in batch 3. - A rank with no cells gets an empty exact locator. The locator is chosen from mesh-wide facts only (isSimplex is agreed over ranks), so every rank takes the same path; _robust_owning_cells returns -1 there where development raised from the empty kd-tree (tested at np 3). - test_0761: the exact-locator branch is decided collectively before the collective classifier call; an empty rank's empty selection is handled. - The _EVAL_FACE_TOL comment says what the tolerance does: it does not make ownership unique near a partition seam (#1178). Underworld development team with AI support from Claude Code
Review record: does the ownership change break a consumer of point ownership?From the integration desk (the session that reviews solver, boundary-condition and fault-placement changes). A fresh reviewer read d77bab4 for this one question, and we checked its quotes there; 65eed15 arrived during the review and we read its diff only. Reading only, on macOS, 12-core Apple M4. Nothing was built or run; every count quoted is the PR's or the Linux-workstation desk's. Answer. We found no consumer that depends on the old loss of these points, no path in migration that duplicates a particle, no double-counted value in Findings
Probes that would settle 3, 4 and 5 (parallel; not ours to run)
Conditions
Not checked: periodic meshes; volume meshes given an overlap by option; the Cython handling of -1 hints; anything executed. Underworld development team with AI support from Claude Code |
|
Re-check of #1175 at 65eed15: both conditions met. READY on the review's conditions. From H1 (review and parallel test runs on a 96-thread Linux workstation (Intel Xeon Gold 6240R, AVX-512; MPICH)). The head's Python is laid over the d77bab4 build; the new commit changes no compiled file. W1's condition iii (the walk-cycling probe) is a separate run and follows. Condition 1: a parallel #1123 test.
Condition 2: the body. It now limits "identical to development" to unsheared meshes, gives the 3 to 52 extra claims on the sheared box, and says that swarm migration changes there. The other items:
One test-side note, not a condition. Under a shell partition that empties the last rank, Underworld development team with AI support from Claude Code |
…inside point (W1's review of #1175) - On #1123's sheared mesh the most violated face of a cell near the wavy boundary can be a boundary face although the point is inside, further along the wall: the walk left the mesh there and lost 7 of 2e5 contained points (no cycling: all seven exited through a one-cell face, the same with 10,000 steps). It now crosses the most violated face that has a neighbour, and stops as outside only when every violated face is on the local boundary: 0 of 2e5 on the sheared mesh, a 3-D box and an annulus. Serially, evaluation's exit-cell test relied on that. - tests/parallel/test_1123_exact_locator_parallel.py: points_in_domain(strict) owns every inside point at np 2 to 4, and a swarm seeded at them keeps every one through migration with lost points deleted (development: 6, 1, 1 owned by no rank). - test_1123: the walk alone finds every contained point on the sheared mesh. Claims stay identical to development on unsheared meshes at np 2 to 4; the serial exterior case is unchanged (5.3 s against development's 9.4 s at this load). Underworld development team with AI support from Claude Code
|
#1175: the walk-failure probe (the integration desk's condition iii), at 65eed15 against development c766bea. From H1 (review and parallel test runs on a 96-thread Linux workstation (Intel Xeon Gold 6240R, AVX-512; MPICH)). Question. Can the walk fail on a point a local cell contains, with the new Method.
The counts were the same before and after the Answer: no. Every contained point the branch fails to own, development fails to own too. The branch drops no point development claimed, and it owns 99.5 % or more of the points development loses. What remains, for the record.
Underworld development team with AI support from Claude Code |
|
Re-check at 3e49802 (integration desk; by reading the diff from 65eed15, nothing run). Conditions (i) and (ii) of our record are met: the body states the sign stage, the serial loss and the The walk hunk (
Condition (iii), the count of contained points the walk fails to place, is reported as 0 on three meshes with a test asserting it; the parallel re-run is the other desk's. The fault-cut walk stays open as listed. Underworld development team with AI support from Claude Code |
|
Code review, from the second review desk (session H3): READY at 3e49802. Run on a 96-thread Linux workstation (single system image; Intel Xeon Gold 6240R, AVX-512; MPICH) with a build of the head. H1's parallel review and W1's ownership review cover their own ground; this review is of the locator code and its claims. What I read.
The barycentric test, the walk, and the lowest-in-star table are correct for straight-sided simplices. The choice is made from mesh-wide facts ( Probes (scripts kept with the record):
Notes, not blocking.
Underworld development team with AI support from Claude Code |
|
#1175 at 3e49802: the walk probe again, and the integration desk's two Low items. From H1 (review and parallel test runs on a 96-thread Linux workstation (Intel Xeon Gold 6240R, AVX-512; MPICH)). The head's library Python is laid over the d77bab4 build; the walk fix is Python only. 1. The walk probe (method as in the 65eed15 post: 1e6 points contained by a local cell by construction, the same points on both builds).
The updated tests at 3e49802: 2. Item b: an outside point whose walk ends with no exit cell (serial).
3. Item a: points outside the local mesh, before and after the fix. 3-D box, 7/8 of 1e6 points outside, best of 3:
The machine was under load, so these carry about ±15 %. No cost from sliding along the boundary shows at this size. Step counts were not instrumented. Underworld development team with AI support from Claude Code |
|
Correction to H1's two walk-probe posts on #1175: the "doubled shear" mesh is folded.
Underworld development team with AI support from Claude Code |
…'s one start dependence in the locator's docstring (H3) Underworld development team with AI support from Claude Code
…epend on the start (H3's review) Underworld development team with AI support from Claude Code
…fallback tested directly The sheared fixture was gmsh's box with #1123's shear and sine terms of amplitude 0.03. gmsh builds differ (1094 cells on macOS against 1086 on Linux), and on one macOS build a cell was turned over, so the locator tests had no right answer. tests/parallel/sheared_box_fixture.py (from #1213): a structured box of cubes split into six tetrahedra, independent of gmsh, with the sine amplitude at 0.025: the sine gradient's norm (2 pi 0.025 = 0.157) is below the linear shear's smallest singular value (0.175), so the map is invertible, and the fixture asserts, collectively, that no cell turned over. test_1123 (serial and parallel) and test_1183 use it. Regression power on it: before #1175, test_1123 fails at np 1, 2 and 4 (116 to 125 inside points classified exterior per distance; 392, 47 and 10 owned by no rank). #1183's 2 per million lived in near-degenerate cells of one gmsh build and no valid fixture reproduces them; test_1183 tests the fallback directly instead: with the walk forced to miss every point, the fallback must find them all, which before #1190 loses 1200 to 1427 of 2e4. Underworld development team with AI support from Claude Code
…claims agree with global_evaluate points_in_domain, which a swarm's migration reads, decided a point far from the local boundary by a boundary-face sign test standing in for containment (Style Charter section 12). On underworldcode#1123's sheared mesh it called contained points exterior: serially 449 of 3825 near-edge points, and at np 2 one inside point owned by no rank, whose particle a swarm then lost, while global_evaluate's ownership (the exact locator, underworldcode#1175) had it. On a straight-sided simplex mesh a point is now in a rank's domain when a local cell contains it; a point no local cell contains takes the face tolerance development applied near the boundary (the evaluation tolerance in parallel, the cell-wall test's own serially), and only within 2 max_radius^2 of the local boundary, as before. Claims change only by contained points: on unsheared 2-D and 3-D boxes and an annulus, the strict claims (migration's) are identical to development at np 1, 2 and 4, and serially every variant is. A swarm in solid rotation on an annulus keeps all 15200 particles over 20 steps at np 1, 2 and 4, as on development. tests/parallel/test_1209_points_in_domain_exact_parallel.py (with the structured sheared box, tests/parallel/sheared_box_fixture.py): development leaves 449 and 1 inside points in no domain at np 1 and 2; none here, and a swarm keeps every one. Underworld development team with AI support from Claude Code
Fixes #1123. Replaces #1117's interim tolerance on simplex meshes (register row 14). Covers #960 item 3. Based on development with #1158.
What changes. On straight-sided simplex volume meshes, the cell that evaluates a point is found exactly:
SimplexLocator.ROUNDOFF = 1e-12, a guard on those dimensionless coordinates, named once.The two pieces are in
discretisation/_simplex_locator.pyandMesh._simplex_locator/_walk_to_owning_cells.Quadrilaterals, hexahedra and 2-manifolds keep the cell-wall test, as the plan says. They follow with an inverse map.
Barycentric against the face-pair test (plan step 1): measured per point on 1e6 points, warm, serial, on a 96-thread Linux workstation (single system image; Intel Xeon Gold 6240R, AVX-512; MPICH).
Both are exact. Barycentric is about 2.1 times faster.
What a rank claims does not change.
_robust_owning_cells.points_in_domain, which swarm migration reads, keeps its boundary-sign test. In parallel its later stages (_eval_use_robust_location, strict validation) call_robust_owning_cells, which this PR changes. Serially they do not._classify_points_in_domain(..., exact_location=True), passed byevaluate_nd)._robust_owning_cells >= 0andpoints_in_domain(strict and not) are identical to development on every rank, on these unsheared meshes.points_in_domainagree with the locator, and starting the walk from a particle's previous cell, is the swarm PR that comes next.#1123. On its sheared 3-D mesh, development (with #1117) gets points 1e-8, 1e-6 and 1e-4 from interior edges wrong by up to 0.18: 10, 12 and 18 of about 1260. They are classified exterior and filled by RBF. On this branch every one is exact (< 2e-15).
Empty ranks. The locator is chosen from mesh-wide facts only (
isSimplexis agreed over ranks at construction). A rank with no cells gets an empty locator that returns -1, so every rank takes the same path. On development,_robust_owning_cellsraised on such a rank ("An error was encountered attempting to find the closest cells"); here it returns -1. That is tested at np 3, and fails on development.#960 item 3.
global_evaluate_nd's rank-local steps (the first pass and the containment round) agree on failure before the next collective. Every rank raises: the failing rank its own error, the others a RuntimeError naming #960. Development hangs (supervisor exit 124). A raise insideevaluate_ndbefore its own collectives is not covered.Cost.
_robust_owning_cells)evaluateglobal_evaluateevaluatewent from 7.0-7.5 s to 11.2-11.8 s. Every point the walk did not place went on to the old 50-centroid face-tolerance search.2.0 * _local_cell_reachfrom every local boundary face control point: a claim needs the point within the tolerance slab of a local face, which lies within the face's size of its control point. The test is rank-local.evaluateagainst development's 6.5 to 7.1 s, and 5.1 s for_robust_owning_cellsagainst 11.0 s. With the full search kept in parallel, the evaluation mask equals the claim mask at np 2 and 4.evaluate: about 22 % cheaper per located point, 10.6 → 8.2 µs at np 1 and 2.7 → 2.1 µs at np 4.The single-rank mover path differs from development's from the first move, and why. H2 found 566 locator calls against 497, and a minimum radius of 4.426e-3 against 4.207e-3 after three moves; both are deterministic on one rank. I traced every
evaluateand locator call of the first move on both builds:The first difference is a cell choice, not a value. In call 0, 9,853 of 11,665 points get a different owning cell. Every one lies on a shared vertex or face (a barycentric coordinate within 1e-12 of 0), and both cells contain it. That is the tie rule: the lowest cell in the star, where development took the containing cell with the nearest centroid.
The values agree to round-off. Where the cell changes, values differ by at most 6.75e-14 on a field of scale 22. In calls 3 to 9, the most is 3.4e-13 on a scale of 64. No value differs where the cell is the same.
The inputs then diverge. They first differ at call 10, by 2.7e-14 in a coordinate, and the paths separate from there.
The mover amplifies round-off of that size on its own. Perturbing development's
evaluateoutputs in calls 0 to 9 by 3e-15 relative (applied changes of 2e-13 to 7e-13) moves development's own path more than the branch does:So the 5 % difference in minimum radius after three moves is the mover's sensitivity to round-off, which development shows by itself. It is not a value the locator gets wrong. Under Louis's rule, a different owning cell on a shared entity with the same value to round-off is expected.
The single-rank wall time, 374 s against 338 s, is not re-timed yet. The machine has not been quiet: its load has been 18 to 27 throughout. The mover's step count follows the path. Development's own run takes 510 or 594
evaluatecalls in one move depending on round-off of 2e-13 (+16 %). H2 measured less time inevaluateon the branch. So the extra wall time is consistent with a path that takes more mover steps, not with a slower locator. A quiet re-time is open and will be added here.Tests.
tests/test_1123_exact_locator_simplex.py:All fail on development.
tests/parallel/test_0960_global_evaluate_agrees_on_failure_parallel.py: hangs on development; passes at np 2 (H1: np 2, 3, 4, 8, and it hangs under the no-agreement mutant).tests/parallel/test_1123_exact_locator_parallel.py: on Strongly sheared 3-D simplex meshes: the point locator's 50-centroid walk misses the containing cell and evaluate returns RBF values off by up to 0.17 #1123's sheared mesh every inside point is owned by some rank (development: 27, 6, 1 and 1 owned by none at np 1 to 4). It is exact serially, and a rank with no cells returns -1 instead of raising. It runs in batch 3 and under--p N.test_0761: two tests encoded the cell-wall path and are rewritten for the exact locator:Run here:
Left open (not in this PR).
global_evaluateis off by up to 1.1e-3 at np 4, against exact serially. Development does the same. The fix is the follow-up: claim by exact containment first.query.shape[0] > 100assertion; this exists on development.UWTN 2026-009. The note describes a kd-tree of control points with face pairs, retrying from the next-nearest control point. This PR keeps the control-point kd-tree for the start cell and replaces the face-pair test and the retries with barycentric coordinates and a face-crossing walk, on simplex meshes. The note would want an update; that is Louis's.
Reviews: H3 (it wrote #1117); W1 checks ownership and the swarm; H1 runs parallel.
Checklist (UW3 Style Charter — docs/developer/UW3_STYLE_CHARTER.md)
level_*andtier_*markers (S8)maybe_/try_/do_) and no commented-out code (S3, S4).array/mesh.X.coords— nowith ....access(...), nomesh.data(S7)pixi.toml/pixi.lockor other dependency changes riding in an unrelated PRUnderworld development team with AI support from Claude Code