ryujin 2.5.0 revision c64172211cf21344cb9b9b0f3a1266aa6400d392
Loading...
Searching...
No Matches
initial_state_leblanc.h
Go to the documentation of this file.
1//
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3// Copyright (C) 2023 - 2026 by the ryujin authors
4//
5
6#pragma once
7
8#include <ryujin/base/compile_time_options.h>
10
11#include <cmath>
12
13namespace ryujin
14{
15 namespace EulerInitialStates
16 {
29 template <typename Description, int dim, typename Number>
30 class LeBlanc : public InitialState<Description, dim, Number>
31 {
32 public:
33 using HyperbolicSystem = typename Description::HyperbolicSystem;
34 using View = typename HyperbolicSystem::template View<dim, Number>;
35 using state_type = typename View::state_type;
36
37 using ScalarNumber = typename View::ScalarNumber;
38
39 LeBlanc(const HyperbolicSystem &hyperbolic_system,
40 const std::string subsection)
41 : InitialState<Description, dim, Number>("leblanc", subsection)
42 , hyperbolic_system_(hyperbolic_system)
43 {
44 } /* Constructor */
45
46 state_type compute(const dealii::Point<dim> &point, Number t) final
47 {
48 /*
49 * The Le Blanc shock tube:
50 */
51
52 /* Initial left and right states (rho, u, p): */
53 using state_type_1d = std::array<Number, 3>;
54 constexpr state_type_1d primitive_left{1., 0., Number(2. / 3. * 1.e-1)};
55 constexpr state_type_1d primitive_right{
56 1.e-3, 0., Number(2. / 3. * 1.e-10)};
57
58 /* The intermediate wave-speeds appearing on the Riemann fan: */
59 constexpr Number rarefaction_speed = 0.49578489518897934;
60 constexpr Number contact_velocity = 0.62183867139173454;
61 constexpr Number right_shock_speed = 0.82911836253346982;
62
63 /*
64 * Velocity and pressure are constant across the middle discontinuity,
65 * only the density jumps: it's a contact wave!
66 */
67 constexpr Number pre_contact_density = 5.4079335349316249e-02;
68 constexpr Number post_contact_density = 3.9999980604299963e-03;
69 constexpr Number contact_pressure = 0.51557792765096996e-03;
70
71 state_type_1d primitive_state;
72 const double &x = point[0];
73
74 if (x <= -1.0 / 3.0 * t) {
75 /* Left state: */
76 primitive_state = primitive_left;
77
78 } else if (x < rarefaction_speed * t) {
79 /* Expansion data (with self-similar variable chi): */
80 const double chi = x / t;
81 primitive_state[0] = std::pow(0.75 - 0.75 * chi, 3.0);
82 primitive_state[1] = 0.75 * (1.0 / 3.0 + chi);
83 primitive_state[2] = (1.0 / 15.0) * std::pow(0.75 - 0.75 * chi, 5.0);
84
85 } else if (x < contact_velocity * t) {
86 primitive_state[0] = pre_contact_density;
87 primitive_state[1] = contact_velocity;
88 primitive_state[2] = contact_pressure;
89
90 } else if (x < right_shock_speed * t) {
91 /* Contact-wave data (velocity and pressure are continuous): */
92 primitive_state[0] = post_contact_density;
93 primitive_state[1] = contact_velocity;
94 primitive_state[2] = contact_pressure;
95
96 } else {
97 /* Right state: */
98 primitive_state = primitive_right;
99 }
100
101 state_type conserved_state;
102 {
103 const auto &[rho, u, p] = primitive_state;
104 conserved_state[0] = rho;
105 conserved_state[1] = rho * u;
106 if constexpr (View::have_energy_equation)
107 conserved_state[dim + 1] = p / ScalarNumber(5. / 3. - 1.) +
108 ScalarNumber(0.5) * rho * u * u;
109 }
110
111 return conserved_state;
112 }
113
114 private:
115 const HyperbolicSystem &hyperbolic_system_;
116 };
117 } // namespace EulerInitialStates
118} // namespace ryujin
LeBlanc(const HyperbolicSystem &hyperbolic_system, const std::string subsection)
typename View::ScalarNumber ScalarNumber
typename Description::HyperbolicSystem HyperbolicSystem
state_type compute(const dealii::Point< dim > &point, Number t) final
typename HyperbolicSystem::template View< dim, Number > View