Reference documentation for deal.II version GIT relicensing-422-gb369f187d8 2024-04-17 18:10: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\}}\)
Loading...
Searching...
No Matches
function_parser.h
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 2005 - 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_function_parser_h
16#define dealii_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>
26
27#include <map>
28#include <vector>
29
31
32// Forward declaration
33#ifndef DOXYGEN
34template <typename>
35class Vector;
36#endif
37
215template <int dim>
217 : public AutoDerivativeFunction<dim>,
219{
220public:
229 FunctionParser(const unsigned int n_components = 1,
230 const double initial_time = 0.0,
231 const double h = 1e-8);
232
239 FunctionParser(const std::string &expression,
240 const std::string &constants = "",
241 const std::string &variable_names = default_variable_names() +
242 ",t",
243 const double h = 1e-8);
244
250
256
262 operator=(const FunctionParser &) = delete;
263
270
274 using ConstMap = std::map<std::string, double>;
275
310 virtual void
311 initialize(const std::string &vars,
312 const std::vector<std::string> &expressions,
313 const ConstMap &constants,
314 const bool time_dependent = false) override;
315
323 void
324 initialize(const std::string &vars,
325 const std::string &expression,
326 const ConstMap &constants,
327 const bool time_dependent = false);
328
334 static std::string
336
343 virtual double
344 value(const Point<dim> &p, const unsigned int component = 0) const override;
345
350 const std::vector<std::string> &
351 get_expressions() const;
352
358 int,
359 std::string,
360 << "Parsing Error at Column " << arg1
361 << ". The parser said: " << arg2);
362
364 int,
365 int,
366 << "The number of components (" << arg1
367 << ") is not equal to the number of expressions (" << arg2
368 << ").");
369
371};
372
373
374template <int dim>
375std::string
377{
378 switch (dim)
379 {
380 case 1:
381 return "x";
382 case 2:
383 return "x,y";
384 case 3:
385 return "x,y,z";
386 default:
388 }
389 return "";
390}
391
392
393
395
396#endif
virtual void initialize(const std::string &vars, const std::vector< std::string > &expressions, const ConstMap &constants, const bool time_dependent=false) override
std::map< std::string, double > ConstMap
virtual double value(const Point< dim > &p, const unsigned int component=0) const override
FunctionParser(FunctionParser &&)=delete
FunctionParser & operator=(FunctionParser &&)=delete
const std::vector< std::string > & get_expressions() const
FunctionParser(const FunctionParser &)=delete
FunctionParser & operator=(const FunctionParser &)=delete
static std::string default_variable_names()
const unsigned int n_components
Definition function.h:163
Definition point.h:111
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:502
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:503
#define DeclException2(Exception2, type1, type2, outsequence)
Definition exceptions.h:539
static ::ExceptionBase & ExcInvalidExpressionSize(int arg1, int arg2)
static ::ExceptionBase & ExcParseError(int arg1, std::string arg2)
#define DEAL_II_NOT_IMPLEMENTED()