Utility class for comparing double values representing epoch dates or elapsed time.
More...
#include <ReservoirCoupling.hpp>
|
static bool | compare_eq (double a, double b) |
| Determines if two double values are equal within a specified tolerance. More...
|
|
static bool | compare_gt (double a, double b) |
| Determines if a is greater than b within the specified tolerance. More...
|
|
static bool | compare_gt_or_eq (double a, double b) |
| Determines if a is greater than b within the specified tolerance. More...
|
|
static bool | compare_lt_or_eq (double a, double b) |
| Determines if a is less than or equal to b within the specified tolerance. More...
|
|
|
static constexpr double | abstol = 1e-15 |
| Absolute tolerance used for comparisons. More...
|
|
static constexpr double | reltol = 1e-15 |
| Relative tolerance used for comparisons. More...
|
|
Utility class for comparing double values representing epoch dates or elapsed time.
This class is used to compare double values that represent:
- Epoch dates (seconds since the Unix epoch)
- Elapsed time (seconds since the start of the simulation)
- Note
- When comparing against the start of a report step or similar, it is important not to miss these points due to numerical issues. Communication between master and slave processes is based on these specific points in time.
-
Epoch values in this century (2000-2100) fall within the range [1e9, 4e9]. A double variable cannot represent such large values with high precision. For example, the date 01-01-2020 corresponds to 1.5778368e9 seconds, and adding 1e-7 seconds to this value does not change it. Microseconds (1e-6) are approximately the smallest time units that can be represented accurately for such numbers.
-
Report steps appear to have a maximum resolution of whole seconds. See the
stepLength()
function in Schedule.cpp
in the opm-common
module, which returns the step length in seconds.
◆ compare_eq()
static bool Opm::ReservoirCoupling::Seconds::compare_eq |
( |
double |
a, |
|
|
double |
b |
|
) |
| |
|
static |
Determines if two double values are equal within a specified tolerance.
Two values a and b are considered equal if:
For example, if abstol = reltol = 1e-15:
- If |a| and |b| are below 1, the absolute tolerance applies.
- If a and b are above 1, the relative tolerance applies.
- Note
- For epoch dates between 01-01-2000 and 01-01-2100, epoch values are in the range [1e9, 4e9]. Therefore,
, meaning differences smaller than one microsecond will be considered equal.
-
This approach is not accurate for numbers close to zero, but such comparisons are not expected.
- Parameters
-
a | First double value. |
b | Second double value. |
- Returns
- True if a and b are considered equal within the tolerance.
◆ compare_gt()
static bool Opm::ReservoirCoupling::Seconds::compare_gt |
( |
double |
a, |
|
|
double |
b |
|
) |
| |
|
static |
Determines if a is greater than b within the specified tolerance.
- Parameters
-
a | First double value. |
b | Second double value. |
- Returns
- True if a is greater than b.
◆ compare_gt_or_eq()
static bool Opm::ReservoirCoupling::Seconds::compare_gt_or_eq |
( |
double |
a, |
|
|
double |
b |
|
) |
| |
|
static |
Determines if a is greater than b within the specified tolerance.
- Parameters
-
a | First double value. |
b | Second double value. |
- Returns
- True if a is greater than b.
◆ compare_lt_or_eq()
static bool Opm::ReservoirCoupling::Seconds::compare_lt_or_eq |
( |
double |
a, |
|
|
double |
b |
|
) |
| |
|
static |
Determines if a is less than or equal to b within the specified tolerance.
- Parameters
-
a | First double value. |
b | Second double value. |
- Returns
- True if a is less than or equal to b.
◆ abstol
constexpr double Opm::ReservoirCoupling::Seconds::abstol = 1e-15 |
|
staticconstexpr |
Absolute tolerance used for comparisons.
◆ reltol
constexpr double Opm::ReservoirCoupling::Seconds::reltol = 1e-15 |
|
staticconstexpr |
Relative tolerance used for comparisons.
The documentation for this struct was generated from the following file: