From 848a1818ff7042f58023611309ac5c8bae1b5c8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Simonis?= Date: Mon, 29 Jan 2024 15:41:20 +0100 Subject: [PATCH] Fix tolerance check for subcycling --- Adapter.C | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Adapter.C b/Adapter.C index 74b63783..38c061ab 100644 --- a/Adapter.C +++ b/Adapter.C @@ -652,7 +652,13 @@ void preciceAdapter::Adapter::adjustSolverTimeStepAndReadData() the same timestep as the one determined by preCICE. */ double tolerance = 1e-14; - if (timestepPrecice_ - timestepSolverDetermined > tolerance) + if (abs(timestepPrecice_ - timestepSolverDetermined) < tolerance) + { + DEBUG(adapterInfo("The solver's timestep is the same as the " + "coupling timestep.")); + timestepSolver_ = timestepPrecice_; + } + else if (timestepPrecice_ - timestepSolverDetermined > tolerance) { // Add a bool 'subCycling = true' which is checked in the storeMeshPoints() function. adapterInfo( @@ -668,7 +674,7 @@ void preciceAdapter::Adapter::adjustSolverTimeStepAndReadData() "warning"); } } - else if (timestepSolverDetermined - timestepPrecice_ > tolerance) + else { // In the last time-step, we adjust to dt = 0, but we don't need to trigger the warning here if (precice_->isCouplingOngoing()) @@ -681,12 +687,6 @@ void preciceAdapter::Adapter::adjustSolverTimeStepAndReadData() } timestepSolver_ = timestepPrecice_; } - else - { - DEBUG(adapterInfo("The solver's timestep is the same as the " - "coupling timestep.")); - timestepSolver_ = timestepPrecice_; - } // Update the solver's timestep (but don't trigger the adjustDeltaT(), // which also triggers the functionObject's adjustTimeStep())