Skip to content

#894: refresh the interface-law operator in place in the rotated Newton loop - #913

Merged
lmoresi merged 4 commits into
developmentfrom
bugfix/rotated-interface-operator-refresh
Oct 31, 2026
Merged

lmoresi merged 4 commits into
developmentfrom
bugfix/rotated-interface-operator-refresh

Conversation

@lmoresi

@lmoresi lmoresi commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

With a fault interface law, the rotated Newton loop handed the KSP a new operator at every iterate. The velocity multigrid kept the finest smoother's operator of iterate 0, and the Galerkin coarse operators with it. This PR refreshes the operator in place.

Stacked on #892's PR (bugfix/fac-live-block-solver); it is retargeted to development when that merges.

What was wrong

The loop built Ahat + Khat into a new Mat at every iterate. PCMG keeps the finest smoother's operator unless the PC's new pmat is the same object. The fieldsplit hands over a new velocity block when the pattern state changes, and a new Pmat object resets that state even with an identical pattern. So on the saddle-point and thin-sheet paths alike, the smoothers worked on iterate 0's operator.

GAMG was never stale: it rebuilds from the live operator at every set-up. The mesh's own multigrid tail (no set_custom_fmg) was stale too.

The fix

The sum is made once, then refreshed in place with MatCopy of Ahat and MatAXPY of the tangent, both SUBSET_NONZERO_PATTERN. This is what the frictionless contact already does with Ahat. The null space attached to the first sum stays with it.

The direct-LU path keeps a fresh sum each iterate. Its pressure pin (zeroRows) drops pattern entries, so an in-place copy would raise "new nonzero ... caused a malloc". That path has no multigrid to go stale.

Measured

Velocity iterations per Newton increment on test_1088's fixture, viscous fault:

path before after
saddle point 2, 32, 31, 26, 27 2, 2, 2, 3, 3
thin sheet 2, 27, 21, 21, 21, 20 2 at every increment
thin sheet, mesh-owned tail 4, 30, 23, 24, 23, 22 4-5

On the box at np 4 with a rate law, the parent capped 746 of 772 velocity sub-solves and had not converged at 60 minutes. This branch converges in 160 s.

Tests

