Skip to content
Snippets Groups Projects
Verified Commit aa186676 authored by Liam Keegan's avatar Liam Keegan
Browse files

fix do_step call

  - was doing a step from `out` -> `out`
  - this resulted in null ptr deref after a failed integration step
  - instead do a step from `prev_out` -> `out`, where `prev_out` is a temporary which stores the previous `out` value
  - closes #29

fix dt > max_step error message
parent b7c04d2a
No related branches found
No related tags found
1 merge request!25Resolve "Add simple adaptive timestepping"
Pipeline #29383 failed
......@@ -108,6 +108,7 @@ public:
const auto& logger = asImpl().logger();
logger.notice("Evolving system: {:.2f}s -> {:.2f}s"_fmt, in.time, end_time);
out = in;
auto prev_out = in;
while (FloatCmp::lt<double>(out.time, end_time)) {
if (FloatCmp::gt<double>(dt, end_time - out.time)) {
logger.detail("Reduce step to match end time: {:.2f}s -> {:.2f}"_fmt,
......@@ -115,7 +116,8 @@ public:
end_time - out.time);
dt = end_time - out.time;
}
do_step(system, out, out, dt);
std::swap(prev_out, out);
do_step(system, prev_out, out, dt);
if (not out) {
logger.warn("Evolving system could not reach final time"_fmt);
break;
......@@ -409,7 +411,7 @@ public:
DUNE_THROW(InvalidStateException,
"time-step '" << dt
<< "' is greater than the maximum allowed step '"
<< _min_step << "'");
<< _max_step << "'");
_stepper.do_step(system, in, out, dt);
while (not out) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment