00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _INTEGRATOR_H_
00021 #define _INTEGRATOR_H_
00022
00023 #define MBSIMINTNS_ "http://mbsim.berlios.de/MBSimIntegrator"
00024 #define MBSIMINTNS "{"MBSIMINTNS_"}"
00025
00026 #include<fmatvec/fmatvec.h>
00027 #include"mbxmlutilstinyxml/tinyxml.h"
00028 #include<string>
00029 #include<iostream>
00030
00031 namespace MBSim {
00032
00033 class DynamicSystemSolver;
00034
00040 class Integrator {
00041 public:
00045 Integrator();
00046
00050 virtual ~Integrator() {};
00051
00052
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
00073 virtual void integrate(DynamicSystemSolver& system) = 0;
00074
00080 void debugInit();
00081
00082 virtual void preIntegrate(DynamicSystemSolver& system) { std::cerr<<"preIntegrate is not defined\n"<<std::endl; }
00083 virtual void subIntegrate(DynamicSystemSolver& system, double tStop) { std::cerr<<"subIntegrate is not defined\n"<<std::endl; }
00084 virtual void postIntegrate(DynamicSystemSolver& system) { std::cerr<<"postIntegrate is not defined\n"<<std::endl; }
00085
00090 virtual void initializeUsingXML(MBXMLUtils::TiXmlElement *element);
00091 virtual MBXMLUtils::TiXmlElement* writeXMLFile(MBXMLUtils::TiXmlNode *element);
00092
00093 static Integrator* readXMLFile(const std::string &filename);
00094 void writeXMLFile(const std::string &name);
00095 void writeXMLFile() { writeXMLFile(getType()); }
00096
00097
00098
00102 virtual std::string getType() const { return "Integrator"; }
00103
00104 protected:
00108 static DynamicSystemSolver* system;
00109
00113 double tStart, tEnd, dtPlot;
00114
00118 fmatvec::Vec z0;
00119
00123 int warnLevel;
00124
00128 bool output;
00129
00133 std::string name;
00134
00135 };
00136
00137 }
00138
00139 #endif
00140