Repository navigation
Facet restore: one answer on every rank, from the whole mesh's boundary (#1176) - #1192
Conversation
H1's case: an annulus moved by deform, walls at 0.45 and 0.90. On development at np 2, 3 and 4 the same query points are restored differently on different ranks, and interior departure points of an exact rotation are moved onto a wall (20, 11, 16 and 18 by rank at np 4). The serial file pins the serial answer and the exactness of the bounded nearest-facet search. Underworld development team with AI support from Claude Code
) Each rank gathers the boundary facets of every rank, in rank order, so a point gets the same answer whichever rank asks. The rebuild is agreed over ranks, so a rank whose own coordinates did not change still takes part in the gather. The nearest-facet search is bounded by the nearest centroid plus the largest facet radius. The bound is exact: the serial answer is unchanged bit for bit. It keeps the cost of searching the whole boundary near or below development's per-rank search (measured in the PR). Underworld development team with AI support from Claude Code
Code review at fec6d95From W1, the integration desk (solver and mesh-surgery code). Scope: the code. The parallel runs are with H1 (the parallel review desk); nothing here was run on more than one process. Built at fec6d95 and run on macOS, 12-core Apple M4, one process. Verdict: no blocking finding in the code. Three small changes asked for (1 to 3), two notes (4, 5), and one defect that predates the branch and is not in its scope (6). What was checked and holdsOne process is unchanged, bit for bit. The restore against the previous code (nearest point over every facet, then the same side test), about 5,000 points per mesh: inside, outside, up to 30 domain widths away, on facet vertices and on facet centroids.
The second row has as many facets as the first query asks for (16), so it runs the "every facet" exit of the loop. The bound is not a tolerance. By reading: the nearest point is no farther than the nearest centroid ( The restore was already collective. Findings
Section 12
Open issues in this territory
Not checked
Underworld development team with AI support from Claude Code |
…ests start at tier B (the integration desk's review) Underworld development team with AI support from Claude Code
|
The integration desk's three points, at 604dd3e:
Docstring and markers only; no code path changed, so nothing was rerun beyond the coverage check (all 467 files reachable). The corner side-test defect from the same review (normal taken from the nearest-centroid facet, not the facet the search found) will be a separate small PR after this one merges. Underworld development team with AI support from Claude Code |
No conflicts. Underworld development team with AI support from Claude Code
|
Verdict: READY at fec6d95, and at 604dd3e. The head moved during the review to 604dd3e, which adds a docstring paragraph saying the facet restore is collective, and moves the two new test files to tier B. No code changed, so these runs stand for it. The dev hub's three checks pass, and so do the issue's own probes at np 1, 2, 4 and 8. The new tests pass at np 2 to 6, and 17 related parallel files pass at np 2 and 4. Two notes below need no change before merge. Parallel review of #1192 (fixes #1176)This is the parallel review by H1 (review and parallel test runs on a 96-thread Linux workstation (Intel Xeon Gold 6240R, AVX-512; MPICH)). The integration desk (W1) reviews the code. What was run.
Check 1: points within round-off of a facet at a partition seamConstruction.
Branch (fec6d95). Every row gives the same result:
Coordinates against np 1. These are not always bit-identical, and the cause is a tie, not a parallel disagreement:
Development, same points.
Check 2: the gathered facets after the geometry changesSequence.
The second change is one of three:
Reference: a fresh mesh moved directly to the same coordinates. Branch. All 19 runs pass: {deform, write} × {scale, local, translate} × {np 1, np 4, band np 4}, plus
Development, same runs.
Note (not introduced by this PR, no change needed).
Check 3: the gather's size and time on a 3-D shell at np 8Setup.
The bounded search against the full search (serial, extra)Setup.
Result. The bounded search returned the full search's nearest point bit for bit on every point, in 3-D and in 2-D (0 differences). The issue's probes, before and after
Development reproduces #1176's table exactly. On the branch:
Tests (branch)
Skips:
The 17 files:
Collectiveness. The restore is now collective. Every library caller (swarm advection's midpoint and position clamps, the semi-Lagrangian trace-back and inflow clamp, the free-surface solver) calls it on every rank, with or without points. The emptyband run and the PR's no-points case both pass. What passed
Not run
Underworld development team with AI support from Claude Code |
No conflicts. Underworld development team with AI support from Claude Code
…lies The side test took its outward normal from the facet whose centroid is nearest the nearest boundary point. Where the two walls' facets at a corner differ in length, that is the other wall's facet, and points just outside were left there (the integration desk's review of underworldcode#1192: 10 of 49 beside a graded box corner). The nearest-point search now returns the facet it found. Inside that facet the normal is the facet's; at a vertex, or a 3-D edge, where several facets meet, it is their angle-weighted (vertex) or plain (edge) sum, so a point beyond a corner is also returned inside, off both walls. Underworld development team with AI support from Claude Code
Fixes #1176.
What changed and why
On a deformed mesh, and on every mesh read from a file,
Mesh.return_coords_to_boundsis the facet restore (_facet_return_coords_to_bounds). The semi-Lagrangian trace-back clamps its midpoints and departure points with it, and swarm advection clamps its midpoints and new positions with it. Each rank tested a point against the boundary facets it held itself, so at more than one rank the answer depended on which rank asked:Now each rank gathers the boundary facets of every rank, in rank order, and tests and restores against those. Every rank holds the same arrays, so a point gets the same answer whichever rank asks, bit for bit between the ranks of one run. Against a one-rank run of the same mesh it agrees to rounding: the integration desk's review found up to 53 of 5,200 points differing in the last bit, by at most 5.6e-17. Two further points:
allreduceof a flag per call. The method's docstring now says it is collective: every rank calls it, with or without points of its own. Every caller in the library already does.d1. Any facet holding a point that near has its centroid withind1plus the largest centroid-to-vertex distance. Only those facets are searched, in ascending index order. The bound is exact: the nearest point, and the facet taken on a tie, are those of the search over every facet, bit for bit (tested).What a user's run sees.
deform.How the in/out decision is made. The ruling was to decide in or out with the global locator, never the asking rank's own facets. This uses the side test, against the outward normal of the facet nearest the point, but over the whole mesh's boundary. On one rank that is the test that was already correct in #1176's measurements. It meets the ruling's requirement that the answer depend only on the point and the whole mesh.
The exact locator (#1175) answers which of a rank's own cells holds a point. Asking it about a point held on another rank would mean sending every point to every rank (a swarm migration) on every call, and it would bring the seam double claims of #1178 into the restore. If the integration desk wants the locator here anyway, say so and I will measure it.
Measurements
All on a 96-thread Linux workstation (single system image, Intel Xeon Gold 6240R, MPICH). Development is at f12d112.
Regression (H1's case, written first). An annulus with radii 1 and 0.5 moved by
deformto 0.9 of its size, so the walls are at 0.45 and 0.90.3-D (script, not in the suite). A spherical shell, cell size 0.2, moved by
deformto 0.9. 1600 interior points and 400 beyond the outer wall, at np 1, 2, 4 and 6: identical on every rank and at every rank count, no interior point moved, and the outside points at radii 0.8890 to 0.8999.Cost. One
deform, then one restore of every local mesh node scaled by 1.02. Best of 3, maximum over ranks.Tests
tests/parallel/test_1176_facet_restore_agrees_across_ranks_parallel.py(level 1, tier a). Three cases:It runs in the parallel phase of
scripts/test.sh(thetests/parallelglob).tests/test_1176_facet_restore_whole_boundary.py(level 1, tier a). Serial:The fixture passes on development as well, since serial was already right there. The exactness cases need the new function. A mutant that drops the facet radius from the bound fails both exactness cases.
What was run
level_3, 5 workerstests/test_0052_collective_guard_scan.pyscripts/check_test_coverage.py,scripts/check_deprecated_patterns.pyNot run
level_3, and macOS.Left open
All_Boundarieslabel falls back to the topological boundary search. That search also returns partition faces, which the gather now carries to every rank. Every constructor and the gmsh reader set the label, so this needs a mesh built some other way. It is markedTODO(BUG)in_boundary_facet_geometry.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(S7): not applicable. The oneself.dataread in_boundary_facet_geometrypredates this PR and is unchanged.allreduceand the gather on every call that rebuilds; np 2 to 6pixi.toml/pixi.lockor other dependency changes riding in an unrelated PRReviews: the integration desk (W1) for the code; H1 (the parallel review desk) for the parallel runs.
Underworld development team with AI support from Claude Code