test_1088 runs three hierarchies (set_custom_fmg, the mesh's own tail, GAMG as a control) on the saddle-point and thin-sheet paths, with a viscous fault and with the frictionless contact as the control. It also has the direct-LU case.

  • After each linear solve it records the operator the multigrid was handed and the finest smoother's operator, and it bounds the Newton increments.
  • On the parent build the four viscous-fault multigrid arms fail; on this build 12 pass.
  • A mutant that skips the in-place refresh fails all six viscous-fault arms.
  • The direct-LU case is an imperative xfail on non-convergence only. That is Direct-LU rotated path does not converge on a split-fault contact solve (slip 4-5% off) #899: the direct-LU path does not converge on any split-fault contact, on development too.

Review

The adversarial review (12e5fc0) is in the first comment.

Issues

Underworld development team with AI support from Claude Code

…perator

With a fault interface law the rotated Newton loop hands the KSP a new
operator at every iterate, and the velocity multigrid keeps the finest
smoother's operator of iterate 0. The test records, after each linear
solve, the operator the multigrid was handed and the finest smoother's
operator, on the saddle-point and thin-sheet paths, with a viscous fault
and with the frictionless contact as the control.

On this commit (no fix) the viscous-fault cases fail: the operators differ
by 0.77-0.87 (relative, Frobenius) at every iterate after the first, on
both paths. The frictionless cases pass. Tier B, serial and parallel, one
file under tests/parallel with no min_size mark (run from the serial
batches beside test_1090).

Underworld development team with AI support from Claude Code
…on loop

With a fault interface law the loop built Ahat + Khat into a new Mat at every
iterate. PCMG keeps the finest smoother's operator unless the PC's new pmat is
that same object, and the fieldsplit hands over a new velocity block when the
pattern changes, so the finest smoother and the Galerkin coarse operators
stayed at iterate 0, on the saddle-point and the thin-sheet paths alike.

The sum is now made once and refreshed in place after that: MatCopy of Ahat
and MatAXPY of the tangent, both SUBSET_NONZERO_PATTERN, which insert into
existing locations and leave the Mat and its nonzero state unchanged. This is
what the frictionless contact already does with Ahat. The tangent's pattern is
fixed by the fault facets and Ahat's by the ptap, so both stay inside the
first sum's pattern. The null space attached to the first sum stays with it,
so the re-attach is gone.

test_1088 passes (it failed on the parent). Velocity iterations per Newton
increment on its fixture, viscous fault: saddle point 2, 32, 31, 26, 27 ->
2, 2, 2, 3, 3; thin sheet 2, 27, 21, 21, 21, 20 -> 2 at every increment.
The test now also bounds them at 5.

Underworld development team with AI support from Claude Code
…erate

The in-place refresh does not fit the direct-LU path: its pressure pin
(zeroRows, without MAT_KEEP_NONZERO_PATTERN) drops the pinned row's entries
from the sum, and the next MatCopy raised "new nonzero at (0,818) caused a
malloc" at iterate 1. That path has no multigrid to go stale, so it builds
a fresh sum as before; the in-place refresh stays on the multigrid paths.

test_1088 gains the LU case. The path does not converge on a fault contact
on development either (#899, filed: 50 increments, slip 4-5% off, with or
without an interface law), so the case is a strict xfail on its
convergence assertion only: the PETSc error above still fails it.

Underworld development team with AI support from Claude Code
…nd GAMG

From the adversarial review of this branch:

- The operator-gap check alone could not see an operator that is the right
  object holding iterate 0's values: a mutant that skips the in-place refresh
  passed the thin-sheet case. The test now also bounds the Newton increments
  (5-6 measured; the mutant takes 49 or stalls) and fails all six
  viscous-fault arms under that mutant.
- The split mesh's own multigrid tail (no set_custom_fmg) was stale too
  (thin sheet 4, 30, 23, 24, 23, 22 before, 4-5 after) and is now an arm.
  GAMG is an arm as a control: it rebuilds from the live operator at every
  set-up and was never stale (31-44 before and after, gap 0).
- The direct-LU case is an imperative xfail on non-convergence (#899) only,
  so a fix to #899 that converges to a different slip fails the test.
- The comment named the wrong trigger: a new Pmat object resets the PC's
  nonzero state even with an identical pattern.
- FAULT_CONTACT_DEPLOYMENT's trap list prescribed a rebuilt copy per
  iterate; it now says to refresh one copy in place, LU excepted.

On the parent build the four viscous-fault multigrid arms fail and the rest
pass; on this build 12 pass and the LU case xfails.

Underworld development team with AI support from Claude Code

lmoresi commented Oct 31, 2026 •

Copy link
Copy Markdown
Member Author

Adversarial review (fixes in 12e5fc0)

Reviewed by a separate agent against docs/developer/guides/adversarial-review.md.

Findings and what was done

  1. The operator-gap check could not see stale values in the right object. A mutant that skips the in-place refresh passed the thin-sheet case.
    Resolution: the test also bounds the Newton increments (5-6 measured; the mutant takes 49 or stalls), and the mutant now fails all six viscous-fault arms.
  2. The mesh's own multigrid tail was stale too, and untested. Without set_custom_fmg, the thin sheet went 4, 30, 23, 24, 23, 22 before and 4-5 after.
    Resolution: it is an arm. GAMG is an arm as a control: it rebuilds from the live operator at every set-up and was never stale (31-44 before and after, gap 0).
  3. The direct-LU case could hide a wrong answer.
    Resolution: it is an imperative xfail on non-convergence (Direct-LU rotated path does not converge on a split-fault contact solve (slip 4-5% off) #899) only, so a fix to Direct-LU rotated path does not converge on a split-fault contact solve (slip 4-5% off) #899 that converges to a different slip fails the test.
  4. The comment named the wrong trigger.
    Resolution: it says a new Pmat object resets the PC's nonzero state even with an identical pattern.
  5. A deployment note prescribed the defect. FAULT_CONTACT_DEPLOYMENT's trap list said to rebuild a copy per iterate.
    Resolution: it says to refresh one copy in place, LU excepted.

On the parent build, the four viscous-fault multigrid arms of test_1088 fail and the rest pass. On this build, 12 pass and the LU case xfails.

Issue verdicts

Underworld development team with AI support from Claude Code

@lmoresi
lmoresi changed the base branch from bugfix/fac-live-block-solver to development October 31, 2026 21:06
@lmoresi
lmoresi merged commit afdfe59 into development Oct 31, 2026
7 checks passed
lmoresi pushed a commit that referenced this pull request Oct 31, 2026
…ilure

D (#892) and the #894 fix both changed rotated_bc.py after this branch's CI
ran. Clean merge; CI re-runs on the combination before #916 merges.

Underworld development team with AI support from Claude Code
lmoresi added a commit that referenced this pull request Oct 31, 2026
Development now carries D (#912) and the #894 fix (#913). The only
conflict was scripts/test.sh, where both branches add a tests/parallel
file to batch 4; both are kept.

Underworld development team with AI support from Claude Code
lmoresi added a commit that referenced this pull request Oct 31, 2026
CI failed test_1106 at np 1 as well as at np 2: Linux counts 4772 patch
rows in serial against 4780 on macOS. The placed fault's cavity fill
differs by a few rows between hosts:
- macOS arm64, custom PETSc 3.25.0;
- CI's Linux x86_64, conda-forge PETSc 3.25.3;
- both with gmsh 4.15.2.
On CI the np 2 count is 4772 too, so the partition does not change the
band there either: the test's single macOS baseline was the defect, not
the halo.

The test accepts exactly the recorded serial counts, one per host. #896's
error added 2110 rows. A new host records its serial count. Passes at np
1 and 2. The merged branch's FAC and fault suite passes: 66 serial, 26 at
np 2 (3 skipped). test_1088 (from #913) passes 12, with its LU case
xfailing (#899).

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.

1 participant