ryujin 2.1.1 revision ee5cbcbf2346c1299c942d0e1f13b46449973c18
Loading...
Searching...
No Matches
initial_state_smooth_wave.h
Go to the documentation of this file.
1//
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3// Copyright (C) 2023 - 2025 by the ryujin authors
4//
5
6#pragma once
7
8#include <compile_time_options.h>
9
11#include <simd.h>
12
13namespace ryujin
14{
15 namespace EulerInitialStates
16 {
28 template <typename Description, int dim, typename Number>
29 class SmoothWave : public InitialState<Description, dim, Number>
30 {
31 public:
33 using View = typename HyperbolicSystem::template View<dim, Number>;
34 using state_type = typename View::state_type;
36 typename HyperbolicSystem::template View<1, Number>::state_type;
37
38 using ScalarNumber = typename View::ScalarNumber;
39
40 SmoothWave(const HyperbolicSystem &hyperbolic_system,
41 const std::string subsection)
42 : InitialState<Description, dim, Number>("smooth wave", subsection)
43 , hyperbolic_system_(hyperbolic_system)
44 {
45 density_ref_ = 1.;
46 this->add_parameter("reference density",
47 density_ref_,
48 "The material reference density");
49
50 pressure_ref_ = 1.;
51 this->add_parameter("reference pressure",
52 pressure_ref_,
53 "The material reference pressure");
54
55 mach_number_ = 1.0;
56 this->add_parameter("mach number",
57 mach_number_,
58 "Mach number of traveling smooth wave");
59
60 /* These are the x_0 and x_1 parameters from references above. */
61 left_ = 0.1;
62 right_ = 0.3;
63 }
64
65 state_type compute(const dealii::Point<dim> &point, Number t) final
66 {
67 const auto view = hyperbolic_system_.template view<dim, Number>();
68
69 auto point_bar = point;
70 point_bar[0] = point_bar[0] - mach_number_ * t;
71 const auto x = Number(point_bar[0]);
72
73 const Number polynomial = Number(64) *
74 ryujin::fixed_power<3>(x - left_) *
75 ryujin::fixed_power<3>(right_ - x) /
76 ryujin::fixed_power<6>(right_ - left_);
77
78 /* Define density profile */
79 Number rho = density_ref_;
80 if (left_ <= point_bar[0] && point_bar[0] <= right_)
81 rho = density_ref_ + polynomial;
82
83 state_type_1d initial_state;
84 initial_state[0] = rho;
85 initial_state[1] = mach_number_;
86 if constexpr (View::have_energy_equation)
87 initial_state[2] = pressure_ref_;
88 return view.from_initial_state(initial_state);
89 }
90
91 private:
92 const HyperbolicSystem &hyperbolic_system_;
93
94 Number density_ref_;
95 Number pressure_ref_;
96 Number mach_number_;
97 Number left_;
98 Number right_;
99 };
100 } // namespace EulerInitialStates
101} // namespace ryujin
typename HyperbolicSystem::template View< 1, Number >::state_type state_type_1d
SmoothWave(const HyperbolicSystem &hyperbolic_system, const std::string subsection)
typename Description::HyperbolicSystem HyperbolicSystem
state_type compute(const dealii::Point< dim > &point, Number t) final
typename HyperbolicSystem::template View< dim, Number > View
Euler::HyperbolicSystem HyperbolicSystem
Definition description.h:34