From fa6f48f113b2d8a09b252a658d108814edf38ea1 Mon Sep 17 00:00:00 2001 From: David Schneider Date: Wed, 24 Jan 2024 17:18:50 +0100 Subject: [PATCH] Introduce tolerances for triggering dt related warnings (#312) * Introduce tolerances for triggering warnings * Use 10^-14 instead of 12 --- Adapter.C | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Adapter.C b/Adapter.C index 717a871b..74b63783 100644 --- a/Adapter.C +++ b/Adapter.C @@ -651,8 +651,8 @@ void preciceAdapter::Adapter::adjustSolverTimeStepAndReadData() If the solver tries to use a bigger timestep, then it needs to use the same timestep as the one determined by preCICE. */ - - if (timestepSolverDetermined < timestepPrecice_) + double tolerance = 1e-14; + if (timestepPrecice_ - timestepSolverDetermined > tolerance) { // Add a bool 'subCycling = true' which is checked in the storeMeshPoints() function. adapterInfo( @@ -668,13 +668,17 @@ void preciceAdapter::Adapter::adjustSolverTimeStepAndReadData() "warning"); } } - else if (timestepSolverDetermined > timestepPrecice_) + else if (timestepSolverDetermined - timestepPrecice_ > tolerance) { - adapterInfo( - "The solver's timestep cannot be larger than the coupling timestep." - " Adjusting from " - + std::to_string(timestepSolverDetermined) + " to " + std::to_string(timestepPrecice_), - "warning"); + // In the last time-step, we adjust to dt = 0, but we don't need to trigger the warning here + if (precice_->isCouplingOngoing()) + { + adapterInfo( + "The solver's timestep cannot be larger than the coupling timestep." + " Adjusting from " + + std::to_string(timestepSolverDetermined) + " to " + std::to_string(timestepPrecice_), + "warning"); + } timestepSolver_ = timestepPrecice_; } else