Skip to content

Solver and return-map failures throw cutback_error - #231

Merged
petlenz merged 1 commit into
mainfrom
fix/solver-cutback-errors
Oct 29, 2026
Merged

petlenz merged 1 commit into
mainfrom
fix/solver-cutback-errors

Conversation

@petlenz

@petlenz petlenz commented Oct 29, 2026

Copy link
Copy Markdown
Member

What / why

Hosts classify a failure by its type (umat/errors.h): fatal_error stops the analysis, cutback_error (a std::runtime_error) means "retry with a smaller increment". Return-map and Newton non-convergence in the library threw plain std::runtime_error, so a host that classifies by type could not tell a step-size problem from a setup fault.

Contract

  • Step-size-recoverable failures (non-convergence, no admissible multiplier, non-positive det F) throw cutback_error with the unchanged message.
  • Setup and misuse errors keep their type (runtime_error, invalid_argument, logic_error); a smaller step cannot fix them.
  • cutback_error derives from runtime_error, so the UMAT catch order in umat_interface.h is untouched (fatal_error first, then std::exception -> pnewdt = 0.25). Callers that catch runtime_error still work.

Changed sites

Site Failure
materials/j2_plasticity.h (2) return-map Newton did not converge; negative plastic multiplier
materials/j2_rk_plasticity.h implicit stage did not converge
materials/drucker_prager_plasticity.h (2) negative multiplier; smooth and apex Newton both failed
materials/j2_kinematic_plasticity.h (2) coupled return map did not converge; negative multiplier
mean_field/kernels.h self_consistent did not converge
materials/neo_hooke.h det F <= 0 (was std::domain_error)

Deviations from the brief

  • The vector_newton.h lines named in the brief (275, 298, 530) are not step-size failures: solve_with_factorization() called without a converged solve (API misuse), check_names (input validation) and the zero_blocks check (model definition). vector_newton::solve() itself never throws; it reports converged() and the materials throw. They are left as they are.
  • Deliberately unchanged: j2_kinematic_plasticity.h graph-driven solver check (configuration, with a test that it is not a cutback_error), orientation.h ACG fit (preprocessing, not part of a step), all weighted_sum/property_engine/material_context/IO errors.
  • Added beyond the brief: self_consistent (non-convergence) and neo_hooke (det F <= 0, previously domain_error; an inverted element is the usual reason for a cutback, and std::domain_error would not be caught by a host catching runtime_error).
  • Materials include umat/errors.h for now; the type is still defined there.

Independence from #222

This PR does not depend on #222. #222 moves cutback_error to core/errors.h and keeps umat::cutback_error through a using-declaration, so both spellings stay valid. If #222 merges first, the only conflict to expect is the added #include "numsim-materials/umat/errors.h" lines, which still resolve through the forwarder, so no change is needed beyond taking either side.

Tests

Each family forces the failure and expects cutback_error; all were red first (the plain runtime_error/domain_error was thrown) and are green now.

  • J2Softening.UnstableSofteningIsRejectedRatherThanClamped, J2Softening.ANonConvergedReturnMapAsksForASmallerStep (zero tolerance)
  • J2Kinematic.ANonConvergedReturnMapAsksForASmallerStep, ANegativeMultiplierAsksForASmallerStep, AGraphDrivenSolverIsAConfigurationErrorNotACutback
  • RkConvergence.AJ2RkStageThatRunsOutOfIterationsThrows, AFailedStageDoesNotInfluenceTheNextCall
  • DruckerPragerErrors.ANegativeMultiplierAsksForASmallerStep, WhenBothNewtonsFailTheStepIsRetryable
  • MeanFieldKernels.SelfConsistentThrowsWhenItDoesNotConverge
  • NeoHooke.ANonPositiveDeterminantAsksForASmallerStep

Gate

Full gate (GCC 14, -O1): BUILD=0 TEST=0 warnings=0, 1454 of 1454 tests passed.

Non-convergence, a negative plastic multiplier and a non-positive det F
are recoverable with a smaller increment, so hosts that classify by type
can retry them. Configuration errors keep their types.
@petlenz
petlenz merged commit d11634f into main Oct 29, 2026
2 checks passed
petlenz added a commit that referenced this pull request Oct 29, 2026
The return-map and convergence failures from #231 included umat/errors.h and
threw umat::cutback_error; the same type now comes from core/errors.h, so no
material header pulls in umat/. test_host_neutral_includes covers the six headers.
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