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