MBSim

Project Page
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 _INTEGRATOR_H_
00021 #define _INTEGRATOR_H_
00022 
00023 #include <fmatvec/fmatvec.h>
00024 #include <fmatvec/atom.h>
00025 #include <mbxmlutilshelper/dom.h>
00026 #include <mbsim/mbsim_event.h>
00027 #include <string>
00028 #include <iostream>
00029 
00030 namespace MBSim {
00031 
00032   const MBXMLUtils::NamespaceURI MBSIMINT("http://mbsim.berlios.de/MBSimIntegrator");
00033 
00034   class DynamicSystemSolver;
00035 
00041   class Integrator : public fmatvec::Atom {
00042     public:
00046       Integrator();
00047       
00051       virtual ~Integrator() {};
00052       
00053       /* GETTER / SETTER */
00054       void setStartTime(double tStart_) { tStart=tStart_; }
00055       void setEndTime(double tEnd_) { tEnd = tEnd_; }
00056       void setPlotStepSize(double dtPlot_) { dtPlot = dtPlot_; }
00057       void setInitialState(const fmatvec::Vec &z0_) { z0 = z0_; }
00058       void setWarnLevel(int level) { warnLevel = level; }
00059       void setOutput(bool flag) { output = flag; }
00060       double getStartTime() const { return tStart; }
00061       double getEndTime() const { return tEnd; }
00062       double getPlotStepSize() const { return dtPlot; }
00063       const fmatvec::Vec& getInitialState() const { return z0; }
00064       int getWarnLevel() const { return warnLevel; }
00065       bool getOutput() const { return output; }
00066       /***************************************************/
00067       
00068       /* INTERFACE FOR DERIVED CLASSES */
00074       virtual void integrate(DynamicSystemSolver& system) = 0;
00075 
00081       void debugInit();
00082 
00083       virtual void preIntegrate(DynamicSystemSolver& system) { throw MBSimError("preIntegrate is not defined"); }
00084       virtual void subIntegrate(DynamicSystemSolver& system, double tStop) { throw MBSimError("subIntegrate is not defined"); }
00085       virtual void postIntegrate(DynamicSystemSolver& system) { throw MBSimError("postIntegrate is not defined"); }
00086 
00091       virtual void initializeUsingXML(xercesc::DOMElement *element);
00092       virtual xercesc::DOMElement* writeXMLFile(xercesc::DOMNode *element);
00093 
00094       static Integrator* readXMLFile(const std::string &filename);
00095       void writeXMLFile(const std::string &name);
00096       void writeXMLFile() { writeXMLFile(getType()); }
00097 
00098       /***************************************************/
00099 
00103       virtual std::string getType() const { return "Integrator"; }
00104 
00105     protected:
00109       static DynamicSystemSolver* system;
00110 
00114       double tStart, tEnd, dtPlot;
00115 
00119       fmatvec::Vec z0;
00120 
00124       int warnLevel;
00125 
00129       bool output;
00130 
00134       std::string name;
00135 
00136   };
00137 
00138 }
00139 
00140 #endif /* _INTEGRATOR_H_ */
00141