MBSim

Project Page
integrator.h
00001 /* Copyright (C) 2004-2014 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 <mbsim/solver.h>
00028 #include <string>
00029 #include <iostream>
00030 
00031 namespace MBSimIntegrator {
00032 
00033   const MBXMLUtils::NamespaceURI MBSIMINT("http://mbsim.berlios.de/MBSimIntegrator");
00034 
00040   class Integrator : public MBSim::Solver {
00041     public:
00045       Integrator();
00046       
00050       virtual ~Integrator() {};
00051       
00052       /* GETTER / SETTER */
00053       void setStartTime(double tStart_) { tStart=tStart_; }
00054       void setEndTime(double tEnd_) { tEnd = tEnd_; }
00055       void setPlotStepSize(double dtPlot_) { dtPlot = dtPlot_; }
00056       void setInitialState(const fmatvec::Vec &z0_) { z0 = z0_; }
00057       void setWarnLevel(int level) { warnLevel = level; }
00058       void setOutput(bool flag) { output = flag; }
00059       double getStartTime() const { return tStart; }
00060       double getEndTime() const { return tEnd; }
00061       double getPlotStepSize() const { return dtPlot; }
00062       const fmatvec::Vec& getInitialState() const { return z0; }
00063       int getWarnLevel() const { return warnLevel; }
00064       bool getOutput() const { return output; }
00065       /***************************************************/
00066       
00067       void execute(MBSim::DynamicSystemSolver& system) { integrate(system); }
00068 
00069       /* INTERFACE FOR DERIVED CLASSES */
00075       virtual void integrate(MBSim::DynamicSystemSolver& system) = 0;
00076 
00082       void debugInit();
00083 
00084       virtual void preIntegrate(MBSim::DynamicSystemSolver& system) { throw MBSim::MBSimError("preIntegrate is not defined"); }
00085       virtual void subIntegrate(MBSim::DynamicSystemSolver& system, double tStop) { throw MBSim::MBSimError("subIntegrate is not defined"); }
00086       virtual void postIntegrate(MBSim::DynamicSystemSolver& system) { throw MBSim::MBSimError("postIntegrate is not defined"); }
00087 
00092       virtual void initializeUsingXML(xercesc::DOMElement *element);
00093       virtual xercesc::DOMElement* writeXMLFile(xercesc::DOMNode *element);
00094 
00095       static Integrator* readXMLFile(const std::string &filename);
00096       void writeXMLFile(const std::string &name);
00097       void writeXMLFile() { writeXMLFile(getType()); }
00098 
00099       /***************************************************/
00100 
00104       virtual std::string getType() const { return "Integrator"; }
00105 
00106     protected:
00110       double tStart, tEnd, dtPlot;
00111 
00115       fmatvec::Vec z0;
00116 
00120       int warnLevel;
00121 
00125       bool output;
00126 
00130       std::string name;
00131 
00132   };
00133 
00134 }
00135 
00136 #endif /* _INTEGRATOR_H_ */
00137