Skip to content

The semi-Lagrangian history starts and records at its nodes, one route on any number of ranks; a simplex box returns points onto its boundary - #1252

Merged
lmoresi merged 5 commits into
developmentfrom
bugfix/semi-lagrangian-without-nudge
Nov 20, 2026
Merged

lmoresi merged 5 commits into
developmentfrom
bugfix/semi-lagrangian-without-nudge

Conversation

@lmoresi

@lmoresi lmoresi commented Nov 20, 2026

Copy link
Copy Markdown
Member

The nodal semi-Lagrangian history no longer nudges its nodes. It records the field and starts its trace at the nodes themselves, by one route on any number of ranks. This builds on #1237's route agreement: the ranks still agree on the route with a logical AND, and serial now takes the same copy route as parallel. No issue was filed; this body is the report.

Measurements are by H7 (the stress-history desk, a Claude session on a 96-thread Linux workstation: Intel Xeon Gold 6240R, MPICH), except where the parallel review's numbers are named.

The nudge

SemiLagrangian moved every node 0.1% toward the centroid of its closest cell (_centroid_shifted_node_coords) for two things:

  • the trace's start velocity;
  • serially, the record of the current field. In parallel the record copied the nodal data instead.

The closest cell a rank can see depends on the partition. So the nudge made serial and parallel take different routes, and it moved a static field at every record. The parallel review measured this on #1237's empty-rank triangle: two SLCN steps of $x + y$, with no flow and that value on the boundary.

route distance from $x + y$
np 1 (nudge route) 7.498e-5
np 3 (copy route), with or without the empty rank 2.533e-5
np 3 against np 1 4.965e-5

What changes:

  • _centroid_shifted_node_coords becomes _node_coords_nd: the nodes themselves.
  • The record takes the copy route on every rank count. An expression psi_fn is evaluated at the nodes.
  • The trace's first velocity is taken at the nodes.
  • IntegrationPointSemiLagrangian's evaluate fallback drops its own nudge.
  • An unused nudge helper is removed.

Test: test_1244, serial and at np 3 (with and without the empty rank). A static $x + y$ stays put to 100 times the solve tolerance (1e-8). Development fails it serially at exactly 7.498e-5. On this branch: serial 2 passed; np 3: 3 passed, test_1236 included.

