Skip to content

A rotated datum lift measures convergence against the datum's scale (#883) - #1261

Merged
lmoresi merged 2 commits into
developmentfrom
bugfix/rotated-datum-lift-reference-883
Nov 20, 2026
Merged

lmoresi merged 2 commits into
developmentfrom
bugfix/rotated-datum-lift-reference-883

Conversation

@lmoresi

@lmoresi lmoresi commented Nov 20, 2026

Copy link
Copy Markdown
Member

A cold-start rotated free-slip solve that lifts a prescribed normal velocity (the datum) now measures convergence against the datum's own forcing. A linear solve converges in one increment instead of two.

What changes

On development.

  • The first increment from u = 0 lifts the datum. The residual at u = 0 does not see the datum.
  • Forced by the datum alone, r0 = 0, so the reference was re-set at iteration 1 to the lifted iterate's residual. For a linear model that is the increment's own Krylov residual, so the relative test could not pass there.
  • With a weak body force beside the datum, the reference stayed at the body force's scale, below the datum's.
  • In both cases a second increment followed.
  • Under consistent_jacobian="continuation", the switch could fire at the lift's iteration 0, where r0 = 0. The issue reports, without a measurement, that a datum-only solve then skips its Picard phase.

Now.

  • After the lift's zeroRowsColumns, the reference takes the larger of its value and the norm of the lifted right-hand side on the free rows: the forcing the datum exerts on the interior.
  • The iteration-1 re-reference is gone.
  • The continuation switch is gated off at the lift's iteration 0, as the convergence test already was.
  • rnorm0 is the first residual measured; the docstring says so. For a datum-only cold start the solve report therefore gives no reduction (its fnorm0 is 0), where it gave a ratio to the lifted residual.

Measured. Annulus, cell size 0.2, datum 0.1 cos 2θ on the outer wall, tolerance 1e-6; serial, macOS (12-core Apple M4).

forcing development: increments, reference this branch
datum alone 2, 7.12e-8 1, 1.716
datum + body force 1e-3 2, 1.05e-4 1, 1.716

The lifted iterate is the same on both branches (residual 7.12e-8 after the lift, to all printed digits). Development then took one more increment, to a residual of 1e-14. This branch stops at the lift, whose residual is 4e-8 of the new reference, within the 1e-6 tolerance.

This changes when a solve stops. A linear datum solve now ends one increment earlier, at the solve's own tolerance rather than past it. A nonlinear datum solve measures against a larger reference from its second increment on.

Tolerances and coordinate matches

None added. The test asserts the increment count (1) and that the final residual is within the solve's tolerance of the reference.

Tests

tests/test_0883_rotated_datum_lift_reference.py, level 2, tier B, two cases (datum alone, and a weak body force beside it):

  • each converges in one increment, against a reference above 1;
  • the final residual is at most 1e-6 times the reference.

On development the same fixture gives 2 increments in both cases (the probe in the table above), so the test fails there.

Serial runs: the rotated slice (test_0207, 0846, 0883, 1018, 1058, 1061, 1066, 1092, 1113, 1131, 1136, 1143, 1158, 1159): 108 passed.

Not run: the parallel datum tests (tests/parallel/test_1066_rotated_datum_parallel.py and its neighbours). The new norm is collective, on a branch every rank takes together.

Review

Adversarial review, below.

Issue state

#883: fixed by this branch (label fixed-in-PR).

Underworld development team with AI support from Claude Code

…883)

A cold start lifts the prescribed normal velocity in its first increment
from u = 0, where the residual ignores the datum. Forced by the datum alone,
r0 = 0 and the reference became the lifted iterate's residual (for a linear
model, that increment's own Krylov residual); with a weak body force beside
it, the reference stayed at the body force's scale. Either way the relative
test could not pass after the lift and a second increment followed
(measured: annulus, datum 0.1 cos 2 theta, 2 increments, references 7.1e-8
and 1.05e-4).

The reference now includes the norm of the lifted right-hand side on the
free rows, the forcing the datum exerts on the interior (1.72 here), and the
linear solve converges in one increment. The re-referencing at iteration 1
is gone, and the continuation switch is no longer tested at the lift's
iteration 0, matching the convergence test. rnorm0 is the first residual
measured; the docstring says so.

test_0883: both cases converge in one increment against a reference above 1.

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

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

Adversarial review, round 1 (head c66c359)

  • Rank asymmetry. The new lifted.norm() is collective. It runs inside if lift_datum and iters == 0, and lift_datum is decided from the collective norm of x̂ and from zero_init_guess, so every rank takes that branch together. _zero_rows_local is rank-local on owned rows. No other collective is moved.
  • Ordering. ref is set from r0 at iteration 0, before the lift, and raised by the lift's norm in the same iteration. Neither the convergence test nor the continuation switch reads it at the lift's iteration 0; both are gated. From iteration 1 on, both see the raised reference.
  • Scale. The free-row norm of the lifted right-hand side is the forcing the linear increment solves against. Its Krylov residual is then measured against that forcing, as the KSP itself measures it. The constrained rows hold diag·x̂, a diagonal scaling of the datum, and are left out of the scale.
  • Answers. A linear datum solve now stops after the lift, at the tolerance, where development took one more increment to 1e-14. The answer moves by at most the tolerance; this is the intended effect, and the PR body says so. A nonlinear datum solve now measures against a larger reference from its second increment on, so it can stop earlier at the same relative tolerance.
  • The solve report. Its reduction becomes None for a datum-only cold start (fnorm0 = 0). The body states it, and the docstring is updated.
  • Tests that cannot fail. The new test's fixture gives 2 increments on development, so its == 1 fails there. The reference bound (> 1) rules out the old reference of 7.1e-8.
  • CI reach. test_0883 is in scripts/test.sh's test_08*py batch.
  • Not run. The continuation switch is gated, but no test exercises a nonlinear datum solve under continuation; the issue gives no measured failure for it. Parallel datum tests are not run (no MPI on this machine).

