Skip to content

Projections measure their increment: a warm projection of a changed field iterates - #1298

Open
lmoresi wants to merge 1 commit into
developmentfrom
bugfix/projection-warm-start-reference
Open

lmoresi wants to merge 1 commit into
developmentfrom
bugfix/projection-warm-start-reference

Conversation

@lmoresi

@lmoresi lmoresi commented Nov 20, 2026

Copy link
Copy Markdown
Member

Projections measure their increment, so a warm projection of a changed field iterates. This amends the convergence-reference rule of #1014 for projections.

The defect

Since #1014 a stationary solve stops at rtol * max(||F(x0)||, ||F(0)||). For a projection, ||F(0)|| is the whole field. Projections are warm-started by default once they have a solution (zero_init_guess=None), and the library re-projects every step of a time loop. So a step whose change stays inside rtol of the whole field took no iteration, and the projection returned the previous step's answer.

A history that stores the projection then drifts. test_1061's forward stress history stores each step's flux through a MultiComponent_Projection at rtol 1e-3. From step 161 the warm guess is already under the target (‖F(x0)‖ 8.34e-5 against 9.34e-5), the projection takes 0 iterations, and the stored flux is the previous step's. The test's error goes from 6.4e-4 to 8.0e-3, against its tolerance of 3e-3. The bisect to #1014 is from the review campaign's sweep.

The fix

SNES_Projection, SNES_Vector_Projection and SNES_MultiComponent_Projection declare _convergence_reference_rule = "increment", and SNES_Tensor_Projection inherits it.

  • What it means: a projection is measured against its own first residual, as a solve with memory already is.
  • Warm solve: reduces the step's change by rtol.
  • Cold solve: unchanged (‖F(x0)‖ = ‖F(0)‖).
  • Unchanged field: converges in one iteration (reason 2, or 4 once the residual is round-off); it does not stall.

Why class-wide. Every projection the library re-solves in a loop is warm by default. The audit below finds skips at every kind of site, and no projection that is better off skipping. One iteration where there were none costs little on a mass-matrix solve. Solving from a zero guess instead would throw away a guess that is usually good, and the increment rule keeps it.

The register row, before and after.

before (#1014, row 1) after (this PR)
stationary equations (Stokes, Poisson, …) max(‖F(x0)‖, ‖F(0)‖) unchanged
solves with memory, or a weak datum (row 2) increment unchanged
projections (scalar, vector, tensor, multi-component) max(‖F(x0)‖, ‖F(0)‖), as stationary increment

The audit

Every projection solve was recorded (class, construction site, warm or cold, iterations, ‖F(x0)‖, target, rtol) over 36 test files that run time loops: viscoelastic Stokes and stress transport, the stress histories, semi-Lagrangian and SLCN histories, the free surface, transient Darcy and Richards, and slip surfaces. The same files ran twice on this branch: once with the projections put back on the stationary rule (development's behaviour), and once as merged. Both runs pass the same 364 tests.

A skip is a warm solve that takes 0 iterations while ‖F(x0)‖ is above 1e-10 of ‖F(0)‖, that is, a field that changed. "Skipped change" is the largest such ‖F(x0)‖/‖F(0)‖ left unprojected.

projection rtol warm solves skips before skipped change skips after iterations before → after
semi-Lagrangian ψ* history (ddt.py:3250) 1e-3 411 of 457 46 2e-7 0 411 → 465
evaluate's multi-component projector 1e-6 138 of 266 23 6e-7 0 298 → 344
stress history forcing (ddt.py:5498) 1e-3 19 of 20 19 2e-7 0 1 → 20
stress histories created during a solve (test_1059) 1e-3 22 of 24 21 2e-4 0 2 → 26
free surface, P1 velocity (free_surface.py:986) 1e-3 16 of 36 16 3e-7 0 38 → 54
Richards / Darcy velocity projector 1e-6 28 of 30 14 7e-7 0 19 → 51
evaluate's scalar projector 1e-6 6 of 212 2 1e-9 0 182 → 193
stress history commit (ddt.py:5050), flux (ddt.py:5819), VE history (ddt.py:1908), thin sheet, transient Darcy, the free surface's mesh velocity, yield continuation 1e-3 to 1e-6 0 in these files 0 unchanged

The flux projection (ddt.py:5819) did not skip in these short files. It skips in test_1061's long run: 11 of 280 solves, from step 161.

Tolerances (not changed here). The review of #1256 found that the history projections' default tolerance is loose for a history that feeds the next step. NavierStokesSLCN's commit projection at 1e-4 reads 0.393421 against an exact 0.393469, and 0.393457 at 1e-10. The rtol column above is each projection's default.

  • Cost of 1e-10: the same 36 files with every projection at 1e-10 pass the same 364 tests in 520 s against 513 s at the defaults. Newton iterations do not rise: each projection is linear, so the work moves into the inner KSP, and the wall time shows it is about 1%.
  • Not in this PR: a tighter default for the history projections is a separate decision, proposed to the maintainer with these numbers.

Tests

  • tests/test_1014_a_warm_projection_iterates_on_a_changed_field.py (tier B, serial). For each of the scalar, vector and multi-component projections: start from a converged projection, change the source variable by 1e-5 of itself, and re-solve warm at the default tolerance. The solve must iterate and land within 1e-2 of the change on a converged projection of the new field.
    • Before the fix: under development's rule all three take 0 iterations.
  • test_1061's forward case (tier C, about an hour). On development it fails: the error is 8.0e-3 against the 3e-3 tolerance, and the flux projection skips 11 of 280 solves from step 161. With this PR it passes in 66 minutes, with 521 projection solves and none skipped.

Runs:

  • Projection users (evaluate and derivatives, metrics and smoothing, adapt, level set, thin sheet, free surface, Darcy and Richards, stress histories, SLCN, VE, advection-diffusion), 166 serial files, tier C excluded: 1377 passed, 17 skipped, 8 xfailed, 2 failed.
    • The 2 failures: test_1086's annulus-with-slip cavity cases at np 4 and np 5. They launch their own MPI runs and were run under four busy pytest workers.
    • Run alone, that file's cases pass on this branch, and also with the projections put back on the stationary rule (8 passed each). So the failures are the load, not this change.
  • The coverage check passes.

Measured on a 96-thread Linux workstation (single system image; Intel Xeon Gold 6240R, AVX-512; MPICH).

Underworld development team with AI support from Claude Code

…ield iterates

Under #1014's reference a stationary solve stops at rtol * max(||F(x0)||,
||F(0)||), and for a projection ||F(0)|| is the whole field. Projections are
warm by default and the library re-projects every step of a time loop, so a
step whose change stayed inside rtol of the field took no iteration and kept
the previous answer: test_1061's forward stress history drifted from 6.4e-4
to 8.0e-3 from step 161. The scalar, vector and multi-component projections
(and so the tensor one) declare the increment rule: a warm solve reduces the
step's change by rtol, a cold one is unchanged.

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

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.

This branch has not been deployed

No deployments
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