ryujin 2.1.1 revision 3913ebe5e1d74c8fef21bcd286906a244031ce08
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 - 2024 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 =
32 typename Description::template HyperbolicSystemView<dim, Number>;
33 using state_type = typename View::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 primitive_left_[2] = 1.;
43 this->add_parameter(
44 "primitive state left",
45 primitive_left_,
46 "Initial 1d primitive state (rho, u, p) on the left");
47
48 primitive_right_[0] = 1.4;
49 primitive_right_[1] = 0.;
50 primitive_right_[2] = 1.;
51 this->add_parameter(
52 "primitive state right",
53 primitive_right_,
54 "Initial 1d primitive state (rho, u, p) on the right");
55
56 const auto convert_states = [&]() {
57 const auto view = hyperbolic_system_.template view<dim, Number>();
58 state_left_ = view.from_initial_state(primitive_left_);
59 state_right_ = view.from_initial_state(primitive_right_);
60 };
61 this->parse_parameters_call_back.connect(convert_states);
62 convert_states();
63 }
64
65 state_type compute(const dealii::Point<dim> &point, Number /*t*/) final
66 {
67 return (point[0] > 0. ? state_right_ : state_left_);
68 }
69
70 private:
71 const HyperbolicSystem &hyperbolic_system_;
72
73 dealii::Tensor<1, 3, Number> primitive_left_;
74 dealii::Tensor<1, 3, Number> primitive_right_;
75
76 state_type state_left_;
77 state_type state_right_;
78 };
79 } // namespace EulerInitialStates
80} // namespace ryujin
state_type compute(const dealii::Point< dim > &point, Number) final
Contrast(const HyperbolicSystem &hyperbolic_system, const std::string subsection)
typename Description::template HyperbolicSystemView< dim, Number > View
typename Description::HyperbolicSystem HyperbolicSystem
Euler::HyperbolicSystem HyperbolicSystem
Definition: description.h:34