deal.II version GIT relicensing-6834-g5b78e6bcdf 2026-10-01 11:20:01+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: Apache-2.0 WITH LLVM-exception OR 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// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
13#ifndef dealii_tensor_function_parser_h
14#define dealii_tensor_function_parser_h
15
16
17#include <deal.II/base/config.h>
18
22#include <deal.II/base/point.h>
23#include <deal.II/base/tensor.h>
25
26#include <map>
27#include <vector>
28
30
31// Forward declaration
32#ifndef DOXYGEN
33template <typename>
34class Vector;
35#endif
36
102template <int rank, int dim, typename Number = double>
104 : public TensorFunction<rank, dim, Number>,
106{
107public:
114 TensorFunctionParser(const double initial_time = 0.0);
115
125 const std::string &expression,
126 const std::string &constants = "",
127 const std::string &variable_names = default_variable_names() + ",t");
128
134
140
147
154
158 using ConstMap = std::map<std::string, double>;
159
160
196 virtual void
197 initialize(const std::string &vars,
198 const std::vector<std::string> &expressions,
199 const ConstMap &constants,
200 const bool time_dependent = false) override;
201
209 void
210 initialize(const std::string &vars,
211 const std::string &expression,
212 const ConstMap &constants,
213 const bool time_dependent = false);
214
220 static std::string
222
227 value(const Point<dim> &p) const override;
228
232 virtual void
233 value_list(const std::vector<Point<dim>> &p,
234 std::vector<Tensor<rank, dim, Number>> &values) const override;
235
240 const std::vector<std::string> &
241 get_expressions() const;
242
248 int,
249 std::string,
250 << "Parsing Error at Column " << arg1
251 << ". The parser said: " << arg2);
252
254 int,
255 int,
256 << "The number of components (" << arg1
257 << ") is not equal to the number of expressions (" << arg2
258 << ").");
259
261private:
265 unsigned int n_components;
266};
267
268
269template <int rank, int dim, typename Number>
270std::string
272{
273 switch (dim)
274 {
275 case 1:
276 return "x";
277 case 2:
278 return "x,y";
279 case 3:
280 return "x,y,z";
281 default:
283 }
284 return "";
285}
286
287
288
290
291#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:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
#define DEAL_II_NOT_IMPLEMENTED()
static ::ExceptionBase & ExcParseError(int arg1, std::string arg2)
static ::ExceptionBase & ExcInvalidExpressionSize(int arg1, int arg2)
#define DeclException2(Exception2, type1, type2, outsequence)