ryujin 2.1.1 revision 0348cbb53a3e4b1da2a4c037e81f88f2d21ce219
initial_state_geotiff.h
Go to the documentation of this file.
1//
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3// Copyright (C) 2024 - 2024 by the ryujin authors
4//
5
6#pragma once
7
8#include <geotiff_reader.h>
10#include <lazy.h>
11
12#include <deal.II/base/function_parser.h>
13
14namespace ryujin
15{
16 namespace ShallowWaterInitialStates
17 {
25 template <typename Description, int dim, typename Number>
26 class GeoTIFF : public InitialState<Description, dim, Number>
27 {
28 public:
30 using View =
31 typename Description::template HyperbolicSystemView<dim, Number>;
32 using state_type = typename View::state_type;
33
34
35 GeoTIFF(const HyperbolicSystem &hyperbolic_system,
36 const std::string subsection)
37 : InitialState<Description, dim, Number>("geotiff", subsection)
38 , hyperbolic_system_(hyperbolic_system)
39 , geotiff_reader_(subsection + "/geotiff")
40 {
41 height_expression_ = "1.4";
42 this->add_parameter(
43 "water height expression",
44 height_expression_,
45 "A function expression describing the initial total water height");
46
47 velocity_expression_ = "0.0";
48 this->add_parameter(
49 "velocity expression",
50 velocity_expression_,
51 "A function expression describing the initial velocity");
52
53 const auto set_up = [this] {
54 using FP = dealii::FunctionParser<dim>;
55 /*
56 * This variant of the constructor initializes the function
57 * parser with support for a time-dependent description involving
58 * a variable »t«:
59 */
60 height_function_ = std::make_unique<FP>(height_expression_);
61 velocity_function_ = std::make_unique<FP>(velocity_expression_);
62 };
63
64 set_up();
65 this->parse_parameters_call_back.connect(set_up);
66 }
67
68 state_type compute(const dealii::Point<dim> &point, Number t) final
69 {
70 const auto z = geotiff_reader_.compute_height(point);
71
72 dealii::Tensor<1, 2, Number> primitive;
73
74 height_function_->set_time(t);
75 primitive[0] = std::max(0., height_function_->value(point) - z);
76
77 velocity_function_->set_time(t);
78 primitive[1] = velocity_function_->value(point);
79
80 const auto view = hyperbolic_system_.template view<dim, Number>();
81 return view.from_initial_state(primitive);
82 }
83
84 auto initial_precomputations(const dealii::Point<dim> &point) ->
86 initial_precomputed_type final
87 {
88 /* Compute bathymetry: */
89 return {static_cast<Number>(geotiff_reader_.compute_height(point))};
90 }
91
92 private:
93 const HyperbolicSystem &hyperbolic_system_;
94 mutable GeoTIFFReader<dim> geotiff_reader_;
95
96 /* Runtime parameters: */
97
98 std::string height_expression_;
99 std::string velocity_expression_;
100
101 /* Fields for muparser support for water height and velocity: */
102
103 std::unique_ptr<dealii::FunctionParser<dim>> height_function_;
104 std::unique_ptr<dealii::FunctionParser<dim>> velocity_function_;
105 };
106 } // namespace ShallowWaterInitialStates
107} // namespace ryujin
typename Description::HyperbolicSystem HyperbolicSystem
auto initial_precomputations(const dealii::Point< dim > &point) -> typename InitialState< Description, dim, Number >::initial_precomputed_type final
state_type compute(const dealii::Point< dim > &point, Number t) final
GeoTIFF(const HyperbolicSystem &hyperbolic_system, const std::string subsection)
typename Description::template HyperbolicSystemView< dim, Number > View
Euler::HyperbolicSystem HyperbolicSystem
Definition: description.h:32