ryujin 2.5.0 revision c64172211cf21344cb9b9b0f3a1266aa6400d392
Loading...
Searching...
No Matches
initial_state_ramp_up.h
Go to the documentation of this file.
1//
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3// Copyright (C) 2022 - 2026 by the ryujin authors
4//
5
6#pragma once
7
8#include <ryujin/base/compile_time_options.h>
10
11namespace ryujin
12{
13 namespace EulerInitialStates
14 {
23 template <typename Description, int dim, typename Number>
24 class RampUp : public InitialState<Description, dim, Number>
25 {
26 public:
27 using HyperbolicSystem = typename Description::HyperbolicSystem;
28 using View = typename HyperbolicSystem::template View<dim, Number>;
29 using state_type = typename View::state_type;
31 typename HyperbolicSystem::template View<1, Number>::state_type;
32
33 RampUp(const HyperbolicSystem &hyperbolic_system,
34 const std::string subsection)
35 : InitialState<Description, dim, Number>("ramp up", subsection)
36 , hyperbolic_system_(hyperbolic_system)
37 {
38 t_initial_ = 0.;
39 this->add_parameter("time initial",
40 t_initial_,
41 "Time until which initial state is prescribed");
42
43 t_final_ = 1.;
44 this->add_parameter("time final",
45 t_final_,
46 "Time from which on the final state is attained)");
47
48 primitive_initial_[0] = 1.4;
49 primitive_initial_[1] = 0.0;
50 if constexpr (View::have_energy_equation)
51 primitive_initial_[2] = 1.;
52 this->add_parameter("primitive state initial",
53 primitive_initial_,
54 "Initial 1d primitive state [rho, u, p] (or [rho, "
55 "u] for the barotropic Euler module)");
56
57 primitive_final_[0] = 1.4;
58 primitive_final_[1] = 3.0;
59 if constexpr (View::have_energy_equation)
60 primitive_final_[2] = 1.;
61 this->add_parameter("primitive state final",
62 primitive_final_,
63 "Final 1d primitive state [rho, u, p] (or [rho, u] "
64 "for the barotropic Euler module)");
65
66 const auto convert_states = [&]() {
67 const auto view = hyperbolic_system_.template view<dim, Number>();
68 state_initial_ = view.from_initial_state(primitive_initial_);
69 state_final_ = view.from_initial_state(primitive_final_);
70 };
71 this->parse_parameters_call_back.connect(convert_states);
72 convert_states();
73 }
74
75 auto compute(const dealii::Point<dim> & /*point*/, Number t)
76 -> state_type final
77 {
78 state_type result;
79
80 if (t <= t_initial_) {
81 result = state_initial_;
82 } else if (t >= t_final_) {
83 result = state_final_;
84 } else {
85 const Number factor =
86 std::cos(0.5 * M_PI * (t - t_initial_) / (t_final_ - t_initial_));
87
88 const Number alpha = factor * factor;
89 const Number beta = Number(1.) - alpha;
90 result = alpha * state_initial_ + beta * state_final_;
91 }
92
93 return result;
94 }
95
96 private:
97 const HyperbolicSystem &hyperbolic_system_;
98
99 Number t_initial_;
100 Number t_final_;
101
102 state_type_1d primitive_initial_;
103 state_type_1d primitive_final_;
104
105 state_type state_initial_;
106 state_type state_final_;
107 };
108 } // namespace EulerInitialStates
109} // namespace ryujin
typename HyperbolicSystem::template View< dim, Number > View
RampUp(const HyperbolicSystem &hyperbolic_system, const std::string subsection)
typename HyperbolicSystem::template View< 1, Number >::state_type state_type_1d
typename Description::HyperbolicSystem HyperbolicSystem
auto compute(const dealii::Point< dim > &, Number t) -> state_type final