12 namespace ScalarConservation
14 template <
int dim,
typename Number>
15 std::tuple<Number, bool>
22 const auto view = hyperbolic_system.view<dim, Number>();
27 constexpr ScalarNumber eps = std::numeric_limits<ScalarNumber>::epsilon();
30 const auto &u_U = view.state(U);
31 const auto &u_P = view.state(P);
33 const auto &u_min = std::get<0>(bounds);
34 const auto &u_max = std::get<1>(bounds);
42 const auto test_max = std::max(
43 Number(0.), std::min(u_U - relax * u_max, relax * u_U - u_max));
44 const auto test_min = std::max(
45 Number(0.), std::min(u_min - relax * u_U, relax * u_min - u_U));
46 if (!(test_max == Number(0.) && test_min == Number(0.))) {
48 std::cout << std::fixed << std::setprecision(16);
49 std::cout <<
"Bounds violation: low-order state (critical)!"
50 <<
"\n\t\tu min: " << u_min
54 <<
"\n\t\tu max: " << u_max <<
"\n"
60 const auto regularization =
61 Number(100. * std::numeric_limits<ScalarNumber>::min());
63 const Number denominator =
65 std::max(regularization, std::abs(u_P) + eps * u_max);
67 t_r = dealii::compare_and_apply_mask<dealii::SIMDComparison::less_than>(
76 (u_max - u_U) * denominator,
79 t_r = dealii::compare_and_apply_mask<dealii::SIMDComparison::less_than>(
88 (u_U - u_min) * denominator,
98 t_r = std::min(t_r, t_max);
99 t_r = std::max(t_r, t_min);
101#ifdef EXPENSIVE_BOUNDS_CHECK
107 const auto u_new = view.state(U + t_r * P);
108 const auto test_new_max = std::max(
109 Number(0.), std::min(u_new - relax * u_max, relax * u_new - u_max));
110 const auto test_new_min = std::max(
111 Number(0.), std::min(u_min - relax * u_new, relax * u_min - u_new));
112 if (!(test_new_max == Number(0.) && test_new_min == Number(0.))) {
114 std::cout << std::fixed << std::setprecision(16);
115 std::cout <<
"Bounds violation: high-order state!"
116 <<
"\n\t\tu min: " << u_min
118 <<
"\n\t\tu: " << u_new
120 <<
"\n\t\tu max: " << u_max <<
"\n"
127 return {t_r, success};
std::array< Number, n_bounds > Bounds
typename View::state_type state_type
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 View::ScalarNumber ScalarNumber
DEAL_II_ALWAYS_INLINE Number negative_part(const Number number)
DEAL_II_ALWAYS_INLINE Number positive_part(const Number number)