00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _TIME_STEPPING_SSC_INTEGRATOR_H_
00022 #define _TIME_STEPPING_SSC_INTEGRATOR_H_
00023
00024 #include "integrator.h"
00025 #include "mbsim/utils/stopwatch.h"
00026
00027 namespace MBSim {
00028 class Link;
00029 }
00030
00031 namespace MBSimIntegrator {
00032
00067 class TimeSteppingSSCIntegrator : public Integrator {
00068
00069 protected:
00070 MBSim::DynamicSystemSolver* sysT1;
00071 MBSim::DynamicSystemSolver* sysT2;
00072 MBSim::DynamicSystemSolver* sysT3;
00073
00074 double dt, dtOld, dte;
00075 double dtMin, dtMax;
00076 double dt_SSC_vorGapControl;
00077 bool driftCompensation;
00078 double t, tPlot;
00079 int qSize, xSize, uSize, zSize;
00080 fmatvec::Vec ze, zi, zT1, zT2, zT3, z1d, z2d, z2dRE, z3d, z4d, z6d, z2b, z3b, z4b, z6b, zStern;
00081 fmatvec::VecInt LS, LSe, LStmp_T1, LStmp_T2, LStmp_T3, LSA, LSB1, LSB2, LSC1, LSC2, LSC3, LSC4, LSD1, LSD2, LSD3, LSD4, LSD5, LSD6;
00082 fmatvec::Vec la, lae, la1d, la2b;
00083 fmatvec::VecInt laSizes, laeSizes, la1dSizes, la2bSizes;
00084 fmatvec::Vec qT1, qT2, qT3;
00085 fmatvec::Vec uT1, uT2, uT3;
00086 fmatvec::Vec xT1, xT2, xT3;
00087 fmatvec::Vec gInActive, gdInActive;
00088 std::vector<MBSim::Link*> SetValuedLinkListT1;
00089 std::vector<MBSim::Link*> SetValuedLinkListT2;
00090 std::vector<MBSim::Link*> SetValuedLinkListT3;
00091
00092 int StepsWithUnchangedConstraints;
00093
00095 int FlagErrorTest;
00097 bool FlagErrorTestAlwaysValid;
00099 fmatvec::Vec aTol;
00101 fmatvec::Vec rTol;
00103 bool FlagSSC;
00107 int maxOrder;
00112 int method;
00113
00114 bool FlagGapControl;
00116 double gapTol;
00118 double maxGainSSC;
00120 double safetyFactorSSC;
00122 std::ofstream integPlot;
00124 bool FlagPlotIntegrator;
00126 bool FlagPlotIntegrationSum;
00128 bool FlagCoutInfo;
00130 bool FlagOutputOnlyAtTPlot;
00132 bool FlagPlotEveryStep;
00134 bool outputInterpolation;
00136 double safetyFactorGapControl;
00144 int GapControlStrategy;
00146 int numThreads;
00148 double time;
00150 MBSim::StopWatch Timer;
00151 int iter, iterA, iterB1, iterB2, iterC1, iterC2, iterC3, iterC4, iterB2RE, maxIterUsed, maxIter, sumIter;
00152 int integrationSteps, integrationStepswithChange, refusedSteps, refusedStepsWithImpact;
00153 int wrongAlertGapControl, stepsOkAfterGapControl, stepsRefusedAfterGapControl, statusGapControl;
00154 int singleStepsT1, singleStepsT2, singleStepsT3;
00155 double dtRelGapControl, qUncertaintyByExtrapolation;
00156 int indexLSException;
00157 fmatvec::Vec gUniActive;
00158 double Penetration, PenetrationCounter, PenetrationLog, PenetrationMin, PenetrationMax;
00159 double maxdtUsed, mindtUsed;
00160 bool ChangeByGapControl;
00161 bool calcBlock2;
00162 bool IterConvergence;
00163 bool ConstraintsChanged, ConstraintsChangedBlock1, ConstraintsChangedBlock2;
00164 int integrationStepsOrder1;
00165 int integrationStepsOrder2;
00166 int order;
00167 int StepTrials;
00168 int AnzahlAktiverKontakte;
00169 double gNDurchschnittprostep;
00170
00171 public:
00173 TimeSteppingSSCIntegrator();
00175 ~TimeSteppingSSCIntegrator();
00177 void setInitialStepSize(double dt_) {dt = dt_;}
00179 void setStepSizeMax(double dtMax_) {dtMax = dtMax_;}
00181 void setStepSizeMin(double dtMin_) {dtMin = dtMin_;}
00183 void setmaxGainSSC(double maxGain) {maxGainSSC = maxGain;}
00185 void setSafetyFactorSSC(double sfactor) {safetyFactorSSC=sfactor;}
00186 void setSafetyFactorGapControl(double s){safetyFactorGapControl=s;}
00188 void setOutputInterpolation(bool flag=true) {outputInterpolation = flag;}
00190 void setFlagPlotIntegrator(bool flag=true) {FlagPlotIntegrator = flag;}
00192 void setFlagOutputOnlyAtTPlot(bool flag=true) {FlagOutputOnlyAtTPlot = flag;}
00202 void setGapControl(int strategy=1) {FlagGapControl=(strategy>=0); GapControlStrategy=(strategy<0)?0:strategy; }
00204 void setDriftCompensation(bool dc) {driftCompensation = dc;}
00209 void setMaxOrder(int order_, int method_=0);
00210
00211 void deactivateSSC(bool flag=false) {FlagSSC=flag;}
00216 void setFlagErrorTest(int Flag, bool alwaysValid=true);
00217
00219 void integrate(MBSim::DynamicSystemSolver& system_);
00221 void integrate(MBSim::DynamicSystemSolver& systemT1_, MBSim::DynamicSystemSolver& systemT2_, MBSim::DynamicSystemSolver& systemT3_, int Threads=0);
00222
00223 void setAbsoluteTolerance(const fmatvec::Vec &aTol_) {aTol = aTol_;}
00224 void setAbsoluteTolerance(double aTol_) {aTol = fmatvec::Vec(1,fmatvec::INIT,aTol_);}
00225 void setRelativeTolerance(const fmatvec::Vec &rTol_) {rTol = rTol_;}
00226 void setRelativeTolerance(double rTol_) {rTol = fmatvec::Vec(1,fmatvec::INIT,rTol_);}
00227 void setgapTolerance(double gTol) {gapTol = gTol;}
00228
00231 void preIntegrate(MBSim::DynamicSystemSolver& system);
00232 void subIntegrate(MBSim::DynamicSystemSolver& system, double tStop);
00233 void postIntegrate(MBSim::DynamicSystemSolver& system);
00234 void preIntegrate(MBSim::DynamicSystemSolver& systemT1_, MBSim::DynamicSystemSolver& systemT2_, MBSim::DynamicSystemSolver& systemT3_);
00235
00237 void getAllSetValuedla(fmatvec::Vec& la_,fmatvec::VecInt& la_Sizes,std::vector<MBSim::Link*> &SetValuedLinkList);
00238 void setAllSetValuedla(const fmatvec::Vec& la_,const fmatvec::VecInt& la_Sizes,std::vector<MBSim::Link*> &SetValuedLinkList);
00239 void getDataForGapControl();
00240 bool testTolerances();
00241 bool GapControl(double qUnsafe, bool SSCTestOK);
00242 bool changedLinkStatus(const fmatvec::VecInt &L1, const fmatvec::VecInt &L2, int ex);
00243 double calculatedtNewRel(const fmatvec::Vec &ErrorLocal, double H);
00244 void plot();
00245
00246 virtual void initializeUsingXML(xercesc::DOMElement *element);
00247 };
00248
00249 }
00250
00251 #endif