No findings.

Issue state:

Underworld development team with AI support from Claude Code

@lmoresi

lmoresi commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Second-desk review by H7 (a Claude review session running parallel probes on a 96-thread Linux workstation: Intel Xeon Gold 6240R, AVX-512, MPICH). The base is development e7e02b9, the merge base of the rotated batch (#1260, #1261, #1262, #1265, #1263). #1261, #1262, #1265 and #1263 change only rotated_bc.py, so each was measured by placing the branch's file, or a clean three-way merge of the files, in a build of e7e02b9. #1260 was built from its own branch. Parallel runs were under the MPI supervisor, at most 4 ranks.

Verdict: passes. Merge it first in the batch.

Measured

Annulus, cell size 0.2, outer datum a cos 2θ, tolerance 1e-6, serial. The answer's error is the largest relative velocity difference from a converged reference.

case development: increments, ref #1261: increments, ref error, development / #1261
datum 0.1 alone 2, 7.3e-8 1, 1.716 0 / 3.0e-7
datum 0.1 + radial body force 1e-3 2, 1.05e-4 1, 1.716 0 / 3.0e-7
small datum 1e-3 against radial body force 1 1, 0.10546 1, 0.10685 1.56e-6 / 1.56e-6
datum 0.1 + rigid-rotation body force 1, 0.1213 1, 1.720 3.6e-7 / 3.6e-7
datum 1e-3 + rotation + radial 1, 0.1608 1, 0.1617 3.7e-7 / 3.7e-7

So the datum cases take one increment and land within the tolerance. A small datum beside a body force changes neither the count nor the answer.

Attacks that failed

  • The lifted right-hand side is not projected off the rotation gauge on an uncached solve (bhat = -F̂, and the gauge modes are collected only after the first assembly). We expected the reference to inflate when the body force has a rotational component. Measured: the reference rises from 0.1608 to 0.1617 only (last row). The rest is the uncached residual's own gauge component, which An uncached rotated solve measures its first residual without the gauge (#884) #1262 removes. With An uncached rotated solve measures its first residual without the gauge (#884) #1262 merged the reference is 0.1279, within 1% of the projected r0 0.1267.
  • The new collective on an asymmetric layout: np 3 with a band partition, whose middle rank holds no wall facet and so no normal or datum rows. The datum alone, datum + rotation and rotation alone cases converge with the serial references (1.71582, 1.71725, 0.0702576) and no hang. The rotated parallel files (14) pass at np 2 and 3.
  • Iterations across the suite: 604 serial rotated solves, development against A rotated datum lift measures convergence against the datum's scale (#883) #1261. No outer or Krylov count rises; one Krylov total falls (test_maxwell_transfer_function_under_a_tide, 49 to 46). Deterministic answers agree to 1.3e-6.
  • test_0883: fails on development, passes here.

Findings

  • Pre-existing, not this PR: with an empty rank, or a random partition, at np 3 the annulus datum solve fails at PC setup (KSP_DIVERGED_PCSETUP_FAILED). Development does the same, so the new collective cannot be tested under those layouts.

Underworld development team with AI support from Claude Code

@lmoresi

lmoresi commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

One more measurement for this PR, from macOS (12-core Apple M4, serial), while probing UNFILED 36.

The fixture is an annulus (inner radius 0.5, outer 1.0, cell size 0.2, qdegree 3), with rotated free slip on both walls, the datum 0.1 cos 2θ on Upper, no body force, and tolerance 1e-6. H7's "datum 0.1 alone" row, on Linux, has development taking 2 increments and converging. Here, on development (66fd34c), the second increment fails:

  • the rotated KSP: KSP_DIVERGED_PC_FAILED (-11), with the fieldsplit PC failed reason 6 (sub-PC error);
  • the velocity block: KSP_DIVERGED_NANORINF (-9) at iteration 0;
  • the pressure block: DIVERGED_DTOL (-4) after 30 iterations.

On this branch (6e37b7b) it converges in 1 increment, with 17 velocity and 7 pressure iterations.

So on this platform development fails outright on the pure-datum case, where on Linux it converged in two increments. This branch fixes both. Plain free slip, with u.n = 0 and a body force, converges in 1 increment on both.

Underworld development team with AI support from Claude Code

@lmoresi
lmoresi merged commit b79a961 into development Nov 20, 2026
10 checks passed
lmoresi added a commit that referenced this pull request Nov 20, 2026
Brings in #1261 (the datum lift reference), which this branch follows; the
merge of rotated_bc.py is automatic.

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.

2 participants