ryujin 2.1.1 revision ee5cbcbf2346c1299c942d0e1f13b46449973c18
Loading...
Searching...
No Matches
initial_state_noh.h
Go to the documentation of this file.
1//
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3// Copyright (C) 2023 - 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 {
27 template <typename Description, int dim, typename Number>
28 class Noh : public InitialState<Description, dim, Number>
29 {
30 public:
32 using View = typename HyperbolicSystem::template View<dim, Number>;
33 using state_type = typename View::state_type;
34
35 Noh(const HyperbolicSystem &hyperbolic_system,
36 const std::string &subsection)
37 : InitialState<Description, dim, Number>("noh", subsection)
38 , hyperbolic_system_(hyperbolic_system)
39 {
40 gamma_ = 1.4;
41 if constexpr (!View::have_gamma) {
42 this->add_parameter("gamma", gamma_, "The ratio of specific heats");
43 }
44
45 rho0_ = 1.0;
46 this->add_parameter(
47 "reference density", rho0_, "The reference density");
48
49 /*
50 * Exact solution assumes this value is negative, but we are just
51 * switching u0 to -u0 by hand in the formulas.
52 */
53 u0_ = 1.0;
54 this->add_parameter("reference velocity magnitude",
55 u0_,
56 "The reference velocity magnitude");
57
58
59 p0_ = 1.e-12;
60 this->add_parameter(
61 "reference pressure", p0_, "The reference pressure");
62
63 this->parse_parameters_call_back.connect([&]() {
64 if constexpr (View::have_gamma) {
65 const auto view = hyperbolic_system_.template view<dim, Number>();
66 gamma_ = view.gamma();
67 }
68 });
69 }
70
71 /* Compute solution */
72 auto compute(const dealii::Point<dim> &point, Number t)
73 -> state_type final
74 {
75 const auto view = hyperbolic_system_.template view<dim, Number>();
76
77 const auto norm = point.norm();
78 const auto min = 10. * std::numeric_limits<Number>::min();
79
80 /* Initialize primitive variables */
81 Number rho = rho0_;
82 auto vel = -u0_ * point / (norm + min);
83 Number p = p0_;
84
85 /* Define exact solutions */
86 const auto D = u0_ * (gamma_ - 1.) / 2.;
87 const bool in_interior = t == Number(0.) ? false : norm / t < D;
88
89 if (in_interior) {
90 rho = rho0_ * std::pow((gamma_ + 1.) / (gamma_ - 1.), dim);
91 vel = 0. * point;
92 p = 0.5 * rho0_ * u0_ * u0_;
93 p *= std::pow(gamma_ + 1., dim) / std::pow(gamma_ - 1., dim - 1);
94 } else {
95 rho = rho0_ * std::pow(1. + t / (norm + min), dim - 1);
96 }
97
98 /* Assemble final state: */
99 state_type result;
100 result[0] = rho;
101 result[1] = Number(vel[0]);
102 if constexpr (dim >= 2)
103 result[2] = Number(vel[1]);
104 if constexpr (dim >= 3)
105 result[3] = Number(vel[2]);
106 if constexpr (View::have_energy_equation)
107 result[dim + 1] = p;
108
109 return view.from_initial_state(result);
110 }
111
112 private:
113 const HyperbolicSystem &hyperbolic_system_;
114 Number gamma_;
115 Number rho0_;
116 Number u0_;
117 Number p0_;
118 };
119 } // namespace EulerInitialStates
120} // namespace ryujin
Noh(const HyperbolicSystem &hyperbolic_system, const std::string &subsection)
typename HyperbolicSystem::template View< dim, Number > View
typename View::state_type state_type
auto compute(const dealii::Point< dim > &point, Number t) -> state_type final
typename Description::HyperbolicSystem HyperbolicSystem
Euler::HyperbolicSystem HyperbolicSystem
Definition description.h:34