Skip to content

main train 2026-11-21: 4 reviewed changes from cekees/proteus - #1370

Merged
cekees merged 11 commits into
proteustoolkit:mainfrom
cekees:train/main-2026-11-21
Nov 22, 2026
Merged

cekees merged 11 commits into
proteustoolkit:mainfrom
cekees:train/main-2026-11-21

Conversation

@cekees

@cekees cekees commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Each change below was reviewed, and passed CI, as its own pull request on cekees/proteus. This branch merges them
onto main at 80ddeac with one merge commit per pull request, in the order listed.

Merge with "Create a merge commit", not squash or rebase, so the commits keep their hashes and the fork's pull requests close themselves.

pull request title commits
cekees#334 ElastoPlastic: constitutive model per material, load stepping, Kirsch and confined-compression verification 3
cekees#336 vdft_reproduce: the flow decks set BC_CONS=True, as the authors' builds ran (dev) 1
cekees#337 C5: a spec's ** 2 on one point is u*u, as the deck's array square is (damBreakLevelSet3D on chewbacca) 1
cekees#338 test/salinity: the levee deck reads a stored mesh (first-dt test failed on the nightly's PETSc-built triangle mesh) 2

Diff against main: 25 files changed, 80415 insertions(+), 103 deletions(-).

cekees and others added 11 commits November 14, 2026 10:17
The elastoplastic model had one test (Griffiths-Lane slope, a regression against
stored values). This adds an exact-solution test in the elastic range: a quarter
plate with a circular hole under remote uniaxial stress (Kirsch), solved in plane
strain on a one-element-thick tetrahedral slab with w = 0 on both faces.

- slab_mesh.py writes nested structured slab meshes in tetgen format from
  formulas (Kuhn split of a mapped grid), so no mesh generator is involved.
- kirsch_exact.py: displacement and stress; the stress from the displacement
  formula matches the stress formula to 1e-7 MPa and the hole is traction free
  to 1e-13.
- kirsch.py: exact displacement on the outer boundary, symmetry planes, free
  hole. Elasticity = cohesion 1e12 and P_a = 0 in the mcdp model.

Measured on macOS arm64 (conda-dev-mpich, serial), relative errors of the P1
solution against the exact one:

  n   elements   L2(u)      L2(stress)  rate u  rate s  max sxx (exact 300)
  4      192     2.630e-02  1.429e-01                   287.4
  8      768     8.964e-03  8.570e-02   1.55    0.74    295.7
  16    3072     2.501e-03  4.586e-02   1.84    0.90    298.2
  32   12288     6.459e-04  2.342e-02   1.95    0.97    299.2

P2 elements on the same meshes: max vertex error 9.69e-06, 1.50e-06, 3.29e-07
(n = 4, 8, 16), limited to second order by the straight-sided hole.

Newton converges in one iteration to a residual of about 1e-7 (from 1.7e9), so
the test uses an absolute tolerance of 1e-5; 1e-8 is below roundoff and makes
the step fail and retry.

The test runs n = 8 and 16 (1 s). Ran: test/solid_mechanics/test_kirsch.py and
test/griffiths_lane_6 (2 passed) locally.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…tepping

Model selection. evaluateConstitutiveModel called mcdp for every material; the
von Mises, Tresca, Drucker-Prager and Mohr-Coulomb calls were commented out and
Coefficients.modelType_block was stored but never used. The kernel now takes
the model type of the element's material ("materialModelTypes" = modelType_block):
0 and 1 mcdp (what every deck ran, so results are unchanged), 2 von Mises,
3 Tresca, 4 Drucker-Prager, 5 Mohr-Coulomb. Values outside 0..5 raise
ValueError. Only mcdp returns the minor principal stress used by the
pressure-dependent modulus, so the other models are for P_a = 0.

Load stepping. The step logic was the strength-reduction workflow: an elastic
gravity step, displacements zeroed, then SRF raised by 0.05 after every step.
Coefficients(loadStepping=True) gives quasi-static load steps instead: no
gravity step, no strength reduction, the unknown is the total displacement
(the kernel forms the step's strain increment as strain(u) - strain_last when
"totalDisplacement" is set), and postStep commits strain and plastic strain.
The default (False) keeps the old behaviour.

Verification (test/solid_mechanics/test_confined_compression.py): confined
compression of a block, yield stress 400 MPa, strain paths up to 3 times the
yield strain including unloading and reverse yield, against a radial-return
reference. macOS arm64, serial, max errors over the quadrature points:

  model                     path (eps/eps_Y)   stress (MPa)  plastic strain
  von Mises (2)             0.5                4.6e-13       0
  von Mises (2)             1.5                4.3e-12       2.8e-17
  von Mises (2)             1.5, 3.0           3.6e-12       2.2e-17
  von Mises (2)             3.0, 1.0           3.8e-12       2.2e-17
  von Mises (2)             3.0, -0.5          3.9e-12       2.6e-17
  von Mises (2)             10 steps to -1.0   3.6e-12       2.4e-17
  Drucker-Prager phi=0 (4)  1.5 / 3.0, 1.0     5.9e-08/7e-07 3.9e-13/6.1e-12
  mcdp (1)                  1.5                1.6e-05       1.0e-10

