Replay pr3 state rollback and test - #7377
Open
ElyesAhmed wants to merge 2 commits into
Open
Conversation
ElyesAhmed
force-pushed
the
replay-pr3-state-rollback-and-test
branch
from
August 31, 2026 09:52
fd39f4d to
e95b270
Compare
Capture and restore dynamic state across simulation sub-steps when a timestep fails to converge and is chopped/retried: - FlowProblem / FlowProblemBlackoil: snapshot and restore rock compaction transmissibility multipliers, minimum effective pressures, maximum water pore volume, and polymer maximum concentration; restore dynamic material law hysteresis state via EclMaterialLawManager. - BlackoilWellModelGeneric: snapshot and restore well/group operating controls, NUPCOL targets, dynamically shut-in wells, WCYCLE open/close timers, and surface network branch/node pressures. - ISTLSolver: clean and deallocate AMG hierarchies and preconditioner caches on updateFailed(). - OutputBlackoilModule: properly initialize per-cell hysteresis parameters.
- Add tests/run-timestep-replay-regressionTest.sh to compare adaptive baseline runs against hardcoded INFOSTEP replay runs. - Add tests/run-all-state-rollback-tests.py and wrapper script to validate state rollback across 17 distinct physics configurations. - Register high-impact replay regression tests in regressionTests.cmake (WCYCLE-1, 2_MSWWELL_MODEL3, MOD4_GRP, EXTREME_ROLLBACK_STRESS, FORCED_ROLLBACK_MULTICUT, etc.). - Document the role of --cpr-reuse-setup=0 in replay tests for exact bitwise trajectory identity (2e-14).
ElyesAhmed
force-pushed
the
replay-pr3-state-rollback-and-test
branch
from
August 31, 2026 10:01
e95b270 to
55d8250
Compare
ElyesAhmed
marked this pull request as ready for review
August 31, 2026 10:03
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.
Summary
This PR completes, hardens, and expands the state rollback mechanism initiated in [#7198].
When a simulator timestep fails to converge and is chopped into smaller sub-steps, any dynamic state modified during the failed iterations or updated at the start of the timestep must be restored to its exact beginning-of-timestep values. Without proper rollback, retried sub-steps start from polluted state, causing non-deterministic trajectories, trajectory divergence, or convergence degradation.
This PR establishes complete state rollback across Blackoil, Well, Aquifer, and Material Law (Hysteresis) subsystems and adds an extensive deterministic timestep replay regression test suite.
Key Additions Beyond #7198
Relative Permeability & Capillary Pressure Hysteresis Rollback:
opm-commonPR, dynamic directional hysteresis inflection points and historical saturation extrema (beginTimeStep()and restored onupdateFailed().Linear Solver & Preconditioner Invalidation Documentation:
ISTLSolver::eraseMatrix()completely deallocates AMG hierarchies, smoothers, and coarse matrix factorizations onupdateFailed().--cpr-reuse-setup=0in replay test harnesses: isolates physical state verification from heuristic preconditioner reuse cadences (solveCount_), ensuring exact bitwise replay identity.Expanded Replay Regression Test Suite & CMake Integration:
tests/run-all-state-rollback-tests.pyproviding automated verification across 17 distinct physics configurations.regressionTests.cmake(runnable via standard CTest):WCYCLE-1(Well cycling timers rollback)2_MSWWELL_MODEL3(Multisegment well state isolation)MOD4_GRP(Group hierarchy and NUPCOL rate allocations)EXTREME_ROLLBACK_STRESS(Multi-physics stress under forced cuts)FORCED_ROLLBACK_MULTICUT(Cascading multi-cut step retries)Architectural Cleanup of Snapshot Structures:
PrevTimestepStatestructs acrossFlowProblem,FlowProblemBlackoil, andBlackoilWellModelGeneric.Subsystem Audit & Rollback Summary
BlackoilWellModelGeneric::PrevTimestepState(wgstate,nupcol_wgstate,closed_this_step,well_open_times,well_close_times,genNetwork_)FlowProblem::PrevTimestepState(rockCompTransMultVal_,minEffectivePressure_,maxWaterPoreVolume_)EclMaterialLawManager::captureBeginTimeStepState()/restoreBeginTimeStepState()FlowProblem::PrevTimestepState(maxPolymerConcentration_)endTimeStep()), zero mid-iteration leakageendTimeStep()Companion PR & Dependencies
opm-commonDependency: Requires companionopm-commonPR [https://github.com/Implement hysteresis state capture and rollback in material law manager opm-common#5327] forEclMaterialLawManagerhysteresis snapshot APIs.Verification Results
All 17 active physics regression cases in$2 \times 10^{-14}$ ) between adaptive baseline runs (with failed iterations and chopped steps) and hardcoded replay runs:
run-all-state-rollback-tests.pyachieve bitwise machine-precision identity (SPE1CASE2_ROCK2DTR(16 cut steps) —MATCH (2e-14)0_BASE_MODEL2(14 cut steps) —MATCH (2e-14)WCYCLE-1(4 cut steps) —MATCH (2e-14)2_MSWWELL_MODEL3(12 cut steps) —MATCH (2e-14)ACTIONX_GCONPROD(15 cut steps) —MATCH (2e-14)ACTIONX_UDQ(21 cut steps) —MATCH (2e-14)MOD4_GRP(8 cut steps) —MATCH (2e-14)2D_OW_CTAQUIFER(5 cut steps) —MATCH (2e-14)2D_FETKOVICHAQUIFER(4 cut steps) —MATCH (2e-14)2D_THREEPHASE_POLY_HETER(7 cut steps) —MATCH (2e-14)7_HYSTERESIS_MODEL2(6 cut steps) —MATCH (2e-14)WAGHYSTR-01(9 cut steps) —MATCH (2e-14)VAPPARS-01(8 cut steps) —MATCH (2e-14)EXTREME_ROLLBACK_STRESS(18 cut steps) —MATCH (2e-14)FORCED_ROLLBACK_MULTICUT(24 cut steps) —MATCH (2e-14)Out of Scope / Deferred for Future Work
flow_comp): State rollback hooks for compositional fluid systems.ISTLSolverGPUISTL.