8#include <compile_time_options.h>
10#include <ryujin/interface/hyperbolic_system.h>
23#include <deal.II/base/memory_space.h>
24#include <deal.II/base/parameter_acceptor.h>
25#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_;
155 equation_of_state_list_;
158 std::shared_ptr<EquationOfState> selected_equation_of_state_;
160 template <
int,
typename,
typename>
188 template <
int dim,
typename Number,
typename MemorySpace>
193 std::is_same_v<MemorySpace, dealii::MemorySpace::Host> ||
194 std::is_same_v<MemorySpace, dealii::MemorySpace::Default>,
195 "Unexpected memory space");
215 using state_type = dealii::Tensor<1, problem_dimension, Number>;
221 dealii::Tensor<1, problem_dimension, dealii::Tensor<1, dim, Number>>;
247 std::array<Number, n_initial_precomputed_values>;
249 template <
int n_comp>
278 hyperbolic_system.parameters_.template view<MemorySpace>())
279 , equation_of_state_(
280 hyperbolic_system.selected_equation_of_state_.get())
297 return equation_of_state_->name();
339 const Number &e)
const
341 const auto &eos = equation_of_state_;
343 if constexpr (std::is_same_v<ScalarNumber, Number>) {
347 for (
unsigned int k = 0; k < Number::size(); ++k) {
358 DEAL_II_ALWAYS_INLINE
inline Number
361 const auto &eos = equation_of_state_;
363 if constexpr (std::is_same_v<ScalarNumber, Number>) {
364 return ScalarNumber(eos->specific_internal_energy(rho, p));
367 for (
unsigned int k = 0; k < Number::size(); ++k) {
368 e[k] =
ScalarNumber(eos->specific_internal_energy(rho[k], p[k]));
378 DEAL_II_ALWAYS_INLINE
inline Number
381 const auto &eos = equation_of_state_;
383 if constexpr (std::is_same_v<ScalarNumber, Number>) {
387 for (
unsigned int k = 0; k < Number::size(); ++k) {
388 p[k] =
ScalarNumber(eos->specific_entropy(rho[k], e[k]));
398 DEAL_II_ALWAYS_INLINE
inline Number
401 const auto &eos = equation_of_state_;
403 if constexpr (std::is_same_v<ScalarNumber, Number>) {
407 for (
unsigned int k = 0; k < Number::size(); ++k) {
419 const Number &e)
const
421 const auto &eos = equation_of_state_;
423 if constexpr (std::is_same_v<ScalarNumber, Number>) {
427 for (
unsigned int k = 0; k < Number::size(); ++k) {
438 DEAL_II_ALWAYS_INLINE
inline Number
441 const auto &eos = equation_of_state_;
443 if constexpr (std::is_same_v<ScalarNumber, Number>) {
447 for (
unsigned int k = 0; k < Number::size(); ++k) {
515 static DEAL_II_HOST_DEVICE dealii::Tensor<1, dim, Number>
556 const state_type &U,
const Number &gamma_min)
const;
569 const state_type &U,
const Number &gamma_min)
const;
584 const Number &gamma_min)
const;
598 const Number &p)
const;
616 const Number &gamma)
const;
626 DEAL_II_HOST_DEVICE Number
648 template <
int component>
654 const dealii::Tensor<1, dim, Number> &normal)
const;
678 template <
typename Lambda>
682 const dealii::Tensor<1, dim, Number> &normal,
683 const Lambda &get_dirichlet_data)
const;
702 const Number &p)
const;
727 const unsigned int i,
734 const unsigned int *js,
745 const dealii::Tensor<1, dim, Number> &c_ij)
const;
756 const dealii::Tensor<1, dim, Number> &c_ij)
const =
delete;
769 const unsigned int i,
775 const unsigned int *js,
795 template <
typename ST>
813 template <
typename ST>
835 template <
typename Lambda>
837 const state_type &state,
const Lambda &lambda)
const;
864 "Compressible Euler equations (arbitrary EOS)",
866 {
"rho",
"m_1",
"m_2",
"E"},
867 {
"rho",
"m_1",
"m_2",
"m_3",
"E"}}},
869 {
"rho",
"v_1",
"v_2",
"e"},
870 {
"rho",
"v_1",
"v_2",
"v_3",
"e"}}},
872 "surrogate_gamma_min",
873 "surrogate_specific_entropy",
874 "surrogate_harten_entropy"},
876 "surrogate_gamma_min",
877 "surrogate_specific_entropy",
878 "surrogate_harten_entropy"},
880 "surrogate_gamma_min",
881 "surrogate_specific_entropy",
882 "surrogate_harten_entropy"}}},
885 , parameters_(
"euler_aeos_hyperbolic_system_parameters",
889 auto ¶meters = *parameters_.view();
891 equation_of_state_ =
"polytropic gas";
895 "The equation of state. Valid names are given by any of the "
896 "subsections defined below");
898 parameters.compute_strict_bounds =
true;
900 "compute strict bounds",
901 parameters.compute_strict_bounds,
902 "Compute strict, but significantly more expensive bounds at various "
903 "places: (a) an expensive, but better upper wavespeed estimate in "
904 "the approximate WaveSpeedEstimator; (b) entropy "
905 "viscosity-commutator "
906 "with correct gamma_min over the stencil; (c) mathematically correct "
907 "surrogate specific entropy minimum with gamma_min over the "
910 parameters.reference_density = 1.;
911 add_parameter(
"reference density",
912 parameters.reference_density,
913 "Problem specific density reference");
915 parameters.vacuum_state_relaxation_small = 1.e2;
916 add_parameter(
"vacuum state relaxation small",
917 parameters.vacuum_state_relaxation_small,
918 "Problem specific vacuum relaxation parameter");
920 parameters.vacuum_state_relaxation_large = 1.e4;
921 add_parameter(
"vacuum state relaxation large",
922 parameters.vacuum_state_relaxation_large,
923 "Problem specific vacuum relaxation parameter");
930 equation_of_state_list_, subsection);
937 ParameterAcceptor::parse_parameters_call_back.connect(
938 [
this] { update_parameters(); });
939 for (
auto &it : equation_of_state_list_)
940 it->parse_parameters_call_back.connect([this] { update_parameters(); });
946 inline void HyperbolicSystem::update_parameters()
948 bool initialized =
false;
949 for (
auto &it : equation_of_state_list_)
952 if (it->name() == equation_of_state_) {
953 selected_equation_of_state_ = it;
955 "Compressible Euler equations (" + it->name() +
" EOS)";
963 "Could not find an equation of state description with name \"" +
964 equation_of_state_ +
"\""));
966 auto ¶meters = *parameters_.view();
968 parameters.covolume_constant =
969 selected_equation_of_state_->covolume_constant();
970 parameters.interpolation_pinfty =
971 selected_equation_of_state_->interpolation_pinfty();
972 parameters.interpolation_q =
973 selected_equation_of_state_->interpolation_q();
977 template <
typename MemorySpace,
int dim,
typename ScalarNumber>
981 const bool skip_constrained_dofs)
const
983 using HostSpace = dealii::MemorySpace::Host;
990 auto &U = state_vector.
U;
1001 constexpr bool transfer =
1003 !std::is_same_v<MemorySpace, dealii::MemorySpace::Host>;
1005 [[maybe_unused]]
const bool host_resident =
1006 U.template is_resident<HostSpace>();
1008 if constexpr (transfer) {
1009 U.template copy_to_memory_space<HostSpace>();
1010 precomputed.template move_to_memory_space<HostSpace>();
1014 const auto sparsity_simd_view =
1020 .template view<ScalarView::problem_dimension, HostSpace>();
1021 const auto precomputed_view =
1023 .template view<ScalarView::n_precomputed_values, HostSpace>();
1025 const auto hyperbolic_system_views =
1026 make_select_view<dim, ScalarNumber, HostSpace>(*
this);
1028 const auto body = [=](
auto sentinel,
unsigned int i) {
1029 using T =
decltype(sentinel);
1033 const unsigned int row_length = sparsity_simd_view.row_length(i);
1034 if (skip_constrained_dofs && row_length == 1)
1037 const auto view = hyperbolic_system_views.template view<T>();
1039 const auto U_i = U_view.template read_tensor<T>(i);
1040 const auto rho_i =
view.density(U_i);
1041 const auto e_i =
view.internal_energy(U_i) / rho_i;
1044 const auto p_i =
view.eos_pressure(rho_i, e_i);
1046 const auto gamma_i =
view.surrogate_gamma(U_i, p_i);
1047 const precomputed_type prec_i{p_i, gamma_i, T(0.), T(0.)};
1048 precomputed_view.template write_tensor<T>(prec_i, i);
1051 loop<HostSpace, ScalarNumber>(
1052 "hyperbolic_kernel_01b", body, 0, n_internal, n_owned);
1055 if constexpr (transfer) {
1058 U.template move_to_memory_space<MemorySpace>();
1059 precomputed.template move_to_memory_space<MemorySpace>();
1062 precomputed.template view<ScalarView::n_precomputed_values, MemorySpace>()
1063 .update_ghost_values();
1070 const auto sparsity_simd_view =
1076 .template view<ScalarView::problem_dimension, MemorySpace>();
1077 const auto precomputed_view =
1079 .template view<ScalarView::n_precomputed_values, MemorySpace>();
1081 const auto hyperbolic_system_views =
1082 make_select_view<dim, ScalarNumber, MemorySpace>(*
this);
1084 const auto body = [=](
auto sentinel,
unsigned int i) {
1085 using T =
decltype(sentinel);
1089 const unsigned int row_length = sparsity_simd_view.row_length(i);
1090 if (skip_constrained_dofs && row_length == 1)
1093 const auto view = hyperbolic_system_views.template view<T>();
1095 const auto U_i = U_view.template read_tensor<T>(i);
1096 auto prec_i = precomputed_view.template read_tensor<T, PT>(i);
1098 auto &[p_i, gamma_min_i, s_i, eta_i] = prec_i;
1100 const unsigned int stride_size = sparsity_simd_view.stride_of_row(i);
1101 const unsigned int *js = sparsity_simd_view.columns(i) + stride_size;
1102 for (
unsigned int col_idx = 1; col_idx < row_length;
1103 ++col_idx, js += stride_size) {
1105 const auto U_j = U_view.template read_tensor<T>(js);
1107 precomputed_view.template read_tensor<T, PT>(js);
1108 const auto p_j = std::get<0>(prec_j);
1109 const auto gamma_j =
view.surrogate_gamma(U_j, p_j);
1110 gamma_min_i = std::min(gamma_min_i, gamma_j);
1113 s_i =
view.surrogate_specific_entropy(U_i, gamma_min_i);
1114 eta_i =
view.surrogate_harten_entropy(U_i, gamma_min_i);
1115 precomputed_view.template write_tensor<T>(prec_i, i);
1118 loop<MemorySpace, ScalarNumber>(
1119 "hyperbolic_kernel_01c", body, 0, n_internal, n_owned);
1124 template <
int dim,
typename Number,
typename MemorySpace>
1125 DEAL_II_HOST_DEVICE_ALWAYS_INLINE Number
1132 template <
int dim,
typename Number,
typename MemorySpace>
1133 DEAL_II_HOST_DEVICE_ALWAYS_INLINE Number
1135 const Number &rho)
const
1137 constexpr ScalarNumber eps = std::numeric_limits<ScalarNumber>::epsilon();
1138 const Number rho_cutoff_large =
1139 reference_density() * vacuum_state_relaxation_large() * eps;
1141 return ryujin::compare_and_apply_mask<dealii::SIMDComparison::less_than>(
1142 std::abs(rho), rho_cutoff_large, Number(0.), rho);
1146 template <
int dim,
typename Number,
typename MemorySpace>
1147 DEAL_II_HOST_DEVICE_ALWAYS_INLINE dealii::Tensor<1, dim, Number>
1151 dealii::Tensor<1, dim, Number> result;
1152 for (
unsigned int i = 0; i < dim; ++i)
1153 result[i] = U[1 + i];
1158 template <
int dim,
typename Number,
typename MemorySpace>
1159 DEAL_II_HOST_DEVICE_ALWAYS_INLINE Number
1167 template <
int dim,
typename Number,
typename MemorySpace>
1168 DEAL_II_HOST_DEVICE_ALWAYS_INLINE Number
1175 const Number rho_inverse =
ScalarNumber(1.) / density(U);
1176 const auto m = momentum(U);
1177 const Number E = total_energy(U);
1178 return E -
ScalarNumber(0.5) * m.norm_square() * rho_inverse;
1182 template <
int dim,
typename Number,
typename MemorySpace>
1183 DEAL_II_HOST_DEVICE_ALWAYS_INLINE
auto
1194 const Number rho_inverse =
ScalarNumber(1.) / density(U);
1195 const auto u = momentum(U) * rho_inverse;
1200 for (
unsigned int i = 0; i < dim; ++i) {
1201 result[1 + i] = -u[i];
1209 template <
int dim,
typename Number,
typename MemorySpace>
1210 DEAL_II_HOST_DEVICE_ALWAYS_INLINE Number
1212 const state_type &U,
const Number &gamma_min)
const
1214 const auto b = Number(eos_covolume_constant());
1215 const auto pinf = Number(eos_interpolation_pinfty());
1216 const auto q = Number(eos_interpolation_q());
1218 const auto rho = density(U);
1221 const auto covolume = Number(1.) - b * rho;
1223 const auto shift = internal_energy(U) - rho * q - pinf * covolume;
1225 return shift *
ryujin::pow(rho_inverse - b, gamma_min) / covolume;
1229 template <
int dim,
typename Number,
typename MemorySpace>
1230 DEAL_II_HOST_DEVICE_ALWAYS_INLINE Number
1232 const state_type &U,
const Number &gamma_min)
const
1234 const auto b = Number(eos_covolume_constant());
1235 const auto pinf = Number(eos_interpolation_pinfty());
1236 const auto q = Number(eos_interpolation_q());
1238 const auto rho = density(U);
1239 const auto m = momentum(U);
1240 const auto E = total_energy(U);
1241 const auto rho_rho_e_q =
1242 rho * E -
ScalarNumber(0.5) * m.norm_square() - rho * rho * q;
1244 const auto exponent =
ScalarNumber(1.) / (gamma_min + Number(1.));
1246 const auto covolume = Number(1.) - b * rho;
1247 const auto covolume_term =
ryujin::pow(covolume, gamma_min - Number(1.));
1249 const auto rho_pinfcov = rho * pinf * covolume;
1252 positive_part(rho_rho_e_q - rho_pinfcov) * covolume_term, exponent);
1256 template <
int dim,
typename Number,
typename MemorySpace>
1257 DEAL_II_HOST_DEVICE_ALWAYS_INLINE
auto
1261 const Number &gamma_min)
const
1278 const auto b = Number(eos_covolume_constant());
1279 const auto pinf = Number(eos_interpolation_pinfty());
1280 const auto q = Number(eos_interpolation_q());
1282 const auto rho = density(U);
1283 const auto m = momentum(U);
1284 const auto E = total_energy(U);
1286 const auto covolume = Number(1.) - b * rho;
1287 const auto covolume_inverse =
ScalarNumber(1.) / covolume;
1289 const auto shift = rho * E -
ScalarNumber(0.5) * m.norm_square() -
1290 rho * rho * q - rho * pinf * covolume;
1292 constexpr auto eps = std::numeric_limits<ScalarNumber>::epsilon();
1293 const auto regularization = m.norm() * eps;
1295 std::max(regularization, eta * covolume_inverse), gamma_min);
1297 factor *= fixed_power<2>(covolume_inverse) / (gamma_min + Number(1.));
1301 const auto first_term = E -
ScalarNumber(2.) * rho * q -
1303 const auto second_term = -(gamma_min - Number(1.)) * shift * b;
1305 result[0] = factor * (covolume * first_term + second_term);
1306 for (
unsigned int i = 0; i < dim; ++i)
1307 result[1 + i] = -factor * covolume * m[i];
1308 result[dim + 1] = factor * covolume * rho;
1314 template <
int dim,
typename Number,
typename MemorySpace>
1315 DEAL_II_HOST_DEVICE_ALWAYS_INLINE Number
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;
1327 const auto numerator = (p + pinf) * covolume;
1328 const auto denominator = rho_e - rho * q - covolume * pinf;
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;
1352 template <
int dim,
typename Number,
typename MemorySpace>
1353 DEAL_II_HOST_DEVICE_ALWAYS_INLINE Number
1355 const state_type &U,
const Number &gamma)
const
1357 const auto b = Number(eos_covolume_constant());
1358 const auto pinf = Number(eos_interpolation_pinfty());
1359 const auto q = Number(eos_interpolation_q());
1361 const auto rho = density(U);
1362 const auto rho_e = internal_energy(U);
1363 const auto covolume = Number(1.) - b * rho;
1366 (rho_e - rho * q - pinf * covolume) / (covolume * covolume * rho);
1367 radicand *= gamma * (gamma - 1.);
1372 template <
int dim,
typename Number,
typename MemorySpace>
1373 DEAL_II_HOST_DEVICE_ALWAYS_INLINE
bool
1377 const auto b = Number(eos_covolume_constant());
1378 const auto pinf = Number(eos_interpolation_pinfty());
1379 const auto q = Number(eos_interpolation_q());
1381 const auto rho = density(U);
1382 const auto rho_e = internal_energy(U);
1383 const auto covolume = Number(1.) - b * rho;
1385 const auto shift = rho_e - rho * q - pinf * covolume;
1387 constexpr auto gt = dealii::SIMDComparison::greater_than;
1390 ryujin::compare_and_apply_mask<gt>(rho, T(0.), T(0.), T(-1.)) +
1391 ryujin::compare_and_apply_mask<gt>(shift, T(0.), T(0.), T(-1.));
1394 if (!(test == Number(0.))) {
1395 std::cout << std::fixed << std::setprecision(16);
1396 std::cout <<
"Bounds violation: Negative state [rho, e] detected!\n";
1397 std::cout <<
"\t\trho: " << rho <<
"\n";
1398 std::cout <<
"\t\tint (shifted): " << shift <<
"\n";
1402 return (test == Number(0.));
1406 template <
int dim,
typename Number,
typename MemorySpace>
1407 template <
int component>
1408 DEAL_II_HOST_DEVICE_ALWAYS_INLINE
auto
1414 const Number &p_bar,
1415 const dealii::Tensor<1, dim, Number> &normal)
const ->
state_type
1417 static_assert(component == 1 || component == 2,
1418 "component has to be 1 or 2");
1420 const auto b = Number(eos_covolume_constant());
1421 const auto pinf = Number(eos_interpolation_pinfty());
1422 const auto q = Number(eos_interpolation_q());
1434 const auto m = momentum(U);
1435 const auto rho = density(U);
1436 const auto vn = m * normal / rho;
1438 const auto gamma = surrogate_gamma(U, p);
1439 const auto a = surrogate_speed_of_sound(U, gamma);
1440 const auto covolume = 1. - b * rho;
1442 const auto m_bar = momentum(U_bar);
1443 const auto rho_bar = density(U_bar);
1444 const auto vn_bar = m_bar * normal / rho_bar;
1446 const auto gamma_bar = surrogate_gamma(U_bar, p_bar);
1447 const auto a_bar = surrogate_speed_of_sound(U_bar, gamma_bar);
1448 const auto covolume_bar = 1. - b * rho_bar;
1461 component == 1 ? vn_bar - 2. * a_bar / (gamma_bar - 1.) * covolume_bar
1462 : vn - 2. * a / (gamma - 1.) * covolume;
1465 component == 2 ? vn_bar + 2. * a_bar / (gamma_bar - 1.) * covolume_bar
1466 : vn + 2. * a / (gamma - 1.) * covolume;
1475 dealii::ExcMessage(
"Encountered R_2 < R_1 in dynamic boundary value "
1476 "enforcement. This implies that the interpolation "
1477 "with Riemann characteristics failed."));
1479 const auto vperp = m / rho - vn * normal;
1481 const auto S = (p + pinf) *
ryujin::pow(Number(1.) / rho - b, gamma);
1498 const auto vn_new = Number(0.5) * (R_1 + R_2);
1528 const auto a_new_square =
1529 ryujin::fixed_power<2>((gamma - 1.) * (R_2 - R_1) / (4. * covolume));
1531 auto term =
ryujin::pow(a_new_square / (gamma * S), 1. / (gamma - 1.));
1536 const auto rho_new = term / (1. + b * term);
1538 const auto covolume_new = (1. - b * rho_new);
1539 const auto p_new = a_new_square / gamma * rho_new * covolume_new - pinf;
1545 const auto rho_e_new =
1546 rho_new * q + (p_new + gamma * pinf) * covolume_new / (gamma - 1.);
1550 for (
unsigned int d = 0; d < dim; ++d) {
1551 U_new[1 + d] = rho_new * (vn_new * normal + vperp)[d];
1554 rho_e_new + 0.5 * rho_new * (vn_new * vn_new + vperp.norm_square());
1560 template <
int dim,
typename Number,
typename MemorySpace>
1561 template <
typename Lambda>
1562 DEAL_II_ALWAYS_INLINE
inline auto
1564 dealii::types::boundary_id
id,
1566 const dealii::Tensor<1, dim, Number> &normal,
1567 const Lambda &get_dirichlet_data)
const ->
state_type
1572 result = get_dirichlet_data();
1579 const auto m_dirichlet = momentum(get_dirichlet_data());
1580 const auto rho = density(result);
1581 const auto m = momentum(result);
1583 for (
unsigned int k = 0; k < dim; ++k)
1584 result[k + 1] = m_dirichlet[k];
1586 Number(0.5) / rho * (m_dirichlet.norm_square() - m.norm_square());
1593 const auto U_dirichlet = get_dirichlet_data();
1594 const auto rho_dirichlet = density(U_dirichlet);
1595 const auto v_dirichlet = momentum(U_dirichlet) / rho_dirichlet;
1596 const auto rho = density(result);
1597 const auto v = momentum(result) / rho;
1599 for (
unsigned int k = 0; k < dim; ++k)
1600 result[k + 1] = rho * v_dirichlet[k];
1602 Number(0.5) * rho * (v_dirichlet.norm_square() - v.norm_square());
1605 auto m = momentum(U);
1606 m -= 1. * (m * normal) * normal;
1607 for (
unsigned int k = 0; k < dim; ++k)
1608 result[k + 1] = m[k];
1611 for (
unsigned int k = 0; k < dim; ++k)
1612 result[k + 1] = Number(0.);
1627 const auto m = momentum(U);
1628 const auto rho = density(U);
1629 const auto rho_e = internal_energy(U);
1636 const auto p = eos_pressure(rho, rho_e / rho);
1637 const auto gamma = surrogate_gamma(U, p);
1638 const auto a = surrogate_speed_of_sound(U, gamma);
1639 const auto vn = m * normal / rho;
1643 result = get_dirichlet_data();
1647 if (vn >= -a && vn <= 0.) {
1648 const auto U_dirichlet = get_dirichlet_data();
1649 const auto rho_dirichlet = density(U_dirichlet);
1650 const auto rho_e_dirichlet = internal_energy(U_dirichlet);
1651 const auto p_dirichlet =
1652 eos_pressure(rho_dirichlet, rho_e_dirichlet / rho_dirichlet);
1654 result = prescribe_riemann_characteristic<2>(
1655 U_dirichlet, p_dirichlet, U, p, normal);
1659 if (vn > 0. && vn <= a) {
1660 const auto U_dirichlet = get_dirichlet_data();
1661 const auto rho_dirichlet = density(U_dirichlet);
1662 const auto rho_e_dirichlet = internal_energy(U_dirichlet);
1663 const auto p_dirichlet =
1664 eos_pressure(rho_dirichlet, rho_e_dirichlet / rho_dirichlet);
1666 result = prescribe_riemann_characteristic<1>(
1667 U, p, U_dirichlet, p_dirichlet, normal);
1672 AssertThrow(
false, dealii::ExcNotImplemented());
1679 template <
int dim,
typename Number,
typename MemorySpace>
1680 DEAL_II_HOST_DEVICE_ALWAYS_INLINE
auto
1682 const Number &p)
const
1685 const auto rho_inverse =
ScalarNumber(1.) / density(U);
1686 const auto m = momentum(U);
1687 const auto E = total_energy(U);
1692 for (
unsigned int i = 0; i < dim; ++i) {
1693 result[1 + i] = m * (m[i] * rho_inverse);
1694 result[1 + i][i] += p;
1696 result[dim + 1] = m * (rho_inverse * (E + p));
1702 template <
int dim,
typename Number,
typename MemorySpace>
1703 DEAL_II_HOST_DEVICE_ALWAYS_INLINE
auto
1707 const unsigned int i,
1710 const auto &[p_i, gamma_min_i, s_i, eta_i] =
1711 pv.template read_tensor<Number, precomputed_type>(i);
1716 template <
int dim,
typename Number,
typename MemorySpace>
1717 DEAL_II_HOST_DEVICE_ALWAYS_INLINE
auto
1721 const unsigned int *js,
1724 const auto &[p_j, gamma_min_j, s_j, eta_j] =
1725 pv.template read_tensor<Number, precomputed_type>(js);
1730 template <
int dim,
typename Number,
typename MemorySpace>
1731 DEAL_II_HOST_DEVICE_ALWAYS_INLINE
auto
1735 const dealii::Tensor<1, dim, Number> &c_ij)
const ->
state_type
1741 template <
int dim,
typename Number,
typename MemorySpace>
1742 template <
typename ST>
1743 DEAL_II_HOST_DEVICE_ALWAYS_INLINE
auto
1747 using T =
typename ST::value_type;
1748 static_assert(std::is_same_v<Number, T>,
"template mismatch");
1750 constexpr auto dim2 = ST::dimension - 2;
1751 static_assert(dim >= dim2,
1752 "the space dimension of the argument state must not be "
1753 "larger than the one of the target state");
1756 result[0] = state[0];
1757 result[dim + 1] = state[dim2 + 1];
1758 for (
unsigned int i = 1; i < dim2 + 1; ++i)
1759 result[i] = state[i];
1765 template <
int dim,
typename Number,
typename MemorySpace>
1766 template <
typename ST>
1767 DEAL_II_ALWAYS_INLINE
inline auto
1771 auto primitive_state = expand_state(initial_state);
1774 const auto rho = density(primitive_state);
1775 const auto p = total_energy(primitive_state);
1776 const auto e = eos_specific_internal_energy(rho, p);
1777 primitive_state[dim + 1] = e;
1779 return from_primitive_state(primitive_state);
1783 template <
int dim,
typename Number,
typename MemorySpace>
1784 DEAL_II_HOST_DEVICE_ALWAYS_INLINE
auto
1788 const auto rho = density(primitive_state);
1790 const auto u = momentum(primitive_state);
1792 const auto &e = total_energy(primitive_state);
1794 auto state = primitive_state;
1796 for (
unsigned int i = 1; i < dim + 1; ++i)
1800 state[dim + 1] = rho * e + Number(0.5) * rho * u * u;
1806 template <
int dim,
typename Number,
typename MemorySpace>
1807 DEAL_II_HOST_DEVICE_ALWAYS_INLINE
auto
1811 const auto rho = density(state);
1812 const auto rho_inverse = Number(1.) / rho;
1813 const auto rho_e = internal_energy(state);
1815 auto primitive_state = state;
1817 for (
unsigned int i = 1; i < dim + 1; ++i)
1818 primitive_state[i] *= rho_inverse;
1820 primitive_state[dim + 1] = rho_e * rho_inverse;
1822 return primitive_state;
1826 template <
int dim,
typename Number,
typename MemorySpace>
1827 template <
typename Lambda>
1828 DEAL_II_HOST_DEVICE_ALWAYS_INLINE
auto
1832 auto result = state;
1833 const auto M = lambda(momentum(state));
1834 for (
unsigned int d = 0; d < dim; ++d)
1835 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
const auto & n_locally_owned() const
const auto & sparsity_pattern_simd() const
const auto & n_locally_internal() const
void populate_equation_of_state_list(equation_of_state_list_type &equation_of_state_list, const std::string &subsection)
constexpr bool have_separate_memory_spaces
@ implicit_transfers_host_resident
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)
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)
std::set< std::shared_ptr< EquationOfState > > equation_of_state_list_type
double vacuum_state_relaxation_large
double interpolation_pinfty
bool compute_strict_bounds
double vacuum_state_relaxation_small
MultiComponentVector< Number > U
MultiComponentVector< Number > precomputed