Repository navigation
points_in_domain uses the exact locator on simplex meshes: a swarm's claims agree with global_evaluate - #1213
Conversation
…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 #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, #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
Underworld development team with AI support from Claude Code
Code review (W1, the integration session; read at 74164de, not run)The change is sound. Swarm claims now rest on containment, as Charter §12 asks. The measurements answer the three questions asked of this review. Four points, none blocking; 1 and 2 are documentation the change makes stale. 1. On a simplex mesh
2. The 3. Cost. At np 4, +0.4 s per million points is the price of walking foreign points that are within reach of a rank's cells. That is acceptable for the correctness it buys.
4. Claims on an unsheared mesh. Your identical-at-np-1/2/4 result covers the case I would have checked: a point on a partition face, or in a cell another rank also holds as a ghost, where the walk could claim on two ranks. It shows the walk claims no point that development's
Underworld development team with AI support from Claude Code |
… mean on a simplex mesh (W1's review) 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)) Verdict on head d106c7d: ready to merge on green from this review (parallel runs; the code review is the integration lead's). The runs below were made on 74164de; d106c7d changes only docstrings in Every claim I could check holds, with two corrections, both in the branch's favour:
The np 4 cost is a little higher in 2-D than the PR body reports. Build. The diff is Python-only. Its merge base is eccae6d, development at the time of the run. I used an installed build whose compiled sources are identical to eccae6d's. Two overlays went over it: development (eccae6d) and the branch (74164de). Each run printed Strict claims on unsheared meshesThe meshes were a 2-D box (cell 1/32), a 3-D box (cell 1/8) and an annulus (cell 1/16, radii 0.5 to 1). Every rank was offered the same point set, about 1.03e5 points:
I compared per-rank
On these meshes the strict claims are identical, as claimed, with no inside point unowned on either tree. Finding 1: development loses contained points on a finer 3-D box; the branch does not. I also offered the full 1e6-point timing set to every rank on the timing meshes. These are a 2-D box at 1/96 and a 3-D box at 1/20, with points all inside or half outside.
Every mismatch is a point the branch claims and development does not. Each is contained in a local cell by a brute-force barycentric test, with a barycentric margin up to 0.22, so none is near a face. Development's strict claims put each of these points on no rank, and the branch puts each on exactly one. A swarm confirms it. At np 4, the 140 points added from rank 0 with
So on an unsheared gmsh box, development's sign test already loses particles at np 4. The PR body's "identical to development at np 1, 2 and 4" holds on the meshes it measured, but not in general. Its other statement, "claims change only by contained points", holds everywhere I looked. The body could say so: the fix is not specific to sheared meshes. Non-strict variant (
|
| np, rank | dropped | contained locally | contained by another rank | outside the domain |
|---|---|---|---|---|
| 2, r0 | 162 | 0 | 108 | 54 |
| 2, r1 | 42 | 0 | 36 | 6 |
| 4, r0 / r1 / r2 / r3 | 3 / 287 / 7 / 1 | 0 | 3 / 169 / 5 / 1 | 0 / 118 / 2 / 0 |
Finding 2. No dropped point is contained locally, and no inside point is left owned by any rank. My counts are larger than the PR body's (1 to 20 per rank) because my point set includes the 10% pad outside the box. Some of the dropped points lie outside the domain, up to 0.099 beyond the box faces. Development's non-strict variant claimed those exterior points by the sign test, so dropping them is a fix. The body's "each is still claimed by another rank" holds for the inside points only.
Sheared box (the PR's fixture)
The point set is the test's own: 5,562 points near edge midpoints, 4,573 of them inside by brute force. "Missed" means inside and in no rank's domain.
The swarm columns:
- added: a swarm seeded at the inside points from rank 0, migrated with lost points deleted;
- re-seeded: a swarm populated at fill 3, every particle then moved to a random inside point and migrated.
| np | tree | missed (strict) | missed (non-strict) | swarm, added | swarm, re-seeded |
|---|---|---|---|---|---|
| 1 | dev | 449 | 392 | 4,124 / 4,573 | 20,087 / 22,254 |
| 1 | branch | 0 | 0 | 4,573 / 4,573 | 22,254 / 22,254 |
| 2 | dev | 1 | 1 | 4,572 / 4,573 | 23,675 / 23,678 |
| 2 | branch | 0 | 0 | 4,573 / 4,573 | 23,678 / 23,678 |
| 4 | dev | 0 | 0 | 4,573 / 4,573 | 24,587 / 24,587 |
| 4 | branch | 0 | 0 | 4,573 / 4,573 | 24,587 / 24,587 |
This reproduces the 449 and the 1. On the branch no point is lost at any np. The exterior points claimed under the face tolerance (11 serially, 666 to 667 in parallel) are the same on both trees.
Advection
Solid rotation on an annulus: cell 1/16, populate fill 3, 20 steps of 0.05, second-order advection.
| np | dev: start / min / end | branch: start / min / end | 20 steps, dev → branch |
|---|---|---|---|
| 1 | 15,200 / 15,200 / 15,200 | 15,200 / 15,200 / 15,200 | 1.09 → 0.64 s |
| 2 | 15,200 / 15,200 / 15,200 | 15,200 / 15,200 / 15,200 | 0.92 → 0.68 s |
| 4 | 15,200 / 15,200 / 15,200 | 15,200 / 15,200 / 15,200 | 0.67 → 0.54 s |
The count held at every step, and the particle radii stayed within [0.502, 0.998].
Cost
points_in_domain(strict_validation=True) on 1e6 points in total. At np 4 each rank takes a quarter of one global uniform set. The mesh sizes are the PR's: 2-D box at 1/96, 3-D box at 1/20. "Half outside" draws the points from a centred box of twice the volume. Each run does a warm-up call, then I take the best of 3 of the maximum over ranks.
| case | np 1: dev → branch | change | np 4: dev → branch | change |
|---|---|---|---|---|
| 2-D, all inside | 2.81 → 1.51 s | −46% | 0.42 → 0.53 s | +24% |
| 2-D, half outside | 2.06 → 2.19 s | +6% | 0.36 → 0.55 s | +51% |
| 3-D, all inside | 9.39 → 2.15 s | −77% | 1.52 → 1.76 s | +15% |
| 3-D, half outside | 10.76 → 10.81 s | +0.5% | 1.54 → 1.93 s | +25% |
The three repeats agreed within 5%. The shape matches the PR body:
- serially, interior points are 1.9 to 4.4 times cheaper, and half-outside costs the same;
- at np 4 the branch costs more.
In 2-D at np 4 the increase is +24 to +51%, against the body's +30 to +57% on its own ratios. The absolute increase is at most 0.4 s per million points. Given finding 1, part of that time buys answers development got wrong.
Empty rank
np 3, with a shell partition that leaves the last rank without cells. Rank 1 was also given an empty input to one strict call. I ran the 2-D box, the 3-D box and the annulus, each with:
- strict and non-strict calls on 2e4 random points;
- a swarm populated at fill 2, then migrated (boxes) or advected 3 steps (annulus).
| mesh | cells per rank | dev | branch |
|---|---|---|---|
| 2-D box | 315, 299, 0 | 4,070 claimed, 0 multiply; swarm 3,684 → 3,684 | identical |
| 3-D box | 561, 525, 0 | 1,925 claimed, 0 multiply; swarm 10,860 → 10,860 | identical |
| annulus | 760, 760, 0 | 9,693 claimed, 0 multiply; swarm 9,120 → 9,120 | identical |
No hang, and the results are identical. The sheared fixture builds its mesh with createFromCellList, not gmsh, so the partition hook does not apply to it. The sheared box was not run with an empty rank.
Tests
tests/parallel/test_1213_points_in_domain_exact_parallel.py, underpytest -s -rA --with-mpi:- branch: passes at np 1, 2 and 4;
- development: fails at np 1 ("449 inside points in no rank's domain") and at np 2 ("1 inside points").
- Neighbours on the branch:
- serial files: test_0068, test_0113, test_0116, test_0530, test_0784 (
global_evaluate), test_0810 and test_1123; - parallel files: test_0756, test_0760, test_0777, test_0786, test_0960, test_1076, test_1093, test_1123 (parallel), test_1175 and test_1183.
- Serially, all files: 45 passed, 26 skipped (MPI-only cases). The parallel files again serially with
--with-mpi: 13 passed, 25 skipped (minimum rank count). - The parallel files at np 2: 33 passed, 5 skipped on each rank, 0 failed.
- serial files: test_0068, test_0113, test_0116, test_0530, test_0784 (
Not run:
- the full serial or parallel suites, and the coverage gate;
- the neighbours at np 4;
- the new test on development at np 4;
- the sheared box with an empty rank (the hook does not apply);
- timing at np 2.
All logs and scripts are kept by the reviewer.
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
…el test runs serially too (H1's review) On the structured fixture the walk from the nearest control point's cell loses no point even without the boundary-following rule, so that test pins the guarantee but no longer the rule. test_the_walk_from_boundary_cells_and_its_recovery starts every point at a random boundary cell: the walk returns only containing cells, every point it loses left through the boundary, it loses fewer than 0.1 % (54 of 2e5), and the restarts and exact fallback place every one. With the walk crossing the most violated face even when it is a boundary face (the rule before), it loses 1232 and the test fails. test_1123_exact_locator_parallel: since #1213 points_in_domain is exact serially too, so the swarm test no longer skips at np 1; docstrings updated. Underworld development team with AI support from Claude Code
points_in_domainuses the exact locator on straight-sided simplex meshes, so a swarm's claims agree withglobal_evaluate's ownership. This is the swarm follow-up #1175 named, and Style Charter section 12's rule: no boundary-face sign test standing in for containment.The defect.
points_in_domain, which a swarm's migration reads, decided a point far from the local boundary by the sign of the nearest boundary face's control point. Only points near the boundary were checked against cells. On #1123's sheared mesh the sign test calls contained points exterior. Measured on the structured sheared box (tests/parallel/sheared_box_fixture.py), at points 1e-8 to 1e-4 off every edge midpoint:global_evaluate(exact locator, Exact point location on simplex meshes: barycentric coordinates and a face-crossing walk (#1123, register row 14) #1175) owns it.At np 2 that point is in a cell of rank 0's own, and the exact locator finds it. But it is farther from rank 0's boundary (dist² 7.9e-3) than
2·max_radius²(6.7e-3), so only the sign test was consulted, and it said outside.The fix (
Mesh._classify_points_in_domain).2·max_radius²of the local boundary. In parallel that is the evaluation tolerance (_EVAL_FACE_TOL); serially, the cell-wall test's own.Claims change only by contained points. Measured on unsheared meshes (a 2-D box, a 3-D box, an annulus), with random points, every vertex, and points 1e-9 to 1e-5 off vertices:
strict_validation=True): identical to development at np 1, 2 and 4;Points just outside the domain boundary (W1's case). 400 points on the x = 1 wall of a 2-D (1/24) and a 3-D (1/8) box, moved outward by a gap from 1e-7 to 1e-4. Claims are identical to development at every gap, and no point is claimed twice:
That serial/parallel difference was already on development, and this PR keeps it.
Double claims dropped. The 1 to 20 non-strict points per rank no longer claimed (above) were claimed twice on development: its non-strict path took the boundary sign without a cell check. One claim per point, by the rank that contains it, is the intended semantics (W1's review).
Swarm migration. A swarm in solid rotation on an annulus (cell size 1/16, populate fill 3, 20 steps of 0.05, second-order advection) keeps all 15,200 particles at every step, at np 1, 2 and 4. That is the same as development; the 20 steps are slightly faster (6.2, 4.0 and 2.5 s against 7.7, 4.8 and 2.9 s).
Cost.
points_in_domainon 1e6 points in total, 1/96 2-D and 1/20 3-D boxes, development → this branch, at a machine load of about 14:Serially, interior points are 1.8 to 4 times cheaper. At np 4 most points are foreign to each rank. A foreign point within reach of a rank's cells is now walked to an exact answer where development took the sign, which costs up to +0.4 s per million.
Tests.
tests/parallel/test_1213_points_in_domain_exact_parallel.py, tier B, on the structured sheared box (added here; the fixture PR builds on it):points_in_domain(strict);Development fails at np 1 (449) and np 2 (1). It passes at np 1, 2 and 4, and runs in batch 3 and under
--p N. Also run:Measured on a 96-thread Linux workstation (single system image; Intel Xeon Gold 6240R, AVX-512; MPICH). W1 reviewed the code (comment 6909604089); the docstrings of
points_in_domainand_classify_points_in_domainnow say whatstrict_validationandcellsmean on a simplex mesh. H1 runs it in 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)get_max_radiusis still reached first on every rank; the rest is rank-local; np 1, 2, 4 checkedpixi.toml/pixi.lockor other dependency changes riding in an unrelated PRUnderworld development team with AI support from Claude Code