The SLCN partition dependence (the #1239 review's finding)

One SLCN level-set step on test_1105's rotation box at 1/32, with the mass correction and reinitialisation off and a fixed ε. Every node is gathered by position. Largest np 1 against np 2 difference:

build SLCN tolerance 1e-4 (default) 1e-12
development 4ab522a 6.5e-5 7.0e-5
this branch 2.1e-5 1.0e-12

The nudge is the part that a tighter tolerance cannot remove, and this PR removes it. What remains at the default tolerance is the solve's own residual: about 2e-5, present at nearly every node, and gone at 1e-12. Whether that residual is biased toward partition seams is being measured separately.

Over a full revolution of test_1105's rotation (200 steps), the transport tolerance makes no difference to the accuracy. At 1e-4 and at 1e-10 alike: indicator mismatch 0.00304, band share 0.15804, L2 distance from the start 0.010024.

An unstructured simplex box returns a point onto its boundary (its own commit)

Without the nudge, a trace foot on a free-slip wall, where $v \cdot n$ is round-off, sits within round-off of the wall. UnstructuredSimplexBox.return_coords_to_bounds moved a point outside the box to 1e-3 inside it and left a point inside where it was: a 1e-3 jump at the wall.

test_1053's ETD-2 case runs one problem twice, as a constant and as a uniform expression. The two runs differ by round-off in the velocity. Their feet were 1.8e-15 apart until one landed either side of the wall and they came back 1.0e-3 apart. The end velocities then differed by 4.4e-9 relative (development: 1.4e-13), against the test's 1e-10.

The simplex box now returns a point onto the boundary, as StructuredQuadBox already does; that is the precedent. This changes where a swarm particle that left a simplex box is put back: onto the wall, not 1e-3 inside it. test_1245 checks this in 2-D and 3-D: a point a round-off outside each wall returns exactly onto it, and a point a round-off inside is left alone. It fails on development.

#745 blamed this same clamp for an integration-point history blowing up at a channel inlet. I rebuilt #745's channel from the issue, since its script was not public: 2.2 × 0.41, simplex box at 0.05, Maxwell, Wi 5, DEVSS η/4, Δt 1/120, integration-point history, with no inflow value set. Its inlet peak:

build t 0.5 t 1.17 t 1.83
development 0.024 7.9 35
this branch 0.025 10.2 45

So this PR does not fix #745: the inset was not the whole of it. #745 stays fixed by the inflow-value route (f6d3259), which this does not touch.

Also here

test_1109 covers a non-symmetric TENSOR history's split advection, from the review of #1248. All four columns are checked against a scalar history of each component.

Tests

  • 109 files covering semi-Lagrangian, SLCN, Navier-Stokes, stress history and swarms, on 4 xdist workers, level 3 excluded: 823 passed, 4 skipped.
  • test_1053, 1106, 1109, 1244 and 1245 on the final head: 23 passed.
  • Parallel: test_1244 and test_1236 at np 3: 3 passed. scripts/test.sh runs test_1244 at np 3.

Checklist (UW3 Style Charter)

  • Style Charter followed (S2); the box clamp is its own commit (S9)
  • Regression tests written first, with level_1 and tier_a/tier_b markers; test_1244 and test_1245 fail on development (S8)
  • No hedging names, commented-out code or exception swallows (S3, S4)
  • Parallel: one route on every rank, tested at np 3 with an empty rank (S11)
  • No coordinates identify entities (S12); no dependency changes
  • AI-assisted

Underworld development team with AI support from Claude Code

… route on any number of ranks

The nodal history evaluated its start velocity, and serially recorded the field, at nodes
nudged 0.1% toward the centroid of their closest cell. The nudge moved a static field at
every record (x + y by 7.498e-5 in two SLCN steps) and made serial take a different route
from parallel. The record now copies a mesh-variable field on every rank count, and the
trace starts at the nodes. The integration-point history's evaluate fallback drops its
nudge too, and an unused nudge helper goes.

Underworld development team with AI support from Claude Code
…-3 inside it

The clamp moved a point a round-off outside to 1e-3 inside and left one a round-off
inside where it was: a 1e-3 jump at the wall. Without the nudge, a trace-back foot on a
free-slip wall (v.n is round-off there) landed either side of it, and two runs of one
problem that differ in round-off differed by 4e-9 (test_1053, ETD-2). StructuredQuadBox
already snaps onto the boundary; the simplex box now does the same.

Underworld development team with AI support from Claude Code
…view of #1248)

Underworld development team with AI support from Claude Code
Copilot AI balanced review requested due to automatic review settings November 20, 2026 04:11

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

Copy link
Copy Markdown
Member Author

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))
(H1 is the session that reviews pull requests and runs the parallel tests.)

Verdict on 264dbce: ready to merge on green from this review.

The one finding worth a follow-up predates this PR (finding 1).

