ryujin 2.1.1 revision 0348cbb53a3e4b1da2a4c037e81f88f2d21ce219
riemann_solver.template.h
Go to the documentation of this file.
1//
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3// Copyright (C) 2020 - 2024 by the ryujin authors
4//
5
6#pragma once
7
8#include <compile_time_options.h>
9
10#include "riemann_solver.h"
11
12#include <newton.h>
13#include <simd.h>
14
15// #define DEBUG_RIEMANN_SOLVER
16
17namespace ryujin
18{
19 namespace EulerAEOS
20 {
21 /*
22 * The RiemannSolver is a guaranteed maximal wavespeed (GMS) estimate
23 * for the extended Riemann problem outlined in
24 * @cite ClaytonGuermondPopov-2022. For extenstions on handling negative
25 * pressures, we follow @cite clayton2023robust (see §4.6).
26 *
27 * In contrast to the algorithm outlined in above reference the
28 * algorithm takes a couple of shortcuts to significantly decrease the
29 * computational footprint. These simplifications still guarantee that
30 * we have an upper bound on the maximal wavespeed - but the number
31 * bound might be larger. In particular:
32 *
33 * - We do not check and treat the case phi(p_min) > 0. This
34 * corresponds to two expansion waves, see §5.2 in the reference. In
35 * this case we have
36 *
37 * 0 < p_star < p_min <= p_max.
38 *
39 * And due to the fact that p_star < p_min the wavespeeds reduce to
40 * a left wavespeed v_L - a_L and right wavespeed v_R + a_R. This
41 * implies that it is sufficient to set p_2 to ANY value provided
42 * that p_2 <= p_min hold true in order to compute the correct
43 * wavespeed.
44 *
45 * If p_2 > p_min then a more pessimistic bound is computed.
46 *
47 * - FIXME: Simplification in p_star_RS
48 */
49
50
51 template <int dim, typename Number>
52 DEAL_II_ALWAYS_INLINE inline Number
53 RiemannSolver<dim, Number>::c(const Number &gamma) const
54 {
55 /*
56 * We implement the continuous and monotonic function c(gamma) as
57 * defined in (A.3) on page A469 of @cite ClaytonGuermondPopov-2022.
58 * But with a simplified quick cut-off for the case gamma > 3:
59 *
60 * c(gamma)^2 = 1 for gamma <= 5 / 3
61 * c(gamma)^2 = (3 * gamma + 11) / (6 * gamma + 6) in between
62 * c(gamma)^2 = max(1/2, 5 / 6 - slope (gamma - 3)) for gamma > 3
63 *
64 * Due to the fact that the function is monotonic we can simply clip
65 * the values without checking the conditions:
66 */
67
68 constexpr ScalarNumber slope =
69 ScalarNumber(-0.34976871477801828189920753948709);
70
71 const Number first_radicand = (ScalarNumber(3.) * gamma + Number(11.)) /
72 (ScalarNumber(6.) * gamma + Number(6.));
73
74 const Number second_radicand =
75 Number(5. / 6.) + slope * (gamma - Number(3.));
76
77 Number radicand = std::min(first_radicand, second_radicand);
78 radicand = std::min(Number(1.), radicand);
79 radicand = std::max(Number(1. / 2.), radicand);
80
81 return std::sqrt(radicand);
82 }
83
84
85 template <int dim, typename Number>
86 DEAL_II_ALWAYS_INLINE inline Number RiemannSolver<dim, Number>::alpha(
87 const Number &rho, const Number &gamma, const Number &a) const
88 {
89 const auto view = hyperbolic_system.view<dim, Number>();
90 const auto interpolation_b = view.eos_interpolation_b();
91
92 const Number numerator =
93 ScalarNumber(2.) * a * (Number(1.) - interpolation_b * rho);
94
95 const Number denominator = gamma - Number(1.);
96
97 return safe_division(numerator, denominator);
98 }
99
100
101 template <int dim, typename Number>
102 DEAL_II_ALWAYS_INLINE inline Number
104 const primitive_type &riemann_data_i,
105 const primitive_type &riemann_data_j) const
106 {
107 const auto view = hyperbolic_system.view<dim, Number>();
108 const auto pinf = view.eos_interpolation_pinfty();
109
110 const auto &[rho_i, u_i, p_i, gamma_i, a_i] = riemann_data_i;
111 const auto &[rho_j, u_j, p_j, gamma_j, a_j] = riemann_data_j;
112 const auto alpha_i = alpha(rho_i, gamma_i, a_i);
113 const auto alpha_j = alpha(rho_j, gamma_j, a_j);
114
115 /*
116 * First get p_min, p_max.
117 *
118 * Then, we get gamma_min/max, and alpha_min/max. Note that the
119 * *_min/max values are associated with p_min/max and are not
120 * necessarily the minimum/maximum of *_i vs *_j.
121 */
122
123 const Number p_min = std::min(p_i, p_j);
124 const Number p_max = std::max(p_i, p_j);
125
126 const Number gamma_min =
127 dealii::compare_and_apply_mask<dealii::SIMDComparison::less_than>(
128 p_i, p_j, gamma_i, gamma_j);
129
130 const Number alpha_min =
131 dealii::compare_and_apply_mask<dealii::SIMDComparison::less_than>(
132 p_i, p_j, alpha_i, alpha_j);
133
134 const Number alpha_hat_min = c(gamma_min) * alpha_min;
135
136 const Number alpha_max = dealii::compare_and_apply_mask<
137 dealii::SIMDComparison::greater_than_or_equal>(
138 p_i, p_j, alpha_i, alpha_j);
139
140 const Number gamma_m = std::min(gamma_i, gamma_j);
141 const Number gamma_M = std::max(gamma_i, gamma_j);
142
143 const Number numerator =
144 dealii::compare_and_apply_mask<dealii::SIMDComparison::equal>(
145 p_max + pinf,
146 Number(0.),
147 Number(0.),
148 positive_part(alpha_hat_min + alpha_max - (u_j - u_i)));
149
150 /*
151 * The admissible set is p_min >= pinf. But numerically let's avoid
152 * division by zero and ensure positivity:
153 */
154 const Number p_ratio = safe_division(p_min + pinf, p_max + pinf);
155
156 /*
157 * Here, we use a trick: The r-factor only shows up in the formula
158 * for the case \gamma_min = \gamma_m, otherwise the r-factor
159 * vanishes. We can accomplish this by using the following modified
160 * exponent (where we substitute gamma_m by gamma_min):
161 */
162 const Number r_exponent =
163 (gamma_M - gamma_min) / (ScalarNumber(2.) * gamma_min * gamma_M);
164
165 /*
166 * Compute (5.7) first formula for \tilde p_1^\ast and (5.8)
167 * second formula for \tilde p_2^\ast at the same time:
168 */
169
170 const Number first_exponent =
171 (gamma_M - Number(1.)) / (ScalarNumber(2.) * gamma_M);
172
173 const Number first_exponent_inverse =
174 safe_division(Number(1.), first_exponent);
175
176 const Number first_denom =
177 alpha_hat_min * ryujin::pow(p_ratio, r_exponent - first_exponent) +
178 alpha_max;
179
180 const Number p_1_tilde =
181 (p_max + pinf) * ryujin::pow(safe_division(numerator, first_denom),
182 first_exponent_inverse) -
183 pinf;
184
185#ifdef DEBUG_RIEMANN_SOLVER
186 std::cout << "RS p_1_tilde = " << p_1_tilde << "\n";
187#endif
188
189 /*
190 * Compute (5.7) second formula for \tilde p_2^\ast and (5.8) first
191 * formula for \tilde p_1^\ast at the same time:
192 */
193
194 const Number second_exponent =
195 (gamma_m - Number(1.)) / (ScalarNumber(2.) * gamma_m);
196
197 const Number second_exponent_inverse =
198 safe_division(Number(1.), second_exponent);
199
200 Number second_denom =
201 alpha_hat_min * ryujin::pow(p_ratio, -second_exponent) +
202 alpha_max * ryujin::pow(p_ratio, r_exponent);
203
204 const Number p_2_tilde =
205 (p_max + pinf) * ryujin::pow(safe_division(numerator, second_denom),
206 second_exponent_inverse) -
207 pinf;
208
209#ifdef DEBUG_RIEMANN_SOLVER
210 std::cout << "RS p_2_tilde = " << p_2_tilde << "\n";
211#endif
212
213 return std::min(p_1_tilde, p_2_tilde);
214 }
215
216
217 template <int dim, typename Number>
218 DEAL_II_ALWAYS_INLINE inline Number
220 const primitive_type &riemann_data_i,
221 const primitive_type &riemann_data_j) const
222 {
223 const auto view = hyperbolic_system.view<dim, Number>();
224 const auto pinf = view.eos_interpolation_pinfty();
225
226 const auto &[rho_i, u_i, p_i, gamma_i, a_i] = riemann_data_i;
227 const auto &[rho_j, u_j, p_j, gamma_j, a_j] = riemann_data_j;
228
229 const Number gamma_m = std::min(gamma_i, gamma_j);
230
231 const Number alpha_hat_i = c(gamma_i) * alpha(rho_i, gamma_i, a_i);
232 const Number alpha_hat_j = c(gamma_j) * alpha(rho_j, gamma_j, a_j);
233
234 /*
235 * Compute (5.10) formula for \tilde p_1^\ast:
236 *
237 * Cost: 2x pow, 4x division, 0x sqrt
238 */
239
240 const Number exponent =
241 (gamma_m - Number(1.)) / (ScalarNumber(2.) * gamma_m);
242 const Number exponent_inverse = Number(1.) / exponent;
243
244 const Number numerator =
245 dealii::compare_and_apply_mask<dealii::SIMDComparison::equal>(
246 p_j + pinf,
247 Number(0.),
248 Number(0.),
249 positive_part(alpha_hat_i + alpha_hat_j - (u_j - u_i)));
250
251 const Number denominator =
252 alpha_hat_i *
253 ryujin::pow(safe_division(p_i + pinf, p_j + pinf), -exponent) +
254 alpha_hat_j;
255
256 const Number p_1_tilde =
257 (p_j + pinf) * ryujin::pow(safe_division(numerator, denominator),
258 exponent_inverse) -
259 pinf;
260
261#ifdef DEBUG_RIEMANN_SOLVER
262 std::cout << "SS p_1_tilde = " << p_1_tilde << "\n";
263#endif
264
265 const auto p_2_tilde = p_star_failsafe(riemann_data_i, riemann_data_j);
266
267 return std::min(p_1_tilde, p_2_tilde);
268 }
269
270
271 template <int dim, typename Number>
272 DEAL_II_ALWAYS_INLINE inline Number
274 const primitive_type &riemann_data_i,
275 const primitive_type &riemann_data_j) const
276 {
277 const auto view = hyperbolic_system.view<dim, Number>();
278 const auto interpolation_b = view.eos_interpolation_b();
279 const auto pinf = view.eos_interpolation_pinfty();
280
281 const auto &[rho_i, u_i, p_i, gamma_i, a_i] = riemann_data_i;
282 const auto &[rho_j, u_j, p_j, gamma_j, a_j] = riemann_data_j;
283
284 /*
285 * Compute (5.11) formula for \tilde p_2^\ast:
286 *
287 * Cost: 0x pow, 3x division, 3x sqrt
288 */
289
290 const Number p_max = std::max(p_i, p_j) + pinf;
291
292 const Number radicand_i = safe_division(
293 ScalarNumber(2.) * (Number(1.) - interpolation_b * rho_i) * p_max,
294 rho_i * ((gamma_i + Number(1.)) * p_max +
295 (gamma_i - Number(1.)) * (p_i + pinf)));
296
297 const Number x_i = std::sqrt(radicand_i);
298
299 const Number radicand_j = safe_division(
300 ScalarNumber(2.) * (Number(1.) - interpolation_b * rho_j) * p_max,
301 rho_j * ((gamma_j + Number(1.)) * p_max +
302 (gamma_j - Number(1.)) * (p_j + pinf)));
303
304 const Number x_j = std::sqrt(radicand_j);
305
306 const Number a = x_i + x_j;
307 const Number b =
308 dealii::compare_and_apply_mask<dealii::SIMDComparison::equal>(
309 a, Number(0.), Number(0.), u_j - u_i);
310
311 const Number c = -(p_i + pinf) * x_i - (p_j + pinf) * x_j;
312
313 const Number base = safe_division(
314 std::abs(-b +
315 std::sqrt(positive_part(b * b - ScalarNumber(4.) * a * c))),
316 std::abs(ScalarNumber(2.) * a));
317
318 const Number p_2_tilde = base * base - pinf;
319
320#ifdef DEBUG_RIEMANN_SOLVER
321 std::cout << "SS p_2_tilde = " << p_2_tilde << "\n";
322#endif
323 return p_2_tilde;
324 }
325
326
327 template <int dim, typename Number>
328 DEAL_II_ALWAYS_INLINE inline Number
330 const primitive_type &riemann_data_i,
331 const primitive_type &riemann_data_j) const
332 {
333 const auto view = hyperbolic_system.view<dim, Number>();
334 const auto pinf = view.eos_interpolation_pinfty();
335
336 const auto &[rho_i, u_i, p_i, gamma_i, a_i] = riemann_data_i;
337 const auto &[rho_j, u_j, p_j, gamma_j, a_j] = riemann_data_j;
338 const auto alpha_i = alpha(rho_i, gamma_i, a_i);
339 const auto alpha_j = alpha(rho_j, gamma_j, a_j);
340
341 /*
342 * First get p_min, p_max.
343 *
344 * Then, we get gamma_min/max, and alpha_min/max. Note that the
345 * *_min/max values are associated with p_min/max and are not
346 * necessarily the minimum/maximum of *_i vs *_j.
347 */
348
349 const Number p_min = std::min(p_i, p_j) + pinf;
350 const Number p_max = std::max(p_i, p_j) + pinf;
351
352 const Number gamma_min =
353 dealii::compare_and_apply_mask<dealii::SIMDComparison::less_than>(
354 p_i, p_j, gamma_i, gamma_j);
355
356 const Number alpha_min =
357 dealii::compare_and_apply_mask<dealii::SIMDComparison::less_than>(
358 p_i, p_j, alpha_i, alpha_j);
359
360 const Number alpha_hat_min = c(gamma_min) * alpha_min;
361
362 const Number gamma_max = dealii::compare_and_apply_mask<
363 dealii::SIMDComparison::greater_than_or_equal>(
364 p_i, p_j, gamma_i, gamma_j);
365
366 const Number alpha_max = dealii::compare_and_apply_mask<
367 dealii::SIMDComparison::greater_than_or_equal>(
368 p_i, p_j, alpha_i, alpha_j);
369
370 const Number alpha_hat_max = c(gamma_max) * alpha_max;
371
372 const Number gamma_m = std::min(gamma_i, gamma_j);
373 const Number gamma_M = std::max(gamma_i, gamma_j);
374
375 const Number p_ratio = safe_division(p_min, p_max);
376
377 /*
378 * Here, we use a trick: The r-factor only shows up in the formula
379 * for the case \gamma_min = \gamma_m, otherwise the r-factor
380 * vanishes. We can accomplish this by using the following modified
381 * exponent (where we substitute gamma_m by gamma_min):
382 */
383 const Number r_exponent =
384 (gamma_M - gamma_min) / (ScalarNumber(2.) * gamma_min * gamma_M);
385
386 /*
387 * Compute a simultaneous upper bound on
388 * (5.7) second formula for \tilde p_2^\ast
389 * (5.8) first formula for \tilde p_1^\ast
390 * (5.11) formula for \tilde p_2^\ast
391 */
392
393 const Number exponent =
394 (gamma_m - Number(1.)) / (ScalarNumber(2.) * gamma_m);
395 const Number exponent_inverse = Number(1.) / exponent;
396
397 const Number numerator =
398 positive_part(alpha_hat_min + /*SIC!*/ alpha_max - (u_j - u_i));
399
400 Number denominator = alpha_hat_min * ryujin::pow(p_ratio, -exponent) +
401 alpha_hat_max * ryujin::pow(p_ratio, r_exponent);
402
403 const auto temp = safe_division(numerator, denominator);
404
405 const Number p_tilde = p_max * ryujin::pow(temp, exponent_inverse) - pinf;
406
407#ifdef DEBUG_RIEMANN_SOLVER
408 std::cout << "IN p_*_tilde = " << p_tilde << "\n";
409#endif
410
411 return p_tilde;
412 }
413
414
415 template <int dim, typename Number>
416 DEAL_II_ALWAYS_INLINE inline Number
417 RiemannSolver<dim, Number>::f(const primitive_type &riemann_data,
418 const Number p_star) const
419 {
420 constexpr ScalarNumber min = std::numeric_limits<ScalarNumber>::min();
421
422 const auto view = hyperbolic_system.view<dim, Number>();
423 const auto interpolation_b = view.eos_interpolation_b();
424 const auto pinf = view.eos_interpolation_pinfty();
425
426 const auto &[rho, u, p, gamma, a] = riemann_data;
427
428 const Number one_minus_b_rho = Number(1.) - interpolation_b * rho;
429 const Number gamma_minus_one = gamma - Number(1.);
430
431 const Number Az =
432 ScalarNumber(2.) * one_minus_b_rho / (rho * (gamma + Number(1.)));
433
434 const Number Bz = gamma_minus_one / (gamma + Number(1.)) * (p + pinf);
435
436 const Number radicand = safe_division(Az, p_star + pinf + Bz);
437
438 /* true_value is shock case */
439 const Number true_value = (p_star - p) * std::sqrt(radicand);
440
441 const auto exponent = ScalarNumber(0.5) * gamma_minus_one / gamma;
442
443 const Number ratio = safe_division(p_star + pinf, p + pinf);
444 const Number factor = ryujin::pow(ratio, exponent) - Number(1.);
445
446 /* false_value is rarefaction case */
447 const auto false_value = ScalarNumber(2.) * a * one_minus_b_rho * factor /
448 std::max(gamma_minus_one, Number(min));
449
450 return dealii::compare_and_apply_mask<
451 dealii::SIMDComparison::greater_than_or_equal>(
452 p_star, p, true_value, false_value);
453 }
454
455
456 template <int dim, typename Number>
457 DEAL_II_ALWAYS_INLINE inline Number
458 RiemannSolver<dim, Number>::phi(const primitive_type &riemann_data_i,
459 const primitive_type &riemann_data_j,
460 const Number p_in) const
461 {
462 const Number &u_i = riemann_data_i[1];
463 const Number &u_j = riemann_data_j[1];
464
465 return f(riemann_data_i, p_in) + f(riemann_data_j, p_in) + u_j - u_i;
466 }
467
468
469 template <int dim, typename Number>
470 DEAL_II_ALWAYS_INLINE inline Number
472 const primitive_type &riemann_data_i,
473 const primitive_type &riemann_data_j) const
474 {
475 const auto view = hyperbolic_system.view<dim, Number>();
476 const auto interpolation_b = view.eos_interpolation_b();
477 const auto pinf = view.eos_interpolation_pinfty();
478
479 const auto &[rho_i, u_i, p_i, gamma_i, a_i] = riemann_data_i;
480 const auto &[rho_j, u_j, p_j, gamma_j, a_j] = riemann_data_j;
481
482 const Number p_max = std::max(p_i, p_j) + pinf;
483
484 const Number radicand_inverse_i =
485 safe_division(ScalarNumber(0.5) * rho_i,
486 Number(1.) - interpolation_b * rho_i) *
487 ((gamma_i + Number(1.)) * p_max +
488 (gamma_i - Number(1.)) * (p_i + pinf));
489
490 const Number value_i =
491 safe_division(p_max - p_i, std::sqrt(radicand_inverse_i));
492
493 const Number radicand_inverse_j =
494 safe_division(ScalarNumber(0.5) * rho_j,
495 Number(1.) - interpolation_b * rho_j) *
496 ((gamma_j + Number(1.)) * p_max +
497 (gamma_j - Number(1.)) * (p_j + pinf));
498
499 const Number value_j =
500 safe_division(p_max - p_j, std::sqrt(radicand_inverse_j));
501
502 return value_i + value_j + u_j - u_i;
503 }
504
505
506 template <int dim, typename Number>
507 DEAL_II_ALWAYS_INLINE inline Number
509 const primitive_type &riemann_data, const Number p_star) const
510 {
511 const auto view = hyperbolic_system.view<dim, Number>();
512 const auto pinf = view.eos_interpolation_pinfty();
513
514 const auto &[rho, u, p, gamma, a] = riemann_data;
515
516 const auto factor =
517 ScalarNumber(0.5) * (gamma + ScalarNumber(1.)) / gamma;
518
519 const Number tmp = safe_division(positive_part(p_star - p), p + pinf);
520
521 return u - a * std::sqrt(Number(1.) + factor * tmp);
522 }
523
524
525 template <int dim, typename Number>
526 DEAL_II_ALWAYS_INLINE inline Number
528 const Number p_star) const
529 {
530 const auto view = hyperbolic_system.view<dim, Number>();
531 const auto pinf = view.eos_interpolation_pinfty();
532
533 const auto &[rho, u, p, gamma, a] = riemann_data;
534
535 const auto factor =
536 ScalarNumber(0.5) * (gamma + ScalarNumber(1.)) / gamma;
537
538 const Number tmp = safe_division(positive_part(p_star - p), p + pinf);
539
540 return u + a * std::sqrt(Number(1.) + factor * tmp);
541 }
542
543
544 template <int dim, typename Number>
545 DEAL_II_ALWAYS_INLINE inline Number
547 const primitive_type &riemann_data_i,
548 const primitive_type &riemann_data_j,
549 const Number p_star) const
550 {
551 const Number nu_11 = lambda1_minus(riemann_data_i, p_star);
552 const Number nu_32 = lambda3_plus(riemann_data_j, p_star);
553
554 return std::max(positive_part(nu_32), negative_part(nu_11));
555 }
556
557
558 template <int dim, typename Number>
559 DEAL_II_ALWAYS_INLINE inline auto
561 const state_type &U,
562 const Number &p,
563 const dealii::Tensor<1, dim, Number> &n_ij) const -> primitive_type
564 {
565 const auto view = hyperbolic_system.view<dim, Number>();
566
567 const auto rho = view.density(U);
568 const auto rho_inverse = ScalarNumber(1.0) / rho;
569
570 const auto m = view.momentum(U);
571 const auto proj_m = n_ij * m;
572
573 const auto gamma = view.surrogate_gamma(U, p);
574
575 const auto interpolation_b = view.eos_interpolation_b();
576 const auto pinf = view.eos_interpolation_pinfty();
577 const auto x = Number(1.) - interpolation_b * rho;
578 const auto a = std::sqrt(gamma * (p + pinf) / (rho * x));
579
580#ifdef EXPENSIVE_BOUNDS_CHECK
582 Number(p + pinf),
583 [](auto val) { return val >= ScalarNumber(0.); },
584 dealii::ExcMessage("Internal error: p + pinf < 0."));
585
587 x,
588 [](auto val) { return val > ScalarNumber(0.); },
589 dealii::ExcMessage("Internal error: 1. - b * rho <= 0."));
590
592 gamma,
593 [](auto val) { return val >= ScalarNumber(1.); },
594 dealii::ExcMessage("Internal error: gamma < 1."));
595#endif
596
597 return {{rho, proj_m * rho_inverse, p, gamma, a}};
598 }
599
600
601 template <int dim, typename Number>
603 const primitive_type &riemann_data_i,
604 const primitive_type &riemann_data_j) const
605 {
606 const auto view = hyperbolic_system.view<dim, Number>();
607 const auto pinf = view.eos_interpolation_pinfty();
608
609 const auto &[rho_i, u_i, p_i, gamma_i, a_i] = riemann_data_i;
610 const auto &[rho_j, u_j, p_j, gamma_j, a_j] = riemann_data_j;
611
612#ifdef DEBUG_RIEMANN_SOLVER
613 std::cout << "rho_left: " << rho_i << std::endl;
614 std::cout << "u_left: " << u_i << std::endl;
615 std::cout << "p_left: " << p_i << std::endl;
616 std::cout << "gamma_left: " << gamma_i << std::endl;
617 std::cout << "a_left: " << a_i << std::endl;
618 std::cout << "rho_right: " << rho_j << std::endl;
619 std::cout << "u_right: " << u_j << std::endl;
620 std::cout << "p_right: " << p_j << std::endl;
621 std::cout << "gamma_right: " << gamma_j << std::endl;
622 std::cout << "a_right: " << a_j << std::endl;
623#endif
624
625 const Number p_max = std::max(p_i, p_j) + pinf;
626 const Number phi_p_max = phi_of_p_max(riemann_data_i, riemann_data_j);
627
628 if (!view.compute_strict_bounds()) {
629#ifdef DEBUG_RIEMANN_SOLVER
630 const Number p_star_RS = p_star_RS_full(riemann_data_i, riemann_data_j);
631 const Number p_star_SS = p_star_SS_full(riemann_data_i, riemann_data_j);
632 const Number p_debug =
633 dealii::compare_and_apply_mask<dealii::SIMDComparison::less_than>(
634 phi_p_max, Number(0.), p_star_SS, std::min(p_max, p_star_RS));
635 std::cout << " p^*_debug = " << p_debug << "\n";
636 std::cout << " phi(p_*_d) = "
637 << phi(riemann_data_i, riemann_data_j, p_debug) << "\n";
638 std::cout << "-> lambda_deb = "
639 << compute_lambda(riemann_data_i, riemann_data_j, p_debug)
640 << std::endl;
641#endif
642
643 const Number p_star_tilde =
644 p_star_interpolated(riemann_data_i, riemann_data_j);
645 const Number p_star_backup =
646 p_star_failsafe(riemann_data_i, riemann_data_j);
647
648 const Number p_2 =
649 dealii::compare_and_apply_mask<dealii::SIMDComparison::less_than>(
650 phi_p_max,
651 Number(0.),
652 std::min(p_star_tilde, p_star_backup),
653 std::min(p_max, p_star_tilde));
654
655#ifdef DEBUG_RIEMANN_SOLVER
656 std::cout << " p^*_tilde = " << p_2 << "\n";
657 std::cout << " phi(p_*_t) = "
658 << phi(riemann_data_i, riemann_data_j, p_2) << "\n";
659 std::cout << "-> lambda_max = "
660 << compute_lambda(riemann_data_i, riemann_data_j, p_2) << "\n"
661 << std::endl;
662#endif
663
664 return compute_lambda(riemann_data_i, riemann_data_j, p_2);
665 }
666
667 const Number p_star_RS = p_star_RS_full(riemann_data_i, riemann_data_j);
668 const Number p_star_SS = p_star_SS_full(riemann_data_i, riemann_data_j);
669
670 const Number p_2 =
671 dealii::compare_and_apply_mask<dealii::SIMDComparison::less_than>(
672 phi_p_max, Number(0.), p_star_SS, std::min(p_max, p_star_RS));
673
674#ifdef DEBUG_RIEMANN_SOLVER
675 std::cout << " p^*_tilde = " << p_2 << "\n";
676 std::cout << " phi(p_*_t) = "
677 << phi(riemann_data_i, riemann_data_j, p_2) << "\n";
678 std::cout << "-> lambda_max = "
679 << compute_lambda(riemann_data_i, riemann_data_j, p_2)
680 << std::endl;
681#endif
682
683 return compute_lambda(riemann_data_i, riemann_data_j, p_2);
684 }
685
686
687 template <int dim, typename Number>
688 DEAL_II_ALWAYS_INLINE inline Number RiemannSolver<dim, Number>::compute(
689 const state_type &U_i,
690 const state_type &U_j,
691 const unsigned int i,
692 const unsigned int *js,
693 const dealii::Tensor<1, dim, Number> &n_ij) const
694 {
695 const auto &[p_i, unused_i, s_i, eta_i] =
696 precomputed_values.template get_tensor<Number, precomputed_type>(i);
697
698 const auto &[p_j, unused_j, s_j, eta_j] =
699 precomputed_values.template get_tensor<Number, precomputed_type>(js);
700
701 const auto riemann_data_i = riemann_data_from_state(U_i, p_i, n_ij);
702 const auto riemann_data_j = riemann_data_from_state(U_j, p_j, n_ij);
703
704 return compute(riemann_data_i, riemann_data_j);
705 }
706
707
708 } // namespace EulerAEOS
709} // namespace ryujin
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 alpha(const Number &rho, const Number &gamma, const Number &a) const
primitive_type riemann_data_from_state(const state_type &U, const Number &p, const dealii::Tensor< 1, dim, Number > &n_ij) const
Number p_star_failsafe(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
Number lambda3_plus(const primitive_type &primitive_state, const Number p_star) 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 phi_of_p_max(const primitive_type &riemann_data_i, const primitive_type &riemann_data_j) const
Number compute_lambda(const primitive_type &riemann_data_i, const primitive_type &riemann_data_j, const Number p_star) const
typename View::ScalarNumber ScalarNumber
Number c(const Number &gamma_Z) const
Number compute(const primitive_type &riemann_data_i, const primitive_type &riemann_data_j) const
#define AssertThrowSIMD(variable, condition, exception)
T pow(const T x, const T b)
DEAL_II_ALWAYS_INLINE Number negative_part(const Number number)
Definition: simd.h:124
DEAL_II_ALWAYS_INLINE Number positive_part(const Number number)
Definition: simd.h:112
DEAL_II_ALWAYS_INLINE Number safe_division(const Number &numerator, const Number &denominator)