MBSim

Project Page
dopri5_integrator.h
00001 /* Copyright (C) 2004-2006  Martin Förg
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  *
00018  * Contact:
00019  *   martin.o.foerg@googlemail.com
00020  *
00021  */
00022 
00023 #ifndef _DOPRI5_INTEGRATOR_H_
00024 #define _DOPRI5_INTEGRATOR_H_
00025 
00026 #include "integrator.h"
00027 
00028 namespace MBSimIntegrator {
00029 
00033   class DOPRI5Integrator : public Integrator {
00034 
00035     private:
00036 
00037       static void fzdot(int* n, double* t, double* z, double* zd, double* rpar, int* ipar);
00038       static void plot(int* nr, double* told, double* t,double* z, int* n, double* con, int* icomp, int* nd, double* rpar, int* ipar, int* irtrn);
00039 
00040       static double tPlot;
00041       static double dtOut;
00042       static fmatvec::Vec zInp;
00043       static bool output_; 
00044       static std::ofstream integPlot;
00045       static double s0; 
00046       static double time;
00047       //static int integrationSteps;
00048    
00050       fmatvec::Vec aTol;
00052       fmatvec::Vec rTol;
00054       double dt0;
00056       int maxSteps;  
00058       double dtMax;
00059 
00060     public:
00061 
00062       DOPRI5Integrator();
00063       ~DOPRI5Integrator() {}
00064 
00065       void setAbsoluteTolerance(const fmatvec::Vec &aTol_) {aTol = aTol_;}
00066       void setAbsoluteTolerance(double aTol_) {aTol = fmatvec::Vec(1,fmatvec::INIT,aTol_);}
00067       void setRelativeTolerance(const fmatvec::Vec &rTol_) {rTol = rTol_;}
00068       void setRelativeTolerance(double rTol_) {rTol = fmatvec::Vec(1,fmatvec::INIT,rTol_);}
00069       void setInitialStepSize(double dt0_) {dt0 = dt0_;}
00070       void setMaxStepNumber(int maxSteps_) {maxSteps = maxSteps_;}    
00071       void setMaximalStepSize(double dtMax_) {dtMax = dtMax_;}
00072       const fmatvec::Vec& getAbsoluteTolerance() const { return aTol; }
00073       const fmatvec::Vec& getRelativeTolerance() const { return rTol; }
00074       double getInitialStepSize() const { return dt0; }
00075       int getMaxStepNumber() const { return maxSteps; }
00076       double getMaximalStepSize() const { return dtMax; }
00077 
00078       void integrate(MBSim::DynamicSystemSolver& system);
00079 
00080       virtual void initializeUsingXML(xercesc::DOMElement *element);
00081       virtual xercesc::DOMElement* writeXMLFile(xercesc::DOMNode *element);
00082 
00083       using Integrator::writeXMLFile;
00084 
00085       virtual std::string getType() const { return "DOPRI5Integrator"; }
00086   };
00087 
00088 }
00089 
00090 #endif