From b6f92d58f5536882c45c65244db15fc988d31f14 Mon Sep 17 00:00:00 2001 From: Mathis Kelm <mathis.kelm@iws.uni-stuttgart.de> Date: Wed, 12 Oct 2022 17:01:56 +0200 Subject: [PATCH] [tabulatedcomponent] use epsilon for float comparison --- dumux/material/components/tabulatedcomponent.hh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dumux/material/components/tabulatedcomponent.hh b/dumux/material/components/tabulatedcomponent.hh index ddeb566395..13a3b88085 100644 --- a/dumux/material/components/tabulatedcomponent.hh +++ b/dumux/material/components/tabulatedcomponent.hh @@ -933,7 +933,7 @@ private: static Scalar interpolateT_(const std::vector<typename RawComponent::Scalar>& values, Scalar T) { Scalar alphaT = tempIdx_(T); - if (alphaT < 0 || alphaT >= nTemp_ - 1) + if (alphaT < 0 - eps_ || alphaT >= nTemp_ - 1 + eps_) return std::numeric_limits<Scalar>::quiet_NaN(); const auto iT = static_cast<int>(alphaT); @@ -949,7 +949,7 @@ private: const GetPIdx& getPIdx, const MinPFunc& minP, const MaxPFunc& maxP) { Scalar alphaT = tempIdx_(T); - if (alphaT < 0 || alphaT >= nTemp_ - 1) + if (alphaT < 0 - eps_ || alphaT >= nTemp_ - 1 + eps_) return std::numeric_limits<Scalar>::quiet_NaN(); using std::clamp; @@ -988,7 +988,7 @@ private: { using std::clamp; Scalar alphaT = tempIdx_(T); - if (alphaT < 0 || alphaT >= nTemp_ - 1) + if (alphaT < 0 -eps_ || alphaT >= nTemp_ - 1 + eps_) return std::numeric_limits<Scalar>::quiet_NaN(); const auto iT = clamp<int>(static_cast<int>(alphaT), 0, nTemp_ - 2); @@ -1336,6 +1336,8 @@ private: static Scalar densityMin_; static Scalar densityMax_; static std::size_t nDensity_; + + static constexpr Scalar eps_ = 1.0e-7; }; template <class RawComponent, bool useVaporPressure> -- GitLab