deal.II version GIT relicensing-2206-gaa53ff9447 2024-12-02 09:10: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
mu_parser_internal.h
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 2019 - 2023 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_mu_parser_internal_h
16#define dealii_mu_parser_internal_h
17
18// This file contains functions used internally by the FunctionParser
19// and the TensorFunctionParser class.
20
21#include <deal.II/base/config.h>
22
24#include <deal.II/base/point.h>
26
27#include <memory>
28#include <string>
29#include <vector>
30
32
33namespace internal
34{
36 {
37 int
38 mu_round(double val);
39
40 double
41 mu_if(double condition, double thenvalue, double elsevalue);
42
43 double
44 mu_or(double left, double right);
45
46 double
47 mu_and(double left, double right);
48
49 double
50 mu_int(double value);
51
52 double
53 mu_ceil(double value);
54
55 double
56 mu_floor(double value);
57
58 double
59 mu_cot(double value);
60
61 double
62 mu_csc(double value);
63
64 double
65 mu_sec(double value);
66
67 double
68 mu_log(double value);
69
70 double
71 mu_pow(double a, double b);
72
73 double
74 mu_erf(double value);
75
76 double
77 mu_erfc(double value);
78
79 // returns a random value in the range [0,1] initializing the generator
80 // with the given seed
81 double
82 mu_rand_seed(double seed);
83
84 // returns a random value in the range [0,1]
85 double
86 mu_rand();
87
91 std::vector<std::string>
93
99 int,
100 std::string,
101 << "Parsing Error at Column " << arg1
102 << ". The parser said: " << arg2);
103
114 {
115 public:
116 virtual ~muParserBase() = default;
117 };
118
127 {
133 ParserData() = default;
134
142 ParserData(const ParserData &) = delete;
143
148 std::vector<double> vars;
149
153 std::vector<std::unique_ptr<muParserBase>> parsers;
154 };
155
156 template <int dim, typename Number>
158 {
159 public:
161
162 virtual ~ParserImplementation() = default;
163
169 virtual void
170 initialize(const std::string &vars,
171 const std::vector<std::string> &expressions,
172 const std::map<std::string, double> &constants,
173 const bool time_dependent = false);
174
179 void
180 init_muparser() const;
181
185 Number
186 do_value(const Point<dim> &p,
187 const double time,
188 unsigned int component) const;
189
193 void
194 do_all_values(const Point<dim> &p,
195 const double time,
196 ArrayView<Number> &values) const;
197
202 std::vector<std::string> expressions;
203
204 private:
211
216 std::map<std::string, double> constants;
217
222 std::vector<std::string> var_names;
223
229
237 unsigned int n_vars;
238 };
239 } // namespace FunctionParser
240} // namespace internal
241
243
244#endif
Definition point.h:111
A class that provides a separate storage location on each thread that accesses the object.
Number do_value(const Point< dim > &p, const double time, unsigned int component) const
Threads::ThreadLocalStorage< internal::FunctionParser::ParserData > parser_data
void do_all_values(const Point< dim > &p, const double time, ArrayView< Number > &values) const
virtual void initialize(const std::string &vars, const std::vector< std::string > &expressions, const std::map< std::string, double > &constants, const bool time_dependent=false)
#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)
#define DeclException2(Exception2, type1, type2, outsequence)
Definition exceptions.h:534
double mu_if(double condition, double thenvalue, double elsevalue)
double mu_erf(double value)
double mu_sec(double value)
double mu_floor(double value)
double mu_csc(double value)
double mu_pow(double a, double b)
double mu_log(double value)
double mu_rand_seed(double seed)
double mu_ceil(double value)
std::vector< std::string > get_function_names()
double mu_cot(double value)
double mu_int(double value)
double mu_or(double left, double right)
double mu_and(double left, double right)
double mu_erfc(double value)
std::vector< std::unique_ptr< muParserBase > > parsers
ParserData(const ParserData &)=delete