FEDEM Solver  R8.0
Source code of the dynamics solver
FFaMathExprFactory.H
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2023 SAP SE
2 //
3 // SPDX-License-Identifier: Apache-2.0
4 //
5 // This file is part of FEDEM - https://openfedem.org
7 
8 #ifndef FFA_MATH_EXPR_FACTORY_H
9 #define FFA_MATH_EXPR_FACTORY_H
10 
12 #include <string>
13 #include <vector>
14 #include <map>
15 
16 class FFaMathExpr;
17 class FFaMathVar;
18 
19 
20 class FFaMathExprFactory : public FFaSingelton<FFaMathExprFactory>
21 {
23  {
24  public:
25  std::string estr;
27  std::vector<FFaMathExpr*> diff;
28  std::vector<FFaMathVar*> args;
29  FFaMathFunc() { expr = NULL; }
30  FFaMathFunc(const FFaMathFunc&) = delete;
31  FFaMathFunc& operator=(const FFaMathFunc&) = delete;
32  ~FFaMathFunc();
33  };
34 
35  typedef std::map<int,FFaMathFunc> IndexMap;
36  typedef IndexMap::iterator IMIter;
37 
38 protected:
40  virtual ~FFaMathExprFactory() {}
41 
42 public:
43  static size_t countArgs(const std::string& expression, const char** vars,
44  std::vector<bool>* present = 0);
45 
46  int create(int id, const std::string& expression,
47  size_t nvar = 1, const char** vars = 0);
48 
49  double getValue(int id, double arg, int& error);
50  double getValue(int id, const double* arg, int& error);
51 
52  double getDiff(int id, double arg, int& error);
53  double getDiff(int id, size_t idArg, const double* arg, int& error);
54 
55 private:
57 
58  friend class FFaSingelton<FFaMathExprFactory>;
59 };
60 
61 #endif
Definition: FFaMathExprFactory.H:23
FFaMathFunc()
Definition: FFaMathExprFactory.H:29
FFaMathFunc(const FFaMathFunc &)=delete
std::vector< FFaMathExpr * > diff
Definition: FFaMathExprFactory.H:27
FFaMathFunc & operator=(const FFaMathFunc &)=delete
std::string estr
Definition: FFaMathExprFactory.H:25
~FFaMathFunc()
Definition: FFaMathExprFactory.C:14
FFaMathExpr * expr
Definition: FFaMathExprFactory.H:26
std::vector< FFaMathVar * > args
Definition: FFaMathExprFactory.H:28
Definition: FFaMathExprFactory.H:21
std::map< int, FFaMathFunc > IndexMap
Definition: FFaMathExprFactory.H:35
int create(int id, const std::string &expression, size_t nvar=1, const char **vars=0)
Definition: FFaMathExprFactory.C:49
IndexMap::iterator IMIter
Definition: FFaMathExprFactory.H:36
double getValue(int id, double arg, int &error)
Definition: FFaMathExprFactory.C:83
virtual ~FFaMathExprFactory()
Definition: FFaMathExprFactory.H:40
FFaMathExprFactory()
Definition: FFaMathExprFactory.H:39
IndexMap myIndexMap
Definition: FFaMathExprFactory.H:56
static size_t countArgs(const std::string &expression, const char **vars, std::vector< bool > *present=0)
Definition: FFaMathExprFactory.C:25
double getDiff(int id, double arg, int &error)
Definition: FFaMathExprFactory.C:118
Definition: FFaMathExpr.H:16
Definition: FFaMathVar.H:15
Template class for singleton classes.
Definition: FFaSingelton.H:20
character(len=500) expression
Explicit function expression.
Definition: initiateFunctionTypeModule.f90:35