Before this change the same deck with model type 2 and one step stayed elastic
(stress -450, -1050, -450 against -516.7, -916.7, -516.7 at 1.5 eps_Y).

Not verified here: Tresca (3) and Mohr-Coulomb (5). On this problem the stress
sits on a corner of their yield surfaces; Tresca returns a non-uniform, wrong
state (stress error 105 MPa at 1.5 eps_Y, one failed step) and Mohr-Coulomb
did not finish (the step size kept halving for 10 minutes). They are wired as
they were written and need a corner treatment before use.

The solid mechanics test decks now share solid_deck.py, and slab_mesh.py gains
a rectangle. Ran locally: test/solid_mechanics (10 passed) and
test/griffiths_lane_6 (2 passed, displacement regression to 10 decimals).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ds ran

The authors' builds read RICHARDS_BC_CONS as ON unless set to 0 (in force since 2026-09-24).
Richards.Coefficients made it opt-in on 2026-11-04 (BC_CONS=False, c59451a), and none of the
decks in vdft_reproduce sets it, so the decks as shipped do not reproduce the manuscript's
coupling table. BC_CONS changes the boundary velocity that the velocity-based transport
coupling sees. Seven flow decks now pass BC_CONS=True (henry, elder, bioswale, levee density
and non-density, mms, simmons_uhd); the README says why.

Measured on a fresh build of the 1.9.1 tag, only BC_CONS changed (serial unless noted):

  UHD level 0, velocity-based, eos, Co 0.5   flux / storage / total (% of solute mass)
    manuscript                               -4.88 / 6.69 / 1.81
    deck as shipped (BC_CONS off)            -2.42 / 6.72 / 4.30
    with BC_CONS=True                        -4.88 / 6.69 / 1.81
  UHD level 0, velocity-based, lagged density: manuscript 2.28; with BC_CONS=True 2.28 / 0 / 2.28
  UHD level 0, lagged, flow limiter off: manuscript 0.7 %; with BC_CONS=True 0.729 %
  UHD level 0, velocity-based, Co 0.25: manuscript 2.1 %; with BC_CONS=True 2.11 %
  UHD level 0, compatible (edge fluxes): -7e-17 % both ways (not affected)
  Bioswale (2 ranks, BIOSWALE_DENSITY=1): manuscript 443 steps; shipped 442; with BC_CONS=True 443
  Henry FCT (serial): 3094 steps, mb_error -4.712444e-18, flow residual -1.390436e-13, identical with and without
  MMS T3 N = 40 FCT (serial): E2(c) 3.614946e-03, E2(psi) 3.859475e-03, identical with and without

Not run: Elder (64 ranks), UHD level 4, Zalesak reference 5, levee at 4 ranks, MMS N >= 80, the
dt ladders (HPC or ceds-model sized); BC_CONS's effect on Elder and the levee is unmeasured.
Henry's low-order deck (henry/low_order/flow_p.py) is left as it is: Henry is not sensitive.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
One conflict, proteus/elastoplastic/ElastoPlastic.h: in residual and jacobian
the branch added the `totalDisplacement` scalar (load stepping) just above
`int nElements_global`, and main (C33 part 4, #300) retyped that
line to proteus_index_t. Kept both: the totalDisplacement lines and main's
proteus_index_t nElements_global. Everything else merged automatically; the
per-material materialModelTypes selection sits on lines main did not touch and
the retyped index declarations carry through. No numerics changed.

Tested on macOS arm64 (conda-dev-mpich, Python 3.13, serial, extensions rebuilt
after the merge): test/solid_mechanics 10 passed, test/griffiths_lane_6 2 passed.
Numbers identical to the branch before the merge (PR body):
  von Mises stress error 4.5e-13 .. 4.3e-12 MPa over the five paths (plastic strain <= 2.8e-17)
  Drucker-Prager phi=0 5.9e-08 / 7.0e-07 MPa, mcdp 1.6e-05 MPa
  Kirsch P1 u errors 8.964e-3, 2.501e-3, stress 8.570e-2, 4.586e-2, rates 1.84 / 0.90

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… square is

test_the_spec_runs_the_deck_bitwise[damBreakLevelSet3D-1/-2] failed only on the
chewbacca nightly (arm64 Mac, pip PETSc 3.26 + TetGen 1.6.1): "38 of 95 datasets
differ" (1 rank), "38 of 100" (2 ranks), the first at phi_t0.

Cause, measured. The deck's phi_init squares an array, (maximum(d, 0)**2).sum();
numpy squares an array by multiplying. ymf prints the same level set as
numpy.maximum(0, x - 1.2)**2 + ..., evaluated one node at a time, where x is a
numpy.float64 and ** is the C library's pow(u, 2.0). pow(u, 2.0) != u*u for
356 to 517 doubles in 400000 (probe on this Mac, chewbacca, darcy, spark2: macOS
arm64, macOS x86_64 and glibc all have them; the array path has 0). So the
spec's phi is one last bit off at a node where that happens, and the run is no
longer bitwise the deck's. Whether the mesh has such a node is luck of its
coordinates: chewbacca's TetGen (the pip PETSc's 1.6.1) makes a 274-node mesh,
and node (1.28692838, 0, 0.65313949) has it (deck 0.10188399497933492, spec
0.10188399497933491); the conda TetGen makes 278 nodes, none has it, so CI and
the other nodes passed.

