Skip to content

Replay pr3 state rollback and test#7198

Open
hnil wants to merge 3 commits into
OPM:masterfrom
hnil:replay-pr3-state-rollback-and-test
Open

Replay pr3 state rollback and test#7198
hnil wants to merge 3 commits into
OPM:masterfrom
hnil:replay-pr3-state-rollback-and-test

Conversation

@hnil

@hnil hnil commented Jun 23, 2026

Copy link
Copy Markdown
Member

No description provided.

hnil and others added 3 commits June 23, 2026 14:29
Improve the HardcodedTimeStepControl and add a gated float-precision mode so a
simulation can be re-run with a recorded sequence of accepted time steps and
reproduce the original results:

- HardcodedTimeStepControl: tolerance-based matching of the next substep time,
  sort the parsed substep times, and ignore empty lines.
- AdaptiveTimeStepping: seed the suggested step at the start of a report step
  from the hardcoded control so the very first substep matches.
- SimulatorReport: print INFOSTEP times with full (20-digit) precision.
- Add a TruncateTimeStepToFloat parameter (default off) that truncates the time
  step size to float precision. This is only used by the timestep-replay
  regression test to make recorded step sizes exactly reproducible; production
  runs are unaffected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add FlowProblem::updateFailed() and advanceTimeLevel() that forward to the
model, and call them from NonlinearSystem::prepareStep() instead of going
directly to the model. This lets the problem (and the models it owns, such as
the well model) hook into timestep failure recovery and time-level advance.

Behaviour is unchanged: the problem methods simply forward to the model.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
When a timestep fails, several pieces of dynamic state were not restored to
their start-of-step values, so a retried step did not start from the same
state. Snapshot this state at the start of a step and restore it on failure:

- BlackoilWellModel(Generic): well/group state (active + nupcol WGState),
  closed-this-step set, WCYCLE open/close times, network state and group state.
  Guide rates are intentionally not snapshotted (they are not updated during
  the Newton iterations, so they need no reset).
- FlowProblem / FlowProblemBlackoil: ROCKCOMP and saturation/pressure maxima,
  polymer adsorption, first-step flag and mixing-rate controls.
- ISTLSolver::eraseMatrix() now frees the matrix/rhs/solvers, and the blackoil
  Newton method resets its primary-variable switch bookkeeping per step.
- CompWellModel gets no-op updateFailed()/advanceTimeLevel() hooks.

Add a deterministic timestep-replay regression test that records the accepted
substep times of a run and re-runs with the hardcoded controller replaying
them, comparing the two outputs (spe1, spe9, and model2 0_BASE_MODEL2). The
baseline and replay both run with --truncate-time-step-to-float so the recorded
step sizes are exactly reproducible. The driver also accepts the -u option used
by the standard regression-test driver.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@hnil hnil added the manual:irrelevant This PR is a minor fix and should not appear in the manual label Jun 23, 2026
@hnil hnil requested a review from bska June 23, 2026 13:06
@bska

bska commented Jun 23, 2026

Copy link
Copy Markdown
Member

Please rebase this PR onto the current master sources to fix the merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

manual:irrelevant This PR is a minor fix and should not appear in the manual

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants