MBSim

Project Page
rksuite_integrator.h
1 /* Copyright (C) 2004-2009 MBSim Development Team
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  * Contact: martin.o.foerg@googlemail.com
18  */
19 
20 #ifndef _RKSUITE_INTEGRATOR_H_
21 #define _RKSUITE_INTEGRATOR_H_
22 
23 #include "integrator.h"
24 
25 namespace MBSim {
26 
30  class RKSuiteIntegrator : public Integrator {
31  public:
36 
40  virtual ~RKSuiteIntegrator() { if(dworkarray) { delete[] dworkarray; dworkarray=0; } }
41 
42  void preIntegrate(DynamicSystemSolver& system);
43  void subIntegrate(DynamicSystemSolver& system, double tStop);
44  void postIntegrate(DynamicSystemSolver& system);
45 
46  /* GETTER / SETTER */
47  void setMethod(int method_) {method = method_;}
48  void setrTol(double rTol_) {rTol = rTol_;}
49  void setThreshold(const fmatvec::Vec &thres_) {thres.resize() = thres_;}
50  void setThreshold(double thres_) {thres.resize() = fmatvec::Vec(1,fmatvec::INIT,thres_);}
51  void setInitialStepSize(double dt0_) {dt0 = dt0_;}
52  /***************************************************/
53 
54 
55  /* INHERITED INTERFACE OF INTEGRATOR */
56  virtual void integrate(DynamicSystemSolver& system);
57  virtual void initializeUsingXML(TiXmlElement *element);
58  /***************************************************/
59 
60  private:
61 
62  static void fzdot(double* t, double* z_, double* zd_);
63 
64  static int zSize;
65 
66  int method;
68  fmatvec::Vec thres;
70  double rTol;
72  double dt0;
73 
74 
75  int ndworkarray, messages, integrationSteps;
76  double t, tPlot, s0, time;
77  double * dworkarray;
78  fmatvec::Vec z, zdGot, zMax;
79 
80  std::ofstream integPlot;
81 
82  };
83 
84 }
85 
86 #endif