22 const Number t_max )
const
28 const auto &[h_min, h_max, v2_max] = bounds;
31 constexpr ScalarNumber eps = std::numeric_limits<ScalarNumber>::epsilon();
32 const auto small = view_.dry_state_relaxation_small();
33 const auto large = view_.dry_state_relaxation_large();
44 auto h_U = view_.water_depth(U);
45 const auto &h_P = view_.water_depth(P);
47 const auto test_min = view_.filter_dry_water_depth(
48 std::max(Number(0.), h_U - relax * h_max));
49 const auto test_max = view_.filter_dry_water_depth(
50 std::max(Number(0.), h_min - relax * h_U));
52 if (!(test_min == Number(0.) && test_max == Number(0.))) {
54 std::cout << std::fixed << std::setprecision(16);
55 std::cout <<
"Bounds violation: low-order water depth (critical)!\n"
56 <<
"\n\t\th min: " << h_min
60 <<
"\n\t\th max: " << h_max <<
"\n"
66 const Number denominator =
69 constexpr auto lt = dealii::SIMDComparison::less_than;
71 t_r = dealii::compare_and_apply_mask<lt>(
80 (h_max - h_U) * denominator,
83 t_r = dealii::compare_and_apply_mask<lt>(
92 (h_U - h_min) * denominator,
102 t_r = std::min(t_r, t_max);
103 t_r = std::max(t_r, t_min);
106#ifdef DEBUG_EXPENSIVE_BOUNDS_CHECK
110 const auto h_new = view_.water_depth(U + t_r * P);
111 const auto test_new_min = view_.filter_dry_water_depth(
112 std::max(Number(0.), h_new - relax * h_max));
113 const auto test_new_max = view_.filter_dry_water_depth(
114 std::max(Number(0.), h_min - relax * h_new));
116 if (!(test_new_min == Number(0.) && test_new_max == Number(0.))) {
118 std::cout << std::fixed << std::setprecision(30);
119 std::cout <<
"Bounds violation: high-order water depth!\n"
120 <<
"\n\t\th min: " << h_min
122 <<
"\n\t\th: " << h_new
124 <<
"\n\t\th max: " << h_max <<
"\n"
146 const auto U_r = U + t_r * P;
147 const auto h_r = view_.water_depth(U_r);
148 const auto q_r = view_.momentum(U_r);
150 const auto psi_r = relax_small * h_r * h_r * v2_max - q_r.norm_square();
156 t_l = dealii::compare_and_apply_mask<
157 dealii::SIMDComparison::greater_than>(psi_r, Number(0.), t_r, t_l);
161 return {t_l, success};
163#ifdef DEBUG_OUTPUT_LIMITER
165 std::cout << std::endl;
166 std::cout << std::fixed << std::setprecision(16);
167 std::cout <<
"t_l: (start) " << t_l << std::endl;
168 std::cout <<
"t_r: (start) " << t_r << std::endl;
172 const auto U_l = U + t_l * P;
173 const auto h_l = view_.water_depth(U_l);
174 const auto q_l = view_.momentum(U_l);
176 const auto psi_l = relax_small * h_l * h_l * v2_max - q_l.norm_square();
186 const auto filtered_h_l = view_.filter_dry_water_depth(h_l);
187 const auto lower_bound =
188 (
ScalarNumber(1.) - relax) * filtered_h_l * filtered_h_l * v2_max -
190 if (!(std::min(Number(0.), psi_l - lower_bound) == Number(0.))) {
192 std::cout << std::fixed << std::setprecision(16);
194 <<
"Bounds violation: low-order square velocity (critical)!\n";
195 std::cout <<
"\t\tPsi left: 0 <= " << psi_l <<
"\n" << std::endl;
204 const Number tolerance(newton_tolerance());
205 if (!(std::max(Number(0.), t_r - t_l - tolerance) == Number(0.))) {
223 const auto &h_U = view_.water_depth(U);
224 const auto &h_P = view_.water_depth(P);
225 const auto &q_U = view_.momentum(U);
226 const auto &q_P = view_.momentum(P);
229 (h_U + t_l * h_P) * h_P * v2_max -
232 (h_U + t_r * h_P) * h_P * v2_max -
236 t_l, t_r, psi_l, psi_r, dpsi_l, dpsi_r, Number(-1.));
238#ifdef DEBUG_OUTPUT_LIMITER
239 if (std::max(Number(0.), psi_r + Number(eps)) == Number(0.)) {
240 std::cout <<
"psi_l: " << psi_l << std::endl;
241 std::cout <<
"psi_r: " << psi_r << std::endl;
242 std::cout <<
"dpsi_l: " << dpsi_l << std::endl;
243 std::cout <<
"dpsi_r: " << dpsi_r << std::endl;
244 std::cout <<
"t_l: (end) " << t_l << std::endl;
245 std::cout <<
"t_r: (end) " << t_r << std::endl;
250#ifdef DEBUG_EXPENSIVE_BOUNDS_CHECK
255 const auto U_new = U + t_l * P;
256 const auto h_new = view_.water_depth(U_new);
257 const auto q_new = view_.momentum(U_new);
260 relax_small * h_new * h_new * v2_max - q_new.norm_square();
262 const auto lower_bound =
266 const bool psi_valid =
267 std::min(Number(0.), psi_new - lower_bound) == Number(0.);
270 std::cout << std::fixed << std::setprecision(16);
271 std::cout <<
"Bounds violation: high-order square velocity!\n";
272 std::cout <<
"\t\tPsi: 0 <= " << psi_new <<
"\n" << std::endl;
280 return {t_l, success};