Repository navigation
Tensor_Projection's work variable takes the tensor's degree; Stokes.tau decodes a log-conformation history - #1210
Conversation
…au decodes a log-conformation history Stokes.tau decodes a log-conformation stress history by projecting the carried stress G (exp(psi*) - I) onto a tensor variable of the history's degree, through Tensor_Projection. Tensor_Projection projects component by component through a scalar work variable, copying each component in and out node for node, and built that variable at degree 2 whatever the tensor's degree. On a degree-1 history the copy raised: "could not broadcast input array from shape (15,) into shape (45,)" on a 4 x 2 quad box. So a log-conformation run could not read its own stress. The work variable now takes the tensor field's degree unless a degree is given (2 when there is no tensor field). Callers that pass their own work variable or a degree are unchanged. Tests in tests/test_1065_log_conformation.py, both failing on development 1b601be: the decoded stress equals the carried stress on a uniform Maxwell shear (rel 1e-8), and a linear tensor projects onto degree 1 exactly (1e-10, at a solver tolerance of 1e-12). Underworld development team with AI support from Claude Code
… form; a mismatched work variable is refused (review of #1210) From the adversarial review: - Stokes.tau's decode kept the projection's default tolerances (snes_rtol 1e-4), so the accuracy of a public return value was incidental. It now projects at 1e-10. - The test compared the decoded stress with the function it projects. It now checks one ETD-1 deformation step from rest in simple shear against the closed form G (c - I) of _deformation_step (rel 1e-6), which a wrong modulus or decode would fail. The degree-1 projection test checks the yy entry too. - The components are copied node for node, so a work variable whose degree or continuity differs from the tensor's (a discontinuous tensor with the default work variable, or a scalar_Field of another degree) now raises when the projection is built, naming both, where it raised a broadcast error in solve(). Every caller in src, tests and the examples passes a matching pair. - The docstring says degree 0 has no smoothing effect. 69 related tests pass, serially. Underworld development team with AI support from Claude Code
Adversarial review recordOne round, by a fresh reviewer that read the code through git without running it. The measurements below were made by the author, serially, on macOS (12-core Apple M4). Findings, all fixed in 3d6eca7
Attacks that found nothing
Tests69 related tests pass. The two decode tests failed on development 1b601be. The refusal test is new behaviour, and it was not run against development. From reading, development builds that projection without complaint and fails later, in Underworld development team with AI support from Claude Code |
|
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)) Verdict on head 3d6eca7: ready to merge on green from this review. No correctness findings. Three low items are below; none blocks the merge. FindingsLow 1: a refused construction leaves its work variable on the meshThe check runs after
Low 2: a discontinuous tensor with default arguments is refusedAsked for nothing else, the default work variable could take the tensor's continuity as it already takes its degree. Today a discontinuous tensor with defaults is refused, and the caller has to build a matching scalar. The message says exactly what to pass, so this is a usability point only. Low 3: the PR body no longer matches the branch
Build noteDevelopment's merge base 1b601be differs in compiled source from the build used here, in
Neither is on the Tensor_Projection or log-conformation path. So the runs below lay the PR's Python on that build without a rebuild. Confirmed correct
What was run
Every parallel run went under the MPI supervisor. Logs are kept by the reviewer. Not run:
Underworld development team with AI support from Claude Code |
A log-conformation run could not read its own stress. No issue was filed: this PR is the report. Found while writing a test for #1209.
The defect
On development 1b601be, serial, macOS (12-core Apple M4):
StructuredQuadBox4 x 2.ViscoElasticPlasticFlowModel(order=1, integrator="etd", objective_rate="upper_convected", stress_history="log_conformation").solve(timestep=0.1).stokes.tauraises:ValueError: could not broadcast input array from shape (15,) into shape (45,).The probe is
issue-sweep/sweep-2026-11-15/p_tau_decode.pyin the campaigns repository.Cause
Stokes.taudecodes the history by projecting the carried stress G (exp(ψ*) − I) onto a tensor variable of the history's degree, throughTensor_Projection. That class projects one component at a time through a scalar work variable, copying each component in and out node for node. It built the work variable at degree 2, whatever the tensor's degree. A degree-1 tensor has 15 nodes on this box; a degree-2 scalar has 45.Fix
test_0505andtest_multicomponent_projection.solve(). Every caller in src, tests and the examples passes a matching pair.Stokes.tauprojects the decoded stress at a solver tolerance of 1e-10. The projection's defaults (snes_rtol 1e-4) made the accuracy of a public return value incidental.Tolerances and coordinate matches
In the library: the decode's solver tolerance, 1e-10. Test bounds:
Tests
Three new tests in
tests/test_1065_log_conformation.py:test_the_decoded_stress_is_the_one_step_closed_form: one ETD-1 deformation step from rest in simple shear, against G(c − I) from the file's_deformation_step, for xx, xy and yy. It fails on development.test_tensor_projection_works_on_a_degree_one_tensor: a linear tensor, all three entries. It fails on development.test_a_work_variable_that_does_not_match_the_tensor_is_refused: new behaviour, not run against development. From reading, development builds that projection and fails later, insolve().Related tests pass, serially: 69, in test_1065, test_0505, test_multicomponent_projection, test_1059 and test_0070.
The two-solver decoded-stress test for #1209's
tau_decoded_<n>naming will be added once both PRs are merged.Review
One round of adversarial review; its record is posted below. Its findings are fixed in 3d6eca7.
Left for a follow-up
Underworld development team with AI support from Claude Code