-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix iteration counts change all iter rebase #2882
base: next
Are you sure you want to change the base?
Conversation
Previously, `Solver::iteration` was updated in the implementations of `Solver::run()`, but if there is any monitor that is called more frequently than the output monitor, this means that `iteration` counts the number of calls to the more frequent monitor, not the number of output steps. Now, have a `SolverMonitor` in the base `Solver` class, that is called at the output frequency, and updates the iteration count.
Previously, the `Solver` implementations passed the loop counter to the `iter` argument of `call_monitors`, but since the iteration has already been completed when the monitors are called, this results in `iter` always being one less than the number of completed monitor-steps at the point when the moniters are called, which is confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid I don't remember now exactly how this was meant to work. If the outputs are working and the iteration counts printed into the log files are correct, then I guess everything should be fine.
When I tried to remind myself what was going on, I came across this line:
BOUT-dev/src/solver/solver.cxx
Line 870 in 1c020f9
++iter; |
With these changes, do we need the
++iter
here?
Oh, indeed, they are broken. How about this:
restart
|
This is needed to provide a meaningfull estimate of the run time
Sounds good to me @dschwoerer! |
This should not be needed anymore, now that we count from 0 to nout.
@ZedThree The unit tests are failing, but I did not figure out what is wrong. I am thus hesitant to just change the expected values. The real code seems to do the right thing, but the fake ones seem to be going wrong somewhere ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
@dschwoerer This is on my to-do list to look at! |
I think there's a bug in the current implementation in
This is with I think the fix is: modified src/solver/solver.cxx
@@ -498,6 +498,9 @@ int Solver::solve(int nout, BoutReal timestep) {
finaliseMonitorPeriods(nout, timestep);
+ number_output_steps = nout;
+ output_timestep = timestep;
+
output_progress.write(
_("Solver running for {:d} outputs with output timestep of {:e}\n"), nout,
timestep); This then runs for 10 output steps with |
I've got my head around the unit tests too, I'll push a fix for them shortly, along with some improved documentation about how the monitor timesteps work |
- Rule of 5 - dynamic_cast instead of static_cast - multiple declarations on single line
This expresses the intentions much better and makes some issues much clearer
`-1` was required for implementation on `next`, current branch adjusts the iteration number to start at zero
I've fixed the unit tests by converting them to use a mock monitor to check exactly what's getting called and with what arguments, and writing the tests in terms of There's just a few clang-tidy warnings in |
Rebase of #2535
TODO:
I have some done some manual testing, but not yet the smaller timestep (and might be wrong)