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