Skip to content

evaluate uses the cell that contains a point before any face tolerance (#1115) - #1117

Merged
lmoresi merged 3 commits into
developmentfrom
bugfix/evaluate-strict-cell-first-1115
Nov 13, 2026
Merged

lmoresi merged 3 commits into
developmentfrom
bugfix/evaluate-strict-cell-first-1115

Conversation

@lmoresi

@lmoresi lmoresi commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

evaluate is exact near edges and vertices on simplex meshes. Fixes #1115.

This changes what evaluate returns near edges and vertices, so it needs a register row, and Louis's sign-off on the table below, before it merges.

What was wrong

Mesh._robust_owning_cells gave each point the first cell it tried, the one of its nearest control point, whenever the point was within the 1e-2 face tolerance of that cell. A point just inside the neighbouring cell, within that tolerance of the face they share, was therefore evaluated in the wrong cell. The box clamp in DMInterpolationEvaluate_UW then put it on the shared face.

The error is about |∇f|·δ for a point at distance δ, for any field, including fields the element represents exactly.

History. The face tolerance and this acceptance date from 2026-05-28 (c52201b, "parallel locator hardening", and 1419c4f). The tolerance was chosen so that a rank admits genuinely-on-face and partition-seam points without claiming points other ranks own. #1014 (register row 6, "reasonable tolerance") did not touch this path, so the defect predates that row.

The change

_robust_owning_cells now locates in two passes:

  1. A cell that contains the point to rounding gets it. _EVAL_CONTAIN_TOL = 1e-10 multiplies the containment test's fixed 1e-3 offset, so in effect it admits points up to 1e-13 model units outside a face, independent of the cell size.
  2. Only a point no local cell contains is given the face tolerance, as before. _EVAL_FACE_TOL = 1e-2 works out the same way: 1e-5 model units outside a face, whatever the cell size.

So the set of points a rank claims is unchanged. Point ownership, points_in_domain and swarm migration are untouched (#1107 is not undone). Only which of a rank's own cells evaluates a point changes.

Before and after

The case is from H1's report on #1115 (H1 is the worker session, running on a 96-thread Linux workstation: single system image, Intel Xeon Gold 6240R, AVX-512, MPICH). It uses a 1/16 simplex box and exact P1 linear and P2 quadratic fields, run serially.

query points development P1 development P2 this branch P1 this branch P2
exactly at interior vertices 8.9e-16 2.7e-15 8.9e-16 2.7e-15
vertex + 1e-9 4.2e-9 (125/276 wrong) 4.7e-9 8.9e-16 2.7e-15
vertex + 1e-7 4.6e-7 (150/276) 4.8e-7 8.9e-16 3.6e-15
vertex + 1e-6 4.0e-6 (137/276) 4.5e-6 1.8e-15 2.7e-15
vertex + 1e-5 4.4e-5 (85/276) 4.9e-5 1.3e-15 2.7e-15
vertex + 1e-4 2.3e-5 (9/276) 3.8e-5 1.8e-15 2.7e-15
edge midpoint + 1e-6 4.6e-6 (246/889) 5.1e-6 1.3e-15 2.7e-15
edge midpoint + 1e-4 3.6e-5 (18/889) 4.4e-5 8.9e-16 2.7e-15
20,000 random interior points 3.5e-5 (5 wrong) 3.5e-5 1.8e-15 (0) 3.6e-15 (0)

Parallel (global_evaluate near the 276 interior vertices, a P2 exact field, points spread over all ranks), counting points wrong by more than 1e-9:

δ development np 2 this branch np 2 development np 3 this branch np 3
1e-8 164 9 160 5
1e-6 140 5 140 11
1e-5 99 10 101 12
1e-4 10 0 11 1

The parallel residual is on partition seams, and #1107 does not change it.

  • Who holds these points: in each case some rank contains the point, while another rank, usually the one it starts on, admits it only within the face slab and keeps it. Migration never moves such a point, so it is evaluated there with the clamp.

  • The size of it: H1 (the worker session, on the same Linux workstation) measured a larger sample, every interior vertex, edge midpoint and face centroid at δ = 0 to 1e-4, plus random points:

    2-D np 2 2-D np 4 3-D np 2 3-D np 4
    development 1053 of 7,825 1066 3391 of 16,215 3399
    this branch 38 75 184 322

    Swarm.migrate offers a point to every nearby domain before giving up (#1093) #1107's migration change leaves these counts exactly as they are. The largest residual error in 3-D at np 4 is 6.5e-5, against 1.4e-4 on development.

  • What would fix it: an ownership change, preferring a rank that contains the point over one that only admits it within the slab. That is a separate change, with its own issue.

Tests

  • tests/test_0511_evaluate_exact_near_edges_and_vertices.py (tier B) covers 2-D and 3-D simplices, P1 and P2, points on vertices and edges and at δ = 1e-8, 1e-6, 1e-5, 1e-4 and 1e-3 from them, with an error at rounding (< 1e-12). It also runs 2-D and 3-D quads as a control. On development the four simplex cases fail and the quads pass; here all 8 pass.

  • test_1052 VEP stability tests fail under PETSc 3.25 (variable-dt pure-VE blow-up), pass in level_1 gate #390 and uw.function.evaluate returns wrong values for P1 fields at points exactly on cell edges (3D) #432 (O(1) errors on 3-D edges): test_0503_evaluate.py and test_0761_point_locator.py give 34 passed and 2 skipped.

  • Parallel, at np 2 and 3: the evaluate, migration and seam files give 50–51 passed on every rank. That covers test_0756, 0760, 0765, 0774, 0777, 0783, 0785, 0796, 1076 and test_1107_interpolation_rank_owning_nothing.

  • 175 serial files that use evaluate, global_evaluate or the locator, at -n 5: 1469 passed and 3 failed. All three are long tests that failed under load:

    • test_1092's Maxwell case timed out at 1500 s, and passes alone on this branch (35 min);
    • test_1060 timed out, as it stalls on development under load;
    • test_1064's constrained case hit PETSc error 101 under load, and has passed alone before.
  • Cost. Random interior points are unchanged within noise. Points near a vertex, the population this fix is for, pay for the containing cell. On development the first cell tried admitted them within its slab; here a point the first cell does not contain walks its neighbours until one does. H1 measured, on a 3-D box at h = 1/12:

    case development this branch
    locator, 1e5 points within 1e-6 of a vertex, serial 0.16–0.23 s 1.9–2.0 s (about 9×)
    evaluate, same points, serial 2.2–2.9 s 3.0–3.4 s
    global_evaluate, 1e5 near-vertex points, np 2 1.1–1.6 s 3.7–3.8 s (about 3×)
    global_evaluate, 1e6 near-vertex points, np 4 6.2 s 19.7 s (3.2×)
    global_evaluate, 1e6 random interior points, np 4 8.8 s 10.3 s (+16%)

    Points foreign to a rank (most points in parallel) and exterior points fail the walk twice, which roughly doubles the locator for them.

Not in this PR

Checklist (UW3 Style Charter)

  • I have read the Style Charter and followed it over the surrounding code
  • No drive-by refactors, renames, or cleanups
  • The bug fix ships its regression test, written first, with level_* and tier_* markers
  • No hedging names, and no commented-out code
  • No new exception swallows
  • No data-access changes
  • Parallel: np 2 and 3 checked
  • No dependency changes
  • AI-assisted work carries the attribution line

Underworld development team with AI support from Claude Code

#1115)

_robust_owning_cells accepted the first cell it tried (the nearest control
point's) whenever the point was within the 1e-2 face tolerance of it. A
point just inside the NEIGHBOURING cell, within that tolerance of the face
they share, was then evaluated in the wrong cell, and the box clamp in
DMInterpolationEvaluate_UW put it on the shared face: an error of about
|grad f| times its distance from the face, for any field, the ones the
element represents exactly included. On a 1/16 simplex box: 4e-6 at 1e-6
from an edge or vertex, 4.4e-5 at 1e-5; 5 of 20,000 random points.

The locator now takes two passes: a cell that contains the point to
rounding (_EVAL_CONTAIN_TOL, 1e-10, face-relative), and the 1e-2 face
tolerance only for points no local cell contains. The set of points a
rank claims is unchanged, so ownership and migration are untouched; only
which of a rank's cells evaluates a point changes.

The face tolerance dates from 2026-05-28 (c52201b, parallel locator
hardening); #1014 (register row 6) did not touch this path.

test_0511 (tier B): 2-D and 3-D simplices, P1 and P2, points on and at
1e-8..1e-3 from vertices and edges, exact to rounding; quads as control.
The four simplex cases fail on development.

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

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 at a8e3a2f, on the merge conditions below. They are corrections to the PR text and register row, plus one follow-up issue. No code change is required.

Review of #1117 (fix for #1115): independent, adversarial

Reviewer: H1 (review and parallel test runs on a 96-thread Linux workstation: Intel Xeon Gold 6240R, AVX-512, MPICH 5.0.1). Head a8e3a2f is compared with base development 8a388dd, using a build of each. #1107 is in neither build. Every number below was measured unless it is marked [read]. Tests ran from git archive copies with -p no:cacheprovider --with-mpi, and MPI runs ran under the repository's MPI supervisor. The other jobs on the machine kept its load average at 20–36, so timings carry about ±20% noise. Logs are kept by the reviewer.

Summary

  • The fix works. Near vertices, edges and faces it is exact to rounding on every straight-sided simplex mesh tested. Points exactly on a vertex, edge or face still locate and evaluate exactly.
  • Ownership is unchanged. Every per-point rank-claim, migration, add_particles_with_coordinates and populate result is bit-identical to development at np 2, 3 and 4, in 2-D and 3-D.
  • test_0511 does its job. It fails 4/8 on development and passes 8/8 on the branch, and it kills both requested mutants.
  • No regressions.
  • Three corrections to the PR's claims:
  • One pre-existing defect turned up while testing sheared 3-D meshes. It is not caused by this PR.

Findings by severity

1. Medium. Cost for points near vertices is 3× in parallel 3-D, not "no measurable change" (H3's item 4)

Method. Times are best of 3, with fresh coordinates on each repetition. Each rank queries N/np points spread over the whole box, so in parallel most points are foreign to the querying rank. The meshes are a 2-D simplex box at h = 1/32 and a 3-D box at h = 1/12.

case locator (_robust_owning_cells) dev → branch evaluate dev → branch global_evaluate dev → branch
3-D, 1e5 random interior, serial 0.43–0.56 → 0.44–0.70 s 1.9–2.5 → 2.0–2.8 s 2.4–3.0 → 2.4–3.3 s
3-D, 1e5 within 1e-6 of a vertex, serial (3 runs) 0.16–0.23 → 1.9–2.0 s (≈9×) 2.2–2.9 → 3.0–3.4 s 4.2–5.4 → 4.2–4.9 s
3-D, 1e5 near-vertex, np 2 (3 runs) 0.24–0.25 → 0.97–1.0 s 0.57–0.58 → 1.14–1.20 s (2×) 1.13–1.64 → 3.7–3.8 s (≈3×)
3-D, 1e5 near-vertex, np 4 0.15 → 0.43 s 0.39 → 0.44 s 0.93 → 1.91 s (2×)
3-D, 1e6 near-vertex, serial 2.66 → 19.5 s (7×) 23.7 → 30.7 s (+30%) 47.6 → 44.9 s
3-D, 1e6 near-vertex, np 4 1.35 → 4.14 s 2.15 → 4.11 s (1.9×) 6.16 → 19.7 s (3.2×)
3-D, 1e6 random interior, np 4 2.22 → 4.62 s 2.71 → 3.68 s (+36%) 8.84 → 10.3 s (+16%)
3-D, 1e6, 7/8 exterior, serial 7.45 → 14.2 s (1.9×) 7.24 → 7.13 s 11.4 → 11.0 s
3-D, 1e6, 7/8 exterior, np 4 1.07 → 2.11 s 1.29 → 1.62 s 8.5 → 10.3 s
2-D, 1e5 random interior, serial 0.15 → 0.23 s 0.79 → 0.75 s 0.92 → 0.88 s
2-D, 1e5 near-vertex, np 4 0.04 → 0.14 s 0.12 → 0.23 s 0.59 → 0.89 s
2-D, 1e6, mostly exterior, np 4 0.35 → 0.98 s 0.68 → 0.97 s 5.7 → 5.2 s
  • Random interior points, serial: the PR's claim holds (no measurable change).
  • Points near vertices: the claim does not hold. This is the population the fix exists for: MMPDE trial points, departure points, and nodes of moved meshes.
    • On development, the first cell tested admits such a point inside its 1e-5 slab.
    • On the branch, the first pass walks the vertex's ring of cells, often 20 or more tets in 3-D, until one contains the point to rounding.
  • Foreign and exterior points within reach of the rank's cells fail the walk twice. This doubles the locator for them, which confirms H3's item 4. It accounts for the parallel locator rising by about 1.8–2× on random points.
  • Cheaper alternative (suggestion, not a condition). Do a single walk that computes the containment value once and tests both thresholds: remember the first cell that passes 1e-2 and stop at the first cell that passes 1e-10. That halves the work for foreign and exterior points. An adjacency step across the most-violated face would make the near-vertex case O(1).
  • Merge condition: replace the PR's timing paragraph with figures that include the near-vertex rows.

2. Medium. The seam residual is not #1107's territory: #1107 leaves it exactly unchanged (H3's item 3)

Method. global_evaluate of an exact P2 field at points spread over all ranks. The query set is every interior vertex and edge midpoint (plus face centroids in 3-D), each at δ = 0, 1e-9, 1e-6, 1e-5 and 1e-4 in a random direction, plus 2000 random points. That is 7,825 points in 2-D and 16,215 in 3-D. The table counts points wrong by more than 1e-9.

development branch branch + #1107's swarm.py change (injected via sitecustomize) development + #1107
2-D np 2 1053 38 38 1053
2-D np 3 1039 61 61 1039
2-D np 4 1066 75 75 1066
3-D np 2 3391 184 184 3391
3-D np 3 3417 282 282 3417
3-D np 4 3399 322 322 3399

3. Medium, pre-existing and not caused by this PR. On strongly sheared 3-D meshes, the 50-neighbour walk misses the containing cell (H3's item 2)

The mesh is a 3-D simplex box mapped by A = [[1, 1.2, 0.3], [0.1, 0.7, 0.5], [0, 0.2, 0.5]], plus a sinusoidal displacement of amplitude 0.03.

  • Errors. Points 1e-8 to 1e-4 from interior edges have errors up to 0.17 (P1 field, range O(1)): 9–13 of 879 edges per δ, and 35–40 of 3,516 in a larger sample.
  • Identical on both builds. The same points and the same errors appear on development.
  • Cause, measured:
    • The truly containing cell's centroid is the 50th–77th nearest. The walk's cap is min(n_cells, 50), so neither pass finds the cell.
    • In serial, points_in_domain then classifies these points as exterior, and they are filled by RBF.
    • The cell the second pass does return is non-containing (barycentric −1e-8 to −2e-5).
  • Not affected: faces at all δ, and points exactly on vertices, edges or faces, are exact on the branch for this mesh.
  • 2-D: a strongly sheared mesh (A = [[1, 1.5], [0.2, 0.6]] plus sinusoid) is exact everywhere on the branch (worst 1.2e-11). Development reaches 1.9e-3.
  • Action: a follow-up issue, not a condition on this PR. Possible fixes are a walk cap scaled by cell anisotropy, or an adjacency walk.

4. Low. 1e-10 is an absolute tolerance (1e-13 model units), not relative to the cell size

[read] _test_if_points_in_cells_internal accepts a point when |p−O|² − |p−I|² > −tol·|O−I|². Here O and I sit ±1e-3 (absolute, model units) from the face, so the test is "outward distance < tol × 1e-3". The two tolerances therefore work out as:

  • _EVAL_CONTAIN_TOL = 1e-13 model units;
  • _EVAL_FACE_TOL = 1e-5 model units, whatever the cell size.

Measured:

  • Unit box. The branch residual at δ = 1e-12–1e-13 is 2–5e-13. That is consistent with a 1e-13 slab, and below test_0511's threshold.
  • Tiny box (L = 1e-6, h = L/16). The branch has a residual of up to 7e-7 (relative to the field range) for points within about 1e-7·L of a face; development has up to 1.4e-3. Points exactly on a vertex, edge or face are exact and located on both.
  • Huge box (L = 1e6). evaluate is wrong on both builds even at cell centroids (3-D 0.84, 2-D 9.5e-7), so the locator is not the cause. A few exact-vertex points are unlocated in 2-D (4/275). Both builds give bit-identical output. This is pre-existing and not investigated further.

Merge condition: in the PR text, describe the tolerance as an absolute 1e-13 in model units, not "face-relative like the old tolerance".

5. Low. test_0511 coverage

  • Mutants (plugin-injected) against test_0511:
    • first pass at 1e-2: killed (4 simplex cases fail);
    • passes in the wrong order, 1e-2 then 1e-10: killed (4 fail);
    • first pass at 1e-6: killed;
    • first pass at 1e-8 (a slab of 1e-11): survives. That is expected, since the test's smallest δ is 1e-8. It is acceptable.
  • Gaps (suggestions only):
    • The 3-D cases test vertices and edges but no face set.
    • There is no deformed-mesh case.
    • The test is serial-only. Under mpirun it fails all 8 cases at np 2 on both builds, because rank-local evaluate sends seam-side points to RBF. That matches test_0503 and test_0757, which also fail under mpirun on both builds. Consider an explicit serial-only mark.

6. Information. Callers that use the cell index now get the containing cell [read]

  • Use only >= 0, so unchanged: fault_network owned(), and the in/out classification in points_in_domain.

  • Use the cell itself, so they change for points within 1e-5 of a face:

    • the evaluate authoritative hint (the intended fix);
    • integration-point variables' nearest-point value (_function.pyx);
    • the swarm _owning_cells cache, which feeds the Voronoi share assignment and the population census npc that drives add/remove;
    • cell_polynomial_projection.locate (reference coordinates).

    Each now uses the cell that contains the point, which is a correction. For a discontinuous field (P0, P2/P0-discontinuous pressure, IP variables), the value at such points can move by O(jump). The register row should say so.

  • Not affected: ddt.py calls _get_closest_local_cells_internal(tol=0.0) directly.

  • Measured: initial populate counts and coordinates are identical. No caller in the regression set depends on the old choice.


Evidence for the PR's main claims

Serial exactness

H1's repro script, h = 1/16, max |error|:

set dev P1 branch P1 dev P2 branch P2 dev quad P1 branch quad P1
exactly at vertices 8.9e-16 8.9e-16 2.7e-15 2.7e-15 8.9e-16 8.9e-16
vertex + 1e-9 4.2e-9 (125/276) 8.9e-16 4.7e-9 2.7e-15 1.3e-15 1.3e-15
vertex + 1e-5 4.4e-5 (85/276) 1.3e-15 4.9e-5 2.7e-15 1.3e-15 1.3e-15
edge midpoint + 1e-6 4.6e-6 (246/889) 1.3e-15 5.1e-6 2.7e-15 1.8e-15 1.8e-15
20,000 random points 3.5e-5 (5) 1.8e-15 3.5e-5 3.6e-15 1.8e-15 1.8e-15

These match the PR's table.

Other meshes, branch worst-case max |error| over vertices, edges, faces (3-D) and cell centroids, each exactly on the entity and at δ = 1e-13 … 1e-4 (development in brackets):

mesh branch development
2-D box P1 4.7e-13 4.8e-5
2-D box P2 5.0e-13 5.6e-5
3-D box P1 1.1e-12 9.7e-5
3-D box P2 1.2e-12 1.0e-4
sheared 2-D P1 6.4e-12 9.3e-4
sheared 2-D P2 1.2e-11 1.9e-3
annulus P1 5.0e-13 4.6e-5
annulus P2 5.3e-13 5.4e-5
spherical shell P1 1.6e-12 1.7e-4

test_0511

Development: 4 failed (all simplex), 4 passed (quads). Branch: 8 passed.

Ownership unchanged (H3's item 1)

The point sets are those of finding 2. At np 2, 3 and 4, in 2-D and 3-D, branch and development give bit-identical results for:

  • per-rank points_in_domain (plain and strict_validation);
  • per-rank claims from _robust_owning_cells (≥ 0);
  • add_particles_with_coordinates placement;
  • final rank after migrate of all points inserted on rank 0;
  • populate(fill_param=2) per-rank counts and sorted coordinates.

Only the local cell index changes: 1,876–1,913 (point, rank) pairs in 2-D and 6,194–6,336 in 3-D.

[read] This is guaranteed by construction. Both passes use the same nearest-control-point start, reach filter and centroid order. A cell that passes at 1e-10 passes at 1e-2, and the second pass is the old call restricted to the lost points, which is batch-independent. So the claimed set is the same.

Regressions

suite development branch
Serial: 65 files (evaluate, global_evaluate, swarm, advection, semi-Lagrangian/DDt, projection, locator, migration), xdist -n 2 496 passed, 6 failed, 4 skipped 500 passed, 2 failed, 4 skipped
Parallel: 22 files in tests/parallel (swarm migration/advection/cache, evaluate rank-locality, global_evaluate empty rank, remap, RBF proxy, interpolation rank owning nothing, empty-rank evaluate/save, …), np 2 80 passed, 8 skipped 80 passed, 8 skipped
Same 22 files, np 4 87 passed, 1 skipped 87 passed, 1 skipped
  • Serial failures. The 2 failures shared by both builds are test_1060 and test_1061 (PETSc error 101 or the 1800 s timeout, under load). Development's other 4 failures are test_0511.
  • The serial evaluate files under mpirun (test_0503, 0503b, 0511, 0757, 0760, 0761, 0784) at np 2 and np 4 give an identical set of failures on both builds. Those files are not parallel-safe.

Merge conditions

  1. PR text, cost. Replace "no measurable change" with figures that include points near vertices and foreign points. In 3-D, global_evaluate is about 3× slower at np 2–4 and the locator 7–9× slower in serial for points within 1e-6 of a vertex. Random points are unchanged in serial.
  2. PR text, seam residual. State that Swarm.migrate offers a point to every nearby domain before giving up (#1093) #1107 leaves the residual unchanged (measured identical counts). Open a separate issue for preferring a rank that contains the point over one that admits it only within the slab.
  3. PR text and comment, tolerance. Describe _EVAL_CONTAIN_TOL as an absolute 1e-13 in model units (and _EVAL_FACE_TOL as 1e-5), not "face-relative".
  4. Register row, as the PR already requires, with Louis's sign-off. The row should also note that discontinuous and integration-point fields, and swarm cell censuses, change for points within 1e-5 of a face.
  5. Follow-up issue, not blocking. The 50-neighbour walk cap misses containing cells on strongly sheared 3-D meshes (finding 3). It is pre-existing.

Underworld development team with AI support from Claude Code

@lmoresi

lmoresi commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

#1117 at a8e3a2f: the cost on one MMPDE mover call (2-D annulus)

Measured by H1 (review and parallel test runs on a 96-thread Linux workstation: Intel Xeon Gold 6240R, AVX-512; MPICH). The machine's load average was about 30 from other jobs, so single timings carry roughly ±15 % noise.

Case. The annulus (r_o 2.2222, r_i 1.2222, cellSize 0.5) at refinement 4, which is 31,744 cells. One call of uw.meshing.node_redistribution, with a metric concentrated along a 45° dipping trace (1 + 20 exp(−d²/0.15²)). Run at np 4, twice per build. Two metric forms:

  • a MeshVariable, so the mover reads it through evaluate and global_evaluate;
  • a sympy expression.

The development build is 8a388dd; #1117 is a8e3a2f on that base. evaluate and global_evaluate were wrapped to sum their wall time; the figure is the maximum over ranks.

metric build mover call inside global_evaluate (64 calls) inside evaluate (2 calls)
MeshVariable development 11.50 s, 11.50 s 7.42 s, 7.44 s 0.88 s, 0.90 s
MeshVariable #1117 12.49 s, 13.29 s 8.05 s, 8.82 s 1.08 s, 0.98 s
sympy development 16.64 s*, 12.55 s 11.37 s*, 8.56 s 0.27 s, 0.26 s
sympy #1117 12.99 s, 14.02 s 8.89 s, 9.76 s 0.31 s, 0.34 s

* The first development sympy run was a load outlier; its repeat is 12.55 s.

  • On a 2-D mover call, evaluate uses the cell that contains a point before any face tolerance (#1115) #1117 costs about +9 to +16 %. For the MeshVariable metric that is 11.5 s → 12.5–13.3 s. Almost all of the difference sits in global_evaluate, which is about 65 % of the call on both builds.
  • For comparison, 2-D near-vertex points at np 4 (1e5 points, from the review): locator 0.04 → 0.14 s, evaluate 0.12 → 0.23 s, global_evaluate 0.59 → 0.89 s, about 1.5×. That is well below the 3-D factor of about 3×.
  • What this does not cover. A 3-D mover step was not timed: no 3-D mover case was at hand. Nor was a whole time step (the mover is part of a 150–350 s step in H2's runs).

Underworld development team with AI support from Claude Code

@lmoresi

lmoresi commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

This PR also fixes #799, the same defect reported from P2 nodes moved off their positions. Probe on #799: on development 1–2 points per offset are wrong, by up to 1.8e-5; on this branch, none, with a maximum error of 1.8e-15.

Underworld development team with AI support from Claude Code

@lmoresi

lmoresi commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

Determinism check: #1117 does not introduce the launch-to-launch differences in the mover runs. They are on development too. Measured by H1 (review and parallel test runs on a 96-thread Linux workstation (Intel Xeon Gold 6240R, AVX-512; MPICH)), np 4, at ec4e30e.

Setup. The mesh-mover timing script from the earlier timing check: Annulus(cellSize=1/64), a wavy thermal front, metric_density_from_gradient(..., metric_choice="front-following"), and the MMPDE mover with step_frac=0.2, accel="cg" and boundary_slip="ring". There are two arms on one build:

Every top-level evaluate / global_evaluate and every locator call is logged per rank with an md5 of its input and output. For the first 40 calls the arrays are saved, so the differences can be measured.

What differs between launches.

  1. The gradient projection, in both arms. The first evaluate reads the projected gradient of T (Vector_Projection). Its input is bit-identical across launches, but its output differs at most points by up to 1.1e-14 against a scale of 22. That happens in every launch, in both arms. I have not located the source inside the projection solve.

  2. The metric density, in both arms. metric_density_from_gradient maps |∇T| to a density through its rank among the gathered values of all ranks (np.interp(gmag, np.sort(gmag_global), linspace(0, 1, N))). A node held by two ranks contributes two near-equal values. Whether they tie exactly depends on the last bit from item 1, and that changes the rank of a node.

    | arm | launch | |∇T| on rank 1 / rank 3 | ρ at the node |
    |---|---|---|---|
    | development | 1, 4 | 0.4215080644981013 / 0.4215080644981013 | 1.6390629765 |
    | development | 2 | …10135 / …1013 | 1.6373333309 |
    | development | 3 | …1012 / …10113 | 1.6373333309 |
    | evaluate uses the cell that contains a point before any face tolerance (#1115) #1117 | 1, 2 | …1012 / …10113 and …10135 / …1013 | 1.6373333309 |
    | evaluate uses the cell that contains a point before any face tolerance (#1115) #1117 | 3, 4 | …1013 / …1013 | 1.6390629765 |

  3. The moved mesh. The mover is sensitive to the metric. On the evaluate uses the cell that contains a point before any face tolerance (#1115) #1117 arm, 0.1 % in one node's density changed the mesh after the first move in 2 of 6 launches: minimum radius 0.00498, 0.00515 and 0.00498 after the first move, against 0.00510 in all three development launches. It changed it after three moves in every launch (0.00422, 0.00401 and 0.00423). In my six development-arm mover launches the flip happened to leave the mesh bit-identical. The direct probe above shows the development arm takes both density values. So this is a matter of how far the difference spreads, not of whether there is one.

Verdict for #1117 on determinism: no objection. The nondeterminism is older than this PR and comes from the metric (items 1 and 2). #1117 changes which cell evaluates a point, so the same rounding difference reaches the mesh more often. It does not create one.

Follow-up (not for this PR). I will file this as its own issue: the percentile map is discontinuous at ties between copies of a shared node, and the gradient projection is not bit-reproducible between launches.

  • For the percentile map, rank owned nodes only, so a shared node counts once. That removes the ties and also stops shared nodes being counted twice.
  • For the gradient projection, find where its last bits come from.

Logs, probes and saved arrays are kept by the reviewer.

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.

3 participants