MBSim

Project Page
lsodar_integrator.h
1 /* Copyright (C) 2004-2006 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 _LSODAR_INTEGRATOR_H_
24 #define _LSODAR_INTEGRATOR_H_
25 
26 #include "integrator.h"
27 
28 namespace MBSim {
29 
33  class LSODARIntegrator : public Integrator {
34  private:
35 
36  static void fzdot(int* zSize, double* t, double* z_, double* zd_);
37  static void fsv(int* zSize, double* t, double* z_, int* nsv, double* sv_);
38 
40  double dtMax;
42  double dtMin;
44  fmatvec::Vec aTol;
46  double rTol;
48  double dt0;
49 
50  bool plotOnRoot;
51 
52  int zSize, iTol, istate, nsv, lrWork, liWork, integrationSteps;
53  double t, tPlot, s0, time;
54  fmatvec::Vec z, rWork;
55  fmatvec::Vector<int> iWork, jsv;
56  std::ofstream integPlot;
57  public:
58 
60  ~LSODARIntegrator() {}
61 
62  void setMaximalStepSize(double dtMax_) {dtMax = dtMax_;}
63  void setMinimalStepSize(double dtMin_) {dtMin = dtMin_;}
64  void setAbsoluteTolerance(const fmatvec::Vec &aTol_) {aTol.resize() = aTol_;}
65  void setAbsoluteTolerance(double aTol_) {aTol.resize() = fmatvec::Vec(1,fmatvec::INIT,aTol_);}
66  void setRelativeTolerance(double rTol_) {rTol = rTol_;}
67  void setInitialStepSize(double dt0_) {dt0 = dt0_;}
68 
69  void setPlotOnRoot(bool b) {plotOnRoot = b;}
70 
71  void integrate(DynamicSystemSolver& system);
72  void preIntegrate(DynamicSystemSolver& system);
73  void subIntegrate(DynamicSystemSolver& system, double tStop);
74  void postIntegrate(DynamicSystemSolver& system);
75 
76  virtual void initializeUsingXML(TiXmlElement *element);
77  };
78 
79 }
80 
81 #endif