Skip to content

The nodal stress history carries the stress it stores (#735, #1009) - #1231

Merged
lmoresi merged 4 commits into
developmentfrom
bugfix/stress-history-moves-with-flow
Nov 19, 2026
Merged

lmoresi merged 4 commits into
developmentfrom
bugfix/stress-history-moves-with-flow

Conversation

@lmoresi

@lmoresi lmoresi commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

The nodal semi-Lagrangian stress history, the Stokes viscoelastic default, refreshed its commit snapshot before the trace-back (ddt.py, SemiLagrangian.update_pre_solve). As a result, every step rebuilt the stored stress from the field that had not moved. On development the default history behaves exactly as stress_transport="none".

This PR refreshes the snapshot after the carry. The Eulerian flavours' snapshot request now takes effect as well: Stokes asked for it before their projection existed, and the request lapsed.

It is ported from bugfix/stress-snapshot-order-735 (913694e, on hold since 2026-11-08, #1009) and bugfix/backward-nodes-snapshot-order (adb20e9, with its adversarial review in docs/reviews/2026-10/). It cherry-picks cleanly onto 4ab522a. The new test is renumbered test_1106, because 1102 is taken.

Measurements are by H7 (the stress-history desk, a Claude session on a 96-thread Linux workstation: Intel Xeon Gold 6240R, MPICH), serial unless stated.

The defect and the regression test

test_1106: a stored stress turned 0.5 rad by eight steps of rigid rotation on a 1/16 simplex box.

history error vs rotated stress error vs where it was made
nodal, development 4ab522a 1.538 0.000
none, development 1.538 0.000
nodal, this PR 0.285 1.451

test_1106 fails 6 of its 9 tests on development (H3's review run at 4ab522a):

  • the nodal rotation (assert 0.0 > 1.0);
  • the frozen-snapshot read, nodal and Eulerian;
  • the thin sheet's frozen read;
  • the split Eulerian snapshot (enable_source_snapshot did nothing, the lapsed request);
  • "none" reading its history frozen. On this branch it passes serial and at np 2 (9 passed). The stress, VEP-stability, initial-history, restart and thin-sheet suites (test_1106, test_1059, test_1052 ×2, test_1063_stress_history_restart, test_1076) give 55 passed.

Waters and King: #1009's bias is the nodal trace's own error

#1009 found the port biased on Waters and King, and that bias is why the port was held. The exact solution has $u\cdot\nabla\sigma\equiv 0$, so a history that does not move is exact there. The control below forces the stress history's trace velocity to $(u, 0)$, which removes the discrete transverse velocity from the trace. It uses the test_1060 setup: pure Maxwell, NavierStokes, BDF-1, centre velocity.

1/h, Δt t exact development (not moving) this PR this PR, trace $(u,0)$ this PR, trace $(0,0)$
16, 0.0125 1.5 0.87580 0.87680 0.87895 0.87678 0.87678
16, 0.0125 2.0 0.72077 0.72156 0.72379 0.72150 0.72153
16, 0.0125 6.5 0.51606 0.52774 0.53001 0.52768 —
32, 0.00625 2.0 0.72077 0.72116 (#1009, eddab70) 0.72380 0.72144 —

The peak transverse velocity $\max|v_y|$ over the run is:

1/h development this PR this PR, trace $(u,0)$
16 5.6e-4 7.6e-4 5.0e-4
32 — 5.9e-4 2.6e-4

With the transverse part of the trace removed, the fixed history reproduces development to 2e-5 at 1/16 at every time, and recovers nine-tenths of the gap at 1/32. The bias therefore comes from the trace sampling the stored stress off the node's own height through the discrete $v_y$, which the carried stress then feeds back. It is the nodal scheme's own error, which the defect hid, and not a fault in the fix. Carried, the nodal history does not converge on this case at fixed Courant number (2.30e-3 at 1/16, 3.03e-3 at 1/32 at t 2).

Two things are open:

The default moves off the nodal history in a follow-up PR (integration point, smoothed), so this residual is not the default's.

Update: test_1054 relied on the defect (5f5a395)

The multimaterial test failed on this branch (15-23% at step 6) and passes on development. Its materials sit on a swarm that is never advected, and its closed forms hold the stress at its point. Carried by the pure shear, the history brings material A's stress across the interface into B's sample point. The same test fails with the integration-point history, so the cause is that the history moves, not the nodal scheme. The test now sets stress_transport = "none", which states what its closed forms assume: 23 passed. All 18 viscoelastic test files that do not set a transport give 153 passed on this branch, serial.

Existing tests that change

  • test_1059: VARYING_SL2 is re-pinned from 0.87325 to 0.87163. The old baseline was set while the nodal history did not move. Carried, it is 4.3e-4 from the Eulerian value at the same step, where it used to be 1.2e-3. The test's comment says so.
  • test_1054: pins stress_transport = "none" (see the update above).
  • test_1052: only docstrings change. The shear-box tests cannot see the snapshot order.

Docs

Closes #1009. Refs #735: its wall excess was measured on the defect and is to be re-measured on this branch before #735 is closed.

Checklist (UW3 Style Charter)

  • Style Charter followed over the surrounding code (S2)
  • No drive-by refactors (S9)
  • Regression test written first, with level_2 and tier_a markers; it fails on development (S8)
  • No hedging names, no commented-out code (S3, S4)
  • Exception swallows: none added (S4)
  • Data access through .array / .data as the surrounding code does (S7)
  • Parallel: test_1106 at np 2 (S11)
  • No coordinates identify entities (S12)
  • No dependency changes
  • AI-assisted

Underworld development team with AI support from Claude Code

The nodal semi-Lagrangian history refreshed its commit snapshot before the trace-back, so
the stored stress was rebuilt every step from the field that had not moved. On development
the default history behaved exactly as stress_transport="none": a stress turned 0.5 rad by
rigid rotation stays where it was made (error 0.000 against the unmoved stress, 1.538 against
the rotated one). update_pre_solve now refreshes the snapshot after the carry, and the
Eulerian flavours' snapshot request takes effect. Ported from bugfix/stress-snapshot-order-735
(913694e) and bugfix/backward-nodes-snapshot-order (adb20e9); the test is renumbered 1106.

Underworld development team with AI support from Claude Code
Copilot AI balanced review requested due to automatic review settings November 19, 2026 10:27
@github-actions

Copy link
Copy Markdown

🔍 Architectural Review Checklist

Thank you for submitting an architectural review! Reviewers should validate:

Design & Architecture

  • Design rationale is clear and well-justified
  • Trade-offs are documented with alternatives considered
  • System architecture is comprehensible
  • Integration points are clearly identified

Implementation

  • Implementation matches documented design
  • Code quality meets project standards
  • Breaking changes are identified and justified
  • Backward compatibility is properly addressed

Testing & Validation

  • Testing strategy is adequate for the changes
  • Test coverage is sufficient
  • Edge cases are properly covered
  • Performance impact has been assessed

Documentation

  • Known limitations are clearly documented
  • Benefits are quantified with metrics
  • User-facing changes are documented
  • Migration guide provided (if needed)

Review Process: See CODE-REVIEW-PROCESS.md

Approval: This PR merge = Review formally approved

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.

@github-actions

Copy link
Copy Markdown

✅ Test Suite: success

The test's materials sit on a swarm that is never advected, and its closed forms keep
the stress at its point; it passed with the default carried history only while the nodal
history did not move. Carried, the pure shear brings material A's stress across the
interface into B's sample point (15-23% at step 6). stress_transport="none" states what the
closed forms assume: 23 passed.

Underworld development team with AI support from Claude Code
@github-actions

Copy link
Copy Markdown

✅ Test Suite: success

@lmoresi

lmoresi commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Second-desk review of #1231, by H3 (the units desk, a Claude session doing second reviews), at 5f5a395. Runs were on a 96-thread Linux workstation (single system image; Intel Xeon Gold 6240R, AVX-512; MPICH).

Verdict: the fix is right and the tests show it. The findings below are in the docs, comments and PR description; none is in the code's behaviour.

What I checked

  • test_1106 fails on development. I ran it on a development 4ab522a build: 6 of its 9 tests fail.
    • test_the_stored_stress_rotates_with_the_flow[semi_lagrangian]: the distance moved from where the stress was made is exactly 0.0 (assert unmoved > 1.0). The default history does not move, the same as stress_transport="none".
    • test_the_commit_reads_the_carried_history_frozen[semi_lagrangian] and [eulerian].
    • test_a_thin_sheet_reads_its_history_frozen_and_keeps_the_maxwell_response.
    • test_the_split_eulerian_history_snapshots_after_its_correction: enable_source_snapshot did nothing, the lapsed request.
    • test_no_transport_leaves_the_stored_stress_and_still_reads_it_frozen.
  • test_1054's switch to "none" is justified. Its swarm is never advected: the file has no advection call. Its material map is fixed at x > 0.5, and its closed forms hold the stress in place. Under the pure shear (EDOT·x, −EDOT·y) a carried history moves material A's stress outward across x = 0.5, so the closed forms only hold for a history that does not move. Setting "none" states that assumption.
  • The VE suites pass on this branch. 29 stress-history and viscoelastic files (test_105[0-4]*, 1059_stress_transport, 1060_stress_store_smoothing, 1061*, 1063_stress_history_restart, 1064_stress_history_units, 1065_log_conformation, 107[68]*, 1084*, 109[234]*, 1106, 1165, 006[67]*, 0070, 0075, 0857*), 6 xdist workers: 236 passed, 0 failed. test_1106 at np 2: 9 passed.
  • The refactor of update_pre_solve.
    • EulerianSUPG used to convert dt and then call the base method. Now Eulerian.update_pre_solve converts dt itself before _carry_history, and has no early return that would skip the transport.
    • Building the Eulerian projection early, in enable_source_snapshot, does not freeze a stale source. The psi_fn setter rebuilds the projection's source whenever the function changes, and the commit sets smoothing to 0.
    • The only change in behaviour is the order of the refresh, as intended.

Findings

  1. transport-schemes.md, the The nodal semi-Lagrangian stress history carries ~50% too much stress at a no-slip wall: two independent transports converge together, it stays flat elsewhere #735 ruling, gives the defect's end as "d77bc9d2 on bugfix/backward-nodes-snapshot-order". That commit is only on the side branch; this PR cherry-picked its change. On development the defect lasts until this PR merges, so the end point should be The nodal stress history carries the stress it stores (#735, #1009) #1231. stress-transport.md already says "until this fix".
  2. The three new TODO(BUG) notes name no issue. They are in _build_projection_source, _apply_split_advection and the SemiLagrangian record fallback. CLAUDE.md's convention is that the inline TODO marks the place and an issue tracks the work. The _apply_split_advection one is a real defect, not a latent one: for a 2×2 symmetric tensor it corrects 2 of the 3 stored components, using the wrong flat entries. That one deserves its own issue.
  3. The PR description.
    • It says test_1106 fails "3 of the 5 cases selected" on development. The whole file fails 6 of 9, as listed above.
    • It doesn't mention that test_1059 re-pins VARYING_SL2 from 0.87325 to 0.87163, a baseline set while the history did not move. The comment in the test explains it; the description should list it under existing tests that changed.

Underworld development team with AI support from Claude Code

…pment

Underworld development team with AI support from Claude Code
@github-actions

Copy link
Copy Markdown

✅ Test Suite: success

@github-actions

Copy link
Copy Markdown

✅ Test Suite: success

@lmoresi
lmoresi merged commit 8a31226 into development Nov 19, 2026
13 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