From 1e5ecb7d1488263ffed18f7cc78d8e08df996705 Mon Sep 17 00:00:00 2001 From: Christoph Lehmann <christoph.lehmann@ufz.de> Date: Fri, 12 Jan 2024 10:35:19 +0100 Subject: [PATCH] [PL] Bugfix: the last time step is an output step, too --- ProcessLib/TimeLoop.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ProcessLib/TimeLoop.cpp b/ProcessLib/TimeLoop.cpp index 51ad6f45d55..b687c02f3d6 100644 --- a/ProcessLib/TimeLoop.cpp +++ b/ProcessLib/TimeLoop.cpp @@ -42,21 +42,27 @@ void updateDeactivatedSubdomains( } bool isOutputStep(std::vector<ProcessLib::Output> const& outputs, - const int timestep, const double t) + const int timestep, const double t, const double end_time) { + if (std::abs(end_time - t) < std::numeric_limits<double>::epsilon()) + { + // the last timestep is an output step + return true; + } + return ranges::any_of(outputs, [timestep, t](auto const& output) { return output.isOutputStep(timestep, t); }); } void preOutputForAllProcesses( - int const timestep, double const t, double const dt, + int const timestep, double const t, double const dt, const double end_time, std::vector<std::unique_ptr<ProcessLib::ProcessData>> const& per_process_data, std::vector<GlobalVector*> const& process_solutions, std::vector<GlobalVector*> const& process_solutions_prev, std::vector<ProcessLib::Output> const& outputs) { - if (!isOutputStep(outputs, timestep, t)) + if (!isOutputStep(outputs, timestep, t, end_time)) { return; } @@ -640,7 +646,7 @@ bool TimeLoop::preTsNonlinearSolvePostTs(double const t, double const dt, // Later on, the timestep_algorithm might reject the timestep. We assume // that this is a rare case, so still, we call preOutput() here. We // don't expect a large overhead from it. - preOutputForAllProcesses(timesteps, t, dt, _per_process_data, + preOutputForAllProcesses(timesteps, t, dt, _end_time, _per_process_data, _process_solutions, _process_solutions_prev, _outputs); -- GitLab