Reference documentation for deal.II version 9.5.0
\(\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\}}\)
Loading...
Searching...
No Matches
tensor_function_parser.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (C) 2005 - 2023 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
36template <typename>
37class Vector;
38#endif
39
105template <int rank, int dim, typename Number = double>
107 : public TensorFunction<rank, dim, Number>,
109{
110public:
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
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
264private:
268 unsigned int n_components;
269};
270
271
272template <int rank, int dim, typename Number>
273std::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:112
TensorFunctionParser & operator=(const TensorFunctionParser &)=delete
virtual Tensor< rank, dim, Number > value(const Point< dim > &p) const override
TensorFunctionParser(const TensorFunctionParser &)=delete
TensorFunctionParser(TensorFunctionParser &&)=delete
TensorFunctionParser & operator=(TensorFunctionParser &&)=delete
virtual void value_list(const std::vector< Point< dim > > &p, std::vector< Tensor< rank, dim, Number > > &values) const override
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
const std::vector< std::string > & get_expressions() const
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:472
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:473
static ::ExceptionBase & ExcParseError(int arg1, std::string arg2)
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
static ::ExceptionBase & ExcInvalidExpressionSize(int arg1, int arg2)
#define DeclException2(Exception2, type1, type2, outsequence)
Definition exceptions.h:533