ryujin 2.5.0 revision c64172211cf21344cb9b9b0f3a1266aa6400d392
Loading...
Searching...
No Matches
initial_state_contrast.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 {
25 template <typename Description, int dim, typename Number>
26 class Contrast : public InitialState<Description, dim, Number>
27 {
28 public:
29 using HyperbolicSystem = typename Description::HyperbolicSystem;
30 using View = typename HyperbolicSystem::template View<dim, Number>;
31 using state_type = typename View::state_type;
33 typename HyperbolicSystem::template View<1, Number>::state_type;
34
35 Contrast(const HyperbolicSystem &hyperbolic_system,
36 const std::string subsection)
37 : InitialState<Description, dim, Number>("contrast", subsection)
38 , hyperbolic_system_(hyperbolic_system)
39 {
40 primitive_left_[0] = 1.4;
41 primitive_left_[1] = 0.;
42 if constexpr (View::have_energy_equation)
43 primitive_left_[2] = 1.;
44 this->add_parameter("primitive state left",
45 primitive_left_,
46 "1d primitive state [rho, u, p] on the left (or "
47 "[rho, u] for the barotropic Euler module)");
48
49 primitive_right_[0] = 1.4;
50 primitive_right_[1] = 0.;
51 if constexpr (View::have_energy_equation)
52 primitive_right_[2] = 1.;
53 this->add_parameter("primitive state right",
54 primitive_right_,
55 "1d primitive state [rho, u, p] on the right (or "
56 "[rho, u] for the barotropic Euler module)");
57
58 const auto convert_states = [&]() {
59 const auto view = hyperbolic_system_.template view<dim, Number>();
60 state_left_ = view.from_initial_state(primitive_left_);
61 state_right_ = view.from_initial_state(primitive_right_);
62 };
63 this->parse_parameters_call_back.connect(convert_states);
64 convert_states();
65 }
66
67 state_type compute(const dealii::Point<dim> &point, Number /*t*/) final
68 {
69 return (point[0] > 0. ? state_right_ : state_left_);
70 }
71
72 private:
73 const HyperbolicSystem &hyperbolic_system_;
74
75 state_type_1d primitive_left_;
76 state_type_1d primitive_right_;
77
78 state_type state_left_;
79 state_type state_right_;
80 };
81 } // namespace EulerInitialStates
82} // namespace ryujin
typename HyperbolicSystem::template View< 1, Number >::state_type state_type_1d
state_type compute(const dealii::Point< dim > &point, Number) final
Contrast(const HyperbolicSystem &hyperbolic_system, const std::string subsection)
typename HyperbolicSystem::template View< dim, Number > View
typename Description::HyperbolicSystem HyperbolicSystem