Skip to content
Snippets Groups Projects
Commit e0e20760 authored by Tom Fischer's avatar Tom Fischer
Browse files

[PL/TimeLoop] Readability: eps as a constexpr double.

parent e0eff1da
No related branches found
No related tags found
No related merge requests found
...@@ -311,6 +311,7 @@ double TimeLoop::computeTimeStepping(const double prev_dt, double& t, ...@@ -311,6 +311,7 @@ double TimeLoop::computeTimeStepping(const double prev_dt, double& t,
bool all_process_steps_accepted = true; bool all_process_steps_accepted = true;
// Get minimum time step size among step sizes of all processes. // Get minimum time step size among step sizes of all processes.
double dt = std::numeric_limits<double>::max(); double dt = std::numeric_limits<double>::max();
constexpr double eps = std::numeric_limits<double>::epsilon();
bool const is_initial_step = std::any_of( bool const is_initial_step = std::any_of(
_per_process_data.begin(), _per_process_data.end(), _per_process_data.begin(), _per_process_data.end(),
...@@ -364,8 +365,7 @@ double TimeLoop::computeTimeStepping(const double prev_dt, double& t, ...@@ -364,8 +365,7 @@ double TimeLoop::computeTimeStepping(const double prev_dt, double& t,
// In case of FixedTimeStepping, which makes // In case of FixedTimeStepping, which makes
// timestep_algorithm->next(...) return false when the ending time // timestep_algorithm->next(...) return false when the ending time
// is reached. // is reached.
t + std::numeric_limits<double>::epsilon() < t + eps < timestep_algorithm->end())
timestep_algorithm->end())
{ {
// Not all processes have accepted steps. // Not all processes have accepted steps.
all_process_steps_accepted = false; all_process_steps_accepted = false;
...@@ -379,9 +379,8 @@ double TimeLoop::computeTimeStepping(const double prev_dt, double& t, ...@@ -379,9 +379,8 @@ double TimeLoop::computeTimeStepping(const double prev_dt, double& t,
all_process_steps_accepted = false; all_process_steps_accepted = false;
} }
if (timestepper_dt > std::numeric_limits<double>::epsilon() || if (timestepper_dt > eps ||
std::abs(t - timestep_algorithm->end()) < std::abs(t - timestep_algorithm->end()) < eps)
std::numeric_limits<double>::epsilon())
{ {
dt = std::min(timestepper_dt, dt); dt = std::min(timestepper_dt, dt);
} }
...@@ -405,8 +404,7 @@ double TimeLoop::computeTimeStepping(const double prev_dt, double& t, ...@@ -405,8 +404,7 @@ double TimeLoop::computeTimeStepping(const double prev_dt, double& t,
} }
else else
{ {
if (t < _end_time || std::abs(t - _end_time) < if (t < _end_time || std::abs(t - _end_time) < eps)
std::numeric_limits<double>::epsilon())
{ {
t -= prev_dt; t -= prev_dt;
rejected_steps++; rejected_steps++;
...@@ -424,7 +422,7 @@ double TimeLoop::computeTimeStepping(const double prev_dt, double& t, ...@@ -424,7 +422,7 @@ double TimeLoop::computeTimeStepping(const double prev_dt, double& t,
dt = NumLib::possiblyClampDtToNextFixedTime(t, dt, dt = NumLib::possiblyClampDtToNextFixedTime(t, dt,
_output->getFixedOutputTimes()); _output->getFixedOutputTimes());
// Check whether the time stepping is stabilized // Check whether the time stepping is stabilized
if (std::abs(dt - prev_dt) < std::numeric_limits<double>::epsilon()) if (std::abs(dt - prev_dt) < eps)
{ {
if (_last_step_rejected) if (_last_step_rejected)
{ {
...@@ -466,8 +464,7 @@ double TimeLoop::computeTimeStepping(const double prev_dt, double& t, ...@@ -466,8 +464,7 @@ double TimeLoop::computeTimeStepping(const double prev_dt, double& t,
} }
else else
{ {
if (t < _end_time || std::abs(t - _end_time) < if (t < _end_time || std::abs(t - _end_time) < eps)
std::numeric_limits<double>::epsilon())
{ {
WARN( WARN(
"Time step {:d} was rejected {:d} times and it will be " "Time step {:d} was rejected {:d} times and it will be "
......
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