GranOO  3.0
A robust and versatile workbench to build 3D dynamic simulations based on the Discrete Element Method
Expression.hpp
Go to the documentation of this file.
1 // This file is part of GranOO, a workbench for DEM simulation.
2 //
3 // Author(s) : - Damien Andre IRCER/UNILIM, Limoges France
4 // <damien.andre@unilim.fr>
5 // - Jean-luc Charles Arts et Metiers ParisTech, CNRS, I2M, Bordeaux France
6 // <jean-luc.charles@ensam.eu>
7 // - Jeremie Girardot Arts et Metiers ParisTech, CNRS, I2M, Bordeaux France
8 // <jeremie.girardot@ensam.eu>
9 // - Cedric Hubert LAMIH/UPHF, Valenciennes France
10 // <cedric.hubert@uphf.fr>
11 // - Ivan Iordanoff Arts et Metiers ParisTech, CNRS, I2M, Bordeaux France
12 // <ivan.iordanoff@ensam.eu>
13 //
14 // Copyright (C) 2008-2019 D. Andre, JL. Charles, J. Girardot, C. Hubert, I. Iordanoff
15 //
16 // This program is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 // This program is distributed in the hope that it will be useful,
22 // but WITHOUT ANY WARRANTY; without even the implied warranty of
23 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 // GNU General Public License for more details.
25 //
26 // You should have received a copy of the GNU General Public License
27 // along with this program. If not, see <http://www.gnu.org/licenses/>.
28 
29 
30 #ifndef GranOO_Math__Expressionhpp
31 #define GranOO_Math__Expressionhpp
32 
33 #include <string>
34 
36 #include "GranOO3/Math/Exprtk.hpp"
37 #include "GranOO3/Core/TinyXml.hpp"
38 
39 #include "GranOO3/Physic/Time.hpp"
40 
41 namespace GranOO3
42 {
43  namespace Math
44  {
45  class Expression
46  {
47  public:
48  static Expression& glob(const std::string& id);
49  static std::string class_ID() {return std::string("Expression");}
50 
51  static Expression* new_object(const TiXmlElement* el);
52  static bool Check(const std::string& str);
53 
54  public:
55  Expression(const std::string & exp);
56  Expression();
57  Expression(const Expression&);
59 
60  virtual ~Expression();
61 
62  void set(const std::string&);
63  bool is_empty() const;
64 
65  std::string info() const;
66  std::string str() const;
67  double operator()(void);
68  double value();
69  double value() const;
70 
71  bool depend_on(double& var) const;
72 
73  double derivate(double& x, double step) const;
74  double second_derivate(double& x, double step) const;
75 
76  double dt(Physic::Time& = Physic::Time::get());
77  double ddt(Physic::Time& = Physic::Time::get());
78 
79  private:
80  private:
81  std::string _str;
83  };
84  }
85 }
86 #endif
Definition: Expression.hpp:46
double second_derivate(double &x, double step) const
Definition: Expression.cpp:150
std::string info() const
Definition: Expression.cpp:120
double dt(Physic::Time &=Physic::Time::get())
Definition: Expression.cpp:171
std::string str() const
Definition: Expression.cpp:125
double value()
Definition: Expression.cpp:135
bool depend_on(double &var) const
Definition: Expression.cpp:160
virtual ~Expression()
Definition: Expression.cpp:107
double derivate(double &x, double step) const
Definition: Expression.cpp:145
double operator()(void)
Definition: Expression.cpp:130
static Expression & glob(const std::string &id)
Definition: Expression.cpp:44
void set(const std::string &)
Definition: Expression.cpp:111
exprtk::expression< double > _expression
Definition: Expression.hpp:82
double ddt(Physic::Time &=Physic::Time::get())
Definition: Expression.cpp:182
Expression & operator=(const Expression &)
Definition: Expression.cpp:96
bool is_empty() const
Definition: Expression.cpp:155
Expression()
Definition: Expression.cpp:79
std::string _str
Definition: Expression.hpp:81
static std::string class_ID()
Definition: Expression.hpp:49
static Expression * new_object(const TiXmlElement *el)
Definition: Expression.cpp:49
static bool Check(const std::string &str)
Definition: Expression.cpp:62
Definition: Time.hpp:45
static Time & get()
Definition: Time.cpp:42
Definition: Common.hpp:198
x y t t *t x y t t t x y t t t x *y t *t t x *y t *t t x y t t t x y t t t x(y+z)