49 template <
int dim,
typename Number>
54 const auto pinf = view_.eos_interpolation_pinfty();
56 const auto &[rho_i, u_i, p_i, gamma_i, a_i] = riemann_data_i;
57 const auto &[rho_j, u_j, p_j, gamma_j, a_j] = riemann_data_j;
59#ifdef DEBUG_WAVE_SPEED_ESTIMATOR
60 std::cout <<
"rho_left: " << rho_i << std::endl;
61 std::cout <<
"u_left: " << u_i << std::endl;
62 std::cout <<
"p_left: " << p_i << std::endl;
63 std::cout <<
"gamma_left: " << gamma_i << std::endl;
64 std::cout <<
"a_left: " << a_i << std::endl;
65 std::cout <<
"rho_right: " << rho_j << std::endl;
66 std::cout <<
"u_right: " << u_j << std::endl;
67 std::cout <<
"p_right: " << p_j << std::endl;
68 std::cout <<
"gamma_right: " << gamma_j << std::endl;
69 std::cout <<
"a_right: " << a_j << std::endl;
72 const Number p_max = std::max(p_i, p_j) + pinf;
73 const Number phi_p_max = phi_of_p_max(riemann_data_i, riemann_data_j);
75 if (!view_.compute_strict_bounds()) {
76#ifdef DEBUG_WAVE_SPEED_ESTIMATOR
77 const Number p_star_RS = p_star_RS_full(riemann_data_i, riemann_data_j);
78 const Number p_star_SS = p_star_SS_full(riemann_data_i, riemann_data_j);
79 const Number p_debug =
80 dealii::compare_and_apply_mask<dealii::SIMDComparison::less_than>(
81 phi_p_max, Number(0.), p_star_SS, std::min(p_max, p_star_RS));
82 std::cout <<
" p^*_debug = " << p_debug <<
"\n";
83 std::cout <<
" phi(p_*_d) = "
84 << phi(riemann_data_i, riemann_data_j, p_debug) <<
"\n";
85 std::cout <<
"-> lambda_deb = "
86 << compute_lambda(riemann_data_i, riemann_data_j, p_debug)
90 const Number p_star_tilde =
91 p_star_interpolated(riemann_data_i, riemann_data_j);
92 const Number p_star_backup =
93 p_star_failsafe(riemann_data_i, riemann_data_j);
96 dealii::compare_and_apply_mask<dealii::SIMDComparison::less_than>(
99 std::min(p_star_tilde, p_star_backup),
100 std::min(p_max, p_star_tilde));
102#ifdef DEBUG_WAVE_SPEED_ESTIMATOR
103 std::cout <<
" p^*_tilde = " << p_2 <<
"\n";
104 std::cout <<
" phi(p_*_t) = "
105 << phi(riemann_data_i, riemann_data_j, p_2) <<
"\n";
106 std::cout <<
"-> lambda_max = "
107 << compute_lambda(riemann_data_i, riemann_data_j, p_2) <<
"\n"
111 return compute_lambda(riemann_data_i, riemann_data_j, p_2);
114 const Number p_star_RS = p_star_RS_full(riemann_data_i, riemann_data_j);
115 const Number p_star_SS = p_star_SS_full(riemann_data_i, riemann_data_j);
118 dealii::compare_and_apply_mask<dealii::SIMDComparison::less_than>(
119 phi_p_max, Number(0.), p_star_SS, std::min(p_max, p_star_RS));
121#ifdef DEBUG_WAVE_SPEED_ESTIMATOR
122 std::cout <<
" p^*_tilde = " << p_2 <<
"\n";
123 std::cout <<
" phi(p_*_t) = "
124 << phi(riemann_data_i, riemann_data_j, p_2) <<
"\n";
125 std::cout <<
"-> lambda_max = "
126 << compute_lambda(riemann_data_i, riemann_data_j, p_2)
130 return compute_lambda(riemann_data_i, riemann_data_j, p_2);
134 template <
int dim,
typename Number>
135 DEAL_II_ALWAYS_INLINE
inline Number
140 const unsigned int i,
141 const unsigned int *js,
142 const dealii::Tensor<1, dim, Number> &n_ij)
const
144 const auto &[p_i, unused_i, s_i, eta_i] =
145 pv.template read_tensor<Number, precomputed_type>(i);
147 const auto &[p_j, unused_j, s_j, eta_j] =
148 pv.template read_tensor<Number, precomputed_type>(js);
150 const auto riemann_data_i = riemann_data_from_state(U_i, p_i, n_ij);
151 const auto riemann_data_j = riemann_data_from_state(U_j, p_j, n_ij);
153 return compute(riemann_data_i, riemann_data_j);
157 template <
int dim,
typename Number>
158 DEAL_II_ALWAYS_INLINE
inline Number
177 const Number first_radicand = (
ScalarNumber(3.) * gamma + Number(11.)) /
180 const Number second_radicand =
181 Number(5. / 6.) + slope * (gamma - Number(3.));
183 Number radicand = std::min(first_radicand, second_radicand);
184 radicand = std::min(Number(1.), radicand);
185 radicand = std::max(Number(1. / 2.), radicand);
187 return std::sqrt(radicand);
191 template <
int dim,
typename Number>
192 DEAL_II_ALWAYS_INLINE
inline Number
195 const Number &a)
const
197 const auto covolume_b = view_.eos_covolume_constant();
199 const Number numerator =
202 const Number denominator = gamma - Number(1.);
208 template <
int dim,
typename Number>
209 DEAL_II_ALWAYS_INLINE
inline Number
214 const auto pinf = view_.eos_interpolation_pinfty();
216 const auto &[rho_i, u_i, p_i, gamma_i, a_i] = riemann_data_i;
217 const auto &[rho_j, u_j, p_j, gamma_j, a_j] = riemann_data_j;
218 const auto alpha_i = alpha(rho_i, gamma_i, a_i);
219 const auto alpha_j = alpha(rho_j, gamma_j, a_j);
229 const Number p_min = std::min(p_i, p_j);
230 const Number p_max = std::max(p_i, p_j);
232 const Number gamma_min =
233 dealii::compare_and_apply_mask<dealii::SIMDComparison::less_than>(
234 p_i, p_j, gamma_i, gamma_j);
236 const Number alpha_min =
237 dealii::compare_and_apply_mask<dealii::SIMDComparison::less_than>(
238 p_i, p_j, alpha_i, alpha_j);
240 const Number alpha_hat_min = c(gamma_min) * alpha_min;
242 const Number alpha_max = dealii::compare_and_apply_mask<
243 dealii::SIMDComparison::greater_than_or_equal>(
244 p_i, p_j, alpha_i, alpha_j);
246 const Number gamma_m = std::min(gamma_i, gamma_j);
247 const Number gamma_M = std::max(gamma_i, gamma_j);
249 const Number numerator =
250 dealii::compare_and_apply_mask<dealii::SIMDComparison::equal>(
260 const Number p_ratio =
safe_division(p_min + pinf, p_max + pinf);
268 const Number r_exponent =
269 (gamma_M - gamma_min) / (
ScalarNumber(2.) * gamma_min * gamma_M);
276 const Number first_exponent =
279 const Number first_exponent_inverse =
282 const Number first_denom =
283 alpha_hat_min *
ryujin::pow(p_ratio, r_exponent - first_exponent) +
286 const Number p_1_tilde =
288 first_exponent_inverse) -
291#ifdef DEBUG_WAVE_SPEED_ESTIMATOR
292 std::cout <<
"RS p_1_tilde = " << p_1_tilde <<
"\n";
300 const Number second_exponent =
303 const Number second_exponent_inverse =
306 Number second_denom =
307 alpha_hat_min *
ryujin::pow(p_ratio, -second_exponent) +
310 const Number p_2_tilde =
312 second_exponent_inverse) -
315#ifdef DEBUG_WAVE_SPEED_ESTIMATOR
316 std::cout <<
"RS p_2_tilde = " << p_2_tilde <<
"\n";
319 return std::min(p_1_tilde, p_2_tilde);
323 template <
int dim,
typename Number>
324 DEAL_II_ALWAYS_INLINE
inline Number
329 const auto pinf = view_.eos_interpolation_pinfty();
331 const auto &[rho_i, u_i, p_i, gamma_i, a_i] = riemann_data_i;
332 const auto &[rho_j, u_j, p_j, gamma_j, a_j] = riemann_data_j;
334 const Number gamma_m = std::min(gamma_i, gamma_j);
336 const Number alpha_hat_i = c(gamma_i) * alpha(rho_i, gamma_i, a_i);
337 const Number alpha_hat_j = c(gamma_j) * alpha(rho_j, gamma_j, a_j);
345 const Number exponent =
347 const Number exponent_inverse = Number(1.) / exponent;
349 const Number numerator =
350 dealii::compare_and_apply_mask<dealii::SIMDComparison::equal>(
356 const Number denominator =
361 const Number p_1_tilde =
366#ifdef DEBUG_WAVE_SPEED_ESTIMATOR
367 std::cout <<
"SS p_1_tilde = " << p_1_tilde <<
"\n";
370 const auto p_2_tilde = p_star_failsafe(riemann_data_i, riemann_data_j);
372 return std::min(p_1_tilde, p_2_tilde);
376 template <
int dim,
typename Number>
377 DEAL_II_ALWAYS_INLINE
inline Number
382 const auto covolume_b = view_.eos_covolume_constant();
383 const auto pinf = view_.eos_interpolation_pinfty();
385 const auto &[rho_i, u_i, p_i, gamma_i, a_i] = riemann_data_i;
386 const auto &[rho_j, u_j, p_j, gamma_j, a_j] = riemann_data_j;
394 const Number p_max = std::max(p_i, p_j) + pinf;
397 ScalarNumber(2.) * (Number(1.) - covolume_b * rho_i) * p_max,
398 rho_i * ((gamma_i + Number(1.)) * p_max +
399 (gamma_i - Number(1.)) * (p_i + pinf)));
401 const Number x_i = std::sqrt(radicand_i);
404 ScalarNumber(2.) * (Number(1.) - covolume_b * rho_j) * p_max,
405 rho_j * ((gamma_j + Number(1.)) * p_max +
406 (gamma_j - Number(1.)) * (p_j + pinf)));
408 const Number x_j = std::sqrt(radicand_j);
410 const Number a = x_i + x_j;
412 dealii::compare_and_apply_mask<dealii::SIMDComparison::equal>(
413 a, Number(0.), Number(0.), u_j - u_i);
415 const Number c = -(p_i + pinf) * x_i - (p_j + pinf) * x_j;
422 const Number p_2_tilde = base * base - pinf;
424#ifdef DEBUG_WAVE_SPEED_ESTIMATOR
425 std::cout <<
"SS p_2_tilde = " << p_2_tilde <<
"\n";
431 template <
int dim,
typename Number>
432 DEAL_II_ALWAYS_INLINE
inline Number
437 const auto pinf = view_.eos_interpolation_pinfty();
439 const auto &[rho_i, u_i, p_i, gamma_i, a_i] = riemann_data_i;
440 const auto &[rho_j, u_j, p_j, gamma_j, a_j] = riemann_data_j;
441 const auto alpha_i = alpha(rho_i, gamma_i, a_i);
442 const auto alpha_j = alpha(rho_j, gamma_j, a_j);
452 const Number p_min = std::min(p_i, p_j) + pinf;
453 const Number p_max = std::max(p_i, p_j) + pinf;
455 const Number gamma_min =
456 dealii::compare_and_apply_mask<dealii::SIMDComparison::less_than>(
457 p_i, p_j, gamma_i, gamma_j);
459 const Number alpha_min =
460 dealii::compare_and_apply_mask<dealii::SIMDComparison::less_than>(
461 p_i, p_j, alpha_i, alpha_j);
463 const Number alpha_hat_min = c(gamma_min) * alpha_min;
465 const Number gamma_max = dealii::compare_and_apply_mask<
466 dealii::SIMDComparison::greater_than_or_equal>(
467 p_i, p_j, gamma_i, gamma_j);
469 const Number alpha_max = dealii::compare_and_apply_mask<
470 dealii::SIMDComparison::greater_than_or_equal>(
471 p_i, p_j, alpha_i, alpha_j);
473 const Number alpha_hat_max = c(gamma_max) * alpha_max;
475 const Number gamma_m = std::min(gamma_i, gamma_j);
476 const Number gamma_M = std::max(gamma_i, gamma_j);
486 const Number r_exponent =
487 (gamma_M - gamma_min) / (
ScalarNumber(2.) * gamma_min * gamma_M);
496 const Number exponent =
498 const Number exponent_inverse = Number(1.) / exponent;
500 const Number numerator =
503 Number denominator = alpha_hat_min *
ryujin::pow(p_ratio, -exponent) +
508 const Number p_tilde = p_max *
ryujin::pow(temp, exponent_inverse) - pinf;
510#ifdef DEBUG_WAVE_SPEED_ESTIMATOR
511 std::cout <<
"IN p_*_tilde = " << p_tilde <<
"\n";
518 template <
int dim,
typename Number>
519 DEAL_II_ALWAYS_INLINE
inline Number
521 const Number p_star)
const
523 constexpr ScalarNumber
min = std::numeric_limits<ScalarNumber>::min();
525 const auto covolume_b = view_.eos_covolume_constant();
526 const auto pinf = view_.eos_interpolation_pinfty();
528 const auto &[rho, u, p, gamma, a] = riemann_data;
530 const Number one_minus_b_rho = Number(1.) - covolume_b * rho;
531 const Number gamma_minus_one = gamma - Number(1.);
534 ScalarNumber(2.) * one_minus_b_rho / (rho * (gamma + Number(1.)));
536 const Number Bz = gamma_minus_one / (gamma + Number(1.)) * (p + pinf);
538 const Number radicand =
safe_division(Az, p_star + pinf + Bz);
541 const Number true_value = (p_star - p) * std::sqrt(radicand);
543 const auto exponent = ScalarNumber(0.5) * gamma_minus_one / gamma;
546 const Number factor =
ryujin::pow(ratio, exponent) - Number(1.);
549 const auto false_value = ScalarNumber(2.) * a * one_minus_b_rho * factor /
550 std::max(gamma_minus_one, Number(
min));
552 return dealii::compare_and_apply_mask<
553 dealii::SIMDComparison::greater_than_or_equal>(
554 p_star, p, true_value, false_value);
558 template <
int dim,
typename Number>
559 DEAL_II_ALWAYS_INLINE
inline Number
561 const primitive_type &riemann_data_i,
562 const primitive_type &riemann_data_j,
563 const Number p_in)
const
565 const Number &u_i = riemann_data_i[1];
566 const Number &u_j = riemann_data_j[1];
568 return f(riemann_data_i, p_in) + f(riemann_data_j, p_in) + u_j - u_i;
572 template <
int dim,
typename Number>
573 DEAL_II_ALWAYS_INLINE
inline Number
578 const auto covolume_b = view_.eos_covolume_constant();
579 const auto pinf = view_.eos_interpolation_pinfty();
581 const auto &[rho_i, u_i, p_i, gamma_i, a_i] = riemann_data_i;
582 const auto &[rho_j, u_j, p_j, gamma_j, a_j] = riemann_data_j;
584 const Number p_max = std::max(p_i, p_j) + pinf;
586 const Number radicand_inverse_i =
588 Number(1.) - covolume_b * rho_i) *
589 ((gamma_i + Number(1.)) * p_max +
590 (gamma_i - Number(1.)) * (p_i + pinf));
592 const Number value_i =
595 const Number radicand_inverse_j =
597 Number(1.) - covolume_b * rho_j) *
598 ((gamma_j + Number(1.)) * p_max +
599 (gamma_j - Number(1.)) * (p_j + pinf));
601 const Number value_j =
604 return value_i + value_j + u_j - u_i;
608 template <
int dim,
typename Number>
609 DEAL_II_ALWAYS_INLINE
inline Number
613 const auto pinf = view_.eos_interpolation_pinfty();
615 const auto &[rho, u, p, gamma, a] = riemann_data;
622 return u - a * std::sqrt(Number(1.) + factor * tmp);
626 template <
int dim,
typename Number>
627 DEAL_II_ALWAYS_INLINE
inline Number
631 const auto pinf = view_.eos_interpolation_pinfty();
633 const auto &[rho, u, p, gamma, a] = riemann_data;
640 return u + a * std::sqrt(Number(1.) + factor * tmp);
644 template <
int dim,
typename Number>
645 DEAL_II_ALWAYS_INLINE
inline Number
649 const Number p_star)
const
651 const Number nu_11 = lambda1_minus(riemann_data_i, p_star);
652 const Number nu_32 = lambda3_plus(riemann_data_j, p_star);
658 template <
int dim,
typename Number>
659 DEAL_II_ALWAYS_INLINE
inline auto
663 const dealii::Tensor<1, dim, Number> &n_ij)
const ->
primitive_type
665 const auto rho = view_.density(U);
668 const auto m = view_.momentum(U);
669 const auto proj_m = n_ij * m;
671 const auto gamma = view_.surrogate_gamma(U, p);
673 const auto covolume_b = view_.eos_covolume_constant();
674 const auto pinf = view_.eos_interpolation_pinfty();
675 const auto x = Number(1.) - covolume_b * rho;
676 const auto a = std::sqrt(gamma * (p + pinf) / (rho * x));
678#ifdef DEBUG_EXPENSIVE_BOUNDS_CHECK
682 dealii::ExcMessage(
"Internal error: p + pinf < 0."));
687 dealii::ExcMessage(
"Internal error: 1. - b * rho <= 0."));
692 dealii::ExcMessage(
"Internal error: gamma < 1."));
695 return {{rho, proj_m * rho_inverse, p, gamma, a}};
typename View::ScalarNumber ScalarNumber
primitive_type riemann_data_from_state(const state_type &U, const Number &p, const dealii::Tensor< 1, dim, Number > &n_ij) const
Number alpha(const Number &rho, const Number &gamma, const Number &a) const
typename View::PrecomputedVectorView PrecomputedVectorView
Number phi_of_p_max(const primitive_type &riemann_data_i, const primitive_type &riemann_data_j) const
Number p_star_SS_full(const primitive_type &riemann_data_i, const primitive_type &riemann_data_j) const
typename View::state_type state_type
typename std::array< Number, riemann_data_size > primitive_type
Number p_star_interpolated(const primitive_type &riemann_data_i, const primitive_type &riemann_data_j) const
Number c(const Number &gamma_Z) const
Number compute_lambda(const primitive_type &riemann_data_i, const primitive_type &riemann_data_j, const Number p_star) const
Number p_star_failsafe(const primitive_type &riemann_data_i, const primitive_type &riemann_data_j) const
Number lambda3_plus(const primitive_type &primitive_state, const Number p_star) const
Number p_star_RS_full(const primitive_type &riemann_data_i, const primitive_type &riemann_data_j) const
Number lambda1_minus(const primitive_type &riemann_data, const Number p_star) const
Number compute(const primitive_type &riemann_data_i, const primitive_type &riemann_data_j) const
#define AssertThrowSIMD(variable, condition, exception)
DEAL_II_HOST_DEVICE T pow(const T x, const T b)
DEAL_II_HOST_DEVICE_ALWAYS_INLINE Number positive_part(const Number number)
DEAL_II_HOST_DEVICE_ALWAYS_INLINE Number negative_part(const Number number)
DEAL_II_ALWAYS_INLINE Number safe_division(const Number &numerator, const Number &denominator)