Skip to content

Commit

Permalink
Introduce tolerances for triggering dt related warnings (#312)
Browse files Browse the repository at this point in the history
* Introduce tolerances for triggering warnings

* Use 10^-14 instead of 12
  • Loading branch information
davidscn authored Jan 24, 2024
1 parent 8db7f75 commit fa6f48f
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions Adapter.C
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
Expand Down

0 comments on commit fa6f48f

Please sign in to comment.