Fix off-by-one error in iteration counter #2549
Merged
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.
Bug introduced in #2534. After #2534, calling the monitors always increments the
Solver::iteration
counter. When monitors are called before the first internal timestep (ifdump_on_restart=true
), we do not actually want to increment the counter - this call is either at the very beginning of a simulation, when the counter should remain 0 until the end of the first output step, or it is effectively a repeat of the last call to monitors in the simulation that is being restarted from so that incrementing the counter would be double-counting.Simplest fix seems to be to decrement the counter if the monitors are called at the beginning of a run. Was not an issue before #2534 because the counter was incremented by each solver implementation rather than by the monitors, so the initial call to monitors did not touch the counter.