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