mbsim  4.0.0
MBSim Kernel
seulex_integrator.h
1 /* Copyright (C) 2004-2018 Martin Förg
2 
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation; either
6  * version 2.1 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 
17  *
18  * Contact:
19  * martin.o.foerg@googlemail.com
20  *
21  */
22 
23 #ifndef _SEULEX_INTEGRATOR_H_
24 #define _SEULEX_INTEGRATOR_H_
25 
26 #include "root_finding_integrator.h"
27 
28 namespace MBSim {
29 
33 
34  public:
35  enum Formalism {
36  ODE=0,
37  DAE1,
38  unknown
39  };
40 
41  private:
42  typedef void (*Fzdot)(int* n, double* t, double* y, double* yd, double* rpar, int* ipar);
43  typedef void (*Mass)(int* n, double* m, int* lmas, double* rpar, int* ipar);
44  static Fzdot fzdot[2];
45  static Mass mass[2];
46  static void fzdotODE(int* n, double* t, double* z, double* zd, double* rpar, int* ipar);
47  static void fzdotDAE1(int* n, double* t, double* y, double* yd, double* rpar, int* ipar);
48  static void massFull(int* n, double* m, int* lmas, double* rpar, int* ipar);
49  static void massReduced(int* n, double* m, int* lmas, double* rpar, int* ipar);
50  static void plot(int* nr, double* told, double* x, double *y, double *rc, int* lrc, int* ic, int* lic, int* n, double* rpar, int* ipar, int* irtrn);
51 
52  void calcSize();
53  void reinit();
54 
55  double tPlot{0};
56  double dtOut{0};
57  double s0;
58  double time{0};
59 
65  double dt0{0};
67  int maxSteps{0};
69  double dtMax{0};
71  Formalism formalism{ODE};
73  bool reduced{false};
75  bool autonom{false};
76 
77  int neq, mlJac, muJac;
78  fmatvec::VecInt iWork;
79  fmatvec::Vec work;
80 
81  public:
82  ~SEULEXIntegrator() override = default;
83 
84  void setAbsoluteTolerance(const fmatvec::Vec &aTol_) { aTol <<= aTol_; }
85  void setAbsoluteTolerance(double aTol_) { aTol.resize(1,fmatvec::INIT,aTol_); }
86  void setRelativeTolerance(const fmatvec::Vec &rTol_) { rTol <<= rTol_; }
87  void setRelativeTolerance(double rTol_) { rTol.resize(1,fmatvec::INIT,rTol_); }
88  void setInitialStepSize(double dt0_) { dt0 = dt0_; }
89  void setMaximumStepSize(double dtMax_) { dtMax = dtMax_; }
90  void setStepLimit(int maxSteps_) { maxSteps = maxSteps_; }
91  void setFormalism(Formalism formalism_) { formalism = formalism_; }
92  void setReducedForm(bool reduced_) { reduced = reduced_; }
93  void setAutonomousSystem(bool autonom_) { autonom = autonom_; }
94 
96  void integrate() override;
97 
98  void initializeUsingXML(xercesc::DOMElement *element) override;
99  };
100 
101 }
102 
103 #endif
double dt0
Definition: seulex_integrator.h:65
int maxSteps
Definition: seulex_integrator.h:67
Integrator with root-finding.
Definition: root_finding_integrator.h:32
DAE-Integrator SEULEX.
Definition: seulex_integrator.h:32
virtual void integrate()=0
start the integration of the system set by setSystem. Each class implemeting this function should cal...
fmatvec::Vec rTol
Definition: seulex_integrator.h:63
double dtMax
Definition: seulex_integrator.h:69
void integrate() override
start the integration of the system set by setSystem. Each class implemeting this function should cal...
Definition: seulex_integrator.cc:202
bool autonom
Definition: seulex_integrator.h:75
void initializeUsingXML(xercesc::DOMElement *element) override
initialize integrator
Definition: seulex_integrator.cc:342
fmatvec::Vec aTol
Definition: seulex_integrator.h:61
namespace MBSim
Definition: bilateral_constraint.cc:29
Formalism formalism
Definition: seulex_integrator.h:71
bool reduced
Definition: seulex_integrator.h:73