deal.II version GIT relicensing-2167-g9622207b8f 2024-11-21 12:40:00+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\}}\)
Loading...
Searching...
No Matches
tensor_function_parser.h
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 2019 - 2024 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15#ifndef dealii_tensor_function_parser_h
16#define dealii_tensor_function_parser_h
17
18
19#include <deal.II/base/config.h>
20
24#include <deal.II/base/point.h>
25#include <deal.II/base/tensor.h>
27
28#include <map>
29#include <vector>
30
32
33// Forward declaration
34#ifndef DOXYGEN
35template <typename>
36class Vector;
37#endif
38
104template <int rank, int dim, typename Number = double>
106 : public TensorFunction<rank, dim, Number>,
108{
109public:
116 TensorFunctionParser(const double initial_time = 0.0);
117
127 const std::string &expression,
128 const std::string &constants = "",
129 const std::string &variable_names = default_variable_names() + ",t");
130
136
142
149
156
160 using ConstMap = std::map<std::string, double>;
161
162
198 virtual void
199 initialize(const std::string &vars,
200 const std::vector<std::string> &expressions,
201 const ConstMap &constants,
202 const bool time_dependent = false) override;
203
211 void
212 initialize(const std::string &vars,
213 const std::string &expression,
214 const ConstMap &constants,
215 const bool time_dependent = false);
216
222 static std::string
224
229 value(const Point<dim> &p) const override;
230
234 virtual void
235 value_list(const std::vector<Point<dim>> &p,
236 std::vector<Tensor<rank, dim, Number>> &values) const override;
237
242 const std::vector<std::string> &
243 get_expressions() const;
244
250 int,
251 std::string,
252 << "Parsing Error at Column " << arg1
253 << ". The parser said: " << arg2);
254
256 int,
257 int,
258 << "The number of components (" << arg1
259 << ") is not equal to the number of expressions (" << arg2
260 << ").");
261
263private:
267 unsigned int n_components;
268};
269
270
271template <int rank, int dim, typename Number>
272std::string
274{
275 switch (dim)
276 {
277 case 1:
278 return "x";
279 case 2:
280 return "x,y";
281 case 3:
282 return "x,y,z";
283 default:
285 }
286 return "";
287}
288
289
290
292
293#endif
Definition point.h:111
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:498
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:499
static ::ExceptionBase & ExcParseError(int arg1, std::string arg2)
static ::ExceptionBase & ExcInvalidExpressionSize(int arg1, int arg2)
#define DeclException2(Exception2, type1, type2, outsequence)
Definition exceptions.h:534
#define DEAL_II_NOT_IMPLEMENTED()