ryujin 2.1.1 revision 0348cbb53a3e4b1da2a4c037e81f88f2d21ce219
hyperbolic_system.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
9
10#include <compile_time_options.h>
11#include <convenience_macros.h>
12#include <discretization.h>
14#include <openmp.h>
15#include <patterns_conversion.h>
16#include <simd.h>
17#include <state_vector.h>
18
19#include <deal.II/base/parameter_acceptor.h>
20#include <deal.II/base/tensor.h>
21
22#include <array>
23
24namespace ryujin
25{
26 namespace EulerAEOS
27 {
28 /*
29 * For various divisions in the arbirtray equation of state module we
30 * have a mathematical guarantee that the numerator and denominator are
31 * nonnegative and the limit (of zero numerator and denominator) must
32 * converge to zero. The following function takes care of rounding
33 * issues when computing such quotients by (a) avoiding division by
34 * zero and (b) ensuring non-negativity of the result.
35 */
36 template <typename Number>
37 DEAL_II_ALWAYS_INLINE inline Number safe_division(const Number &numerator,
38 const Number &denominator)
39 {
40 using ScalarNumber = typename get_value_type<Number>::type;
41 constexpr ScalarNumber min = std::numeric_limits<ScalarNumber>::min();
42
43 return std::max(numerator, Number(0.)) /
44 std::max(denominator, Number(min));
45 }
46
47
48 template <int dim, typename Number>
50
63 class HyperbolicSystem final : public dealii::ParameterAcceptor
64 {
65 public:
69 static inline std::string problem_name =
70 "Compressible Euler equations (arbitrary EOS)";
71
75 HyperbolicSystem(const std::string &subsection = "/HyperbolicSystem");
76
83 template <int dim, typename Number>
84 auto view() const
85 {
87 }
88
89 private:
94
95 std::string equation_of_state_;
96 double reference_density_;
97 double vacuum_state_relaxation_small_;
98 double vacuum_state_relaxation_large_;
99 bool compute_strict_bounds_;
100
102 equation_of_state_list_;
103
104 using EquationOfState = EquationOfStateLibrary::EquationOfState;
105 std::shared_ptr<EquationOfState> selected_equation_of_state_;
106
107 template <int dim, typename Number>
110 }; /* HyperbolicSystem */
111
112
129 template <int dim, typename Number>
131 {
132 public:
137 HyperbolicSystemView(const HyperbolicSystem &hyperbolic_system)
138 : hyperbolic_system_(hyperbolic_system)
139 {
140 }
141
145 template <int dim2, typename Number2>
146 auto view() const
147 {
148 return HyperbolicSystemView<dim2, Number2>{hyperbolic_system_};
149 }
150
155
160
161 DEAL_II_ALWAYS_INLINE inline const std::string &equation_of_state() const
162 {
163 return hyperbolic_system_.equation_of_state_;
164 }
165
166 DEAL_II_ALWAYS_INLINE inline ScalarNumber reference_density() const
167 {
168 return hyperbolic_system_.reference_density_;
169 }
170
171 DEAL_II_ALWAYS_INLINE inline ScalarNumber
173 {
174 return hyperbolic_system_.vacuum_state_relaxation_small_;
175 }
176
177 DEAL_II_ALWAYS_INLINE inline ScalarNumber
179 {
180 return hyperbolic_system_.vacuum_state_relaxation_large_;
181 }
182
183 DEAL_II_ALWAYS_INLINE inline bool compute_strict_bounds() const
184 {
185 return hyperbolic_system_.compute_strict_bounds_;
186 }
187
189
193
198 DEAL_II_ALWAYS_INLINE inline Number eos_pressure(const Number &rho,
199 const Number &e) const
200 {
201 const auto &eos = hyperbolic_system_.selected_equation_of_state_;
202
203 if constexpr (std::is_same_v<ScalarNumber, Number>) {
204 return ScalarNumber(eos->pressure(rho, e));
205 } else {
206 Number p;
207 for (unsigned int k = 0; k < Number::size(); ++k) {
208 p[k] = ScalarNumber(eos->pressure(rho[k], e[k]));
209 }
210 return p;
211 }
212 }
213
218 DEAL_II_ALWAYS_INLINE inline Number
219 eos_specific_internal_energy(const Number &rho, const Number &p) const
220 {
221 const auto &eos = hyperbolic_system_.selected_equation_of_state_;
222
223 if constexpr (std::is_same_v<ScalarNumber, Number>) {
224 return ScalarNumber(eos->specific_internal_energy(rho, p));
225 } else {
226 Number e;
227 for (unsigned int k = 0; k < Number::size(); ++k) {
228 e[k] = ScalarNumber(eos->specific_internal_energy(rho[k], p[k]));
229 }
230 return e;
231 }
232 }
233
238 DEAL_II_ALWAYS_INLINE inline Number eos_temperature(const Number &rho,
239 const Number &e) const
240 {
241 const auto &eos = hyperbolic_system_.selected_equation_of_state_;
242
243 if constexpr (std::is_same_v<ScalarNumber, Number>) {
244 return ScalarNumber(eos->temperature(rho, e));
245 } else {
246 Number temp;
247 for (unsigned int k = 0; k < Number::size(); ++k) {
248 temp[k] = ScalarNumber(eos->temperature(rho[k], e[k]));
249 }
250 return temp;
251 }
252 }
253
258 DEAL_II_ALWAYS_INLINE inline Number
259 eos_speed_of_sound(const Number &rho, const Number &e) const
260 {
261 const auto &eos = hyperbolic_system_.selected_equation_of_state_;
262
263 if constexpr (std::is_same_v<ScalarNumber, Number>) {
264 return ScalarNumber(eos->speed_of_sound(rho, e));
265 } else {
266 Number c;
267 for (unsigned int k = 0; k < Number::size(); ++k) {
268 c[k] = ScalarNumber(eos->speed_of_sound(rho[k], e[k]));
269 }
270 return c;
271 }
272 }
273
277 DEAL_II_ALWAYS_INLINE inline ScalarNumber eos_interpolation_b() const
278 {
279 const auto &eos = hyperbolic_system_.selected_equation_of_state_;
280 return ScalarNumber(eos->interpolation_b());
281 }
282
286 DEAL_II_ALWAYS_INLINE inline ScalarNumber eos_interpolation_pinfty() const
287 {
288 const auto &eos = hyperbolic_system_.selected_equation_of_state_;
289 return ScalarNumber(eos->interpolation_pinfty());
290 }
291
296 DEAL_II_ALWAYS_INLINE inline ScalarNumber eos_interpolation_q() const
297 {
298 const auto &eos = hyperbolic_system_.selected_equation_of_state_;
299 return ScalarNumber(eos->interpolation_q());
300 }
301
302
306 static constexpr bool have_gamma = false;
307
311 static constexpr bool have_eos_interpolation_b = true;
312
313
315
319
320 private:
321 const HyperbolicSystem &hyperbolic_system_;
322
323 public:
325
329
333 static constexpr unsigned int problem_dimension = 2 + dim;
334
338 using state_type = dealii::Tensor<1, problem_dimension, Number>;
339
343 using flux_type =
344 dealii::Tensor<1, problem_dimension, dealii::Tensor<1, dim, Number>>;
345
350
355 static inline const auto component_names =
356 []() -> std::array<std::string, problem_dimension> {
357 if constexpr (dim == 1)
358 return {"rho", "m", "E"};
359 else if constexpr (dim == 2)
360 return {"rho", "m_1", "m_2", "E"};
361 else if constexpr (dim == 3)
362 return {"rho", "m_1", "m_2", "m_3", "E"};
363 __builtin_trap();
364 }();
365
370 static inline const auto primitive_component_names =
371 []() -> std::array<std::string, problem_dimension> {
372 if constexpr (dim == 1)
373 return {"rho", "v", "e"};
374 else if constexpr (dim == 2)
375 return {"rho", "v_1", "v_2", "e"};
376 else if constexpr (dim == 3)
377 return {"rho", "v_1", "v_2", "v_3", "e"};
378 __builtin_trap();
379 }();
380
384 static constexpr unsigned int n_precomputed_values = 4;
385
389 using precomputed_type = std::array<Number, n_precomputed_values>;
390
394 static inline const auto precomputed_names =
395 std::array<std::string, n_precomputed_values>{
396 {"p",
397 "surrogate_gamma_min",
398 "surrogate_specific_entropy",
399 "surrogate_harten_entropy"}};
400
404 static constexpr unsigned int n_initial_precomputed_values = 0;
405
410 std::array<Number, n_initial_precomputed_values>;
411
415 static inline const auto initial_precomputed_names =
416 std::array<std::string, n_initial_precomputed_values>{};
417
421 using StateVector = Vectors::
422 StateVector<ScalarNumber, problem_dimension, n_precomputed_values>;
423
429
435
443
445
449
453 static constexpr unsigned int n_precomputation_cycles = 2;
454
459 template <typename DISPATCH, typename SPARSITY>
460 void precomputation_loop(unsigned int cycle,
461 const DISPATCH &dispatch_check,
462 const SPARSITY &sparsity_simd,
463 StateVector &state_vector,
464 unsigned int left,
465 unsigned int right) const;
466
468
472
477 static Number density(const state_type &U);
478
485 Number filter_vacuum_density(const Number &rho) const;
486
491 static dealii::Tensor<1, dim, Number> momentum(const state_type &U);
492
497 static Number total_energy(const state_type &U);
498
503 static Number internal_energy(const state_type &U);
504
511
513
519
530 const Number &gamma_min) const;
531
542 Number surrogate_harten_entropy(const state_type &U,
543 const Number &gamma_min) const;
544
557 const Number &eta,
558 const Number &gamma_min) const;
559
571 Number surrogate_gamma(const state_type &U, const Number &p) const;
572
588 Number surrogate_pressure(const state_type &U, const Number &gamma) const;
589
598 Number surrogate_speed_of_sound(const state_type &U,
599 const Number &gamma) const;
600
606 bool is_admissible(const state_type &U) const;
607
609
613
620 template <int component>
622 const state_type &U,
623 const Number &p,
624 const state_type &U_bar,
625 const Number &p_bar,
626 const dealii::Tensor<1, dim, Number> &normal) const;
627
646 template <typename Lambda>
648 apply_boundary_conditions(const dealii::types::boundary_id id,
649 const state_type &U,
650 const dealii::Tensor<1, dim, Number> &normal,
651 const Lambda &get_dirichlet_data) const;
652
654
658
669 flux_type f(const state_type &U, const Number &p) const;
670
692 const InitialPrecomputedVector &piv,
693 const unsigned int i,
694 const state_type &U_i) const;
695
698 const InitialPrecomputedVector &piv,
699 const unsigned int *js,
700 const state_type &U_j) const;
701
708 const flux_contribution_type &flux_j,
709 const dealii::Tensor<1, dim, Number> &c_ij) const;
710
714 static constexpr bool have_high_order_flux = false;
715
717 const flux_contribution_type &flux_i,
718 const flux_contribution_type &flux_j,
719 const dealii::Tensor<1, dim, Number> &c_ij) const = delete;
720
725
727 static constexpr bool have_source_terms = false;
728
730 const unsigned int i,
731 const state_type &U_i,
732 const ScalarNumber tau) const = delete;
733
735 const unsigned int *js,
736 const state_type &U_j,
737 const ScalarNumber tau) const = delete;
738
740
744
755 template <typename ST>
756 state_type expand_state(const ST &state) const;
757
770 template <typename ST>
771 state_type from_initial_state(const ST &initial_state) const;
772
777 state_type from_primitive_state(const state_type &primitive_state) const;
778
783 state_type to_primitive_state(const state_type &state) const;
784
790 template <typename Lambda>
792 const Lambda &lambda) const;
794 }; /* HyperbolicSystemView */
795
796
797 /*
798 * -------------------------------------------------------------------------
799 * Inline definitions
800 * -------------------------------------------------------------------------
801 */
802
803
805 const std::string &subsection /*= "HyperbolicSystem"*/)
806 : ParameterAcceptor(subsection)
807 {
808 equation_of_state_ = "polytropic gas";
809 add_parameter(
810 "equation of state",
811 equation_of_state_,
812 "The equation of state. Valid names are given by any of the "
813 "subsections defined below");
814
815 compute_strict_bounds_ = true;
816 add_parameter(
817 "compute strict bounds",
818 compute_strict_bounds_,
819 "Compute strict, but significantly more expensive bounds at various "
820 "places: (a) an expensive, but better upper wavespeed estimate in "
821 "the approximate RiemannSolver; (b) entropy viscosity-commutator "
822 "with correct gamma_min over the stencil; (c) mathematically correct "
823 "surrogate specific entropy minimum with gamma_min over the "
824 "stencil.");
825
826 reference_density_ = 1.;
827 add_parameter("reference density",
828 reference_density_,
829 "Problem specific density reference");
830
831 vacuum_state_relaxation_small_ = 1.e2;
832 add_parameter("vacuum state relaxation small",
833 vacuum_state_relaxation_small_,
834 "Problem specific vacuum relaxation parameter");
835
836 vacuum_state_relaxation_large_ = 1.e4;
837 add_parameter("vacuum state relaxation large",
838 vacuum_state_relaxation_large_,
839 "Problem specific vacuum relaxation parameter");
840
841 /*
842 * And finally populate the equation of state list with all equation of
843 * state configurations defined in the EquationOfState namespace:
844 */
846 equation_of_state_list_, subsection);
847
848 const auto populate_functions = [this]() {
849 bool initialized = false;
850 for (auto &it : equation_of_state_list_)
851
852 /* Populate EOS-specific quantities and functions */
853 if (it->name() == equation_of_state_) {
854 selected_equation_of_state_ = it;
856 "Compressible Euler equations (" + it->name() + " EOS)";
857 initialized = true;
858 break;
859 }
860
861 AssertThrow(
862 initialized,
863 dealii::ExcMessage(
864 "Could not find an equation of state description with name \"" +
865 equation_of_state_ + "\""));
866 };
867
868 ParameterAcceptor::parse_parameters_call_back.connect(populate_functions);
869 populate_functions();
870 }
871
872
873 template <int dim, typename Number>
874 template <typename DISPATCH, typename SPARSITY>
875 DEAL_II_ALWAYS_INLINE inline void
877 unsigned int cycle [[maybe_unused]],
878 const DISPATCH &dispatch_check,
879 const SPARSITY &sparsity_simd,
880 StateVector &state_vector,
881 unsigned int left,
882 unsigned int right) const
883 {
884 Assert(cycle == 0 || cycle == 1, dealii::ExcInternalError());
885
886 const auto &U = std::get<0>(state_vector);
887 auto &precomputed = std::get<1>(state_vector);
888
889 /* We are inside a thread parallel context */
890
891 const auto &eos = hyperbolic_system_.selected_equation_of_state_;
892 unsigned int stride_size = get_stride_size<Number>;
893
894 if (cycle == 0) {
895 if (eos->prefer_vector_interface()) {
896 /*
897 * Set up temporary storage for p, rho, e and make two calls into
898 * the eos library.
899 */
900 const auto offset = left;
901 const auto size = right - left;
902
903 static /* shared */ std::vector<double> p;
904 static /* shared */ std::vector<double> rho;
905 static /* shared */ std::vector<double> e;
907 {
908 p.resize(size);
909 rho.resize(size);
910 e.resize(size);
911 }
912
914 for (unsigned int i = 0; i < size; i += stride_size) {
915 const auto U_i = U.template get_tensor<Number>(offset + i);
916 const auto rho_i = density(U_i);
917 const auto e_i = internal_energy(U_i) / rho_i;
918 /*
919 * Populate rho and e also for interpolated values from
920 * constrainted degrees of freedom so that the vectors contain
921 * physically admissible entries throughout.
922 */
923 write_entry<Number>(rho, rho_i, i);
924 write_entry<Number>(e, e_i, i);
925 }
926
927 /* Make sure the call into eospac (and others) is single threaded. */
929 {
930 eos->pressure(p, rho, e);
931 }
932
934 for (unsigned int i = 0; i < size; i += stride_size) {
935 /* Skip constrained degrees of freedom: */
936 const unsigned int row_length = sparsity_simd.row_length(i);
937 if (row_length == 1)
938 continue;
939
940 dispatch_check(i);
941
942 using PT = precomputed_type;
943 const auto U_i = U.template get_tensor<Number>(offset + i);
944 const auto p_i = get_entry<Number>(p, i);
945 const auto gamma_i = surrogate_gamma(U_i, p_i);
946 const PT prec_i{p_i, gamma_i, Number(0.), Number(0.)};
947 precomputed.template write_tensor<Number>(prec_i, offset + i);
948 }
949 } else {
950 /*
951 * This is the variant with slightly better performance provided
952 * that a call to the eos is not too expensive. This variant
953 * calls into the eos library for every single degree of freedom.
954 */
956 for (unsigned int i = left; i < right; i += stride_size) {
957 /* Skip constrained degrees of freedom: */
958 const unsigned int row_length = sparsity_simd.row_length(i);
959 if (row_length == 1)
960 continue;
961
962 dispatch_check(i);
963
964 const auto U_i = U.template get_tensor<Number>(i);
965 const auto rho_i = density(U_i);
966 const auto e_i = internal_energy(U_i) / rho_i;
967 const auto p_i = eos_pressure(rho_i, e_i);
968
969 const auto gamma_i = surrogate_gamma(U_i, p_i);
970 using PT = precomputed_type;
971 const PT prec_i{p_i, gamma_i, Number(0.), Number(0.)};
972 precomputed.template write_tensor<Number>(prec_i, i);
973 }
974 } /* prefer_vector_interface */
975 } /* cycle == 0 */
976
977 if (cycle == 1) {
979 for (unsigned int i = left; i < right; i += stride_size) {
980 using PT = precomputed_type;
981
982 /* Skip constrained degrees of freedom: */
983 const unsigned int row_length = sparsity_simd.row_length(i);
984 if (row_length == 1)
985 continue;
986
987 dispatch_check(i);
988
989 const auto U_i = U.template get_tensor<Number>(i);
990 auto prec_i = precomputed.template get_tensor<Number, PT>(i);
991 auto &[p_i, gamma_min_i, s_i, eta_i] = prec_i;
992
993 const unsigned int *js = sparsity_simd.columns(i) + stride_size;
994 for (unsigned int col_idx = 1; col_idx < row_length;
995 ++col_idx, js += stride_size) {
996
997 const auto U_j = U.template get_tensor<Number>(js);
998 const auto prec_j = precomputed.template get_tensor<Number, PT>(js);
999 auto &[p_j, gamma_min_j, s_j, eta_j] = prec_j;
1000 const auto gamma_j = surrogate_gamma(U_j, p_j);
1001 gamma_min_i = std::min(gamma_min_i, gamma_j);
1002 }
1003
1004 s_i = surrogate_specific_entropy(U_i, gamma_min_i);
1005 eta_i = surrogate_harten_entropy(U_i, gamma_min_i);
1006 precomputed.template write_tensor<Number>(prec_i, i);
1007 }
1008 }
1009 }
1010
1011
1012 template <int dim, typename Number>
1013 DEAL_II_ALWAYS_INLINE inline Number
1015 {
1016 return U[0];
1017 }
1018
1019
1020 template <int dim, typename Number>
1021 DEAL_II_ALWAYS_INLINE inline Number
1023 const Number &rho) const
1024 {
1025 constexpr ScalarNumber eps = std::numeric_limits<ScalarNumber>::epsilon();
1026 const Number rho_cutoff_large =
1027 reference_density() * vacuum_state_relaxation_large() * eps;
1028
1029 return dealii::compare_and_apply_mask<dealii::SIMDComparison::less_than>(
1030 std::abs(rho), rho_cutoff_large, Number(0.), rho);
1031 }
1032
1033
1034 template <int dim, typename Number>
1035 DEAL_II_ALWAYS_INLINE inline dealii::Tensor<1, dim, Number>
1037 {
1038 dealii::Tensor<1, dim, Number> result;
1039 for (unsigned int i = 0; i < dim; ++i)
1040 result[i] = U[1 + i];
1041 return result;
1042 }
1043
1044
1045 template <int dim, typename Number>
1046 DEAL_II_ALWAYS_INLINE inline Number
1048 {
1049 return U[1 + dim];
1050 }
1051
1052
1053 template <int dim, typename Number>
1054 DEAL_II_ALWAYS_INLINE inline Number
1056 {
1057 /*
1058 * rho e = (E - 1/2*m^2/rho)
1059 */
1060 const Number rho_inverse = ScalarNumber(1.) / density(U);
1061 const auto m = momentum(U);
1062 const Number E = total_energy(U);
1063 return E - ScalarNumber(0.5) * m.norm_square() * rho_inverse;
1064 }
1065
1066
1067 template <int dim, typename Number>
1068 DEAL_II_ALWAYS_INLINE inline auto
1070 const state_type &U) -> state_type
1071 {
1072 /*
1073 * With
1074 * rho e = E - 1/2 |m|^2 / rho
1075 * we get
1076 * (rho e)' = (1/2m^2/rho^2, -m/rho , 1 )^T
1077 */
1078
1079 const Number rho_inverse = ScalarNumber(1.) / density(U);
1080 const auto u = momentum(U) * rho_inverse;
1081
1082 state_type result;
1083
1084 result[0] = ScalarNumber(0.5) * u.norm_square();
1085 for (unsigned int i = 0; i < dim; ++i) {
1086 result[1 + i] = -u[i];
1087 }
1088 result[dim + 1] = ScalarNumber(1.);
1089
1090 return result;
1091 }
1092
1093
1094 template <int dim, typename Number>
1095 DEAL_II_ALWAYS_INLINE inline Number
1097 const state_type &U, const Number &gamma_min) const
1098 {
1099 const auto b = Number(eos_interpolation_b());
1100 const auto pinf = Number(eos_interpolation_pinfty());
1101 const auto q = Number(eos_interpolation_q());
1102
1103 const auto rho = density(U);
1104 const auto rho_inverse = ScalarNumber(1.) / rho;
1105
1106 const auto covolume = Number(1.) - b * rho;
1107
1108 const auto shift = internal_energy(U) - rho * q - pinf * covolume;
1109
1110 return shift * ryujin::pow(rho_inverse - b, gamma_min) / covolume;
1111 }
1112
1113
1114 template <int dim, typename Number>
1115 DEAL_II_ALWAYS_INLINE inline Number
1117 const state_type &U, const Number &gamma_min) const
1118 {
1119 const auto b = Number(eos_interpolation_b());
1120 const auto pinf = Number(eos_interpolation_pinfty());
1121 const auto q = Number(eos_interpolation_q());
1122
1123 const auto rho = density(U);
1124 const auto m = momentum(U);
1125 const auto E = total_energy(U);
1126 const auto rho_rho_e_q =
1127 rho * E - ScalarNumber(0.5) * m.norm_square() - rho * rho * q;
1128
1129 const auto exponent = ScalarNumber(1.) / (gamma_min + Number(1.));
1130
1131 const auto covolume = Number(1.) - b * rho;
1132 const auto covolume_term = ryujin::pow(covolume, gamma_min - Number(1.));
1133
1134 const auto rho_pinfcov = rho * pinf * covolume;
1135
1136 return ryujin::pow(
1137 positive_part(rho_rho_e_q - rho_pinfcov) * covolume_term, exponent);
1138 }
1139
1140
1141 template <int dim, typename Number>
1142 DEAL_II_ALWAYS_INLINE inline auto
1144 const state_type &U, const Number &eta, const Number &gamma_min) const
1145 -> state_type
1146 {
1147 /*
1148 * With
1149 * eta = (shift * (1-b*rho)^{gamma-1}) ^ {1/(gamma+1)},
1150 * shift = rho * E - 1/2 |m|^2 - rho^2 * q - p_infty * rho * (1 - b rho)
1151 *
1152 * shift' = [E - 2 * rho * q - p_infty * (1 - 2 b rho), -m, rho]^T
1153 * factor = 1/(gamma+1) * (eta/(1-b rho))^-gamma / (1-b rho)^2
1154 *
1155 * we get
1156 *
1157 * eta' = factor * (1-b*rho) * shift' -
1158 * factor * shift * (gamma - 1) * b * [1, 0, 0]^T
1159 *
1160 */
1161 const auto b = Number(eos_interpolation_b());
1162 const auto pinf = Number(eos_interpolation_pinfty());
1163 const auto q = Number(eos_interpolation_q());
1164
1165 const auto rho = density(U);
1166 const auto m = momentum(U);
1167 const auto E = total_energy(U);
1168
1169 const auto covolume = Number(1.) - b * rho;
1170 const auto covolume_inverse = ScalarNumber(1.) / covolume;
1171
1172 const auto shift = rho * E - ScalarNumber(0.5) * m.norm_square() -
1173 rho * rho * q - rho * pinf * covolume;
1174
1175 constexpr auto eps = std::numeric_limits<ScalarNumber>::epsilon();
1176 const auto regularization = m.norm() * eps;
1177
1178 auto factor = ryujin::pow(
1179 std::max(regularization, eta * covolume_inverse), -gamma_min);
1180 factor *= fixed_power<2>(covolume_inverse) / (gamma_min + Number(1.));
1181
1182 state_type result;
1183
1184 const auto first_term = E - ScalarNumber(2.) * rho * q -
1185 pinf * (Number(1.) - ScalarNumber(2.) * b * rho);
1186 const auto second_term = -(gamma_min - Number(1.)) * shift * b;
1187
1188 result[0] = factor * (covolume * first_term + second_term);
1189 for (unsigned int i = 0; i < dim; ++i)
1190 result[1 + i] = -factor * covolume * m[i];
1191 result[dim + 1] = factor * covolume * rho;
1192
1193 return result;
1194 }
1195
1196
1197 template <int dim, typename Number>
1198 DEAL_II_ALWAYS_INLINE inline Number
1200 const Number &p) const
1201 {
1202 const auto b = Number(eos_interpolation_b());
1203 const auto pinf = Number(eos_interpolation_pinfty());
1204 const auto q = Number(eos_interpolation_q());
1205
1206 const auto rho = density(U);
1207 const auto rho_e = internal_energy(U);
1208 const auto covolume = Number(1.) - b * rho;
1209
1210 const auto numerator = (p + pinf) * covolume;
1211 const auto denominator = rho_e - rho * q - covolume * pinf;
1212 return Number(1.) + safe_division(numerator, denominator);
1213 }
1214
1215
1216 template <int dim, typename Number>
1217 DEAL_II_ALWAYS_INLINE inline Number
1219 const state_type &U, const Number &gamma) const
1220 {
1221 const auto b = Number(eos_interpolation_b());
1222 const auto pinf = Number(eos_interpolation_pinfty());
1223 const auto q = Number(eos_interpolation_q());
1224
1225 const auto rho = density(U);
1226 const auto rho_e = internal_energy(U);
1227 const auto covolume = Number(1.) - b * rho;
1228
1229 return positive_part(gamma - Number(1.)) *
1230 safe_division(rho_e - rho * q, covolume) -
1231 gamma * pinf;
1232 }
1233
1234
1235 template <int dim, typename Number>
1236 DEAL_II_ALWAYS_INLINE inline Number
1238 const state_type &U, const Number &gamma) const
1239 {
1240 const auto b = Number(eos_interpolation_b());
1241 const auto pinf = Number(eos_interpolation_pinfty());
1242 const auto q = Number(eos_interpolation_q());
1243
1244 const auto rho = density(U);
1245 const auto rho_e = internal_energy(U);
1246 const auto covolume = Number(1.) - b * rho;
1247
1248 auto radicand =
1249 (rho_e - rho * q - pinf * covolume) / (covolume * covolume * rho);
1250 radicand *= gamma * (gamma - 1.);
1251 return std::sqrt(positive_part(radicand));
1252 }
1253
1254
1255 template <int dim, typename Number>
1256 DEAL_II_ALWAYS_INLINE inline bool
1258 {
1259 const auto b = Number(eos_interpolation_b());
1260 const auto pinf = Number(eos_interpolation_pinfty());
1261 const auto q = Number(eos_interpolation_q());
1262
1263 const auto rho = density(U);
1264 const auto rho_e = internal_energy(U);
1265 const auto covolume = Number(1.) - b * rho;
1266
1267 const auto shift = rho_e - rho * q - pinf * covolume;
1268
1269 constexpr auto gt = dealii::SIMDComparison::greater_than;
1270 using T = Number;
1271 const auto test =
1272 dealii::compare_and_apply_mask<gt>(rho, T(0.), T(0.), T(-1.)) + //
1273 dealii::compare_and_apply_mask<gt>(shift, T(0.), T(0.), T(-1.));
1274
1275#ifdef DEBUG_OUTPUT
1276 if (!(test == Number(0.))) {
1277 std::cout << std::fixed << std::setprecision(16);
1278 std::cout << "Bounds violation: Negative state [rho, e] detected!\n";
1279 std::cout << "\t\trho: " << rho << "\n";
1280 std::cout << "\t\tint (shifted): " << shift << "\n";
1281 }
1282#endif
1283
1284 return (test == Number(0.));
1285 }
1286
1287
1288 template <int dim, typename Number>
1289 template <int component>
1290 DEAL_II_ALWAYS_INLINE inline auto
1292 const state_type &U,
1293 const Number &p,
1294 const state_type &U_bar,
1295 const Number &p_bar,
1296 const dealii::Tensor<1, dim, Number> &normal) const -> state_type
1297 {
1298 static_assert(component == 1 || component == 2,
1299 "component has to be 1 or 2");
1300
1301 const auto b = Number(eos_interpolation_b());
1302 const auto pinf = Number(eos_interpolation_pinfty());
1303 const auto q = Number(eos_interpolation_q());
1304
1305 /*
1306 * The "four" Riemann characteristics are formed under the assumption
1307 * of a locally isentropic flow. For this, we first transform both
1308 * states into {rho, vn, vperp, gamma, a}, where we use the NASG EOS
1309 * interpolation to derive a surrogate gamma and speed of sound a.
1310 *
1311 * See, e.g., https://arxiv.org/pdf/2004.08750, "Compressible flow in
1312 * a NOble-Abel Stiffened-Gas fluid", M. I. Radulescu.
1313 */
1314
1315 const auto m = momentum(U);
1316 const auto rho = density(U);
1317 const auto vn = m * normal / rho;
1318
1319 const auto gamma = surrogate_gamma(U, p);
1320 const auto a = surrogate_speed_of_sound(U, gamma);
1321 const auto covolume = 1. - b * rho;
1322
1323 const auto m_bar = momentum(U_bar);
1324 const auto rho_bar = density(U_bar);
1325 const auto vn_bar = m_bar * normal / rho_bar;
1326
1327 const auto gamma_bar = surrogate_gamma(U_bar, p_bar);
1328 const auto a_bar = surrogate_speed_of_sound(U_bar, gamma_bar);
1329 const auto covolume_bar = 1. - b * rho_bar;
1330
1331 /*
1332 * Now compute the Riemann characteristics {R_1, R_2, vperp, s}:
1333 * R_1 = v * n - 2 / (gamma - 1) * a * (1 - b * rho)
1334 * R_2 = v * n + 2 / (gamma - 1) * a * (1 - b * rho)
1335 * vperp
1336 * S = (p + p_infty) / rho^gamma * (1 - b * rho)^gamma
1337 *
1338 * Here, we replace either R_1, or R_2 with values coming from U_bar:
1339 */
1340
1341 const auto R_1 =
1342 component == 1 ? vn_bar - 2. * a_bar / (gamma_bar - 1.) * covolume_bar
1343 : vn - 2. * a / (gamma - 1.) * covolume;
1344
1345 const auto R_2 =
1346 component == 2 ? vn_bar + 2. * a_bar / (gamma_bar - 1.) * covolume_bar
1347 : vn + 2. * a / (gamma - 1.) * covolume;
1348
1349 /*
1350 * Note that we are really hoping for the best here... We require
1351 * that R_2 >= R_1 so that we can extract a valid sound speed...
1352 */
1353
1354 Assert(
1355 R_2 >= R_1,
1356 dealii::ExcMessage("Encountered R_2 < R_1 in dynamic boundary value "
1357 "enforcement. This implies that the interpolation "
1358 "with Riemann characteristics failed."));
1359
1360 const auto vperp = m / rho - vn * normal;
1361
1362 const auto S = (p + pinf) * ryujin::pow(Number(1.) / rho - b, gamma);
1363
1364 /*
1365 * Now, we have to reconstruct the actual conserved state U from the
1366 * Riemann characteristics R_1, R_2, vperp, and s. We first set up
1367 * {vn_new, vperp_new, a_new, S} and then solve for {rho_new, p_new}
1368 * with the help of the NASG EOS surrogate formulas:
1369 *
1370 * S = (p + p_infty) / rho^gamma * (1 - b * rho)^gamma
1371 *
1372 * a^2 = gamma * (p + p_infty) / (rho * cov)
1373 *
1374 * This implies:
1375 *
1376 * a^2 / (gamma * S) = rho^{gamma - 1} / (1 - b * rho)^{1 + gamma}
1377 */
1378
1379 const auto vn_new = Number(0.5) * (R_1 + R_2);
1380
1381 /*
1382 * Technically, we would need to solve for rho subject to a number of
1383 * nonlinear relationships:
1384 *
1385 * a = (gamma - 1) * (R_2 - R_1) / (4. * (1 - b * rho))
1386 *
1387 * a^2 / (gamma * S) = rho^{gamma - 1} / (1 - b * rho)^{gamma + 1}
1388 *
1389 * This seems to be a bit expensive for the fact that our dynamic
1390 * boundary conditions are already terribly heuristic...
1391 *
1392 * So instead, we rewrite this system as:
1393 *
1394 * a * (1 - b * rho) = (gamma - 1) * (R_2 - R_1) / 4.
1395 *
1396 * a^2 / (gamma * S) (1 - b * rho)^2
1397 * = (rho / (1 - b * rho))^{gamma - 1}
1398 *
1399 * And compute the terms on the left simply with the old covolume and
1400 * solving an easier easier nonlinear equation for the density. The
1401 * resulting system reads:
1402 *
1403 * a = (gamma - 1) * (R_2 - R_1) / (4. * (1 - b * rho_old))
1404 * A = {a^2 / (gamma * S) (1 - b * rho_old)^{2 gamma}}^{1/(gamma - 1)}
1405 *
1406 * rho = A / (1 + b * A)
1407 */
1408
1409 const auto a_new_square =
1410 ryujin::fixed_power<2>((gamma - 1.) * (R_2 - R_1) / (4. * covolume));
1411
1412 auto term = ryujin::pow(a_new_square / (gamma * S), 1. / (gamma - 1.));
1413 if (b != ScalarNumber(0.)) {
1414 term *= std::pow(covolume, 2. / (gamma - 1.));
1415 }
1416
1417 const auto rho_new = term / (1. + b * term);
1418
1419 const auto covolume_new = (1. - b * rho_new);
1420 const auto p_new = a_new_square / gamma * rho_new * covolume_new - pinf;
1421
1422 /*
1423 * And translate back into conserved quantities:
1424 */
1425
1426 const auto rho_e_new =
1427 rho_new * q + (p_new + gamma * pinf) * covolume_new / (gamma - 1.);
1428
1429 state_type U_new;
1430 U_new[0] = rho_new;
1431 for (unsigned int d = 0; d < dim; ++d) {
1432 U_new[1 + d] = rho_new * (vn_new * normal + vperp)[d];
1433 }
1434 U_new[1 + dim] =
1435 rho_e_new + 0.5 * rho_new * (vn_new * vn_new + vperp.norm_square());
1436
1437 return U_new;
1438 }
1439
1440
1441 template <int dim, typename Number>
1442 template <typename Lambda>
1443 DEAL_II_ALWAYS_INLINE inline auto
1445 dealii::types::boundary_id id,
1446 const state_type &U,
1447 const dealii::Tensor<1, dim, Number> &normal,
1448 const Lambda &get_dirichlet_data) const -> state_type
1449 {
1450 state_type result = U;
1451
1452 if (id == Boundary::dirichlet) {
1453 result = get_dirichlet_data();
1454
1455 } else if (id == Boundary::dirichlet_momentum) {
1456 /* Only enforce Dirichlet conditions on the momentum: */
1457 auto m_dirichlet = momentum(get_dirichlet_data());
1458 for (unsigned int k = 0; k < dim; ++k)
1459 result[k + 1] = m_dirichlet[k];
1460
1461 } else if (id == Boundary::slip) {
1462 auto m = momentum(U);
1463 m -= 1. * (m * normal) * normal;
1464 for (unsigned int k = 0; k < dim; ++k)
1465 result[k + 1] = m[k];
1466
1467 } else if (id == Boundary::no_slip) {
1468 for (unsigned int k = 0; k < dim; ++k)
1469 result[k + 1] = Number(0.);
1470
1471 } else if (id == Boundary::dynamic) {
1472 /*
1473 * On dynamic boundary conditions, we distinguish four cases:
1474 *
1475 * - supersonic inflow: prescribe full state
1476 * - subsonic inflow:
1477 * decompose into Riemann invariants and leave R_2
1478 * characteristic untouched.
1479 * - supersonic outflow: do nothing
1480 * - subsonic outflow:
1481 * decompose into Riemann invariants and prescribe incoming
1482 * R_1 characteristic.
1483 */
1484 const auto m = momentum(U);
1485 const auto rho = density(U);
1486 const auto rho_e = internal_energy(U);
1487
1488 /*
1489 * We do not have precomputed values available. Thus, simply query
1490 * the pressure oracle and compute a surrogate speed of sound from
1491 * there:
1492 */
1493 const auto p = eos_pressure(rho, rho_e / rho);
1494 const auto gamma = surrogate_gamma(U, p);
1495 const auto a = surrogate_speed_of_sound(U, gamma);
1496 const auto vn = m * normal / rho;
1497
1498 /* Supersonic inflow: */
1499 if (vn < -a) {
1500 result = get_dirichlet_data();
1501 }
1502
1503 /* Subsonic inflow: */
1504 if (vn >= -a && vn <= 0.) {
1505 const auto U_dirichlet = get_dirichlet_data();
1506 const auto rho_dirichlet = density(U_dirichlet);
1507 const auto rho_e_dirichlet = internal_energy(U_dirichlet);
1508 const auto p_dirichlet =
1509 eos_pressure(rho_dirichlet, rho_e_dirichlet / rho_dirichlet);
1510
1511 result = prescribe_riemann_characteristic<2>(
1512 U_dirichlet, p_dirichlet, U, p, normal);
1513 }
1514
1515 /* Subsonic outflow: */
1516 if (vn > 0. && vn <= a) {
1517 const auto U_dirichlet = get_dirichlet_data();
1518 const auto rho_dirichlet = density(U_dirichlet);
1519 const auto rho_e_dirichlet = internal_energy(U_dirichlet);
1520 const auto p_dirichlet =
1521 eos_pressure(rho_dirichlet, rho_e_dirichlet / rho_dirichlet);
1522
1523 result = prescribe_riemann_characteristic<1>(
1524 U, p, U_dirichlet, p_dirichlet, normal);
1525 }
1526 /* Supersonic outflow: do nothing, i.e., keep U as is */
1527
1528 } else {
1529 AssertThrow(false, dealii::ExcNotImplemented());
1530 }
1531
1532 return result;
1533 }
1534
1535
1536 template <int dim, typename Number>
1537 DEAL_II_ALWAYS_INLINE inline auto
1539 const Number &p) const -> flux_type
1540 {
1541 const auto rho_inverse = ScalarNumber(1.) / density(U);
1542 const auto m = momentum(U);
1543 const auto E = total_energy(U);
1544
1545 flux_type result;
1546
1547 result[0] = m;
1548 for (unsigned int i = 0; i < dim; ++i) {
1549 result[1 + i] = m * (m[i] * rho_inverse);
1550 result[1 + i][i] += p;
1551 }
1552 result[dim + 1] = m * (rho_inverse * (E + p));
1553
1554 return result;
1555 }
1556
1557
1558 template <int dim, typename Number>
1559 DEAL_II_ALWAYS_INLINE inline auto
1561 const PrecomputedVector &pv,
1562 const InitialPrecomputedVector & /*piv*/,
1563 const unsigned int i,
1564 const state_type &U_i) const -> flux_contribution_type
1565 {
1566 const auto &[p_i, gamma_min_i, s_i, eta_i] =
1567 pv.template get_tensor<Number, precomputed_type>(i);
1568 return f(U_i, p_i);
1569 }
1570
1571
1572 template <int dim, typename Number>
1573 DEAL_II_ALWAYS_INLINE inline auto
1575 const PrecomputedVector &pv,
1576 const InitialPrecomputedVector & /*piv*/,
1577 const unsigned int *js,
1578 const state_type &U_j) const -> flux_contribution_type
1579 {
1580 const auto &[p_j, gamma_min_j, s_j, eta_j] =
1581 pv.template get_tensor<Number, precomputed_type>(js);
1582 return f(U_j, p_j);
1583 }
1584
1585
1586 template <int dim, typename Number>
1587 DEAL_II_ALWAYS_INLINE inline auto
1589 const flux_contribution_type &flux_i,
1590 const flux_contribution_type &flux_j,
1591 const dealii::Tensor<1, dim, Number> &c_ij) const -> state_type
1592 {
1593 return -contract(add(flux_i, flux_j), c_ij);
1594 }
1595
1596
1597 template <int dim, typename Number>
1598 template <typename ST>
1600 -> state_type
1601 {
1602 using T = typename ST::value_type;
1603 static_assert(std::is_same_v<Number, T>, "template mismatch");
1604
1605 constexpr auto dim2 = ST::dimension - 2;
1606 static_assert(dim >= dim2,
1607 "the space dimension of the argument state must not be "
1608 "larger than the one of the target state");
1609
1610 state_type result;
1611 result[0] = state[0];
1612 result[dim + 1] = state[dim2 + 1];
1613 for (unsigned int i = 1; i < dim2 + 1; ++i)
1614 result[i] = state[i];
1615
1616 return result;
1617 }
1618
1619
1620 template <int dim, typename Number>
1621 template <typename ST>
1622 DEAL_II_ALWAYS_INLINE inline auto
1624 const ST &initial_state) const -> state_type
1625 {
1626 auto primitive_state = expand_state(initial_state);
1627
1628 /* pressure into specific internal energy: */
1629 const auto rho = density(primitive_state);
1630 const auto p = /*SIC!*/ total_energy(primitive_state);
1631 const auto e = eos_specific_internal_energy(rho, p);
1632 primitive_state[dim + 1] = e;
1633
1634 return from_primitive_state(primitive_state);
1635 }
1636
1637
1638 template <int dim, typename Number>
1639 DEAL_II_ALWAYS_INLINE inline auto
1641 const state_type &primitive_state) const -> state_type
1642 {
1643 const auto rho = density(primitive_state);
1644 /* extract velocity: */
1645 const auto u = /*SIC!*/ momentum(primitive_state);
1646 /* extract specific internal energy: */
1647 const auto &e = /*SIC!*/ total_energy(primitive_state);
1648
1649 auto state = primitive_state;
1650 /* Fix up momentum: */
1651 for (unsigned int i = 1; i < dim + 1; ++i)
1652 state[i] *= rho;
1653
1654 /* Compute total energy: */
1655 state[dim + 1] = rho * e + Number(0.5) * rho * u * u;
1656
1657 return state;
1658 }
1659
1660
1661 template <int dim, typename Number>
1662 DEAL_II_ALWAYS_INLINE inline auto
1664 const state_type &state) const -> state_type
1665 {
1666 const auto rho = density(state);
1667 const auto rho_inverse = Number(1.) / rho;
1668 const auto rho_e = internal_energy(state);
1669
1670 auto primitive_state = state;
1671 /* Fix up velocity: */
1672 for (unsigned int i = 1; i < dim + 1; ++i)
1673 primitive_state[i] *= rho_inverse;
1674 /* Set specific internal energy: */
1675 primitive_state[dim + 1] = rho_e * rho_inverse;
1676
1677 return primitive_state;
1678 }
1679
1680
1681 template <int dim, typename Number>
1682 template <typename Lambda>
1684 const state_type &state, const Lambda &lambda) const -> state_type
1685 {
1686 auto result = state;
1687 const auto M = lambda(momentum(state));
1688 for (unsigned int d = 0; d < dim; ++d)
1689 result[1 + d] = M[d];
1690 return result;
1691 }
1692 } // namespace EulerAEOS
1693} // namespace ryujin
dealii::Tensor< 1, problem_dimension, Number > state_type
Vectors::StateVector< ScalarNumber, problem_dimension, n_precomputed_values > StateVector
state_type from_initial_state(const ST &initial_state) const
std::array< Number, n_initial_precomputed_values > initial_precomputed_type
Number surrogate_harten_entropy(const state_type &U, const Number &gamma_min) const
flux_contribution_type flux_contribution(const PrecomputedVector &pv, const InitialPrecomputedVector &piv, const unsigned int i, const state_type &U_i) const
static Number internal_energy(const state_type &U)
state_type to_primitive_state(const state_type &state) const
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
typename get_value_type< Number >::type ScalarNumber
static dealii::Tensor< 1, dim, Number > momentum(const state_type &U)
Number surrogate_pressure(const state_type &U, const Number &gamma) const
Number surrogate_speed_of_sound(const state_type &U, const Number &gamma) const
DEAL_II_ALWAYS_INLINE const std::string & equation_of_state() const
DEAL_II_ALWAYS_INLINE ScalarNumber vacuum_state_relaxation_large() const
static constexpr unsigned int n_precomputed_values
DEAL_II_ALWAYS_INLINE ScalarNumber reference_density() const
state_type from_primitive_state(const state_type &primitive_state) const
void precomputation_loop(unsigned int cycle, const DISPATCH &dispatch_check, const SPARSITY &sparsity_simd, StateVector &state_vector, unsigned int left, unsigned int right) const
static state_type internal_energy_derivative(const state_type &U)
DEAL_II_ALWAYS_INLINE Number eos_temperature(const Number &rho, const Number &e) const
DEAL_II_ALWAYS_INLINE ScalarNumber eos_interpolation_b() const
DEAL_II_ALWAYS_INLINE Number eos_pressure(const Number &rho, const Number &e) const
static constexpr unsigned int problem_dimension
state_type nodal_source(const PrecomputedVector &pv, const unsigned int *js, const state_type &U_j, const ScalarNumber tau) const =delete
Number surrogate_specific_entropy(const state_type &U, const Number &gamma_min) const
DEAL_II_ALWAYS_INLINE ScalarNumber eos_interpolation_pinfty() const
static Number total_energy(const state_type &U)
bool is_admissible(const state_type &U) const
DEAL_II_ALWAYS_INLINE bool compute_strict_bounds() const
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_ALWAYS_INLINE Number eos_specific_internal_energy(const Number &rho, const Number &p) const
static constexpr unsigned int n_precomputation_cycles
HyperbolicSystemView(const HyperbolicSystem &hyperbolic_system)
DEAL_II_ALWAYS_INLINE ScalarNumber eos_interpolation_q() const
Number filter_vacuum_density(const Number &rho) const
flux_type f(const state_type &U, const Number &p) const
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
state_type expand_state(const ST &state) const
std::array< Number, n_precomputed_values > precomputed_type
state_type surrogate_harten_entropy_derivative(const state_type &U, const Number &eta, const Number &gamma_min) const
DEAL_II_ALWAYS_INLINE ScalarNumber vacuum_state_relaxation_small() const
Number surrogate_gamma(const state_type &U, const Number &p) const
static constexpr unsigned int n_initial_precomputed_values
DEAL_II_ALWAYS_INLINE Number eos_speed_of_sound(const Number &rho, const Number &e) const
dealii::Tensor< 1, problem_dimension, dealii::Tensor< 1, dim, Number > > flux_type
static Number density(const state_type &U)
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
state_type nodal_source(const PrecomputedVector &pv, const unsigned int i, const state_type &U_i, const ScalarNumber tau) const =delete
state_type apply_galilei_transform(const state_type &state, const Lambda &lambda) const
HyperbolicSystem(const std::string &subsection="/HyperbolicSystem")
typename get_value_type< Number >::type ScalarNumber
dealii::Tensor< 1, problem_dimension, Number > state_type
std::array< Number, n_precomputed_values > precomputed_type
Vectors::StateVector< ScalarNumber, problem_dimension, n_precomputed_values > StateVector
void populate_equation_of_state_list(equation_of_state_list_type &equation_of_state_list, const std::string &subsection)
@ dirichlet_momentum
#define RYUJIN_OMP_FOR
Definition: openmp.h:70
#define RYUJIN_OMP_SINGLE
Definition: openmp.h:100
T pow(const T x, const T b)
DEAL_II_ALWAYS_INLINE Number positive_part(const Number number)
Definition: simd.h:112
std::set< std::shared_ptr< EquationOfState > > equation_of_state_list_type
DEAL_II_ALWAYS_INLINE Number safe_division(const Number &numerator, const Number &denominator)
DEAL_II_ALWAYS_INLINE FT add(const FT &flux_left_ij, const FT &flux_right_ij)
DEAL_II_ALWAYS_INLINE dealii::Tensor< 1, problem_dim, T > contract(const FT &flux_ij, const TT &c_ij)