Fluid structure interaction suite
function.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2022 by Luca Heltai
4 //
5 // This file is part of the FSI-suite platform, based on the deal.II library.
6 //
7 // The FSI-suite platform is free software; you can use it, redistribute it,
8 // and/or modify it under the terms of the GNU Lesser General Public License as
9 // published by the Free Software Foundation; either version 3.0 of the License,
10 // or (at your option) any later version. The full text of the license can be
11 // found in the file LICENSE at the top level of the FSI-suite platform
12 // distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef parsed_tools_function_h
17 #define parsed_tools_function_h
18 
21 
22 namespace ParsedTools
23 {
27  template <int dim>
28  class Function : public dealii::ParameterAcceptor,
29  public dealii::FunctionParser<dim>
30  {
31  public:
62  Function(const std::string &section_name = "",
63  const std::string &expression = "0",
64  const std::string &function_description = "Function expression",
65  const std::map<std::string, double> &constants = {},
66  const std::string &variable_names =
67  dealii::FunctionParser<dim>::default_variable_names() + ",t",
68  const double h = 1e-8);
69 
73  void
74  update_constants(const std::map<std::string, double> &constants);
75 
79  void
80  update_expression(const std::string &expr);
81 
82  private:
87  void
88  reinit();
89 
93  std::string expression;
94 
98  std::map<std::string, double> constants;
99 
103  const std::string variable_names;
104  };
105 } // namespace ParsedTools
106 #endif
const std::string section_name
A wrapper for the FunctionParser class.
Definition: function.h:30
std::map< std::string, double > constants
Constants that can be used in the expression.
Definition: function.h:98
void reinit()
Reset the Function object using the expression, the constants, and the variables stored in this class...
Definition: function.cc:70
void update_expression(const std::string &expr)
Reinitialize the function with the new expression.
Definition: function.cc:104
Function(const std::string &section_name="", const std::string &expression="0", const std::string &function_description="Function expression", const std::map< std::string, double > &constants={}, const std::string &variable_names=FunctionParser< dim >::default_variable_names()+",t", const double h=1e-8)
Build a Function based on ParameterAcceptor.
Definition: function.cc:24
void update_constants(const std::map< std::string, double > &constants)
Reinitialize the function with the new constants.
Definition: function.cc:83
const std::string variable_names
Keep variable names around to re-initialize the FunctionParser class.
Definition: function.h:103
std::string expression
The actual FunctionParser expression.
Definition: function.h:93
SymmetricTensor< 2, dim, Number > e(const Tensor< 2, dim, Number > &F)
We collect in this namespace some wrappers around commonly used deal.II classes, derived from the Par...