Reference documentation for deal.II version GIT relicensing-1062-gc06da148b8 2024-07-15 19:20: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
223template <int dim>
225 : public AutoDerivativeFunction<dim>,
227{
228public:
237 FunctionParser(const unsigned int n_components = 1,
238 const double initial_time = 0.0,
239 const double h = 1e-8);
240
247 FunctionParser(const std::string &expression,
248 const std::string &constants = "",
249 const std::string &variable_names = default_variable_names() +
250 ",t",
251 const double h = 1e-8);
252
258
264
270 operator=(const FunctionParser &) = delete;
271
278
282 using ConstMap = std::map<std::string, double>;
283
318 virtual void
319 initialize(const std::string &vars,
320 const std::vector<std::string> &expressions,
321 const ConstMap &constants,
322 const bool time_dependent = false) override;
323
331 void
332 initialize(const std::string &vars,
333 const std::string &expression,
334 const ConstMap &constants,
335 const bool time_dependent = false);
336
342 static std::string
344
351 virtual double
352 value(const Point<dim> &p, const unsigned int component = 0) const override;
353
358 const std::vector<std::string> &
359 get_expressions() const;
360
366 int,
367 std::string,
368 << "Parsing Error at Column " << arg1
369 << ". The parser said: " << arg2);
370
372 int,
373 int,
374 << "The number of components (" << arg1
375 << ") is not equal to the number of expressions (" << arg2
376 << ").");
377
379};
380
381
382template <int dim>
383std::string
385{
386 switch (dim)
387 {
388 case 1:
389 return "x";
390 case 2:
391 return "x,y";
392 case 3:
393 return "x,y,z";
394 default:
396 }
397 return "";
398}
399
400
401
403
404#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()