12 namespace ScalarConservation
14 template <
int dim,
typename Number>
15 std::tuple<Number, bool>
25 constexpr ScalarNumber eps = std::numeric_limits<ScalarNumber>::epsilon();
28 const auto &u_U = hyperbolic_system.state(U);
29 const auto &u_P = hyperbolic_system.state(P);
31 const auto &u_min = std::get<0>(bounds);
32 const auto &u_max = std::get<1>(bounds);
38 const auto test_min = std::max(Number(0.), u_U - relax * u_max);
39 const auto test_max = std::max(Number(0.), u_min - relax * u_U);
40 if (!(test_min == Number(0.) && test_max == Number(0.))) {
42 std::cout << std::fixed << std::setprecision(16);
43 std::cout <<
"Bounds violation: low-order state (critical)!"
44 <<
"\n\t\tu min: " << u_min
48 <<
"\n\t\tu max: " << u_max <<
"\n"
54 const Number denominator =
57 t_r = dealii::compare_and_apply_mask<dealii::SIMDComparison::less_than>(
66 (u_max - u_U) * denominator,
69 t_r = dealii::compare_and_apply_mask<dealii::SIMDComparison::less_than>(
78 (u_U - u_min) * denominator,
88 t_r = std::min(t_r, t_max);
89 t_r = std::max(t_r, t_min);
95 const auto u_new = hyperbolic_system.state(U + t_r * P);
96 const auto test_new_min = std::max(Number(0.), u_new - relax * u_max);
97 const auto test_new_max = std::max(Number(0.), u_min - relax * u_new);
98 if (!(test_new_min == Number(0.) && test_new_max == Number(0.))) {
100 std::cout << std::fixed << std::setprecision(16);
101 std::cout <<
"Bounds violation: high-order state!"
102 <<
"\n\t\tu min: " << u_min
104 <<
"\n\t\tu: " << u_new
106 <<
"\n\t\tu max: " << u_max <<
"\n"
113 return {t_r, success};
typename HyperbolicSystemView::state_type state_type
std::array< Number, n_bounds > Bounds
std::tuple< Number, bool > limit(const Bounds &bounds, const state_type &U, const state_type &P, const Number t_min=Number(0.), const Number t_max=Number(1.))
typename get_value_type< Number >::type ScalarNumber
DEAL_II_ALWAYS_INLINE Number negative_part(const Number number)
DEAL_II_ALWAYS_INLINE Number positive_part(const Number number)