12 namespace EulerInitialStates
44 template <
typename Description,
int dim,
typename Number>
54 const std::string &subsection)
57 , hyperbolic_system_(hyperbolic_system)
60 if constexpr (!View::have_gamma) {
61 this->add_parameter(
"gamma", gamma_,
"The ratio of specific heats");
65 this->add_parameter(
"velocity galilean frame",
67 "Velocity used to apply a Galilean transformation "
68 "to the otherwise stationary solution");
72 "velocity left", velocity_left_,
"Left limit velocity");
74 velocity_right_ = 7. / 27.;
76 "velocity right", velocity_right_,
"Right limit velocity");
80 "density left", density_left_,
"Left limit density");
83 this->add_parameter(
"mu", mu_,
"Shear viscosity");
87 dealii::ParameterAcceptor::parse_parameters_call_back.connect([
this]() {
88 const auto view = hyperbolic_system_.template view<dim, Number>();
90 if constexpr (View::have_gamma) {
91 gamma_ = view.gamma();
95 velocity_left_ > velocity_right_,
96 dealii::ExcMessage(
"The left limiting velocity must be greater "
97 "than the right limiting velocity"));
99 AssertThrow(velocity_left_ > 0.,
101 "The left limiting velocity must be positive"));
107 const double velocity_origin =
108 std::sqrt(velocity_left_ * velocity_right_);
112 const double Pr = 0.75;
113 const double factor = 2. * gamma_ / (gamma_ + 1.)
114 * mu_ / (density_left_ * velocity_left_ * Pr);
116 psi = [=,
this](
double x,
double v) {
118 velocity_left_ / (velocity_left_ - velocity_right_);
120 velocity_right_ / (velocity_left_ - velocity_right_);
121 const double log_l = std::log(velocity_left_ - v) -
122 std::log(velocity_left_ - velocity_origin);
123 const double log_r = std::log(v - velocity_right_) -
124 std::log(velocity_origin - velocity_right_);
126 const double value = factor * (c_l * log_l - c_r * log_r) - x;
128 const double derivative = factor * (-c_l / (velocity_left_ - v) -
129 c_r / (v - velocity_right_));
131 return std::make_tuple(value, derivative);
136 constexpr double tol = 1.e-12;
138 const double x_left = std::get<0>(
139 psi(0., (1. - tol) * velocity_left_ + tol * velocity_right_));
141 const double x_right = std::get<0>(
142 psi(0., tol * velocity_left_ + (1. - tol) * velocity_right_));
144 const double norm = (x_right - x_left) * tol;
148 find_velocity = [=,
this](
double x) {
151 return double(velocity_left_);
153 return double(velocity_right_);
157 0.5 * std::tanh(10. * (x - 0.5 * (x_right + x_left)) /
160 velocity_left_ * (0.5 - nu) + velocity_right_ * (nu + 0.5);
162 auto [f, df] = psi(x, v);
164 while (std::abs(f) > norm) {
165 const double v_next = v - f / df;
168 if (std::abs(v_next - v) <
169 tol * 0.5 * (velocity_right_ + velocity_left_)) {
174 if (v_next < velocity_right_)
175 v = 0.5 * (velocity_right_ + v);
176 else if (v_next > velocity_left_)
177 v = 0.5 * (velocity_left_ + v);
181 const auto [new_f, new_df] = psi(x, v);
193 const auto view = hyperbolic_system_.template view<dim, Number>();
196 const double R_infty = (gamma_ + 1) / (gamma_ - 1);
199 const double x = point[0] - velocity_ * t;
200 const double v = find_velocity(x);
201 Assert(v >= velocity_right_, dealii::ExcInternalError());
202 Assert(v <= velocity_left_, dealii::ExcInternalError());
203 const double rho = density_left_ * velocity_left_ / v;
204 Assert(rho > 0., dealii::ExcInternalError());
205 const double e = 1. / (2. * gamma_) *
206 (R_infty * velocity_left_ * velocity_right_ - v * v);
207 Assert(e > 0., dealii::ExcInternalError());
209 using state_type_1d =
typename Description::
211 const auto state_1d = state_type_1d{
213 Number(rho * (velocity_ + v)),
214 Number(rho * (e + 0.5 * (velocity_ + v) * (velocity_ + v)))}};
216 return view.expand_state(state_1d);
224 Number velocity_left_;
225 Number velocity_right_;
226 Number density_left_;
228 std::function<std::tuple<double, double>(
double,
double)> psi;
229 std::function<double(
double)> find_velocity;
typename Description::template HyperbolicSystemView< dim, Number > View
state_type compute(const dealii::Point< dim > &point, Number t) final
typename View::state_type state_type
BeckerSolution(const HyperbolicSystem &hyperbolic_system, const std::string &subsection)
typename Description::HyperbolicSystem HyperbolicSystem
dealii::Tensor< 1, problem_dimension, Number > state_type
Euler::HyperbolicSystem HyperbolicSystem