8#include <ryujin/base/compile_time_options.h>
20#include <deal.II/base/memory_space.h>
21#include <deal.II/base/parameter_acceptor.h>
22#include <deal.II/base/tensor.h>
35 typename MemorySpace = dealii::MemorySpace::Host>
36 class HyperbolicSystemView;
97 typename Number = double,
98 typename MemorySpace = dealii::MemorySpace::Host>
110 typename MemorySpace = dealii::MemorySpace::Host>
129 template <
typename MemorySpace = dealii::MemorySpace::Host,
131 typename ScalarNumber>
135 const bool skip_constrained_dofs =
true)
const;
148 void update_parameters();
152 std::string equation_of_state_;
154 std::vector<std::unique_ptr<EquationOfState>> equation_of_state_list_;
158 template <
int,
typename,
typename>
186 template <
int dim,
typename Number,
typename MemorySpace>
191 std::is_same_v<MemorySpace, dealii::MemorySpace::Host> ||
192 std::is_same_v<MemorySpace, dealii::MemorySpace::Default>,
193 "Unexpected memory space");
213 using state_type = dealii::Tensor<1, problem_dimension, Number>;
219 dealii::Tensor<1, problem_dimension, dealii::Tensor<1, dim, Number>>;
245 std::array<Number, n_initial_precomputed_values>;
247 template <
int n_comp>
276 hyperbolic_system.parameters_.template view<MemorySpace>())
277 , equation_of_state_(hyperbolic_system.selected_equation_of_state_)
294 return equation_of_state_->name();
336 const Number &e)
const
338 const auto &eos = equation_of_state_;
340 if constexpr (std::is_same_v<ScalarNumber, Number>) {
344 for (
unsigned int k = 0; k < Number::size(); ++k) {
355 DEAL_II_ALWAYS_INLINE
inline Number
358 const auto &eos = equation_of_state_;
360 if constexpr (std::is_same_v<ScalarNumber, Number>) {
361 return ScalarNumber(eos->specific_internal_energy(rho, p));
364 for (
unsigned int k = 0; k < Number::size(); ++k) {
365 e[k] =
ScalarNumber(eos->specific_internal_energy(rho[k], p[k]));
375 DEAL_II_ALWAYS_INLINE
inline Number
378 const auto &eos = equation_of_state_;
380 if constexpr (std::is_same_v<ScalarNumber, Number>) {
384 for (
unsigned int k = 0; k < Number::size(); ++k) {
385 p[k] =
ScalarNumber(eos->specific_entropy(rho[k], e[k]));
395 DEAL_II_ALWAYS_INLINE
inline Number
398 const auto &eos = equation_of_state_;
400 if constexpr (std::is_same_v<ScalarNumber, Number>) {
404 for (
unsigned int k = 0; k < Number::size(); ++k) {
416 const Number &e)
const
418 const auto &eos = equation_of_state_;
420 if constexpr (std::is_same_v<ScalarNumber, Number>) {
424 for (
unsigned int k = 0; k < Number::size(); ++k) {
435 DEAL_II_ALWAYS_INLINE
inline Number
438 const auto &eos = equation_of_state_;
440 if constexpr (std::is_same_v<ScalarNumber, Number>) {
444 for (
unsigned int k = 0; k < Number::size(); ++k) {
512 static DEAL_II_HOST_DEVICE dealii::Tensor<1, dim, Number>
553 const state_type &U,
const Number &gamma_min)
const;
566 const state_type &U,
const Number &gamma_min)
const;
581 const Number &gamma_min)
const;
595 const Number &p)
const;
613 const Number &gamma)
const;
623 DEAL_II_HOST_DEVICE Number
645 template <
int component>
651 const dealii::Tensor<1, dim, Number> &normal)
const;
675 template <
typename Lambda>
679 const dealii::Tensor<1, dim, Number> &normal,
680 const Lambda &get_dirichlet_data)
const;
699 const Number &p)
const;
724 const unsigned int i,
731 const unsigned int *js,
742 const dealii::Tensor<1, dim, Number> &c_ij)
const;
753 const dealii::Tensor<1, dim, Number> &c_ij)
const =
delete;
766 const unsigned int i,
772 const unsigned int *js,
792 template <
typename ST>
810 template <
typename ST>
832 template <
typename Lambda>
861 "Compressible Euler equations (arbitrary EOS)",
863 {
"rho",
"m_1",
"m_2",
"E"},
864 {
"rho",
"m_1",
"m_2",
"m_3",
"E"}}},
866 {
"rho",
"v_1",
"v_2",
"e"},
867 {
"rho",
"v_1",
"v_2",
"v_3",
"e"}}},
869 "surrogate_gamma_min",
870 "surrogate_specific_entropy",
871 "surrogate_harten_entropy"},
873 "surrogate_gamma_min",
874 "surrogate_specific_entropy",
875 "surrogate_harten_entropy"},
877 "surrogate_gamma_min",
878 "surrogate_specific_entropy",
879 "surrogate_harten_entropy"}}},
882 , parameters_(
"euler_aeos_hyperbolic_system_parameters",
886 auto ¶meters = *parameters_.view();
890 equation_of_state_ =
"polytropic gas";
894 "The equation of state. Valid names are given by any of the "
895 "subsections defined below",
899 parameters.compute_strict_bounds =
true;
901 "compute strict bounds",
902 parameters.compute_strict_bounds,
903 "Compute strict, but significantly more expensive bounds at various "
904 "places: (a) an expensive, but better upper wavespeed estimate in "
905 "the approximate WaveSpeedEstimator; (b) entropy "
906 "viscosity-commutator "
907 "with correct gamma_min over the stencil; (c) mathematically correct "
908 "surrogate specific entropy minimum with gamma_min over the "
911 parameters.reference_density = 1.;
912 add_parameter(
"reference density",
913 parameters.reference_density,
914 "Problem specific density reference");
916 parameters.vacuum_state_relaxation_small = 1.e2;
917 add_parameter(
"vacuum state relaxation small",
918 parameters.vacuum_state_relaxation_small,
919 "Problem specific vacuum relaxation parameter");
921 parameters.vacuum_state_relaxation_large = 1.e4;
922 add_parameter(
"vacuum state relaxation large",
923 parameters.vacuum_state_relaxation_large,
924 "Problem specific vacuum relaxation parameter");
931 ParameterAcceptor::parse_parameters_call_back.connect(
932 [
this] { update_parameters(); });
933 for (
auto &it : equation_of_state_list_)
934 it->parse_parameters_call_back.connect([this] { update_parameters(); });
940 inline void HyperbolicSystem::update_parameters()
943 equation_of_state_list_, equation_of_state_);
945 selected_equation_of_state_->name() +
" EOS)";
947 auto ¶meters = *parameters_.view();
949 parameters.covolume_constant =
950 selected_equation_of_state_->covolume_constant();
951 parameters.interpolation_pinfty =
952 selected_equation_of_state_->interpolation_pinfty();
953 parameters.interpolation_q =
954 selected_equation_of_state_->interpolation_q();
958 template <
typename MemorySpace,
int dim,
typename ScalarNumber>
962 const bool skip_constrained_dofs)
const
964 using HostSpace = dealii::MemorySpace::Host;
966 const unsigned int n_internal = offline_data.n_locally_internal();
967 const unsigned int n_owned = offline_data.n_locally_owned();
971 auto &U = state_vector.
state;
982 constexpr bool transfer =
984 !std::is_same_v<MemorySpace, dealii::MemorySpace::Host>;
986 [[maybe_unused]]
const bool host_resident =
987 U.template is_resident<HostSpace>();
989 if constexpr (transfer) {
990 U.template copy_to_memory_space<HostSpace>();
991 precomputed.template move_to_memory_space<HostSpace>();
995 const auto sparsity_simd_view =
996 offline_data.sparsity_pattern_simd().template view<HostSpace>();
1001 .template view<ScalarView::problem_dimension, HostSpace>();
1002 const auto precomputed_view =
1004 .template view<ScalarView::n_precomputed_values, HostSpace>();
1006 const auto hyperbolic_system_views =
1007 make_select_view<dim, ScalarNumber, HostSpace>(*
this);
1009 const auto body = [=](
auto sentinel,
unsigned int i) {
1010 using T =
decltype(sentinel);
1014 const unsigned int row_length = sparsity_simd_view.row_length(i);
1015 if (skip_constrained_dofs && row_length == 1)
1018 const auto view = hyperbolic_system_views.template view<T>();
1020 const auto U_i = U_view.template read_tensor<T>(i);
1021 const auto rho_i =
view.density(U_i);
1022 const auto e_i =
view.internal_energy(U_i) / rho_i;
1025 const auto p_i =
view.eos_pressure(rho_i, e_i);
1027 const auto gamma_i =
view.surrogate_gamma(U_i, p_i);
1028 const precomputed_type prec_i{p_i, gamma_i, T(0.), T(0.)};
1029 precomputed_view.template write_tensor<T>(prec_i, i);
1032 loop<HostSpace, ScalarNumber>(
1033 "hyperbolic_kernel_01b", body, 0, n_internal, n_owned);
1036 if constexpr (transfer) {
1039 U.template move_to_memory_space<MemorySpace>();
1040 precomputed.template move_to_memory_space<MemorySpace>();
1043 precomputed.template view<ScalarView::n_precomputed_values, MemorySpace>()
1044 .update_ghost_values();
1051 const auto sparsity_simd_view =
1052 offline_data.sparsity_pattern_simd().template view<MemorySpace>();
1057 .template view<ScalarView::problem_dimension, MemorySpace>();
1058 const auto precomputed_view =
1060 .template view<ScalarView::n_precomputed_values, MemorySpace>();
1062 const auto hyperbolic_system_views =
1063 make_select_view<dim, ScalarNumber, MemorySpace>(*
this);
1065 const auto body = [=](
auto sentinel,
unsigned int i) {
1066 using T =
decltype(sentinel);
1070 const unsigned int row_length = sparsity_simd_view.row_length(i);
1071 if (skip_constrained_dofs && row_length == 1)
1074 const auto view = hyperbolic_system_views.template view<T>();
1076 const auto U_i = U_view.template read_tensor<T>(i);
1077 auto prec_i = precomputed_view.template read_tensor<T, PT>(i);
1079 auto &[p_i, gamma_min_i, s_i, eta_i] = prec_i;
1081 const unsigned int stride_size = sparsity_simd_view.stride_of_row(i);
1082 const unsigned int *js = sparsity_simd_view.columns(i) + stride_size;
1083 for (
unsigned int col_idx = 1; col_idx < row_length;
1084 ++col_idx, js += stride_size) {
1086 const auto U_j = U_view.template read_tensor<T>(js);
1088 precomputed_view.template read_tensor<T, PT>(js);
1089 const auto p_j = std::get<0>(prec_j);
1090 const auto gamma_j =
view.surrogate_gamma(U_j, p_j);
1091 gamma_min_i = std::min(gamma_min_i, gamma_j);
1094 s_i =
view.surrogate_specific_entropy(U_i, gamma_min_i);
1095 eta_i =
view.surrogate_harten_entropy(U_i, gamma_min_i);
1096 precomputed_view.template write_tensor<T>(prec_i, i);
1099 loop<MemorySpace, ScalarNumber>(
1100 "hyperbolic_kernel_01c", body, 0, n_internal, n_owned);
1105 template <
int dim,
typename Number,
typename MemorySpace>
1106 DEAL_II_HOST_DEVICE_ALWAYS_INLINE Number
1113 template <
int dim,
typename Number,
typename MemorySpace>
1114 DEAL_II_HOST_DEVICE_ALWAYS_INLINE Number
1116 const Number &rho)
const
1118 constexpr ScalarNumber eps = std::numeric_limits<ScalarNumber>::epsilon();
1119 const Number rho_cutoff_large =
1120 reference_density() * vacuum_state_relaxation_large() * eps;
1122 return ryujin::compare_and_apply_mask<dealii::SIMDComparison::less_than>(
1123 std::abs(rho), rho_cutoff_large, Number(0.), rho);
1127 template <
int dim,
typename Number,
typename MemorySpace>
1128 DEAL_II_HOST_DEVICE_ALWAYS_INLINE dealii::Tensor<1, dim, Number>
1132 dealii::Tensor<1, dim, Number> result;
1133 for (
unsigned int i = 0; i < dim; ++i)
1134 result[i] = U[1 + i];
1139 template <
int dim,
typename Number,
typename MemorySpace>
1140 DEAL_II_HOST_DEVICE_ALWAYS_INLINE Number
1148 template <
int dim,
typename Number,
typename MemorySpace>
1149 DEAL_II_HOST_DEVICE_ALWAYS_INLINE Number
1156 const Number rho_inverse =
ScalarNumber(1.) / density(U);
1157 const auto m = momentum(U);
1158 const Number E = total_energy(U);
1159 return E -
ScalarNumber(0.5) * m.norm_square() * rho_inverse;
1163 template <
int dim,
typename Number,
typename MemorySpace>
1164 DEAL_II_HOST_DEVICE_ALWAYS_INLINE
auto
1175 const Number rho_inverse =
ScalarNumber(1.) / density(U);
1176 const auto u = momentum(U) * rho_inverse;
1181 for (
unsigned int i = 0; i < dim; ++i) {
1182 result[1 + i] = -u[i];
1190 template <
int dim,
typename Number,
typename MemorySpace>
1191 DEAL_II_HOST_DEVICE_ALWAYS_INLINE Number
1193 const state_type &U,
const Number &gamma_min)
const
1195 const auto b = Number(eos_covolume_constant());
1196 const auto pinf = Number(eos_interpolation_pinfty());
1197 const auto q = Number(eos_interpolation_q());
1199 const auto rho = density(U);
1202 const auto covolume = Number(1.) - b * rho;
1204 const auto shift = internal_energy(U) - rho * q - pinf * covolume;
1206 return shift *
ryujin::pow(rho_inverse - b, gamma_min) / covolume;
1210 template <
int dim,
typename Number,
typename MemorySpace>
1211 DEAL_II_HOST_DEVICE_ALWAYS_INLINE Number
1213 const state_type &U,
const Number &gamma_min)
const
1215 const auto b = Number(eos_covolume_constant());
1216 const auto pinf = Number(eos_interpolation_pinfty());
1217 const auto q = Number(eos_interpolation_q());
1219 const auto rho = density(U);
1220 const auto m = momentum(U);
1221 const auto E = total_energy(U);
1222 const auto rho_rho_e_q =
1223 rho * E -
ScalarNumber(0.5) * m.norm_square() - rho * rho * q;
1225 const auto exponent =
ScalarNumber(1.) / (gamma_min + Number(1.));
1227 const auto covolume = Number(1.) - b * rho;
1228 const auto covolume_term =
ryujin::pow(covolume, gamma_min - Number(1.));
1230 const auto rho_pinfcov = rho * pinf * covolume;
1233 positive_part(rho_rho_e_q - rho_pinfcov) * covolume_term, exponent);
1237 template <
int dim,
typename Number,
typename MemorySpace>
1238 DEAL_II_HOST_DEVICE_ALWAYS_INLINE
auto
1242 const Number &gamma_min)
const
1259 const auto b = Number(eos_covolume_constant());
1260 const auto pinf = Number(eos_interpolation_pinfty());
1261 const auto q = Number(eos_interpolation_q());
1263 const auto rho = density(U);
1264 const auto m = momentum(U);
1265 const auto E = total_energy(U);
1267 const auto covolume = Number(1.) - b * rho;
1268 const auto covolume_inverse =
ScalarNumber(1.) / covolume;
1270 const auto shift = rho * E -
ScalarNumber(0.5) * m.norm_square() -
1271 rho * rho * q - rho * pinf * covolume;
1273 constexpr auto eps = std::numeric_limits<ScalarNumber>::epsilon();
1274 const auto regularization = m.norm() * eps;
1276 std::max(regularization, eta * covolume_inverse), gamma_min);
1278 factor *= fixed_power<2>(covolume_inverse) / (gamma_min + Number(1.));
1282 const auto first_term = E -
ScalarNumber(2.) * rho * q -
1284 const auto second_term = -(gamma_min - Number(1.)) * shift * b;
1286 result[0] = factor * (covolume * first_term + second_term);
1287 for (
unsigned int i = 0; i < dim; ++i)
1288 result[1 + i] = -factor * covolume * m[i];
1289 result[dim + 1] = factor * covolume * rho;
1295 template <
int dim,
typename Number,
typename MemorySpace>
1296 DEAL_II_HOST_DEVICE_ALWAYS_INLINE Number
1300 const auto b = Number(eos_covolume_constant());
1301 const auto pinf = Number(eos_interpolation_pinfty());
1302 const auto q = Number(eos_interpolation_q());
1304 const auto rho = density(U);
1305 const auto rho_e = internal_energy(U);
1306 const auto covolume = Number(1.) - b * rho;
1308 const auto numerator = (p + pinf) * covolume;
1309 const auto denominator = rho_e - rho * q - covolume * pinf;
1314 template <
int dim,
typename Number,
typename MemorySpace>
1315 DEAL_II_HOST_DEVICE_ALWAYS_INLINE Number
1317 const state_type &U,
const Number &gamma)
const
1319 const auto b = Number(eos_covolume_constant());
1320 const auto pinf = Number(eos_interpolation_pinfty());
1321 const auto q = Number(eos_interpolation_q());
1323 const auto rho = density(U);
1324 const auto rho_e = internal_energy(U);
1325 const auto covolume = Number(1.) - b * rho;
1333 template <
int dim,
typename Number,
typename MemorySpace>
1334 DEAL_II_HOST_DEVICE_ALWAYS_INLINE Number
1336 const state_type &U,
const Number &gamma)
const
1338 const auto b = Number(eos_covolume_constant());
1339 const auto pinf = Number(eos_interpolation_pinfty());
1340 const auto q = Number(eos_interpolation_q());
1342 const auto rho = density(U);
1343 const auto rho_e = internal_energy(U);
1344 const auto covolume = Number(1.) - b * rho;
1347 (rho_e - rho * q - pinf * covolume) / (covolume * covolume * rho);
1348 radicand *= gamma * (gamma - 1.);
1353 template <
int dim,
typename Number,
typename MemorySpace>
1354 DEAL_II_HOST_DEVICE_ALWAYS_INLINE
bool
1358 const auto b = Number(eos_covolume_constant());
1359 const auto pinf = Number(eos_interpolation_pinfty());
1360 const auto q = Number(eos_interpolation_q());
1362 const auto rho = density(U);
1363 const auto rho_e = internal_energy(U);
1364 const auto covolume = Number(1.) - b * rho;
1366 const auto shift = rho_e - rho * q - pinf * covolume;
1368 constexpr auto gt = dealii::SIMDComparison::greater_than;
1371 ryujin::compare_and_apply_mask<gt>(rho, T(0.), T(0.), T(-1.)) +
1372 ryujin::compare_and_apply_mask<gt>(shift, T(0.), T(0.), T(-1.));
1375 if (!(test == Number(0.))) {
1376 std::cout << std::fixed << std::setprecision(16);
1377 std::cout <<
"Bounds violation: Negative state [rho, e] detected!\n";
1378 std::cout <<
"\t\trho: " << rho <<
"\n";
1379 std::cout <<
"\t\tint (shifted): " << shift <<
"\n";
1383 return (test == Number(0.));
1387 template <
int dim,
typename Number,
typename MemorySpace>
1388 template <
int component>
1389 DEAL_II_HOST_DEVICE_ALWAYS_INLINE
auto
1395 const Number &p_bar,
1396 const dealii::Tensor<1, dim, Number> &normal)
const ->
state_type
1398 static_assert(component == 1 || component == 2,
1399 "component has to be 1 or 2");
1401 const auto b = Number(eos_covolume_constant());
1402 const auto pinf = Number(eos_interpolation_pinfty());
1403 const auto q = Number(eos_interpolation_q());
1415 const auto m = momentum(U);
1416 const auto rho = density(U);
1417 const auto vn = m * normal / rho;
1419 const auto gamma = surrogate_gamma(U, p);
1420 const auto a = surrogate_speed_of_sound(U, gamma);
1421 const auto covolume = 1. - b * rho;
1423 const auto m_bar = momentum(U_bar);
1424 const auto rho_bar = density(U_bar);
1425 const auto vn_bar = m_bar * normal / rho_bar;
1427 const auto gamma_bar = surrogate_gamma(U_bar, p_bar);
1428 const auto a_bar = surrogate_speed_of_sound(U_bar, gamma_bar);
1429 const auto covolume_bar = 1. - b * rho_bar;
1442 component == 1 ? vn_bar - 2. * a_bar / (gamma_bar - 1.) * covolume_bar
1443 : vn - 2. * a / (gamma - 1.) * covolume;
1446 component == 2 ? vn_bar + 2. * a_bar / (gamma_bar - 1.) * covolume_bar
1447 : vn + 2. * a / (gamma - 1.) * covolume;
1456 dealii::ExcMessage(
"Encountered R_2 < R_1 in dynamic boundary value "
1457 "enforcement. This implies that the interpolation "
1458 "with Riemann characteristics failed."));
1460 const auto vperp = m / rho - vn * normal;
1462 const auto S = (p + pinf) *
ryujin::pow(Number(1.) / rho - b, gamma);
1479 const auto vn_new = Number(0.5) * (R_1 + R_2);
1509 const auto a_new_square =
1510 ryujin::fixed_power<2>((gamma - 1.) * (R_2 - R_1) / (4. * covolume));
1512 auto term =
ryujin::pow(a_new_square / (gamma * S), 1. / (gamma - 1.));
1517 const auto rho_new = term / (1. + b * term);
1519 const auto covolume_new = (1. - b * rho_new);
1520 const auto p_new = a_new_square / gamma * rho_new * covolume_new - pinf;
1526 const auto rho_e_new =
1527 rho_new * q + (p_new + gamma * pinf) * covolume_new / (gamma - 1.);
1531 for (
unsigned int d = 0; d < dim; ++d) {
1532 U_new[1 + d] = rho_new * (vn_new * normal + vperp)[d];
1535 rho_e_new + 0.5 * rho_new * (vn_new * vn_new + vperp.norm_square());
1541 template <
int dim,
typename Number,
typename MemorySpace>
1542 template <
typename Lambda>
1543 DEAL_II_ALWAYS_INLINE
inline auto
1545 dealii::types::boundary_id
id,
1547 const dealii::Tensor<1, dim, Number> &normal,
1548 const Lambda &get_dirichlet_data)
const ->
state_type
1553 result = get_dirichlet_data();
1560 const auto m_dirichlet = momentum(get_dirichlet_data());
1561 const auto rho = density(result);
1562 const auto m = momentum(result);
1564 for (
unsigned int k = 0; k < dim; ++k)
1565 result[k + 1] = m_dirichlet[k];
1567 Number(0.5) / rho * (m_dirichlet.norm_square() - m.norm_square());
1574 const auto U_dirichlet = get_dirichlet_data();
1575 const auto rho_dirichlet = density(U_dirichlet);
1576 const auto v_dirichlet = momentum(U_dirichlet) / rho_dirichlet;
1577 const auto rho = density(result);
1578 const auto v = momentum(result) / rho;
1580 for (
unsigned int k = 0; k < dim; ++k)
1581 result[k + 1] = rho * v_dirichlet[k];
1583 Number(0.5) * rho * (v_dirichlet.norm_square() - v.norm_square());
1586 auto m = momentum(U);
1587 m -= 1. * (m * normal) * normal;
1588 for (
unsigned int k = 0; k < dim; ++k)
1589 result[k + 1] = m[k];
1592 for (
unsigned int k = 0; k < dim; ++k)
1593 result[k + 1] = Number(0.);
1608 const auto m = momentum(U);
1609 const auto rho = density(U);
1610 const auto rho_e = internal_energy(U);
1617 const auto p = eos_pressure(rho, rho_e / rho);
1618 const auto gamma = surrogate_gamma(U, p);
1619 const auto a = surrogate_speed_of_sound(U, gamma);
1620 const auto vn = m * normal / rho;
1624 result = get_dirichlet_data();
1628 if (vn >= -a && vn <= 0.) {
1629 const auto U_dirichlet = get_dirichlet_data();
1630 const auto rho_dirichlet = density(U_dirichlet);
1631 const auto rho_e_dirichlet = internal_energy(U_dirichlet);
1632 const auto p_dirichlet =
1633 eos_pressure(rho_dirichlet, rho_e_dirichlet / rho_dirichlet);
1635 result = prescribe_riemann_characteristic<2>(
1636 U_dirichlet, p_dirichlet, U, p, normal);
1640 if (vn > 0. && vn <= a) {
1641 const auto U_dirichlet = get_dirichlet_data();
1642 const auto rho_dirichlet = density(U_dirichlet);
1643 const auto rho_e_dirichlet = internal_energy(U_dirichlet);
1644 const auto p_dirichlet =
1645 eos_pressure(rho_dirichlet, rho_e_dirichlet / rho_dirichlet);
1647 result = prescribe_riemann_characteristic<1>(
1648 U, p, U_dirichlet, p_dirichlet, normal);
1653 AssertThrow(
false, dealii::ExcNotImplemented());
1660 template <
int dim,
typename Number,
typename MemorySpace>
1661 DEAL_II_HOST_DEVICE_ALWAYS_INLINE
auto
1663 const Number &p)
const
1666 const auto rho_inverse =
ScalarNumber(1.) / density(U);
1667 const auto m = momentum(U);
1668 const auto E = total_energy(U);
1673 for (
unsigned int i = 0; i < dim; ++i) {
1674 result[1 + i] = m * (m[i] * rho_inverse);
1675 result[1 + i][i] += p;
1677 result[dim + 1] = m * (rho_inverse * (E + p));
1683 template <
int dim,
typename Number,
typename MemorySpace>
1684 DEAL_II_HOST_DEVICE_ALWAYS_INLINE
auto
1688 const unsigned int i,
1691 const auto &[p_i, gamma_min_i, s_i, eta_i] =
1692 pv.template read_tensor<Number, precomputed_type>(i);
1697 template <
int dim,
typename Number,
typename MemorySpace>
1698 DEAL_II_HOST_DEVICE_ALWAYS_INLINE
auto
1702 const unsigned int *js,
1705 const auto &[p_j, gamma_min_j, s_j, eta_j] =
1706 pv.template read_tensor<Number, precomputed_type>(js);
1711 template <
int dim,
typename Number,
typename MemorySpace>
1712 DEAL_II_HOST_DEVICE_ALWAYS_INLINE
auto
1716 const dealii::Tensor<1, dim, Number> &c_ij)
const ->
state_type
1722 template <
int dim,
typename Number,
typename MemorySpace>
1723 template <
typename ST>
1724 DEAL_II_HOST_DEVICE_ALWAYS_INLINE
auto
1728 using T =
typename ST::value_type;
1729 static_assert(std::is_same_v<Number, T>,
"template mismatch");
1731 constexpr auto dim2 = ST::dimension - 2;
1732 static_assert(dim >= dim2,
1733 "the space dimension of the argument state must not be "
1734 "larger than the one of the target state");
1737 result[0] =
state[0];
1738 result[dim + 1] =
state[dim2 + 1];
1739 for (
unsigned int i = 1; i < dim2 + 1; ++i)
1740 result[i] =
state[i];
1746 template <
int dim,
typename Number,
typename MemorySpace>
1747 template <
typename ST>
1748 DEAL_II_ALWAYS_INLINE
inline auto
1752 auto primitive_state = expand_state(initial_state);
1755 const auto rho = density(primitive_state);
1756 const auto p = total_energy(primitive_state);
1757 const auto e = eos_specific_internal_energy(rho, p);
1758 primitive_state[dim + 1] = e;
1760 return from_primitive_state(primitive_state);
1764 template <
int dim,
typename Number,
typename MemorySpace>
1765 DEAL_II_HOST_DEVICE_ALWAYS_INLINE
auto
1769 const auto rho = density(primitive_state);
1771 const auto u = momentum(primitive_state);
1773 const auto &e = total_energy(primitive_state);
1775 auto state = primitive_state;
1777 for (
unsigned int i = 1; i < dim + 1; ++i)
1781 state[dim + 1] = rho * e + Number(0.5) * rho * u * u;
1787 template <
int dim,
typename Number,
typename MemorySpace>
1788 DEAL_II_HOST_DEVICE_ALWAYS_INLINE
auto
1792 const auto rho = density(
state);
1793 const auto rho_inverse = Number(1.) / rho;
1794 const auto rho_e = internal_energy(
state);
1796 auto primitive_state =
state;
1798 for (
unsigned int i = 1; i < dim + 1; ++i)
1799 primitive_state[i] *= rho_inverse;
1801 primitive_state[dim + 1] = rho_e * rho_inverse;
1803 return primitive_state;
1807 template <
int dim,
typename Number,
typename MemorySpace>
1808 template <
typename Lambda>
1809 DEAL_II_HOST_DEVICE_ALWAYS_INLINE
auto
1813 auto result =
state;
1814 const auto M = lambda(momentum(
state));
1815 for (
unsigned int d = 0; d < dim; ++d)
1816 result[1 + d] = M[d];
DEAL_II_HOST_DEVICE flux_contribution_type flux_contribution(const PrecomputedVectorView &pv, const InitialPrecomputedVectorView &piv, const unsigned int i, const state_type &U_i) const
state_type from_initial_state(const ST &initial_state) const
DEAL_II_HOST_DEVICE state_type to_primitive_state(const state_type &state) const
DEAL_II_HOST_DEVICE state_type from_primitive_state(const state_type &primitive_state) const
dealii::Tensor< 1, problem_dimension, dealii::Tensor< 1, dim, Number > > flux_type
dealii::Tensor< 1, problem_dimension, Number > state_type
static constexpr bool have_gamma
DEAL_II_HOST_DEVICE Number surrogate_harten_entropy(const state_type &U, const Number &gamma_min) const
static DEAL_II_HOST_DEVICE Number density(const state_type &U)
DEAL_II_HOST_DEVICE_ALWAYS_INLINE ScalarNumber eos_interpolation_pinfty() const
DEAL_II_HOST_DEVICE_ALWAYS_INLINE ScalarNumber eos_interpolation_q() const
static constexpr unsigned int n_initial_precomputed_values
static DEAL_II_HOST_DEVICE dealii::Tensor< 1, dim, Number > momentum(const state_type &U)
DEAL_II_HOST_DEVICE Number filter_vacuum_density(const Number &rho) const
DEAL_II_ALWAYS_INLINE Number eos_temperature(const Number &rho, const Number &e) const
static DEAL_II_HOST_DEVICE Number internal_energy(const state_type &U)
DEAL_II_ALWAYS_INLINE Number eos_cold_curve_bound(const Number &rho) const
typename get_value_type< Number >::type ScalarNumber
DEAL_II_HOST_DEVICE Number surrogate_speed_of_sound(const state_type &U, const Number &gamma) const
static DEAL_II_HOST_DEVICE state_type internal_energy_derivative(const state_type &U)
static constexpr bool have_energy_equation
DEAL_II_HOST_DEVICE_ALWAYS_INLINE ScalarNumber reference_density() const
HyperbolicSystemView(const HyperbolicSystem &hyperbolic_system)
static constexpr bool have_source_terms
state_type apply_boundary_conditions(const dealii::types::boundary_id id, const state_type &U, const dealii::Tensor< 1, dim, Number > &normal, const Lambda &get_dirichlet_data) const
DEAL_II_HOST_DEVICE Number surrogate_pressure(const state_type &U, const Number &gamma) const
std::array< Number, n_precomputed_values > precomputed_type
DEAL_II_HOST_DEVICE Number surrogate_gamma(const state_type &U, const Number &p) const
DEAL_II_HOST_DEVICE state_type apply_galilei_transform(const state_type &state, const Lambda &lambda) const
DEAL_II_ALWAYS_INLINE Number eos_specific_entropy(const Number &rho, const Number &e) const
DEAL_II_HOST_DEVICE state_type flux_divergence(const flux_contribution_type &flux_i, const flux_contribution_type &flux_j, const dealii::Tensor< 1, dim, Number > &c_ij) const
DEAL_II_HOST_DEVICE bool is_admissible(const state_type &U) const
DEAL_II_HOST_DEVICE state_type nodal_source(const PrecomputedVectorView &pv, const unsigned int i, const state_type &U_i, const ScalarNumber tau) const =delete
std::array< Number, n_initial_precomputed_values > initial_precomputed_type
static DEAL_II_HOST_DEVICE Number total_energy(const state_type &U)
static constexpr bool have_covolume_constant
DEAL_II_HOST_DEVICE Number surrogate_specific_entropy(const state_type &U, const Number &gamma_min) const
DEAL_II_ALWAYS_INLINE Number eos_specific_internal_energy(const Number &rho, const Number &p) const
DEAL_II_HOST_DEVICE state_type high_order_flux_divergence(const flux_contribution_type &flux_i, const flux_contribution_type &flux_j, const dealii::Tensor< 1, dim, Number > &c_ij) const =delete
DEAL_II_HOST_DEVICE_ALWAYS_INLINE ScalarNumber vacuum_state_relaxation_large() const
static constexpr unsigned int problem_dimension
DEAL_II_HOST_DEVICE state_type nodal_source(const PrecomputedVectorView &pv, const unsigned int *js, const state_type &U_j, const ScalarNumber tau) const =delete
DEAL_II_ALWAYS_INLINE Number eos_speed_of_sound(const Number &rho, const Number &e) const
flux_type flux_contribution_type
static constexpr unsigned int n_precomputed_values
DEAL_II_HOST_DEVICE_ALWAYS_INLINE ScalarNumber eos_covolume_constant() const
static constexpr bool have_high_order_flux
DEAL_II_HOST_DEVICE state_type surrogate_harten_entropy_derivative(const state_type &U, const Number &eta, const Number &gamma_min) const
DEAL_II_HOST_DEVICE state_type expand_state(const ST &state) const
DEAL_II_ALWAYS_INLINE Number eos_pressure(const Number &rho, const Number &e) const
DEAL_II_HOST_DEVICE_ALWAYS_INLINE bool compute_strict_bounds() const
DEAL_II_HOST_DEVICE flux_type f(const state_type &U, const Number &p) const
DEAL_II_ALWAYS_INLINE const std::string & equation_of_state() const
DEAL_II_HOST_DEVICE_ALWAYS_INLINE ScalarNumber vacuum_state_relaxation_small() const
DEAL_II_HOST_DEVICE state_type prescribe_riemann_characteristic(const state_type &U, const Number &p, const state_type &U_bar, const Number &p_bar, const dealii::Tensor< 1, dim, Number > &normal) const
void fill_precomputed_values(const OfflineData< dim, ScalarNumber > &offline_data, StateVector< ScalarNumber > &state_vector, const bool skip_constrained_dofs=true) const
HyperbolicSystem(const std::string &subsection="/HyperbolicSystem")
dealii::Tensor< 1, problem_dimension, Number > state_type
typename get_value_type< Number >::type ScalarNumber
std::string problem_name_
static Base & select(const std::vector< std::unique_ptr< Base > > &objects, const std::string &name)
static std::vector< std::unique_ptr< Base > > create(Args... args)
static dealii::Patterns::Selection selection(const std::vector< std::unique_ptr< Base > > &objects)
constexpr bool have_separate_memory_spaces
@ implicit_transfers_host_resident
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 safe_division(const Number &numerator, const Number &denominator)
DEAL_II_HOST_DEVICE_ALWAYS_INLINE dealii::Tensor< 1, problem_dim, T > contract(const FT &flux_ij, const TT &c_ij)
DEAL_II_HOST_DEVICE_ALWAYS_INLINE FT add(const FT &flux_left_ij, const FT &flux_right_ij)
double vacuum_state_relaxation_large
double interpolation_pinfty
bool compute_strict_bounds
double vacuum_state_relaxation_small
MultiComponentVector< Number > state
MultiComponentVector< Number > precomputed