ryujin 2.5.0 revision c64172211cf21344cb9b9b0f3a1266aa6400d392
Loading...
Searching...
No Matches
initial_state_shock_front.h
Go to the documentation of this file.
1//
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3// Copyright (C) 2022 - 2026 by the ryujin authors
4//
5
6#pragma once
7
8#include <ryujin/base/compile_time_options.h>
10
11namespace ryujin
12{
13 namespace EulerInitialStates
14 {
27 template <typename Description, int dim, typename Number>
28 class ShockFront : public InitialState<Description, dim, Number>
29 {
30 public:
31 using HyperbolicSystem = typename Description::HyperbolicSystem;
32 using View = typename HyperbolicSystem::template View<dim, Number>;
33 using state_type = typename View::state_type;
34
35 ShockFront(const HyperbolicSystem &hyperbolic_system,
36 const std::string subsection)
37 : InitialState<Description, dim, Number>("shock front", subsection)
38 , hyperbolic_system_(hyperbolic_system)
39 {
40 gamma_ = 1.4;
41 if constexpr (!View::have_gamma) {
42 this->add_parameter("gamma", gamma_, "The ratio of specific heats");
43 }
44
45 primitive_right_[0] = 1.4;
46 primitive_right_[1] = 0.0;
47 primitive_right_[2] = 1.;
48 this->add_parameter(
49 "primitive state",
50 primitive_right_,
51 "1d primitive state [rho, u, p] (for the Noble-Abel gas EOS) "
52 "before the shock (to the right)");
53
54 mach_number_ = 2.0;
55 this->add_parameter(
56 "mach number",
57 mach_number_,
58 "Mach number of shock front (S1, S3 = mach * a_L/R)");
59
60 const auto compute_and_convert_states = [&]() {
61 const auto view = hyperbolic_system_.template view<dim, Number>();
62
63 if constexpr (View::have_gamma) {
64 gamma_ = view.gamma();
65 }
66
67 /* Compute post-shock state and S3: */
68
69 auto b = Number(0.);
70 if constexpr (View::have_covolume_constant)
71 b = view.eos_covolume_constant();
72
73 const auto &rho_R = primitive_right_[0];
74 const auto &u_R = primitive_right_[1];
75 const auto &p_R = primitive_right_[2];
76 /* a_R^2 = gamma * p / rho / (1 - b * rho) */
77 const Number a_R = std::sqrt(gamma_ * p_R / rho_R / (1 - b * rho_R));
78 const Number mach_R = u_R / a_R;
79
80 S3_ = mach_number_ * a_R;
81 const Number delta_mach = mach_R - mach_number_;
82
83 const Number rho_L =
84 rho_R * (gamma_ + Number(1.)) * delta_mach * delta_mach /
85 ((gamma_ - Number(1.)) * delta_mach * delta_mach + Number(2.));
86 const Number u_L =
87 (Number(1.) - rho_R / rho_L) * S3_ + rho_R / rho_L * u_R;
88 const Number p_L = p_R *
89 (Number(2.) * gamma_ * delta_mach * delta_mach -
90 (gamma_ - Number(1.))) /
91 (gamma_ + Number(1.));
92
93 using state_type_1d =
94 typename HyperbolicSystem::template View<1, Number>::state_type;
95
96 if constexpr (View::have_energy_equation) {
97 state_left_ =
98 view.from_initial_state(state_type_1d{{rho_L, u_L, p_L}});
99 state_right_ =
100 view.from_initial_state(state_type_1d{{rho_R, u_R, p_R}});
101 } else {
102 state_left_ = view.from_initial_state(state_type_1d{{rho_L, u_L}});
103 state_right_ = view.from_initial_state(state_type_1d{{rho_R, u_R}});
104 }
105 };
106
107 this->parse_parameters_call_back.connect(compute_and_convert_states);
108 compute_and_convert_states();
109 }
110
111
112 state_type compute(const dealii::Point<dim> &point, Number t) final
113 {
114 const Number position_1d = Number(point[0] - S3_ * t);
115 return (position_1d > 0. ? state_right_ : state_left_);
116 }
117
118 private:
119 const HyperbolicSystem &hyperbolic_system_;
120
121 Number gamma_;
122
123 dealii::Tensor<1, 3, Number> primitive_left_;
124 dealii::Tensor<1, 3, Number> primitive_right_;
125 Number mach_number_;
126 Number S3_;
127
128 state_type state_left_;
129 state_type state_right_;
130 };
131 } // namespace EulerInitialStates
132} // namespace ryujin
typename Description::HyperbolicSystem HyperbolicSystem
state_type compute(const dealii::Point< dim > &point, Number t) final
ShockFront(const HyperbolicSystem &hyperbolic_system, const std::string subsection)
typename HyperbolicSystem::template View< dim, Number > View