From dd72c6a675329e092112374e3aeae305be2d3775 Mon Sep 17 00:00:00 2001 From: HOCH PHILIPPE <philippe.hoch@gmail.com> Date: Tue, 6 May 2025 23:56:21 +0200 Subject: [PATCH] Add Barth Jespersen Lim --- src/scheme/LimitationTools.hpp | 42 ++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/scheme/LimitationTools.hpp diff --git a/src/scheme/LimitationTools.hpp b/src/scheme/LimitationTools.hpp new file mode 100644 index 00000000..e71b7d51 --- /dev/null +++ b/src/scheme/LimitationTools.hpp @@ -0,0 +1,42 @@ +#ifndef LIMITATION_TOOLS_HPP +#define LIMITATION_TOOLS_HPP + +namespace toolsLimitation +{ +inline double +computeCoefLimitationBarthJespersen(const double State, + const double minval, + const double maxval, + const double minvalvois, + const double maxvalvois, + bool enableWeakBoundPositivityOnly = false) +{ + static constexpr double epsZer0 = 1e-14; + // on applique le traitement idem de l'ordre 2.. + double coef1 = 0, coef2 = 0; + if (enableWeakBoundPositivityOnly) { + coef1 = 1; + const double minGlobal = 1e-12; + + if (std::fabs(minval - State) <= epsZer0) // epsIsEqualAbs()) + coef2 = 1.; + else + coef2 = (minGlobal - State) / ((minval - State)); + + } else { + if (std::fabs(maxval - State) <= epsZer0) // epsIsEqualAbs()) + coef1 = 1.; + else + coef1 = (maxvalvois - State) / ((maxval - State)); + + if (std::fabs(minval - State) <= epsZer0) // epsIsEqualAbs()) + coef2 = 1.; + else + coef2 = (minvalvois - State) / ((minval - State)); + } + // return alfa = + return std::max(0., std::min(1., std::min(coef1, coef2))); + // return alfa; +} +} // namespace toolsLimitation +#endif -- GitLab