Repository navigation
Conversation
property_engine::checkpoint()/restore() snapshot the serialized history by position in the engine's history list; restore() returns old and new values exactly, after any number of commits, clears a failed update like revert() and refuses a checkpoint of another context. material_context and material_point forward both. A report case may set max_cutbacks (default 0, unchanged behaviour): a step that does not converge or throws a cutback_error returns to the checkpoint at its start and runs again in 2, 4, ... substeps. The substeps are recorded in step_record; the CSV format is unchanged.
A report step is retried in more substeps on any std::runtime_error, as UMAT does: the return maps throw runtime_error, not only cutback_error. fatal_error and logic_error are rethrown without a retry. cut_step rejects max_cutbacks outside 0 ... 20 (a negative value never reached the last level and 1 << cut overflowed). restore() checks the number of history properties and keeps the context marked failed until every one is back. checkpoint() documents that only history properties are saved.
Member
Author
|
Review fixes, commit 4665616.
Red before the fix (gate fix225red, 1474 tests, 10 failed counting the ASan twins): Gate after: BUILD=0 TEST=0, 0 warnings, 1474 tests (GCC 14 + ASan). Design remarks, no code change:
|
# Conflicts: # include/numsim-materials/core/property_engine.h
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #215 (part of #221, #184 phase 2: checkpoints and cutbacks). Independent of the other epic PRs; it can merge in any order.
What and why
commit()/revert()give history two levels, enough for one Newton step but not for substepping: after two accepted substepsrevert()cannot go back to tₙ. This adds a checkpoint within a step and uses it for cutbacks in the report loop.Engine (
core/property_engine.h)history_checkpoint<Traits>: the serialized bytes of every history property, by position in the engine's history list, plus the owning engine. No keys, no lookups;property_base::serialize()/deserialize()carry both values, so numsim-core is unchanged.checkpoint() constandrestore(history_checkpoint const&). Restore brings old and new back exactly as they were and clears the failed state likerevert(). A checkpoint of another context (or a default-constructed one), or one with a different number of history properties, throwsstd::logic_error. Only history properties are saved; state a material keeps outside them across calls is not restored.revert(); nothing existing is touched (keeps the overlap with Property engine: keep the typed edges, export the graph (DOT/JSON), name the cycle #213 small).Forwarding:
material_context::checkpoint()/restore()(with the finalize() gate,checkpoint_typealias) andmaterial_point::checkpoint()/restore().Report loop (
report/case_runner.h)"max_cutbacks"(default 0, 0 ... 20;cut_steprejects other values withstd::invalid_argument). A step that does not converge, or whose evaluation throws astd::runtime_error(umat::cutback_errorand the return-map failures of the materials, as UMAT treats them), goes back to the checkpoint taken at its start and runs again in 2, 4, ... substeps; every substep but the last is accepted. At the last level the failure is recorded (or rethrown) exactly as today.load_path::substeps(step, n)splits a step from the end of the step before (along its segment); the last substep ends exactly at the step's load and fraction, and time and dt are split too.step_recordgetscutbacksandsubsteps(the Newton summary of each substep at the final level;resultstays the last one). The CSV format is unchanged.Decisions / deviations from the issue
max_cutbackslives on the case (load_case, parsed inreport_json.h, next totangent_everyandfd_step), not inreport_spec.h: that header only merges includes and substitutes parameters, it has no spec struct. Studies inherit it from their case.max_cutbacks = 0the loop takes the old path (no checkpoint is taken), so reports without the key run exactly as before.std::runtime_error, matching UMAT (cutback_erroris one; so are the Newton/return-map failures).umat::fatal_errorandstd::logic_errorpropagate without a retry.checkpoint()on a context whose last update threw throws: a partly updated state is no point to come back to.step_recordcarries the substeps for sinks that want them.Tests
test_history_checkpoint(new): bitwise restore after two committed steps with an int history (int_counter) and a rank-4 history (compared throughsave_statebytes, old and new); a continuation after restore matches the uninterrupted run; a failed update followed byrestore()updates again; a foreign or empty checkpoint throws and leaves the context unchanged; finalize() gate;material_pointforwarding.test_report_case:load_path::substeps(segment crossing, unloaded start, one substep = the step bitwise);max_cutbacksparsing (default 0, negative/fraction/above 20 throw); an exponential-damage softening case under uniaxial stress (point max_iter 5) that fails at the full increment withmax_cutbacks0 and 1 and converges with 2, its result bitwise equal to the case run in four steps;max_cutbacks = 0and the default give the same CSV, and cutbacks a case does not need change nothing; acutback_errororruntime_errorthrown by a material (a fixture limiting the strain increment) is rethrown without cutbacks and cut away with one;logic_errorandfatal_errorare thrown once and not retried;max_cutbacks-1, 21 and 40 throwinvalid_argument; a step failing after accepted substeps returns to its start (history counter); finite-strain cutback; tangent check combined with cutbacks.docs/materials/*/report.jsonCSVs (14 reports) are byte-identical to main.Gate
GCC 14 + ASan: BUILD=0 TEST=0, 0 warnings, 1474 tests (main: 1440).