ryujin 2.1.1 revision b04fb4aba7bd97ddfa5994a6b4b6e8586eb15db2
Loading...
Searching...
No Matches
initial_state_function.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
10#include "hyperbolic_system.h"
12
13#include <deal.II/base/function_parser.h>
14
15namespace ryujin
16{
17 namespace ScalarConservation
18 {
20
26 template <int dim, typename Number>
27 class Function : public InitialState<HyperbolicDescription, dim, Number>
28 {
29 public:
31 using state_type = typename View::state_type;
32
33 Function(const HyperbolicSystem &hyperbolic_system,
34 const std::string subsection)
35 : InitialState<HyperbolicDescription, dim, Number>("function",
36 subsection)
37 , hyperbolic_system(hyperbolic_system)
38 {
39 expression_ = "0.25 * x";
40 this->add_parameter("expression",
41 expression_,
42 "A function expression for the initial state");
43
44 /*
45 * Set up the muparser object with the final flux description from
46 * the parameter file:
47 */
48 const auto set_up_muparser = [this] {
49 /*
50 * This variant of the constructor initializes the function
51 * parser with support for a time-dependent description involving
52 * a variable »t«:
53 */
54 function_ =
55 std::make_unique<dealii::FunctionParser<dim>>(expression_);
56 };
57
58 set_up_muparser();
59 this->parse_parameters_call_back.connect(set_up_muparser);
60 }
61
62 state_type compute(const dealii::Point<dim> &point, Number t) final
63 {
64 function_->set_time(t);
65 state_type result;
66 result[0] = function_->value(point);
67 return result;
68 }
69
70 private:
71 const HyperbolicSystem &hyperbolic_system;
72
73 std::string expression_;
74 std::unique_ptr<dealii::FunctionParser<dim>> function_;
75 };
76 } // namespace ScalarConservation
77} // namespace ryujin
typename HyperbolicDescription::HyperbolicSystem HyperbolicSystem
Function(const HyperbolicSystem &hyperbolic_system, const std::string subsection)
state_type compute(const dealii::Point< dim > &point, Number t) final
dealii::Tensor< 1, problem_dimension, Number > state_type
Euler::HyperbolicDescription HyperbolicDescription