MBSim

Project Page
rksuite_integrator.h
00001 /* Copyright (C) 2004-2009 MBSim Development Team
00002  *
00003  * This library is free software; you can redistribute it and/or 
00004  * modify it under the terms of the GNU Lesser General Public 
00005  * License as published by the Free Software Foundation; either 
00006  * version 2.1 of the License, or (at your option) any later version. 
00007  *  
00008  * This library is distributed in the hope that it will be useful, 
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of 
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
00011  * Lesser General Public License for more details. 
00012  *  
00013  * You should have received a copy of the GNU Lesser General Public 
00014  * License along with this library; if not, write to the Free Software 
00015  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
00016  *
00017  * Contact: martin.o.foerg@googlemail.com
00018  */
00019 
00020 #ifndef _RKSUITE_INTEGRATOR_H_
00021 #define _RKSUITE_INTEGRATOR_H_
00022 
00023 #include "integrator.h"
00024 
00025 namespace MBSim {
00026 
00030   class RKSuiteIntegrator : public Integrator {
00031     public:
00035       RKSuiteIntegrator();
00036       
00040       virtual ~RKSuiteIntegrator() { if(dworkarray) { delete[] dworkarray; dworkarray=0; } }
00041 
00042       void preIntegrate(DynamicSystemSolver& system);
00043       void subIntegrate(DynamicSystemSolver& system, double tStop);
00044       void postIntegrate(DynamicSystemSolver& system);
00045 
00046       /* GETTER / SETTER */
00047       void setMethod(int method_) {method = method_;}
00048       void setrTol(double rTol_) {rTol = rTol_;}
00049       void setThreshold(const fmatvec::Vec &thres_) {thres = thres_;}
00050       void setThreshold(double thres_) {thres = fmatvec::Vec(1,fmatvec::INIT,thres_);}
00051       void setInitialStepSize(double dt0_) {dt0 = dt0_;}
00052       /***************************************************/
00053 
00054 
00055       /* INHERITED INTERFACE OF INTEGRATOR */
00056       virtual void integrate(DynamicSystemSolver& system);
00057       virtual void initializeUsingXML(MBXMLUtils::TiXmlElement *element);
00058       /***************************************************/
00059 
00060     private:
00061 
00062       static void fzdot(double* t, double* z_, double* zd_);
00063 
00064       static int zSize;
00065 
00066       int method;
00068       fmatvec::Vec thres;
00070       double rTol;
00072       double dt0;
00073 
00074 
00075       int ndworkarray, messages, integrationSteps;
00076       double t, tPlot, s0, time;
00077       double * dworkarray;
00078       fmatvec::Vec z, zdGot, zMax;
00079 
00080       std::ofstream integPlot;
00081 
00082   };
00083 
00084 }
00085 
00086 #endif