diff --git a/src/scheme/LimitationTools.hpp b/src/scheme/LimitationTools.hpp new file mode 100644 index 0000000000000000000000000000000000000000..e71b7d51c5b28121fd23da4e0c785fe03e1f50d3 --- /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