Fix: DispatchRun.exact_squares rewrites u**2 as numpy.square(u) in the code of a
field (_field) and of SWFlow's point functions (_OfPoint) before they are
compiled; an array evaluates identically (numpy.square is what ** 2 already is
for an array), a point now equals it too.

Before/after, chewbacca's own mesh (deck run in a temp dir there, nothing kept):
  nodes whose spec phi differs from the deck's: 1 of 274 -> 0 of 274
  conda mesh (this Mac, 278 nodes): 0 -> 0
New test_a_squared_initial_value_is_the_product_the_deck_computes: equal at 200
points where pow != u*u found by search (fails without the change at the first).
Run here (macOS arm64, conda env proteus-bc-261025, ymf origin/main 6868e7c):
test/dispatch 107 passed (106 before + the new one), damBreakLevelSet3D at 1 and
2 ranks bitwise.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…no longer depends on the triangle binary

test_first_dt_of_an_explicit_transport_respects_its_cfl[3] failed on every fleet-nightly pip prefix (ceds-model,
darcy, spark2, yoda-2404/2604) and passed on the conda CI legs and chewbacca. Cause: the levee deck generated its
mesh with the 'triangle' on PATH, and each environment's triangle makes a different mesh from the same levee_case_d.poly
and options 'pAq30Dena0.5': 26411 elements (Mac conda-forge), 26366 (Linux conda-forge, Debian), 26312 (the
PETSc-built triangle the nightly puts first on PATH). RKEV.initialize_dt takes min(interval, floored CFL dt *
M_min/1e-14); M_min is the same (0.071288) and the floored CFL follows the mesh:

  mesh      max edge CFL   first dt (s)            c after the first step, SSP33     SSP11
  26411     1.8555e13      0.1920947474532487      [-2.31, 9.51]                     [0, 4.49]
  26312     1.4291e13      0.24941296514510153     [-7.331, 16.075] (> bound 10)     passes

The 26312 line, run on the Mac conda build with the PETSc triangle's output replayed, reproduces the nightly's
(-7.330996940912488, 16.074950920619713, 0.2494129651451016) to 14 digits: not BLAS/MUMPS/SuperLU/flags/test order.

Fix (the test meshing policy: a test downstream of meshing reads a stored mesh): the levee deck's triangle output is
committed (stored_mesh/levee_case_d.{node,ele,edge}, 2.2 MB, force-added: *.ele is ignored), the levee_deck fixture
copies it in and _run no longer forces genMesh for it. The bound is |c| <= 20: above the worst measured value on
either mesh, far below the 1e8 of the failure the test guards against.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The recording test built the levee deck without the stored_mesh flag, so it still
meshed with whichever triangle is on PATH (26411, 26366 or 26312 elements). It now
reuses test_vdft_compatible's levee_deck fixture.

Measured: both parametrizations pass (2 passed, 12.8 s, Mac conda); and still
pass with a triangle on PATH that exits 3, so no mesher is called.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ping, Kirsch and confined-compression verification

From cekees/solid-contact at f30483c (#334).
…uthors' builds ran (dev)

From cekees/vdft-decks-bc-cons at b27d0a4 (#336).
…y square is (damBreakLevelSet3D on chewbacca)

From cekees/c5-arm64-dambreak at f49fe16 (#337).
…dt test failed on the nightly's PETSc-built triangle mesh)

From cekees/c0-r15 at 393895b (#338).
@cekees
cekees merged commit 67ace21 into proteustoolkit:main Nov 22, 2026
9 checks passed
@cekees
cekees deleted the train/main-2026-11-21 branch November 22, 2026 02:14
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