Repository navigation
Conversation
…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
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_Projectionat 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_ProjectionandSNES_MultiComponent_Projectiondeclare_convergence_reference_rule = "increment", andSNES_Tensor_Projectioninherits it.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.
max(‖F(x0)‖, ‖F(0)‖)max(‖F(x0)‖, ‖F(0)‖), as stationaryThe 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.
ddt.py:3250)evaluate's multi-component projectorddt.py:5498)free_surface.py:986)evaluate's scalar projectorddt.py:5050), flux (ddt.py:5819), VE history (ddt.py:1908), thin sheet, transient Darcy, the free surface's mesh velocity, yield continuationThe 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.
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.Runs:
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