mbsim  4.0.0
MBSim Kernel
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
28namespace MBSim {
29 class Link;
30}
31
32namespace MBSim {
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
135 fmatvec::Vec aTol;
136
138 fmatvec::Vec rTol;
139
142
147
153
154 /* Flag for Gap Control - Gap Control not available for implicit integration*/
155 bool FlagGapControl;
156
158 double gapTol;
159
162
165
167 std::ofstream integPlot;
168
171
174
177
180
183
192
194 int numThreads, numThreadsB1;
195
197 double time, dhdztime, timeB1, timeB2, timePlot, timePlotPar;
198
200 MBSim::StopWatch Timer, dhdzTimer, TimerB1, TimerB2, TimerPlot, TimerPlotPar;
201
203 int iter, iterA, iterB1, iterB2, iterC1, iterC2, iterC3, iterC4, iterB2RE, maxIterUsed, maxIter, sumIter;
204
206 int integrationSteps, integrationStepswithChange, refusedSteps, refusedStepsWithImpact;
207
209 int JacUpdateT1, JacUpdateT2, JacUpdateT3;
210
212 int wrongAlertGapControl, stepsOkAfterGapControl, stepsRefusedAfterGapControl, statusGapControl;
213
215 int singleStepsT1, singleStepsT2, singleStepsT3;
216
218 double dtRelGapControl, qUncertaintyByExtrapolation;
219 int indexLSException;
220 fmatvec::Vec gUniActive;
221 double Penetration, PenetrationCounter, PenetrationLog, PenetrationMin, PenetrationMax;
222 double maxdtUsed, mindtUsed;
223 bool ChangeByGapControl;
224 bool calcBlock2;
225 bool IterConvergence;
226 bool ConstraintsChanged, ConstraintsChangedBlock1, ConstraintsChangedBlock2, ConstraintsChanged_B1_A;
227 int integrationStepsOrder1, integrationStepsOrder2;
228 int order;
229 int StepTrials;
230 int AnzahlAktiverKontakte;
231 double gNDurchschnittprostep;
232
234 int iter_T1, iter_T2, iter_T3, step;
235
236 fmatvec::RangeV Iq, Iu, Ix;
237
239 bool expInt;
240
242 int it_T1, it_T2, it_T3;
243
245 bool gAC_T1, gAC_T2, gAC_T3, gAC_reg_T1, gAC_reg_T2, gAC_reg_T3;
246
248 bool upgedated_T1, upgedated_T2, upgedated_T3;
249
251 bool JacUpdate_B1_T1, JacUpdate_B2_T1, JacUpdate_B1_T2, JacUpdate_B2_T2, JacUpdate_T1, JacUpdate_T2;
252
254 int itMax;
255
257 double itTol;
258
260 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;
261 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;
262
264 double theta;
265
266 bool parJac;
267 bool parInt;
268
269 std::vector<MBSim::DynamicSystemSolver*> *psystems;
270
273
274 int maxImpIter;
275 int JacConstSteps;
276
279
282
283 // TODO delme
284 fmatvec::Mat JacVgl, JacVgl2, JacVgl3;
285
288
289 public:
290
293
296
298 void setInitialStepSize(double dt_) {dt = dt_;}
299
301 void setStepSizeMax(double dtMax_) {dtMax = dtMax_;}
302
304 void setStepSizeMin(double dtMin_) {dtMin = dtMin_;}
305
307 void setmaxGainSSC(double maxGain) {maxGainSSC = maxGain;}
308
310 void setSafetyFactorSSC(double sfactor) {safetyFactorSSC=sfactor;}
311 void setSafetyFactorGapControl(double s){safetyFactorGapControl=s;}
312
314 void setOutputInterpolation(bool flag=true) {outputInterpolation = flag;}
315
317 void setFlagPlotIntegrator(bool flag=true) {FlagPlotIntegrator = flag;}
318
328 void setGapControl(int strategy=1) {FlagGapControl=(strategy>=0); GapControlStrategy=(strategy<0)?0:strategy; }
329
331 void setDriftCompensation(bool dc) {driftCompensation = dc;}
332
337 void setMaxOrder(int order_, int method_=0);
338
339 /* deactivate step size control */
340 void deactivateSSC(bool flag=false) {FlagSSC=flag;}
341
346 void setFlagErrorTest(int Flag, bool alwaysValid=true);
347
350 void integrate(MBSim::DynamicSystemSolver& system_, std::vector<MBSim::DynamicSystemSolver*> systems);
351
352 void integrate(MBSim::DynamicSystemSolver& systemT1_, MBSim::DynamicSystemSolver& systemT2_, MBSim::DynamicSystemSolver& systemT3_, MBSim::DynamicSystemSolver& systemTP_, int Threads=0);
353 void integrate(MBSim::DynamicSystemSolver& systemT1_, MBSim::DynamicSystemSolver& systemT2_, MBSim::DynamicSystemSolver& systemT3_, MBSim::DynamicSystemSolver& systemTP_, std::vector<MBSim::DynamicSystemSolver*> systems, int Threads=0);
354
356 void setAbsoluteTolerance(const fmatvec::Vec &aTol_) {aTol <<= aTol_;}
357 void setAbsoluteTolerance(double aTol_) {aTol.resize(1,fmatvec::INIT,aTol_);}
358 void setRelativeTolerance(const fmatvec::Vec &rTol_) {rTol <<= rTol_;}
359 void setRelativeTolerance(double rTol_) {rTol.resize(1,fmatvec::INIT,rTol_);}
360 void setgapTolerance(double gTol) {gapTol = gTol;}
361
364 void subIntegrate(MBSim::DynamicSystemSolver& system, double tStop);
365 void postIntegrate(MBSim::DynamicSystemSolver& system);
367
369 void getAllSetValuedla(fmatvec::Vec& la_,fmatvec::VecInt& la_Sizes,std::vector<MBSim::Link*> &SetValuedLinkList);
370 void setAllSetValuedla(const fmatvec::Vec& la_,const fmatvec::VecInt& la_Sizes,std::vector<MBSim::Link*> &SetValuedLinkList);
371 void getDataForGapControl();
372 bool testTolerances();
373 bool GapControl(double qUnsafe, bool SSCTestOK);
374 bool changedLinkStatus(const fmatvec::VecInt &L1, const fmatvec::VecInt &L2, int ex);
375 double calculatedtNewRel(const fmatvec::Vec &ErrorLocal, double H);
376 void plot();
377 void plotPar();
378 void doIntegPlot();
379
380 virtual void initializeUsingXML(xercesc::DOMElement *element);
381
389 void update(MBSim::DynamicSystemSolver& system, const fmatvec::Vec& z, double t, int nrSys_=1);
390
391 void doStep(MBSim::DynamicSystemSolver& system_, fmatvec::Vec& z_, int nrSys_, double t_, double dt_, bool exp_);
392
401 void doExpStep(MBSim::DynamicSystemSolver& system_, fmatvec::Vec& z_, int nrSys_, double t_, double dt_);
402
411 void doImpStep(MBSim::DynamicSystemSolver& system_, fmatvec::Vec& z_, int nrSys_, double t_, double dt_);
412
421 void doLinImpStep(MBSim::DynamicSystemSolver& system_, fmatvec::Vec& z_, int nrSys_, double t_, double dt_);
422
424 void setTheta(double theta_ ) { theta = theta_; }
425
427 void getdhdqdhdu(fmatvec::Mat& dhdq_, fmatvec::Mat& dhdu_, const fmatvec::Vec z_, const double t_, const int nsys_);
428
430 void setItMax(int itMax_) {itMax = itMax_;}
431
433 void setInexactJac(bool inexactJac_) {inexactJac = inexactJac_;}
434
436 void setItTol(double itTol_) {itTol = itTol_;}
437
439 void setSetValuedForceLawsExplicit(bool SetValuedForceLawsExplicit_) {SetValuedForceLawsExplicit = SetValuedForceLawsExplicit_;}
440
442 void setPlotParallel(bool plotParallel_) {plotParallel = plotParallel_;}
443 };
444
445}
446
447#endif
Explicit and Implicit time-stepping integrator of first or higer order with StepSize Control (SSC) St...
Definition: auto_time_stepping_ssc_integrator.h:93
void setFlagPlotIntegrator(bool flag=true)
Definition: auto_time_stepping_ssc_integrator.h:317
void setInexactJac(bool inexactJac_)
Definition: auto_time_stepping_ssc_integrator.h:433
double time
Definition: auto_time_stepping_ssc_integrator.h:197
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:544
fmatvec::Vec rTol
Definition: auto_time_stepping_ssc_integrator.h:138
bool outputInterpolation
Definition: auto_time_stepping_ssc_integrator.h:179
bool FlagPlotEveryStep
Definition: auto_time_stepping_ssc_integrator.h:176
bool FlagSSC
Definition: auto_time_stepping_ssc_integrator.h:141
void setGapControl(int strategy=1)
Definition: auto_time_stepping_ssc_integrator.h:328
std::ofstream integPlot
Definition: auto_time_stepping_ssc_integrator.h:167
bool upgedated_T1
Definition: auto_time_stepping_ssc_integrator.h:248
int FlagErrorTest
Definition: auto_time_stepping_ssc_integrator.h:129
double itTol
Definition: auto_time_stepping_ssc_integrator.h:257
bool FlagErrorTestAlwaysValid
Definition: auto_time_stepping_ssc_integrator.h:132
bool plotParallel
Definition: auto_time_stepping_ssc_integrator.h:281
void setTheta(double theta_)
Definition: auto_time_stepping_ssc_integrator.h:424
AutoTimeSteppingSSCIntegrator()
Definition: auto_time_stepping_ssc_integrator.cc:45
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:287
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:327
int GapControlStrategy
Definition: auto_time_stepping_ssc_integrator.h:191
int it_T1
Definition: auto_time_stepping_ssc_integrator.h:242
int integrationSteps
Definition: auto_time_stepping_ssc_integrator.h:206
void setOutputInterpolation(bool flag=true)
Definition: auto_time_stepping_ssc_integrator.h:314
int singleStepsT1
Definition: auto_time_stepping_ssc_integrator.h:215
void setStepSizeMax(double dtMax_)
Definition: auto_time_stepping_ssc_integrator.h:301
int method
Definition: auto_time_stepping_ssc_integrator.h:152
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:228
bool SetValuedForceLawsExplicit
Definition: auto_time_stepping_ssc_integrator.h:278
void setPlotParallel(bool plotParallel_)
Definition: auto_time_stepping_ssc_integrator.h:442
bool inexactJac
Definition: auto_time_stepping_ssc_integrator.h:272
bool JacUpdate_B1_T1
Definition: auto_time_stepping_ssc_integrator.h:251
~AutoTimeSteppingSSCIntegrator()
Definition: auto_time_stepping_ssc_integrator.cc:80
void setDriftCompensation(bool dc)
Definition: auto_time_stepping_ssc_integrator.h:331
bool FlagPlotIntegrator
Definition: auto_time_stepping_ssc_integrator.h:170
void getAllSetValuedla(fmatvec::Vec &la_, fmatvec::VecInt &la_Sizes, std::vector< MBSim::Link * > &SetValuedLinkList)
Definition: auto_time_stepping_ssc_integrator.cc:2344
int itMax
Definition: auto_time_stepping_ssc_integrator.h:254
double gapTol
Definition: auto_time_stepping_ssc_integrator.h:158
void setItTol(double itTol_)
Definition: auto_time_stepping_ssc_integrator.h:436
void preIntegrate(MBSim::DynamicSystemSolver &system)
Definition: auto_time_stepping_ssc_integrator.cc:716
void setFlagErrorTest(int Flag, bool alwaysValid=true)
Definition: auto_time_stepping_ssc_integrator.cc:87
void setInitialStepSize(double dt_)
Definition: auto_time_stepping_ssc_integrator.h:298
bool FlagPlotIntegrationSum
Definition: auto_time_stepping_ssc_integrator.h:173
bool gAC_T1
Definition: auto_time_stepping_ssc_integrator.h:245
int JacCounter
Definition: auto_time_stepping_ssc_integrator.h:287
bool expInt
Definition: auto_time_stepping_ssc_integrator.h:239
double safetyFactorSSC
Definition: auto_time_stepping_ssc_integrator.h:164
fmatvec::Vec aTol
Definition: auto_time_stepping_ssc_integrator.h:135
void setAbsoluteTolerance(const fmatvec::Vec &aTol_)
Definition: auto_time_stepping_ssc_integrator.h:356
int JacUpdateT1
Definition: auto_time_stepping_ssc_integrator.h:209
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:105
MBSim::StopWatch Timer
Definition: auto_time_stepping_ssc_integrator.h:200
void setItMax(int itMax_)
Definition: auto_time_stepping_ssc_integrator.h:430
void setStepSizeMin(double dtMin_)
Definition: auto_time_stepping_ssc_integrator.h:304
double maxGainSSC
Definition: auto_time_stepping_ssc_integrator.h:161
int iter
Definition: auto_time_stepping_ssc_integrator.h:203
int maxOrder
Definition: auto_time_stepping_ssc_integrator.h:146
void setMaxOrder(int order_, int method_=0)
Definition: auto_time_stepping_ssc_integrator.cc:95
double dtRelGapControl
Definition: auto_time_stepping_ssc_integrator.h:218
int wrongAlertGapControl
Definition: auto_time_stepping_ssc_integrator.h:212
int iter_T1
Definition: auto_time_stepping_ssc_integrator.h:234
void setSafetyFactorSSC(double sfactor)
Definition: auto_time_stepping_ssc_integrator.h:310
int numThreads
Definition: auto_time_stepping_ssc_integrator.h:194
double theta
Definition: auto_time_stepping_ssc_integrator.h:264
fmatvec::Mat dhdq_n_T1
Definition: auto_time_stepping_ssc_integrator.h:260
void setmaxGainSSC(double maxGain)
Definition: auto_time_stepping_ssc_integrator.h:307
void setSetValuedForceLawsExplicit(bool SetValuedForceLawsExplicit_)
Definition: auto_time_stepping_ssc_integrator.h:439
double safetyFactorGapControl
Definition: auto_time_stepping_ssc_integrator.h:182
solver interface for modelling and simulation of dynamic systems
Definition: dynamic_system_solver.h:61
integrator-interface for dynamic systems
Definition: integrator.h:37
virtual void integrate()=0
start the integration of the system set by setSystem. Each class implemeting this function should cal...
MBSim::DynamicSystemSolver * system
dynamic system
Definition: solver.h:86
Definition: stopwatch.h:35
namespace MBSim
Definition: bilateral_constraint.cc:30