Skip to content
Snippets Groups Projects
Commit fec96cdf authored by Dennis Gläser's avatar Dennis Gläser Committed by Timo Koch
Browse files

[timeloop] add comment on setDt check

parent 7f55a108
No related branches found
No related tags found
1 merge request!3618[TimeLoop] define base tolerance
...@@ -245,6 +245,12 @@ public: ...@@ -245,6 +245,12 @@ public:
{ {
using std::min; using std::min;
timeStepSize_ = min(dt, maxTimeStepSize()); timeStepSize_ = min(dt, maxTimeStepSize());
// Warn if dt is so small w.r.t. current time that it renders float addition meaningless
// For instance, consider (may depend on architecture):
// double cien = 100;
// double mil = 1000;
// if (cien + 1e-14 == cien) std::cout << "Will not be printed" << std::endl;
// if (mil + 1e-14 == mil) std::cout << "Will be printed" << std::endl;
if (!finished() && (time_ + timeStepSize_ == time_)) if (!finished() && (time_ + timeStepSize_ == time_))
std::cerr << Fmt::format("You have set a very small timestep size (dt = {:.5g}).", timeStepSize_) std::cerr << Fmt::format("You have set a very small timestep size (dt = {:.5g}).", timeStepSize_)
<< " This might lead to numerical problems!\n"; << " This might lead to numerical problems!\n";
......
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