ryujin 2.1.1 revision 9dcb748690310d6a540ebb8b066d1a0834fc7604
initial_state_paraboloid.h
Go to the documentation of this file.
1//
2// SPDX-License-Identifier: MIT
3// Copyright (C) 2020 - 2023 by the ryujin authors
4//
5
6#pragma once
7
8#include "hyperbolic_system.h"
9#include <initial_state.h>
10
11namespace ryujin
12{
13 namespace ShallowWater
14 {
23 template <int dim, typename Number, typename state_type>
24 class Paraboloid : public InitialState<dim, Number, state_type, 1>
25 {
26 public:
27 Paraboloid(const HyperbolicSystem &hyperbolic_system,
28 const std::string subsection)
29 : InitialState<dim, Number, state_type, 1>("paraboloid", subsection)
30 , hyperbolic_system(hyperbolic_system)
31 {
32 a_ = 1.;
33 this->add_parameter(
34 "free surface radius", a_, "Radius of the circular free surface");
35
36 h_0_ = 0.1;
37 this->add_parameter(
38 "water height", h_0_, "Water height at central point");
39
40 eta_ = 0.5;
41 this->add_parameter("eta", eta_, "The eta parameter");
42 }
43
44 state_type compute(const dealii::Point<dim> &point, Number t) final
45 {
46 /* Initialize primitive variables */
47 Number h = 0.; // water depth
48 Number v_x = 0.; // velocity in x-direction
49 Number v_y = 0.; // velocity in y-direction (if in 2D)
50
51 /* Common quantities */
52 const auto z = compute_bathymetry(point);
53 const auto g = hyperbolic_system.gravity();
54 const Number omega = std::sqrt(2. * g * h_0_) / a_;
55
56 /* Define profiles for each dimension */
57 switch (dim) {
58 case 1:
59 /* Fake 1D configuration */
60 {
61 const Number &x = point[0];
62
63 h = eta_ * h_0_ / (a_ * a_) * (2. * x * std::cos(omega * t)) - z;
64 h = std::max(h, Number(0.));
65
66 v_x = -eta_ * omega * std::sin(omega * t);
67 }
68 break;
69
70 case 2:
71 /* 2D configuration as described in reference above */
72 {
73 const Number &x = point[0];
74 const Number &y = point[1];
75
76 h = eta_ * h_0_ / (a_ * a_) *
77 (2. * x * std::cos(omega * t) +
78 2 * y * std::sin(omega * t)) -
79 z;
80 h = std::max(h, Number(0.));
81
82 v_x = -eta_ * omega * std::sin(omega * t);
83 v_y = eta_ * omega * std::cos(omega * t);
84 }
85 break;
86 }
87
88 /* Set final state */
89 if constexpr (dim == 1)
90 return hyperbolic_system.template expand_state<dim>(
92 else if constexpr (dim == 2)
93 return hyperbolic_system.template expand_state<dim>(
94 HyperbolicSystem::state_type<2, Number>{{h, h * v_x, h * v_y}});
95 else {
96 AssertThrow(false, dealii::ExcNotImplemented());
97 __builtin_trap();
98 }
99 }
100
101 auto initial_precomputations(const dealii::Point<dim> &point) ->
103 final
104 {
105 /* Compute bathymetry: */
106 return {compute_bathymetry(point)};
107 }
108
109 private:
110 const HyperbolicSystem &hyperbolic_system;
111
112 DEAL_II_ALWAYS_INLINE inline Number
113 compute_bathymetry(const dealii::Point<dim> &point) const
114 {
115 return -h_0_ * (Number(1.) - point.norm_square() / (a_ * a_));
116 }
117
118 Number a_;
119 Number h_0_;
120 Number eta_;
121 };
122
123 } // namespace ShallowWater
124} // namespace ryujin
typename HyperbolicSystemView::state_type state_type
dealii::Tensor< 1, problem_dimension< dim >, Number > state_type
auto initial_precomputations(const dealii::Point< dim > &point) -> typename InitialState< dim, Number, state_type, 1 >::precomputed_type final
state_type compute(const dealii::Point< dim > &point, Number t) final
Paraboloid(const HyperbolicSystem &hyperbolic_system, const std::string subsection)