/home/runner/work/DiFfRG_current/DiFfRG_current/DiFfRG/include/DiFfRG/discretization/FV/limiter/superbee_limiter.hh Source File#

DiFfRG: /home/runner/work/DiFfRG_current/DiFfRG_current/DiFfRG/include/DiFfRG/discretization/FV/limiter/superbee_limiter.hh Source File
DiFfRG
Discretization Framework for functional Renormalization Group flows
superbee_limiter.hh
Go to the documentation of this file.
1#pragma once
2
4
5#include <cmath>
6
7namespace DiFfRG
8{
9 namespace def
10 {
29 {
30 public:
31 template <typename NumberType> static NumberType slope_limit(const NumberType &du_1, const NumberType &du_2)
32 {
33 using std::abs;
34 using std::max;
35 using std::min;
36
37 // Branch-free same-sign indicator: 1 when du_1 and du_2 share strict sign, else 0.
38 // Identity: |sgn(a)+sgn(b)| / 2.
39 const int s1 = limiter_utils::sgn(du_1);
40 const int s2 = limiter_utils::sgn(du_2);
41 if (s1 == 0 || s2 == 0 || s1 != s2) return NumberType(0);
42
43 // Both slopes strictly positive or strictly negative. Work in the
44 // common-sign convention then re-apply the sign at the end.
45 const auto a = abs(du_1);
46 const auto b = abs(du_2);
47
48 // minmod(2a, b) and minmod(a, 2b) in this regime collapse to
49 // min(2a, b) and min(a, 2b); maxmod is then max() of those.
50 const auto m1 = min(NumberType(2) * a, b);
51 const auto m2 = min(a, NumberType(2) * b);
52 const auto limited = max(m1, m2);
53
54 return NumberType(s1) * limited;
55 }
56 };
57 static_assert(HasSlopeLimiter<SuperbeeLimiter>);
58
59 } // namespace def
60} // namespace DiFfRG
Superbee slope limiter (Roe, 1986).
Definition superbee_limiter.hh:29
static NumberType slope_limit(const NumberType &du_1, const NumberType &du_2)
Definition superbee_limiter.hh:31
int sgn(T val)
Signum helper: returns -1, 0 or +1.
Definition abstract_limiter.hh:43
Definition complex_math.hh:10