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