Skip to content

On a split-node fault the stress history stays on the grid; tracing flavours are refused (#871) - #1232

Merged
lmoresi merged 2 commits into
developmentfrom
feature/stress-history-no-fault-crossing
Nov 20, 2026
Merged

lmoresi merged 2 commits into
developmentfrom
feature/stress-history-no-fault-crossing

Conversation

@lmoresi

@lmoresi lmoresi commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Two commits on development after #1231 (merged as 8a31226): 1eadd5f, the guard, and 8265ec0, from the parallel review.

A semi-Lagrangian trace must not cross a fault. Louis, on #871 (2026-11-15): "as we found in the fault sessions, trace back should not actually cross the fault!"

A trajectory traced from a point within about h/2 of a split-node fault can be located in a cell on the other side of the slit, and the history it reads there belongs to the other block. #871 measured this on a Maxwell thin sheet: a period-2-step slip-rate oscillation and patchy stress, both removed by the grid history. ThinSheet already defaults to the grid history for this reason. Stokes did not: its viscoelastic history was exposed by default.

Until the trace itself respects the fault (clipping the trajectory at fault facets in CharacteristicTrace.departure_points, plus a side-aware evaluation at the foot), this PR adds a guard in _StressHistoryMixin._create_stress_history_ddt.

When the mesh carries a split-node fault (mesh._fault_point_pairs):

stress_transport behaviour
not set defaults to "eulerian", the grid (SUPG) history
"semi_lagrangian", "integration_point", "forward" refused when the history is made, with a ValueError naming #871
"none" allowed: no transport, so it does not trace
"lagrangian" allowed: material points, not a trace

The decision is reduced over ranks (MAX), so every rank takes it together. Unfaulted meshes are unchanged.

The guard sits in the stress-history mixin, so it applies to ThinSheet as well. A flat ThinSheet on a faulted mesh now refuses "semi_lagrangian", which base allowed. That is Louis's no-crossing rule, and ThinSheet's docstring now says so. ThinSheet's own default was already the grid history.

Before the model is assigned, the stress_transport getter reports the effective default: "eulerian" on a faulted mesh. That read is rank-local; the decision taken when the history is made is the collective one.

Tests

tests/test_1107_stress_history_fault_guard.py uses add_fault on a simplex box, with a frictionless fault in simple shear and a Maxwell model:

  • the default on a faulted mesh is the grid history, and one step solves;
  • the three tracing flavours are refused;
  • "none" and "eulerian" are allowed;
  • an unfaulted mesh keeps the usual default.

It also checks that "lagrangian" is allowed, that the getter reads "eulerian" on a faulted mesh before the model, and that a faulted ThinSheet refuses a trace. On this branch, with the thin-sheet suites test_1076 and test_1077, it gives 17 passed. On development (4ab522a) it gives 6 failed and 4 passed. The failures are the guard's own cases: the default case, the three refusals, the getter, and the ThinSheet refusal. The grid-history and unfaulted cases pass, as they should. tests/parallel/test_1107_..._parallel.py checks that every rank defaults to the grid history and solves, and that every rank refuses, including when only rank 0 holds the fault record (the MAX itself): 3 passed at np 2 and at np 3.

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

Refs #871. #871 stays open for the trace-level fix.

Checklist (UW3 Style Charter)

  • Style Charter followed (S2); no drive-by changes (S9)
  • Test written first, with level_1 and tier_a markers; it fails on development (S8)
  • No hedging names, commented-out code or exception swallows (S3, S4)
  • Parallel: a collective decision, tested at np 2 (S11)
  • No coordinates identify entities (S12); no dependency changes
  • AI-assisted

Underworld development team with AI support from Claude Code

…lavours are refused (#871)

A trace from a point within about h/2 of the slit can be located on the other side of
it, and reads the other block's history (#871). Until the trace respects the fault, a
Stokes solver whose mesh has a split-node fault takes stress_transport="eulerian" by
default, and refuses "semi_lagrangian", "integration_point" and "forward" when the
history is made, naming #871. "none" and "lagrangian" do not trace and stay available.
The decision is reduced over ranks, so every rank takes it together.

Underworld development team with AI support from Claude Code
@lmoresi
lmoresi force-pushed the feature/stress-history-no-fault-crossing branch from 8cafff6 to 1eadd5f Compare November 19, 2026 23:40
@lmoresi
lmoresi changed the base branch from bugfix/stress-history-moves-with-flow to development November 19, 2026 23:40
@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 1eadd5f (and 8cafff6): changes requested (small: one docstring, the PR body, one test case; finding 1). The runs below were made on fb44b56. The head has since moved to 1eadd5f, rebased onto development after #1231 merged; git diff 8cafff6d 1eadd5f6 over solvers.py and the two test_1107 files is empty. 8cafff6 is the same commit rebased onto a94ffb0: git diff fb44b564 8cafff6d -- src/underworld3/systems/solvers.py tests/ is empty, the PR commit's own diff is identical line for line, and the only file that differs is one line of docs/developer/guides/transport-schemes.md, which came from a94ffb0. The guard itself is correct. Every rank took the same decision and gave the same refusal in every layout tried, including an empty rank and a fault that sits on one rank only, and nothing hung.

Method

The base is #1231's head at 5f5a395, which merge-bases with development at 4ab522a. Both #1231 and this PR change Python files only. Both were run as Python overlays on one build of 4ab522a, whose compiled sources match the merge base exactly (an empty diff over *.pyx *.pxi *.pxd *.h *.c setup.py), and every run printed underworld3.__file__ to confirm which overlay was loaded. The parallel layouts are a test-only shell partition of the gmsh mesh:

  • band: horizontal bands of cells.
  • emptyband: bands over np-1 ranks, so the last rank holds no cells.
  • rand7: random assignment with seed 7.

The fault mesh is the PR's own faulted_box(): a 1/16 simplex box with add_fault, 19 split-node pairs. add_fault partitions the add-on itself, and in every layout the 19 pairs ended up on one rank only:

np layout cells per rank fault pairs per rank
2 band 350 / 280 19 / 0
2 rand7 307 / 323 0 / 19
3 band 210 / 221 / 199 0 / 19 / 0
3 rand7 204 / 215 / 211 0 / 19 / 0
3 emptyband 332 / 298 / 0 19 / 0 / 0

Results

"Same on all ranks" means that the outcome was gathered from every rank and compared whole: the stress_transport chosen, the history class, and for a refusal the exception type and the first 400 characters of the message. In this table "every" means np 1, np 2 (band, emptyband, rand7) and np 3 (band, emptyband, rand7).

case np layout base (5f5a395) PR (fb44b56)
faulted, transport not set every every semi_lagrangian, SemiLagrangian eulerian, EulerianSUPG; same on all ranks
faulted, none every every allowed, EulerianSUPG allowed, EulerianSUPG
faulted, lagrangian every every allowed, Lagrangian allowed, Lagrangian
faulted, eulerian every every allowed allowed
faulted, semi_lagrangian every every allowed ValueError naming #871, the same message on all ranks
faulted, integration_point every every allowed ValueError naming #871, the same message on all ranks
faulted, forward every every allowed ValueError naming #871, the same message on all ranks
unfaulted, all 7 settings every every default semi_lagrangian, every mode allowed identical to base
faulted, record stripped on ranks without pairs (the MAX itself) 2, 3 band, emptyband semi_lagrangian everywhere default eulerian and refusal on every rank, including ranks with no record
ThinSheet on a flat faulted box, semi_lagrangian 1, 2, 3 band allowed refused (finding 1)
ThinSheet, default / none / unfaulted semi_lagrangian 1, 2, 3 band eulerian / none / allowed unchanged
refused, then stress_transport = "eulerian" and the model assigned again 1 – (no refusal) recovers: EulerianSUPG
VE solve, eulerian default, 4 steps 1, 2, 3 –, band, rand7, emptyband – runs; agrees with np 1 (below)
VE solve, none and lagrangian on the faulted box, 4 steps 1 – – run
test_1107 (7 tests) 1 – 4 failed, 3 passed 7 passed
test_1107_..._parallel (2 tests) 2 band 2 failed 2 passed
test_1107_..._parallel 2 default, rand7 – 2 passed
test_1107_..._parallel 3 band 2 failed 2 passed
test_1107_..._parallel 3 default – 2 passed
test_1107_..._parallel 3 emptyband – hangs in the second test's mesh load. This is not caused by this PR: the same hang occurs on base (note A)
VE and stress-history neighbours, 14 files 1 – 117 passed 117 passed, identical per file
test_1092 (thin-sheet prescribed normal) 1 – timed out at 25 min timed out at 25 min

The VE solve was a frictionless fault in simple shear with a Maxwell model at Δt = 0.1, run for 4 steps at a Stokes tolerance of 1e-8. The table gives the largest relative difference from np 1 over the 4 steps:

run ∫|v|² ∫τxy² ∫τxx² max |τ|
faulted, np 2 band 9.9e-7 7.9e-6 2.9e-5 3.4e-4
faulted, np 2 rand7 2.1e-7 1.4e-5 5.6e-5 3.6e-4
faulted, np 3 emptyband 4.3e-7 1.0e-5 9.6e-5 4.1e-4
control: unfaulted box, eulerian, np 2 band 4.7e-6 2.5e-5 – 2.1e-4

The faulted runs agree with np 1 as closely as the unfaulted control does, which uses the same grid history. The spread comes from the history's own projections, not from the fault or the guard.

Findings

  1. Medium: the guard also covers the thin sheet, but nothing in the PR says so.
    • What changed: _resolve_stress_transport_for_faults lives in _StressHistoryMixin, which SNES_ThinSheet shares. On a flat mesh with a split fault, ThinSheet with stress_transport = "semi_lagrangian" (or integration_point, or forward) now raises. On base it was allowed. The refusal fits Semi-Lagrangian stress history reads across a split-node fault near the slit #871: the thin sheet is where the oscillation was measured.
    • What is missing:
      • The PR body says "Stokes".
      • The tests cover Stokes only.
      • SNES_ThinSheet.stress_transport's docstring still says "On a flat mesh they may be chosen, but next to a split-node fault a trace-back reads across the slit", which is no longer true.
    • Requested:
      • update that sentence;
      • say in the body that the thin sheet is covered;
      • add one ThinSheet refusal case to test_1107.
  2. Low: before the history is made, stress_transport still reads "semi_lagrangian" on a faulted mesh. The decision is taken in _create_stress_history_ddt, when the constitutive model is assigned, so a script that reads the property first sees the unfaulted default. Meanwhile the property's docstring now says "On a mesh with a split-node fault the default is eulerian". Either resolve the default in the getter as well, or add "once the history is made" to the docstring.
  3. Low: the PR body's table lists "lagrangian" as allowed, but test_the_grid_histories_are_allowed_on_a_faulted_mesh covers only none and eulerian. Here lagrangian was allowed on every rank and solved 4 steps at np 1. Adding it to the parametrize (the test model is order 1, which the particle history needs) would pin the claim.
  4. Low, optional: the tests do not exercise the MAX reduction. add_fault gives every rank the fault name key ({"Flt": {}} on a rank with no pairs), which is truthy, so every rank's local test is already true. collect_point_pairs, used by the extruded sheet, does the same. As far as I can find, the reduction is a safeguard that no current code path needs. That is a good reason to keep it, and also why nothing currently tests it. Here the record was emptied or deleted on the ranks with no pairs, and every rank still defaulted and refused together at np 2 and 3. A parallel test that strips the record on one rank would keep the reduction covered.

Confirmed correct

  • Where the decision is made: in _create_stress_history_ddt, before anything else in it, just after the early return for an existing history. That return is rank-consistent. The method runs from the constitutive-model setter and from the VE_Stokes constructor, not from the Stokes constructor. The allreduce is its first collective and depends only on mesh state, so every rank reaches it together. A refusal is raised before any history object is created, so the error is collective and nothing is left half-built. Setting an allowed transport and assigning the model again then works.

  • A fault added after the solver is built: Mesh.add_fault never changes a mesh in place; it returns a new child mesh. All assignments of _fault_point_pairs in src/ are on a new mesh: the add_fault child, the redistributed add-on, and the extruded sheet.

    • A solver built on the parent therefore keeps its semi_lagrangian history over an unfaulted mesh, which is correct for that mesh, and it still solves (np 1, 2, 3).
    • A solver built on the child gets the guard.
    • A second add_fault on a faulted mesh gives a child holding both faults and leaves the existing solver on the parent.

    The decision is not re-evaluated, but no path was found that would need it.

  • Bypass: a history passed in through DFDt= bypasses the guard. That is an explicit user choice and was left as it is.

  • Unfaulted meshes: default and every mode identical to base, at np 1, 2 and 3.

  • The new tests: they fail on base (4 of 7 serial; both parallel tests at np 2 and 3) and pass on the PR.

Run and not run

  • Run:
    • the probes and tests in the tables, serial and at np 2 and 3, under an MPI supervisor with a 300 s silence limit;
    • the neighbours serial, one pytest per file, on both base and PR: test_0070, 1051, 1052 ×2, 1053, 1054 (multimaterial), 1059 (stress transport), 1063 (stress-history restart), 1064, 1076, 1077 (thin-sheet faults), 1094, 1106, 1159. Each file gave the same count on both.
    • test_1092 was also started on both but did not finish (see "Not run").
  • Not run:
    • test_1060 and test_1061 (tier C, long);
    • test_1092 to completion: it hit the 25-minute per-file limit on base and PR alike;
    • the neighbours in parallel;
    • 3-D faults (add_fault with a sheet);
    • the extruded thin-sheet path;
    • the restart of a faulted VE run;
    • any long VE run on a faulted mesh.
  • Base branch moved: The nodal stress history carries the stress it stores (#735, #1009) #1231's head is now e86987f, with development merged in. That merge brings The boundary-condition wrapper checks its label and PETSc's answer; a rewire replaces boundary kernels (#1138, #1069) #1211, which changes compiled code and limits EulerianSUPG's weak inflow term to exterior faces, so the fault's Plus and Minus boundaries no longer get it. 8cafff6 still sits on a94ffb0. It merges onto e86987f cleanly, but that combination was not built or run here. The default faulted history has no inflow datum, so the changed branch of EulerianSUPG is not on the path this PR's default takes.

Note A (not this PR): two hangs or aborts with an empty rank reproduce on base exactly as on the PR. Both come from the test-only shell partition.

  • np 3, emptyband: after a VE solve on the faulted box, the next gmsh mesh load hangs in labelsLoad: PETSc's ReadLabelStratumHDF5, with ranks in mismatched star-forest setups. It hangs on base with the semi_lagrangian and eulerian histories alike. This is why the parallel test file hangs at np 3 with emptyband, since its second test builds a new mesh after the first solves.
  • np 2, emptyband: creating a MeshVariable on the add_fault child of an unfaulted mesh with an empty rank fails on one rank with a PETSc MPI error in UW_DMCreateInterpolationWithinPlex, while the other rank waits.

Both will be raised separately; logs kept by the reviewer.

Underworld development team with AI support from Claude Code

…hinSheet says it refuses a trace there; tests for lagrangian, ThinSheet and the MAX (review of #1232)

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

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.)

Re-check of 8265ec0: ready to merge on green from this review. All four findings from the first review are fixed, and the fixes hold at np 1, 2 and 3. Two small notes on the PR body follow; neither blocks the merge.

Method

#1231 has merged, so this PR's base is now development, at 8a31226. Against that base the PR changes Python files only: solvers.py, thin_sheet.py and the two test files. Both the PR and development were run as Python overlays on one build whose compiled sources match 8a31226 exactly (an empty diff over *.pyx *.pxi *.pxd *.h *.c setup.py). That build is clean, 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:

  • band: horizontal bands of cells.
  • rand7: random assignment with seed 7.

add_fault puts all 19 split-node pairs on one rank: rank 1 of 3 with band, rank 0 of 2 with band.

Results

"Same on all ranks" means the outcome was gathered from every rank and compared whole: the transport chosen, the history class, and for a refusal the exception type and message.

case np layout development (8a31226) PR (8265ec0)
Stokes, faulted box, each of the 7 settings 1, 2, 3 –, band, rand7 default semi_lagrangian, every mode allowed default eulerian; semi_lagrangian, integration_point and forward refused naming #871; none, lagrangian and eulerian allowed; same on all ranks
Stokes, unfaulted box, each of the 7 settings 1, 2, 3 –, band, rand7 default semi_lagrangian, every mode allowed identical to development
ThinSheet, flat faulted box, semi_lagrangian 1, 2, 3 –, band, rand7 allowed refused on every rank, the same message on all ranks
ThinSheet, flat: faulted default, none; unfaulted semi_lagrangian 1, 2, 3 –, band, rand7 eulerian / none / allowed unchanged
Fault record emptied or deleted on ranks with no pairs; default, semi_lagrangian, lagrangian 2, 3 band, rand7 semi_lagrangian on every rank eulerian, refusal, and lagrangian respectively on every rank
Getter before the model, stock add_fault mesh 1, 2, 3 –, band, rand7 semi_lagrangian on every rank eulerian on every rank
Getter before the model, record emptied on the ranks with no pairs 2, 3 band, rand7 semi_lagrangian on every rank differs between ranks: at np 3 band, semi_lagrangian, eulerian, semi_lagrangian. After the model is assigned: eulerian and EulerianSUPG on every rank
add_fault after the solver is built; a second add_fault 1, 2, 3 –, band, rand7 as in the first review unchanged: the solver stays on its own mesh; a solver on the new mesh gets the guard
test_1107 + test_1076 + test_1077 1 – 6 failed, 11 passed: the 6 failures are in test_1107; the thin-sheet suites pass 17 passed
test_1107_..._parallel (3 tests) 2 default, band 3 failed 3 passed
test_1107_..._parallel 3 default, band, rand7 3 failed (default) 3 passed
test_1107_..._parallel, with the allreduce replaced by the local value 2, 3 default, band – the first two tests run through; the new MAX test hangs, and the supervisor stops it (note 1)

The getter

The getter reads the local record (getattr(self.mesh, "_fault_point_pairs", None)), so it can disagree between ranks before the history exists, but only when a rank lacks the record. A rank holding no pairs does not cause it. Every current path that writes the record gives each rank the fault-name key, even with no local pairs: the add_fault child, the redistributed add-on, and collect_point_pairs for the extruded sheet. With stock meshes the getter agreed on every rank in every layout. It disagreed only when the record was stripped on purpose, as above.

The disagreement is harmless:

  • Inside the library every reader of stress_transport runs after _resolve_stress_transport_for_faults. That function either sets _stress_transport on every rank, or finds no fault on any rank, in which case the local read is falsy everywhere and gives the same semi_lagrangian.
  • The history that is made is the collective decision. With the stripped record, every rank built EulerianSUPG.
  • Only user code that branches on the getter before assigning the model, and then enters a collective, could be misled, and only on a mesh whose record is missing on some ranks, which nothing in the library produces. The code comment and the PR body both say the read is rank-local. That is enough.

Notes

  1. Low, no change needed: the new MAX test (test_every_rank_refuses_when_only_one_rank_holds_the_fault_record) does catch a regression to a local decision. With the reduction removed, rank 0 refuses and waits in the test's closing allreduce, while the other ranks go on to build a semi-Lagrangian history and block in MeshVariable._setup_ds. So the regression shows as a hang, at np 2 and np 3, rather than as a failed assertion. The module's 300 s pytest timeout bounds it. A divergent decision cannot fail more cleanly than this, so the test is fine as it is.
  2. Low, PR body only:
    • Stale development count: the body says that on development test_1107 "gives 4 failed … and 3 passed". With the new tests it gives 6 failed and 4 passed (6 failed and 11 passed together with test_1076 and test_1077).
    • Session code: the first line says "from H1's review", a session code without its meaning. "from the review" is enough.

Confirmed correct

  • The thin-sheet docstring now states the refusal, and the PR body says the guard covers ThinSheet.
  • The getter reports eulerian on a faulted mesh before the model is assigned.
  • lagrangian is now in the allowed parametrize, and passes.
  • The decision when the history is made is unchanged from the first review: an allreduce MAX at the start of _create_stress_history_ddt, and a refusal raised before any history object exists.
  • Unfaulted meshes behave the same as on development, at np 1, 2 and 3.
  • The new serial and parallel tests fail on development and pass on the PR.

Run and not run

  • Run: everything in the table, serial and at np 2 and 3, each parallel run under an MPI supervisor with a 300 s silence limit, and nothing above 3 ranks.
  • Not run in this re-check:
    • the wider viscoelastic neighbour set. The first review ran it on the same guard code: 117 passed on base and PR alike;
    • the VE solve comparison across ranks, whose code path is unchanged since the first review;
    • the empty-rank layout, whose two pre-existing hangs (reported in the first review) are not this PR's.

Logs kept by the reviewer.

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.

3 participants