All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
auto_time_stepping_ssc_integrator.h
1 /* Copyright (C) 2004-2009 MBSim Development Team
2 
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation; either
6  * version 2.1 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16  *
17  * Contact:
18  * jan.p.clauberg@googlemail.com
19  * huber@amm.mw.tum.de
20  */
21 
22 #ifndef _AUTO_TIME_STEPPING_SSC_INTEGRATOR_H_
23 #define _AUTO_TIME_STEPPING_SSC_INTEGRATOR_H_
24 
25 #include "integrator.h"
26 #include "mbsim/utils/stopwatch.h"
27 
28 namespace MBSim {
29  class Link;
30 }
31 
32 namespace MBSimIntegrator {
33 
94 
95  protected:
100 
101  double dt, dtOld, dte;
102  double dtMin, dtMax;
103  double dt_SSC_vorGapControl;
104  bool driftCompensation;
105  double t, tPlot, tPlotP;
106  int qSize, xSize, uSize, zSize;
107  fmatvec::Vec ze, zeP, zi, ziP, zT1, zT2, zT3, zTP, z1d, z2d, z2dRE, z3d, z4d, z6d, z2b, z3b, z4b, z6b, zStern;
108 
109  fmatvec::VecInt LS, LSe, LSA, LSB1, LSB2, LSC1, LSC2, LSC3, LSC4, LSD1, LSD2, LSD3, LSD4, LSD5, LSD6;
110  fmatvec::VecInt LS_Reg, LSe_Reg, LSA_Reg, LSB1_Reg, LSB2_Reg, LSC1_Reg, LSC2_Reg, LSC3_Reg, LSC4_Reg, LSD1_Reg, LSD2_Reg, LSD3_Reg, LSD4_Reg, LSD5_Reg, LSD6_Reg;
111  fmatvec::VecInt LS_Reg_T1, LS_Reg_T2, LS_Reg_T3;
112  fmatvec::VecInt LS_Reg_z2b, S_Reg_z1d, LS_Reg_z4b, LS_Reg_z6b, LS_Reg_z1d, LS_Reg_z3b, LSB1_2_Reg;
113  fmatvec::VecInt LS_tmp;
114 
115  fmatvec::Vec la, laP, lae, laeP, la1d, la2b;
116  fmatvec::VecInt laSizes, laSizesP, laeSizes, laeSizesP, la1dSizes, la2bSizes;
117  fmatvec::Vec qT1, qT2, qT3, qTP;
118  fmatvec::Vec uT1, uT2, uT3, uTP;
119  fmatvec::Vec xT1, xT2, xT3, xTP;
120  fmatvec::Vec gInActive, gdInActive;
121  std::vector<MBSim::Link*> SetValuedLinkListT1;
122  std::vector<MBSim::Link*> SetValuedLinkListT2;
123  std::vector<MBSim::Link*> SetValuedLinkListT3;
124  std::vector<MBSim::Link*> SetValuedLinkListTP;
125 
126  int StepsWithUnchangedConstraints;
127 
130 
133 
136 
139 
141  bool FlagSSC;
142 
146  int maxOrder;
147 
152  int method;
153 
154  /* Flag for Gap Control - Gap Control not available for implicit integration*/
155  bool FlagGapControl;
156 
158  double gapTol;
159 
161  double maxGainSSC;
162 
165 
167  std::ofstream integPlot;
168 
171 
174 
177 
180 
183 
186 
195 
197  int numThreads, numThreadsB1;
198 
200  double time, dhdztime, timeB1, timeB2, timePlot, timePlotPar;
201 
203  MBSim::StopWatch Timer, dhdzTimer, TimerB1, TimerB2, TimerPlot, TimerPlotPar;
204 
206  int iter, iterA, iterB1, iterB2, iterC1, iterC2, iterC3, iterC4, iterB2RE, maxIterUsed, maxIter, sumIter;
207 
209  int integrationSteps, integrationStepswithChange, refusedSteps, refusedStepsWithImpact;
210 
212  int JacUpdateT1, JacUpdateT2, JacUpdateT3;
213 
215  int wrongAlertGapControl, stepsOkAfterGapControl, stepsRefusedAfterGapControl, statusGapControl;
216 
218  int singleStepsT1, singleStepsT2, singleStepsT3;
219 
221  double dtRelGapControl, qUncertaintyByExtrapolation;
222  int indexLSException;
223  fmatvec::Vec gUniActive;
224  double Penetration, PenetrationCounter, PenetrationLog, PenetrationMin, PenetrationMax;
225  double maxdtUsed, mindtUsed;
226  bool ChangeByGapControl;
227  bool calcBlock2;
228  bool IterConvergence;
229  bool ConstraintsChanged, ConstraintsChangedBlock1, ConstraintsChangedBlock2, ConstraintsChanged_B1_A;
230  int integrationStepsOrder1, integrationStepsOrder2;
231  int order;
232  int StepTrials;
233  int AnzahlAktiverKontakte;
234  double gNDurchschnittprostep;
235 
237  int iter_T1, iter_T2, iter_T3, step;
238 
239  fmatvec::RangeV Iq, Iu, Ix;
240 
242  bool expInt;
243 
245  int it_T1, it_T2, it_T3;
246 
248  bool gAC_T1, gAC_T2, gAC_T3, gAC_reg_T1, gAC_reg_T2, gAC_reg_T3;
249 
251  bool upgedated_T1, upgedated_T2, upgedated_T3;
252 
254  bool JacUpdate_B1_T1, JacUpdate_B2_T1, JacUpdate_B1_T2, JacUpdate_B2_T2, JacUpdate_T1, JacUpdate_T2;
255 
257  int itMax;
258 
260  double itTol;
261 
263  fmatvec::Mat dhdq_n_T1, dhdu_n_T1, dhdq_n_T2, dhdu_n_T2, dhdq_n_T3, dhdu_n_T3, dhdq_T1, dhdu_T1, dhdq_T2, dhdu_T2, dhdq_T3, dhdu_T3;
264  fmatvec::Mat dhdq_z1d, dhdu_z1d, dhdq_z2b, dhdq_z3b, dhdq_z4b, dhdq_z6b, dhdu_z2b, dhdu_z3b, dhdu_z4b, dhdu_z6b, dhdq_end, dhdu_end, dhdq_z2d, dhdu_z2d, dhdq_z2dRE, dhdu_z2dRE, dhdq_z3d, dhdu_z3d, dhdq_z4d, dhdu_z4d, dhdq_z6d, dhdu_z6d;
265 
267  double theta;
268 
269  bool parJac;
270  bool parInt;
271 
272  std::vector<MBSim::DynamicSystemSolver*> *psystems;
273 
276 
277  int maxImpIter;
278  int JacConstSteps;
279 
282 
285 
288 
289  // TODO delme
290  fmatvec::Mat JacVgl, JacVgl2, JacVgl3;
291 
294 
295  public:
296 
299 
302 
304  void setInitialStepSize(double dt_) {dt = dt_;}
305 
307  void setStepSizeMax(double dtMax_) {dtMax = dtMax_;}
308 
310  void setStepSizeMin(double dtMin_) {dtMin = dtMin_;}
311 
313  void setmaxGainSSC(double maxGain) {maxGainSSC = maxGain;}
314 
316  void setSafetyFactorSSC(double sfactor) {safetyFactorSSC=sfactor;}
317  void setSafetyFactorGapControl(double s){safetyFactorGapControl=s;}
318 
320  void setOutputInterpolation(bool flag=true) {outputInterpolation = flag;}
321 
323  void setFlagPlotIntegrator(bool flag=true) {FlagPlotIntegrator = flag;}
324 
334  void setGapControl(int strategy=1) {FlagGapControl=(strategy>=0); GapControlStrategy=(strategy<0)?0:strategy; }
335 
337  void setDriftCompensation(bool dc) {driftCompensation = dc;}
338 
343  void setMaxOrder(int order_, int method_=0);
344 
345  /* deactivate step size control */
346  void deactivateSSC(bool flag=false) {FlagSSC=flag;}
347 
352  void setFlagErrorTest(int Flag, bool alwaysValid=true);
353 
355  void integrate(MBSim::DynamicSystemSolver& system_);
356  void integrate(MBSim::DynamicSystemSolver& system_, std::vector<MBSim::DynamicSystemSolver*> systems);
357 
358  void integrate(MBSim::DynamicSystemSolver& systemT1_, MBSim::DynamicSystemSolver& systemT2_, MBSim::DynamicSystemSolver& systemT3_, MBSim::DynamicSystemSolver& systemTP_, int Threads=0);
359  void integrate(MBSim::DynamicSystemSolver& systemT1_, MBSim::DynamicSystemSolver& systemT2_, MBSim::DynamicSystemSolver& systemT3_, MBSim::DynamicSystemSolver& systemTP_, std::vector<MBSim::DynamicSystemSolver*> systems, int Threads=0);
360 
362  void setAbsoluteTolerance(const fmatvec::Vec &aTol_) {aTol.resize() = aTol_;}
363  void setAbsoluteTolerance(double aTol_) {aTol.resize() = fmatvec::Vec(1,fmatvec::INIT,aTol_);}
364  void setRelativeTolerance(const fmatvec::Vec &rTol_) {rTol.resize() = rTol_;}
365  void setRelativeTolerance(double rTol_) {rTol.resize() = fmatvec::Vec(1,fmatvec::INIT,rTol_);}
366  void setgapTolerance(double gTol) {gapTol = gTol;}
367 
370  void subIntegrate(MBSim::DynamicSystemSolver& system, double tStop);
371  void postIntegrate(MBSim::DynamicSystemSolver& system);
373 
375  void getAllSetValuedla(fmatvec::Vec& la_,fmatvec::VecInt& la_Sizes,std::vector<MBSim::Link*> &SetValuedLinkList);
376  void setAllSetValuedla(const fmatvec::Vec& la_,const fmatvec::VecInt& la_Sizes,std::vector<MBSim::Link*> &SetValuedLinkList);
377  void getDataForGapControl();
378  bool testTolerances();
379  bool GapControl(double qUnsafe, bool SSCTestOK);
380  bool changedLinkStatus(const fmatvec::VecInt &L1, const fmatvec::VecInt &L2, int ex);
381  double calculatedtNewRel(const fmatvec::Vec &ErrorLocal, double H);
382  void plot();
383  void plotPar();
384  void doIntegPlot();
385 
386  virtual void initializeUsingXML(xercesc::DOMElement *element);
387 
395  void update(MBSim::DynamicSystemSolver& system, const fmatvec::Vec& z, double t, int nrSys_=1);
396 
397  void doStep(MBSim::DynamicSystemSolver& system_, fmatvec::Vec& z_, int nrSys_, double t_, double dt_, bool exp_);
398 
407  void doExpStep(MBSim::DynamicSystemSolver& system_, fmatvec::Vec& z_, int nrSys_, double t_, double dt_);
408 
417  void doImpStep(MBSim::DynamicSystemSolver& system_, fmatvec::Vec& z_, int nrSys_, double t_, double dt_);
418 
427  void doLinImpStep(MBSim::DynamicSystemSolver& system_, fmatvec::Vec& z_, int nrSys_, double t_, double dt_);
428 
430  void setTheta(double theta_ ) { theta = theta_; }
431 
433  void getdhdqdhdu(fmatvec::Mat& dhdq_, fmatvec::Mat& dhdu_, const fmatvec::Vec z_, const double t_, const int nsys_);
434 
436  void setItMax(int itMax_) {itMax = itMax_;}
437 
439  void setInexactJac(bool inexactJac_) {inexactJac = inexactJac_;}
440 
442  void setItTol(double itTol_) {itTol = itTol_;}
443 
445  void setSetValuedForceLawsExplicit(bool SetValuedForceLawsExplicit_) {SetValuedForceLawsExplicit = SetValuedForceLawsExplicit_;}
446 
448  void setDebugOutput(bool debugOutput_) {debugOutput = debugOutput_;}
449 
451  void setPlotParallel(bool plotParallel_) {plotParallel = plotParallel_;}
452  };
453 
454 }
455 
456 #endif
std::ofstream integPlot
Definition: auto_time_stepping_ssc_integrator.h:167
bool outputInterpolation
Definition: auto_time_stepping_ssc_integrator.h:182
bool plotParallel
Definition: auto_time_stepping_ssc_integrator.h:287
void setInitialStepSize(double dt_)
Definition: auto_time_stepping_ssc_integrator.h:304
void setItMax(int itMax_)
Definition: auto_time_stepping_ssc_integrator.h:436
void getdhdqdhdu(fmatvec::Mat &dhdq_, fmatvec::Mat &dhdu_, const fmatvec::Vec z_, const double t_, const int nsys_)
Definition: auto_time_stepping_ssc_integrator.cc:107
int integrationSteps
Definition: auto_time_stepping_ssc_integrator.h:209
double dtRelGapControl
Definition: auto_time_stepping_ssc_integrator.h:221
Vector< Ref, double > Vec
void setAbsoluteTolerance(const fmatvec::Vec &aTol_)
Definition: auto_time_stepping_ssc_integrator.h:362
int iter_T1
Definition: auto_time_stepping_ssc_integrator.h:237
int method
Definition: auto_time_stepping_ssc_integrator.h:152
solver interface for modelling and simulation of dynamic systems
Definition: dynamic_system_solver.h:48
bool JacUpdate_B1_T1
Definition: auto_time_stepping_ssc_integrator.h:254
int itMax
Definition: auto_time_stepping_ssc_integrator.h:257
void doExpStep(MBSim::DynamicSystemSolver &system_, fmatvec::Vec &z_, int nrSys_, double t_, double dt_)
Do One Explicit Time Integration Step.
Definition: auto_time_stepping_ssc_integrator.cc:289
void setDebugOutput(bool debugOutput_)
Definition: auto_time_stepping_ssc_integrator.h:448
bool FlagSSC
Definition: auto_time_stepping_ssc_integrator.h:141
void update(MBSim::DynamicSystemSolver &system, const fmatvec::Vec &z, double t, int nrSys_=1)
special update of dynamic system for theta time stepping integrator
Definition: auto_time_stepping_ssc_integrator.cc:230
AutoTimeSteppingSSCIntegrator()
Definition: auto_time_stepping_ssc_integrator.cc:46
void setMaxOrder(int order_, int method_=0)
Definition: auto_time_stepping_ssc_integrator.cc:97
double itTol
Definition: auto_time_stepping_ssc_integrator.h:260
void setGapControl(int strategy=1)
Definition: auto_time_stepping_ssc_integrator.h:334
double theta
Definition: auto_time_stepping_ssc_integrator.h:267
void setInexactJac(bool inexactJac_)
Definition: auto_time_stepping_ssc_integrator.h:439
int JacUpdateT1
Definition: auto_time_stepping_ssc_integrator.h:212
double gapTol
Definition: auto_time_stepping_ssc_integrator.h:158
double safetyFactorGapControl
Definition: auto_time_stepping_ssc_integrator.h:185
void setPlotParallel(bool plotParallel_)
Definition: auto_time_stepping_ssc_integrator.h:451
double maxGainSSC
Definition: auto_time_stepping_ssc_integrator.h:161
fmatvec::Vec aTol
Definition: auto_time_stepping_ssc_integrator.h:135
fmatvec::Vec rTol
Definition: auto_time_stepping_ssc_integrator.h:138
bool FlagPlotEveryStep
Definition: auto_time_stepping_ssc_integrator.h:179
~AutoTimeSteppingSSCIntegrator()
Definition: auto_time_stepping_ssc_integrator.cc:82
bool expInt
Definition: auto_time_stepping_ssc_integrator.h:242
bool inexactJac
Definition: auto_time_stepping_ssc_integrator.h:275
void doImpStep(MBSim::DynamicSystemSolver &system_, fmatvec::Vec &z_, int nrSys_, double t_, double dt_)
Do One Implicit Time Integration Step.
Definition: auto_time_stepping_ssc_integrator.cc:325
int JacCounter
Definition: auto_time_stepping_ssc_integrator.h:293
void setStepSizeMax(double dtMax_)
Definition: auto_time_stepping_ssc_integrator.h:307
void getAllSetValuedla(fmatvec::Vec &la_, fmatvec::VecInt &la_Sizes, std::vector< MBSim::Link * > &SetValuedLinkList)
Definition: auto_time_stepping_ssc_integrator.cc:2339
bool FlagErrorTestAlwaysValid
Definition: auto_time_stepping_ssc_integrator.h:132
bool debugOutput
Definition: auto_time_stepping_ssc_integrator.h:284
int FlagErrorTest
Definition: auto_time_stepping_ssc_integrator.h:129
void setStepSizeMin(double dtMin_)
Definition: auto_time_stepping_ssc_integrator.h:310
void setSetValuedForceLawsExplicit(bool SetValuedForceLawsExplicit_)
Definition: auto_time_stepping_ssc_integrator.h:445
void setDriftCompensation(bool dc)
Definition: auto_time_stepping_ssc_integrator.h:337
void setItTol(double itTol_)
Definition: auto_time_stepping_ssc_integrator.h:442
void preIntegrate(MBSim::DynamicSystemSolver &system)
Definition: auto_time_stepping_ssc_integrator.cc:707
Definition: stopwatch.h:35
bool FlagPlotIntegrator
Definition: auto_time_stepping_ssc_integrator.h:170
fmatvec::Mat dhdq_n_T1
Definition: auto_time_stepping_ssc_integrator.h:263
int numThreads
Definition: auto_time_stepping_ssc_integrator.h:197
bool FlagPlotIntegrationSum
Definition: auto_time_stepping_ssc_integrator.h:173
void setmaxGainSSC(double maxGain)
Definition: auto_time_stepping_ssc_integrator.h:313
void integrate(MBSim::DynamicSystemSolver &system_)
Definition: auto_time_stepping_ssc_integrator.cc:668
int it_T1
Definition: auto_time_stepping_ssc_integrator.h:245
void setFlagErrorTest(int Flag, bool alwaysValid=true)
Definition: auto_time_stepping_ssc_integrator.cc:89
int iter
Definition: auto_time_stepping_ssc_integrator.h:206
int GapControlStrategy
Definition: auto_time_stepping_ssc_integrator.h:194
Explicit and Implicit time-stepping integrator of first or higer order with StepSize Control (SSC) St...
Definition: auto_time_stepping_ssc_integrator.h:93
double safetyFactorSSC
Definition: auto_time_stepping_ssc_integrator.h:164
bool FlagCoutInfo
Definition: auto_time_stepping_ssc_integrator.h:176
bool gAC_T1
Definition: auto_time_stepping_ssc_integrator.h:248
int singleStepsT1
Definition: auto_time_stepping_ssc_integrator.h:218
bool upgedated_T1
Definition: auto_time_stepping_ssc_integrator.h:251
bool SetValuedForceLawsExplicit
Definition: auto_time_stepping_ssc_integrator.h:281
int maxOrder
Definition: auto_time_stepping_ssc_integrator.h:146
void setSafetyFactorSSC(double sfactor)
Definition: auto_time_stepping_ssc_integrator.h:316
void setTheta(double theta_)
Definition: auto_time_stepping_ssc_integrator.h:430
integrator-interface for dynamic systems
Definition: integrator.h:40
void doLinImpStep(MBSim::DynamicSystemSolver &system_, fmatvec::Vec &z_, int nrSys_, double t_, double dt_)
Do One Linear Implicit Time Integration Step.
Definition: auto_time_stepping_ssc_integrator.cc:538
MBSim::StopWatch Timer
Definition: auto_time_stepping_ssc_integrator.h:203
void setFlagPlotIntegrator(bool flag=true)
Definition: auto_time_stepping_ssc_integrator.h:323
static DynamicSystemSolver * system
dynamic system
Definition: solver.h:65
int wrongAlertGapControl
Definition: auto_time_stepping_ssc_integrator.h:215
virtual void initializeUsingXML(xercesc::DOMElement *element)
initialize integrator
Definition: auto_time_stepping_ssc_integrator.cc:2408
double time
Definition: auto_time_stepping_ssc_integrator.h:200
void setOutputInterpolation(bool flag=true)
Definition: auto_time_stepping_ssc_integrator.h:320

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML