Reference documentation for deal.II version GIT c415589cf0 2022-08-14 18:50:02+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
tensor_function_parser.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2005 - 2022 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_tensor_function_parser_h
17 #define dealii_tensor_function_parser_h
18 
19 
20 #include <deal.II/base/config.h>
21 
25 #include <deal.II/base/point.h>
26 #include <deal.II/base/tensor.h>
28 
29 #include <map>
30 #include <vector>
31 
33 
34 // Forward declaration
35 #ifndef DOXYGEN
36 template <typename>
37 class Vector;
38 #endif
39 
105 template <int rank, int dim, typename Number = double>
107  : public TensorFunction<rank, dim, Number>,
109 {
110 public:
117  TensorFunctionParser(const double initial_time = 0.0);
118 
128  const std::string &expression,
129  const std::string &constants = "",
130  const std::string &variable_names = default_variable_names() + ",t");
131 
137 
143 
149  operator=(const TensorFunctionParser &) = delete;
150 
157 
161  using ConstMap = std::map<std::string, double>;
162 
163 
199  virtual void
200  initialize(const std::string & vars,
201  const std::vector<std::string> &expressions,
202  const ConstMap & constants,
203  const bool time_dependent = false) override;
204 
212  void
213  initialize(const std::string &vars,
214  const std::string &expression,
215  const ConstMap & constants,
216  const bool time_dependent = false);
217 
223  static std::string
225 
230  value(const Point<dim> &p) const override;
231 
235  virtual void
236  value_list(const std::vector<Point<dim>> & p,
237  std::vector<Tensor<rank, dim, Number>> &values) const override;
238 
243  const std::vector<std::string> &
244  get_expressions() const;
245 
251  int,
252  std::string,
253  << "Parsing Error at Column " << arg1
254  << ". The parser said: " << arg2);
255 
257  int,
258  int,
259  << "The number of components (" << arg1
260  << ") is not equal to the number of expressions (" << arg2
261  << ").");
262 
264 private:
268  unsigned int n_components;
269 };
270 
271 
272 template <int rank, int dim, typename Number>
273 std::string
275 {
276  switch (dim)
277  {
278  case 1:
279  return "x";
280  case 2:
281  return "x,y";
282  case 3:
283  return "x,y,z";
284  default:
285  Assert(false, ExcNotImplemented());
286  }
287  return "";
288 }
289 
290 
291 
293 
294 #endif
Definition: point.h:111
TensorFunctionParser(const double initial_time=0.0)
virtual Tensor< rank, dim, Number > value(const Point< dim > &p) const override
TensorFunctionParser(const TensorFunctionParser &)=delete
TensorFunctionParser(TensorFunctionParser &&)=delete
TensorFunctionParser & operator=(const TensorFunctionParser &)=delete
TensorFunctionParser & operator=(TensorFunctionParser &&)=delete
virtual void initialize(const std::string &vars, const std::vector< std::string > &expressions, const ConstMap &constants, const bool time_dependent=false) override
static std::string default_variable_names()
std::map< std::string, double > ConstMap
virtual void value_list(const std::vector< Point< dim >> &p, std::vector< Tensor< rank, dim, Number >> &values) const override
const std::vector< std::string > & get_expressions() const
Definition: tensor.h:503
Definition: vector.h:110
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:442
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:443
static ::ExceptionBase & ExcInvalidExpressionSize(int arg1, int arg2)
#define Assert(cond, exc)
Definition: exceptions.h:1473
static ::ExceptionBase & ExcNotImplemented()
#define DeclException2(Exception2, type1, type2, outsequence)
Definition: exceptions.h:532
static ::ExceptionBase & ExcParseError(int arg1, std::string arg2)