MBSim

Project Page
quasi_static_integrator.h
00001 /* Copyright (C) 2004-2010 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 _QUASI_STATIC_INTEGRATOR_H_
00021 #define _QUASI_STATIC_INTEGRATOR_H_
00022 
00023 #include "integrator.h"
00024 #include "mbsim/functions/function.h"
00025 #include<mbsim/dynamic_system_solver.h>
00026 
00027 namespace MBSimIntegrator {
00028 
00034   class hgFun : public MBSim::Function<fmatvec::Vec(fmatvec::Vec)> {
00035     public:
00039       hgFun(MBSim::DynamicSystemSolver* sys_) :
00040           sys(sys_), t(0) {
00041       }
00042 
00046       virtual ~hgFun() {
00047       }
00048       ;
00049 
00050       /* INHERITED INTERFACE */
00051       fmatvec::Vec operator()(const fmatvec::Vec& qla);
00052 
00053       void setT(double t) {
00054         this->t = t;
00055       }
00056 
00057       /*******************************************************/
00058 
00059     private:
00060 
00061       MBSim::DynamicSystemSolver* sys;
00062       double t;
00063 
00064   };
00065 
00071   class jacFun : public MBSim::Function<fmatvec::SqrMat(fmatvec::Vec)> {
00072     public:
00076       jacFun(MBSim::DynamicSystemSolver* sys_, double t_, fmatvec::Vec& z_) :
00077           sys(sys_), t(t_), z(z_) {
00078       }
00079 
00083       virtual ~jacFun() {
00084       }
00085       ;
00086 
00087       /* INHERITED INTERFACE */
00088       fmatvec::SqrMat operator()(const fmatvec::Vec& q);
00089       /*******************************************************/
00090 
00091     private:
00092 
00093       MBSim::DynamicSystemSolver* sys;
00094       double t;
00095       fmatvec::Vec z;
00096 
00097   };
00103   class QuasiStaticIntegrator : public Integrator {
00104     public:
00108       QuasiStaticIntegrator();
00109 
00113       virtual ~QuasiStaticIntegrator() {
00114       }
00115 
00116       void preIntegrate(MBSim::DynamicSystemSolver& system);
00117       void subIntegrate(MBSim::DynamicSystemSolver& system, double tStop);
00118       void postIntegrate(MBSim::DynamicSystemSolver& system);
00119 
00120       /* INHERITED INTERFACE OF INTEGRATOR */
00121       virtual void integrate(MBSim::DynamicSystemSolver& system);
00122       virtual void initializeUsingXML(xercesc::DOMElement *element);
00123       /***************************************************/
00124 
00125       /* GETTER / SETTER */
00126       void setStepSize(double dt_) {
00127         dt = dt_;
00128       }
00129       void setgTolerance(double tolerance_) {
00130         gTol = tolerance_;
00131       }
00132       void sethTolerance(double tolerance_) {
00133         hTol = tolerance_;
00134       }
00135       void setmaxExtraPolate(int value) {
00136         maxExtraPolate = value;
00137       }
00138       void setextraPolateAfter(int value) {
00139         extraPolateAfter = value;
00140       }
00141       void setupdateJacobianEvery(int value) {
00142         updateJacobianEvery = value;
00143       }
00144       /***************************************************/
00145 
00146     private:
00150       double dt;
00151 
00155       double t, tPlot;
00156 
00160       double gTol;
00161 
00165       double hTol;
00166 
00170       int iter, step, integrationSteps, maxIter, sumIter;
00171 
00175       int maxExtraPolate;
00176 
00180       int extraPolateAfter;
00181 
00185       int updateJacobianEvery;
00186 
00190       double s0, time;
00191 
00195       int stepPlot;
00196 
00200       fmatvec::Vec z, q, u, x;
00201 
00205       std::ofstream integPlot;
00206   };
00207 
00208 }
00209 
00210 #endif /* _QUASI_STATIC_INTEGRATOR_H_ */
00211