ryujin 2.1.1 revision 3913ebe5e1d74c8fef21bcd286906a244031ce08
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 - 2024 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 =
34 typename Description::template HyperbolicSystemView<dim, Number>;
35 using state_type = typename View::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 initial_state;
83 {
84 initial_state[0] = rho;
85 initial_state[1] = mach_number_;
86 initial_state[dim + 1] = pressure_ref_;
87 }
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
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 Description::template HyperbolicSystemView< dim, Number > View
Euler::HyperbolicSystem HyperbolicSystem
Definition: description.h:34