The head has since moved to c6330cc, a merge of development (#1246, #1249, #1244). The PR's own changes are unchanged; scripts/test.sh gains only development's decade lines that let CI find test_1244 and test_1245. The runs below are at 264dbce.

Method

All four PR files under src/ and scripts/ are Python or shell, with no compiled sources. The merge base with development is 1901a46. Both the PR and the merge base were run as Python overlays on the development c2f8b4f build:

  • The build's compiled sources match the merge base exactly (an empty diff over *.pyx *.pxi *.pxd *.h *.c setup.py).
  • It was built after its commit, and its installed Python files match its tree.

Every run printed underworld3.__file__ to confirm which overlay was loaded. The parallel layouts are a test-only shell partition of the gmsh mesh:

  • default: PETSc's own partition.
  • band: horizontal bands of cells.

Field changes were measured by a pytest plugin. After each test, it saved every live mesh variable on both builds, and the two builds were then compared field by field. Each figure is the largest and the RMS difference, divided by the field's largest magnitude. The errors against exact or reference solutions come from copies of the benchmark tests that print the quantity each test asserts on.

(a) Answers, development (1901a46) against the PR, serial

Solved fields:

benchmark (mesh) field max change / scale RMS change / scale
test_1100_SLVectorCartesian, quad box V_num 4.4e-4 8.7e-5
same, simplex box (irregular / regular) V_num 1.1e-2 / 1.1e-2 8.5e-4 / 9.1e-4
test_1100_AdvDiffCartesian, quad / simplex ×2 T 4.4e-4 / 1.6e-3 / 3.7e-4 5e-5 to 7e-5
test_1105_levelset_rotation, SLCN, 200 steps psi 1.6e-2 1.1e-3
test_1105, SUPG (control) psi identical identical
test_1101 swarm, half revolution (disc) / square box T / Tb 1.2e-5 / 2.6e-2 1.9e-6 / 6.9e-4
test_1110_advDiffAnnulus T 1.2e-4 1.0e-5
test_1071_slcn_moving_mesh (annulus) Tsl 2.5e-3 3.5e-4
test_0855_oldframe_sl_traceback, static-mesh case (annulus) T 5.6e-3 2.0e-4
test_1056_units_slcn_traceback T 9.8e-4 to 1.9e-3 1.1e-4 to 1.8e-4
test_0066_integration_point_slcn (solved fields) T, T_ip at most 1.5e-5 at most 1e-6
Navier-Stokes: test_0610, test_1164, test_1060 U, P ≤ 9e-16 ≤ 2e-16
VE, test_1053 ETD-2 (the case the PR describes) v, p 3.5e-4 / 1.5e-3 5e-5 / 3e-4

Errors against the exact or reference solution:

benchmark measure development PR direction
SLVectorCartesian, quad / irregular simplex / regular simplex relative L2 error against the analytic field 0.10441 / 0.10513 / 0.10597 0.10434 / 0.10304 / 0.10387 better by 0.1%, 2.0% and 2.0%
AdvDiffCartesian, three meshes largest error against AdvectedFront 0.02203 / 0.01607 / 0.01122 0.02201 / 0.01598 / 0.01126 the same (±0.6%)
levelset rotation, SLCN, one revolution L2 distance from the start 0.010280 0.010024 better 2.5%
same share of nodes in the band 0.15926 0.15804 better
same indicator mismatch 0.002840 0.003043 worse by 7%, against a bound of 0.01
swarm advection, square box integral error / peak 0.06674 / 0.18958 0.06602 / 0.18958 better 1% / the same
swarm advection, disc integral error 0.020129 0.020126 the same

Every benchmark test passes on both builds.

(b) A static field, and np 1 against np 3

The triangle is #1237's, with two static SLCN steps of x + y (test_1244's setup), gathered by node position. The largest of |T - (x + y)| over all nodes:

case np development PR
triangle sized for np 3, serial 1 7.498e-5 3.0e-11
every rank holds cells 3 2.533e-5 8.9e-11
one rank empty 3 2.533e-5 8.0e-11
np 1 against np 3, node by node 1 vs 3 4.965e-5 5.8e-11 (full), 8.1e-11 (empty rank)
test np development PR
test_1244 serial 1 2 failed 2 passed
test_1244_..._parallel 2 – skipped (np 3 or more, as the file states)
same 3 2 failed 2 passed
same 4 – 2 passed
test_1236 (an SLCN step on an empty rank) 2 – skipped (np 3 or more)
same 3, 4 passed passed

(c) The swarm effect of the snap

A wall probe on the unit simplex box (cell size 0.1) was run at np 1, 2 (band and default) and 3 (band and default):

  • (i) placed points: ten points exactly on walls and corners, including (0, 0.5) on the band layout's partition seam, and the same points a round-off (1e-15) outside, returned by the mesh's clamp. The test is which ranks claim each one, and whether a swarm keeps each through add_particles_with_coordinates and migration.
  • (ii) advected swarm: a populated swarm (1452 particles) driven 0.6 into the left wall and into the lower-left corner.
check np layout development PR
clamp of a round-off-outside point any – moved 1e-3 inside onto the wall exactly
every on-wall or clamped point claimed by some rank 1, 2, 3 all yes yes
swarm driven into the wall: count over 4 steps 1, 2, 3 all 1452 throughout 1452 throughout
where those particles sit 1, 2, 3 all 864 at x = 1e-3 (one at 1.6e-12) 864 exactly on x = 0
swarm driven into the corner: count 1, 2, 3 all 1452 throughout 1452 throughout
on-wall point on a seam: claimed by two ranks, added twice 2 band, default yes, for exact on-wall input yes; for clamped points too (finding 1)

All swarm, tracer and particle tests run passed identically on both builds:

tests np development PR
test_0067, 0068, 0069, 0070, 0071, 0072, 0073, 0074, 0110, 0111, 0112, 0113, 0530, 0761, 0857 1 all passed all passed, same counts
test_1245 1 2 failed 2 passed
test_0756, 0760, 0765, 0767, 0777, 0796 (empty rank), 1093 2 all passed all passed, same counts
test_0767, the four np-4 cases 4 6 passed 6 passed
test_0810 (the #810 regression) 1, 2 skipped (needs AMR PETSc) skipped

(d) #745

This is #745's channel as the author rebuilt it: Wi 5, the integration-point history with no inflow value, Δt 1/120. The script was copied unchanged and run on both builds. The peak deviatoric stress:

build t 0.5 t 1.17 t 1.83
development 0.0240 7.86 41.8
PR 0.0252 10.19 44.7

The failure without an inflow value is still there, so the snap does not fix #745, as the PR says. The two t 1.83 values differ from the author's (35.2 and 45.2), as expected once the runs have blown up. The route that does fix #745, test_1059::test_the_integration_point_history_takes_the_inflow_value_at_an_inlet, passes on the PR.

Findings

  1. Low, from before this PR, but the snap now reaches it: a point exactly on a box wall and on a partition seam is claimed by two ranks.
    • What happens: points_in_domain claims such a point on two ranks, so add_particles_with_coordinates, which filters a rank-identical array by that claim, adds it twice. At np 2 the ten placed points became 12 particles with the band layout and 11 with the default one.
    • Already true on development: exact on-wall input behaves this way there too.
    • What the snap changes: on development a point returned by the clamp sat 1e-3 inside and was claimed once. On the PR it sits exactly on the wall and is duplicated in the same way.
    • Advection is unaffected: it routes existing particles by migration, which never duplicated or lost one here.
    • Next step: a tie-break for on-wall seam points in points_in_domain is a separate issue, not a change to this PR.
  2. Low: in the level-set rotation, the SLCN indicator mismatch is 7% worse (0.00284 to 0.00304), well inside the test's 0.01. The L2 distance and the band share improve. Noted so the figure is not later read as a regression.
  3. Low: the largest field change outside the benchmarks is test_0855's static-annulus case, at 5.6e-3 of the field. The test has no exact reference, so its direction is not known. The test still passes, since it compares the old-frame path with the plain one on the same build.

Spot checks and what was not run

  • VE and Navier-Stokes, serial on the PR, all passed: test_1059 (28, including Integration-point stress history blows up at the inlet of a plain channel (Wi 1 and 5, Re 100); nodal and grid histories are stable there #745's inflow test), 1094, 1106, 1052 (VEP stability), 1063 (stress-history restart), 1109 (3, the new TENSOR case included), 1018 (26, rotated free slip under every rheology), 1053, 0610, 1056 (Navier-Stokes SUPG), 1060 and 1164.
  • Not run:
    • the author's full 109-file sweep;
    • the benchmarks in parallel, beyond test_1244 and test_1236;
    • 3-D, except as test_1245 covers it;
    • test_0810, which needs an AMR-enabled PETSc;
    • test_1100's quad-mesh xfail case is reported as xpassed on both builds.
  • Resources: each parallel run went under an MPI supervisor with a 300 s silence limit, on 4 cores.

Logs kept by the reviewer.

Underworld development team with AI support from Claude Code

@lmoresi
lmoresi merged commit 9047164 into development Nov 20, 2026
10 checks passed
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