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