Guest User

Untitled

a guest
Aug 18th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 34.63 KB | None | 0 0
  1.  
  2. diff -uNr ../../mbdyn-1.7.1/mbdyn/base/invsolver.cc base/invsolver.cc
  3. --- ../../mbdyn-1.7.1/mbdyn/base/invsolver.cc 2016-07-23 01:43:08.428143846 +0530
  4. +++ base/invsolver.cc 2016-08-04 00:15:08.594514437 +0530
  5. @@ -245,9 +245,9 @@
  6.  
  7. /* relink those known drive callers that might need
  8. * the data manager, but were verated ahead of it */
  9. - if (pStrategyChangeDrive) {
  10. + /*if (pStrategyChangeDrive) {
  11. pStrategyChangeDrive->SetDrvHdl(pDM->pGetDrvHdl());
  12. - }
  13. + }*/
  14.  
  15. ASSERT(iNumDofs > 0);
  16.  
  17. @@ -625,9 +625,11 @@
  18. /* Riduce il passo */
  19. CurrStep = StepIntegrator::REPEATSTEP;
  20. doublereal dOldCurrTimeStep = dCurrTimeStep;
  21. - dCurrTimeStep = NewTimeStep(dCurrTimeStep,
  22. + dCurrTimeStep = timeStepPtr -> dGetNewStepTime(CurrStep, iStIter);
  23. + /*dCurrTimeStep = NewTimeStep(dCurrTimeStep,
  24. iStIter,
  25. CurrStep);
  26. + */
  27. if (dCurrTimeStep < dOldCurrTimeStep) {
  28. DEBUGCOUT("Changing time step"
  29. " during step "
  30. @@ -747,7 +749,8 @@
  31. bSolConv = false;
  32.  
  33. /* Calcola il nuovo timestep */
  34. - dCurrTimeStep = NewTimeStep(dCurrTimeStep, iStIter, CurrStep);
  35. + dCurrTimeStep = timeStepPtr -> dGetNewStepTime(CurrStep,iStIter);
  36. + //NewTimeStep(dCurrTimeStep, iStIter, CurrStep);
  37. DEBUGCOUT("Current time step: " << dCurrTimeStep << std::endl);
  38.  
  39. return true;
  40. @@ -1110,7 +1113,7 @@
  41.  
  42. doublereal dTol = ::dDefaultTol;
  43. doublereal dSolutionTol = 0.;
  44. - integer iMaxIterations = ::iDefaultMaxIterations;
  45. + iMaxIterations = ::iDefaultMaxIterations;
  46. bool bModResTest = false;
  47.  
  48. #ifdef USE_MULTITHREAD
  49. @@ -1487,129 +1490,12 @@
  50. goto EndOfCycle;
  51.  
  52. case STRATEGY: {
  53. - switch (KeyWords(HP.GetWord())) {
  54. - case STRATEGYFACTOR: {
  55. - CurrStrategy = FACTOR;
  56. -
  57. - /*
  58. - * strategy: factor ,
  59. - * <reduction factor> ,
  60. - * <steps before reduction> ,
  61. - * <raise factor> ,
  62. - * <steps before raise> ,
  63. - * <min iterations> ,
  64. - * <max iterations> ;
  65. - */
  66. -
  67. - StrategyFactor.dReductionFactor = HP.GetReal();
  68. - if (StrategyFactor.dReductionFactor >= 1.) {
  69. - silent_cerr("warning, "
  70. - "illegal reduction factor "
  71. - "at line " << HP.GetLineData()
  72. - << "; default value 1. "
  73. - "(no reduction) will be used"
  74. - << std::endl);
  75. - StrategyFactor.dReductionFactor = 1.;
  76. - }
  77. -
  78. - StrategyFactor.iStepsBeforeReduction = HP.GetInt();
  79. - if (StrategyFactor.iStepsBeforeReduction <= 0) {
  80. - silent_cerr("warning, "
  81. - "illegal number of steps "
  82. - "before reduction at line "
  83. - << HP.GetLineData()
  84. - << "; default value 1 will be "
  85. - "used (it may be dangerous)"
  86. - << std::endl);
  87. - StrategyFactor.iStepsBeforeReduction = 1;
  88. - }
  89. -
  90. - StrategyFactor.dRaiseFactor = HP.GetReal();
  91. - if (StrategyFactor.dRaiseFactor <= 1.) {
  92. - silent_cerr("warning, "
  93. - "illegal raise factor at line "
  94. - << HP.GetLineData()
  95. - << "; default value 1. "
  96. - "(no raise) will be used"
  97. - << std::endl);
  98. - StrategyFactor.dRaiseFactor = 1.;
  99. - }
  100. -
  101. - StrategyFactor.iStepsBeforeRaise = HP.GetInt();
  102. - if (StrategyFactor.iStepsBeforeRaise <= 0) {
  103. - silent_cerr("warning, "
  104. - "illegal number of steps "
  105. - "before raise at line "
  106. - << HP.GetLineData()
  107. - << "; default value 1 will be "
  108. - "used (it may be dangerous)"
  109. - << std::endl);
  110. - StrategyFactor.iStepsBeforeRaise = 1;
  111. - }
  112. -
  113. - StrategyFactor.iMinIters = HP.GetInt();
  114. - if (StrategyFactor.iMinIters <= 0) {
  115. - silent_cerr("warning, "
  116. - "illegal minimum number "
  117. - "of iterations at line "
  118. - << HP.GetLineData()
  119. - << "; default value 0 will be "
  120. - "used (never raise)"
  121. - << std::endl);
  122. - StrategyFactor.iMinIters = 1;
  123. - }
  124.  
  125. - StrategyFactor.iMaxIters = 0;
  126. - if (HP.IsArg()) {
  127. - StrategyFactor.iMaxIters = HP.GetInt();
  128. - if (StrategyFactor.iMaxIters <= 0) {
  129. - silent_cerr("warning, "
  130. - "illegal mmaximim number "
  131. - "of iterations at line "
  132. - << HP.GetLineData()
  133. - << "; default value will be "
  134. - "used"
  135. - << std::endl);
  136. - StrategyFactor.iMaxIters = 0;
  137. - }
  138. - }
  139. -
  140. - DEBUGLCOUT(MYDEBUG_INPUT,
  141. - "Time step control strategy: "
  142. - "Factor" << std::endl
  143. - << "Reduction factor: "
  144. - << StrategyFactor.dReductionFactor
  145. - << "Steps before reduction: "
  146. - << StrategyFactor.iStepsBeforeReduction
  147. - << "Raise factor: "
  148. - << StrategyFactor.dRaiseFactor
  149. - << "Steps before raise: "
  150. - << StrategyFactor.iStepsBeforeRaise
  151. - << "Min iterations: "
  152. - << StrategyFactor.iMinIters
  153. - << "Max iterations: "
  154. - << StrategyFactor.iMaxIters
  155. - << std::endl);
  156. - break;
  157. - }
  158. -
  159. - case STRATEGYNOCHANGE: {
  160. - CurrStrategy = NOCHANGE;
  161. - break;
  162. - }
  163. -
  164. - case STRATEGYCHANGE: {
  165. - CurrStrategy = CHANGE;
  166. + timeStepPtr = ReadTimeStepData(this,HP);
  167. + /*if(typeid(timeStepPtr) == typeid(ChangeStep)){
  168. pStrategyChangeDrive = HP.GetDriveCaller(true);
  169. - break;
  170. - }
  171. -
  172. - default:
  173. - silent_cerr("unknown time step control "
  174. - "strategy at line "
  175. - << HP.GetLineData() << std::endl);
  176. - throw ErrGeneric(MBDYN_EXCEPT_ARGS);
  177. - }
  178. + }*/
  179. +
  180. break;
  181. }
  182.  
  183. @@ -1948,7 +1834,7 @@
  184.  
  185. EndOfCycle: /* esce dal ciclo di lettura */
  186.  
  187. - switch (CurrStrategy) {
  188. + /*switch (CurrStrategy) {
  189. case FACTOR:
  190. if (StrategyFactor.iMaxIters <= StrategyFactor.iMinIters) {
  191. silent_cerr("warning, "
  192. @@ -1967,7 +1853,7 @@
  193.  
  194. default:
  195. break;
  196. - }
  197. + }*/
  198.  
  199. if (dFinalTime < dInitialTime) {
  200. eAbortAfter = AFTER_ASSEMBLY;
  201. diff -uNr ../../mbdyn-1.7.1/mbdyn/base/Makefile.am base/Makefile.am
  202. --- ../../mbdyn-1.7.1/mbdyn/base/Makefile.am 2016-04-25 00:40:43.000000000 +0530
  203. +++ base/Makefile.am 2016-07-18 23:52:53.402920113 +0530
  204. @@ -169,6 +169,9 @@
  205. vec3drv.h \
  206. thirdorderstepsol.h \
  207. thirdorderstepsol.cc \
  208. +TimeStepControl.h \
  209. +TimeStepControl.cc \
  210. +TimeStepFunctorClass.h\
  211. userelem.cc \
  212. userelem.h \
  213. usesock.cc \
  214. diff -uNr ../../mbdyn-1.7.1/mbdyn/base/Makefile.in base/Makefile.in
  215. --- ../../mbdyn-1.7.1/mbdyn/base/Makefile.in 2016-04-25 01:03:37.000000000 +0530
  216. +++ base/Makefile.in 2016-07-18 23:54:21.578985631 +0530
  217. @@ -194,11 +194,12 @@
  218. solver.cc solver.h solver_impl.h solverdiagnostics.cc \
  219. solverdiagnostics.h stepsol.cc stepsol.h stepsol.hc symcltp.h \
  220. tpldrive.cc tpldrive.h tpldrive_impl.cc tpldrive_impl.h \
  221. - vec3drv.h thirdorderstepsol.h thirdorderstepsol.cc userelem.cc \
  222. - userelem.h usesock.cc usesock.h varstep.cc varstep.h \
  223. - ScalarFunctions.h ScalarFunctionsImpl.h ScalarFunctionsImpl.cc \
  224. - ginaccltp.h ginacdrive.cc ginacdrive.h mbrtai_utils.c \
  225. - mbrtai_utils.h rtai_in_drive.cc rtai_in_drive.h \
  226. + vec3drv.h thirdorderstepsol.h thirdorderstepsol.cc \
  227. + TimeStepControl.h TimeStepControl.cc TimeStepFunctorClass.h \
  228. + userelem.cc userelem.h usesock.cc usesock.h varstep.cc \
  229. + varstep.h ScalarFunctions.h ScalarFunctionsImpl.h \
  230. + ScalarFunctionsImpl.cc ginaccltp.h ginacdrive.cc ginacdrive.h \
  231. + mbrtai_utils.c mbrtai_utils.h rtai_in_drive.cc rtai_in_drive.h \
  232. rtai_out_elem.cc rtai_out_elem.h rtaisolver.cc rtaisolver.h \
  233. eigjdqz.cc eigjdqz.h schurdataman.cc schurdataman.h
  234. @USE_GINAC_TRUE@am__objects_1 = ginacdrive.lo
  235. @@ -223,9 +224,10 @@
  236. simentity.lo sockdrv.lo socketstreamdrive.lo \
  237. socketstream_out_elem.lo streamdrive.lo streamoutelem.lo \
  238. solver.lo solverdiagnostics.lo stepsol.lo tpldrive.lo \
  239. - tpldrive_impl.lo thirdorderstepsol.lo userelem.lo usesock.lo \
  240. - varstep.lo ScalarFunctionsImpl.lo $(am__objects_1) \
  241. - $(am__objects_2) $(am__objects_3) $(am__objects_4)
  242. + tpldrive_impl.lo thirdorderstepsol.lo TimeStepControl.lo \
  243. + userelem.lo usesock.lo varstep.lo ScalarFunctionsImpl.lo \
  244. + $(am__objects_1) $(am__objects_2) $(am__objects_3) \
  245. + $(am__objects_4)
  246. @BUILD_STATIC_MODULES_TRUE@am__objects_5 = module-nodedistdrive.lo \
  247. @BUILD_STATIC_MODULES_TRUE@ module-minmaxdrive.lo
  248. @BUILD_STATIC_MODULES_TRUE@@USE_OCTAVE_TRUE@am__objects_6 = \
  249. @@ -536,11 +538,12 @@
  250. solver.cc solver.h solver_impl.h solverdiagnostics.cc \
  251. solverdiagnostics.h stepsol.cc stepsol.h stepsol.hc symcltp.h \
  252. tpldrive.cc tpldrive.h tpldrive_impl.cc tpldrive_impl.h \
  253. - vec3drv.h thirdorderstepsol.h thirdorderstepsol.cc userelem.cc \
  254. - userelem.h usesock.cc usesock.h varstep.cc varstep.h \
  255. - ScalarFunctions.h ScalarFunctionsImpl.h ScalarFunctionsImpl.cc \
  256. - $(am__append_3) $(am__append_4) $(am__append_5) \
  257. - $(am__append_6)
  258. + vec3drv.h thirdorderstepsol.h thirdorderstepsol.cc \
  259. + TimeStepControl.h TimeStepControl.cc TimeStepFunctorClass.h \
  260. + userelem.cc userelem.h usesock.cc usesock.h varstep.cc \
  261. + varstep.h ScalarFunctions.h ScalarFunctionsImpl.h \
  262. + ScalarFunctionsImpl.cc $(am__append_3) $(am__append_4) \
  263. + $(am__append_5) $(am__append_6)
  264. nodist_libbase_la_SOURCES = $(am__append_1) $(am__append_2)
  265. libbase_la_LIBADD = @LIBS@ @SECURITY_LIBS@ $(GINACLIB_LIBS)
  266. libbase_la_LDFLAGS = -static
  267. @@ -638,6 +641,7 @@
  268. -rm -f *.tab.c
  269.  
  270. @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ScalarFunctionsImpl.Plo@am__quote@
  271. +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TimeStepControl.Plo@am__quote@
  272. @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/adams_res.Plo@am__quote@
  273. @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/auth.Plo@am__quote@
  274. @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bicg.Plo@am__quote@
  275. diff -uNr ../../mbdyn-1.7.1/mbdyn/base/solver.cc base/solver.cc
  276. --- ../../mbdyn-1.7.1/mbdyn/base/solver.cc 2016-04-25 00:40:43.000000000 +0530
  277. +++ base/solver.cc 2016-08-04 00:17:52.796632457 +0530
  278. @@ -78,13 +78,14 @@
  279. #include "Rot.hh"
  280. #include "cleanup.h"
  281. #include "drive_.h"
  282. -
  283. +#include "TimeStepControl.h"
  284. #include "solver_impl.h"
  285.  
  286. #include "ac/lapack.h"
  287. #include "ac/arpack.h"
  288. #include "eigjdqz.h"
  289.  
  290. +
  291. #ifdef HAVE_SIGNAL
  292. /*
  293. * MBDyn starts with mbdyn_keep_going == MBDYN_KEEP_GOING.
  294. @@ -267,11 +268,9 @@
  295. #ifdef USE_MULTITHREAD
  296. nThreads(nThreads),
  297. #endif /* USE_MULTITHREAD */
  298. -CurrStrategy(NOCHANGE),
  299. sInputFileName(sInFName),
  300. sOutputFileName(sOutFName),
  301. HP(HPar),
  302. -pStrategyChangeDrive(NULL),
  303. EigAn(),
  304. pRTSolver(0),
  305. iNumPreviousVectors(2),
  306. @@ -294,10 +293,6 @@
  307. iDummyStepsNumber(::iDefaultDummyStepsNumber),
  308. dDummyStepsRatio(::dDefaultDummyStepsRatio),
  309. eAbortAfter(AFTER_UNKNOWN),
  310. -iStepsAfterReduction(0),
  311. -iStepsAfterRaise(0),
  312. -iWeightedPerformedIters(0),
  313. -bLastChance(false),
  314. RegularType(INT_UNKNOWN),
  315. DummyType(INT_UNKNOWN),
  316. pDerivativeSteps(0),
  317. @@ -347,6 +342,7 @@
  318. iTotIter(0),
  319. iStIter(0),
  320. dTotErr(0.),
  321. +timeStepPtr(NULL),
  322. dTest(std::numeric_limits<double>::max()),
  323. dSolTest(std::numeric_limits<double>::max()),
  324. bSolConv(false),
  325. @@ -354,11 +350,8 @@
  326. lStep(0)
  327. {
  328. DEBUGCOUTFNAME("Solver::Solver");
  329. -
  330. + ::InitTimeStepData();
  331. ASSERT(!sInFName.empty());
  332. -
  333. - StrategyFactor.iMinIters = 1;
  334. - StrategyFactor.iMaxIters = 0;
  335. }
  336.  
  337. #ifdef USE_MULTITHREAD
  338. @@ -569,9 +562,10 @@
  339.  
  340. /* relink those known drive callers that might need
  341. * the data manager, but were verated ahead of it */
  342. - if (pStrategyChangeDrive) {
  343. + timeStepPtr->SetDriveHandler(pDM->pGetDrvHdl());
  344. + /*if (pStrategyChangeDrive) {
  345. pStrategyChangeDrive->SetDrvHdl(pDM->pGetDrvHdl());
  346. - }
  347. + }*/
  348.  
  349. ASSERT(iNumDofs > 0);
  350.  
  351. @@ -1198,8 +1192,10 @@
  352. dCurrTimeStep = dRefTimeStep;
  353.  
  354. ASSERT(pFirstRegularStep!= NULL);
  355. - StepIntegrator::StepChange CurrStep = StepIntegrator::NEWSTEP;
  356. + CurrStep = StepIntegrator::NEWSTEP;
  357.  
  358. +
  359. + timeStepPtr->Init(iMaxIterations,dCurrTimeStep ,MaxTimeStep ,dInitialTimeStep);
  360. /* Setup SolutionManager(s) */
  361. SetupSolmans(pFirstRegularStep->GetIntegratorNumUnknownStates(), true);
  362. pCurrStepIntegrator = pFirstRegularStep;
  363. @@ -1222,9 +1218,10 @@
  364. /* Riduce il passo */
  365. CurrStep = StepIntegrator::REPEATSTEP;
  366. doublereal dOldCurrTimeStep = dCurrTimeStep;
  367. - dCurrTimeStep = NewTimeStep(dOldCurrTimeStep,
  368. + dCurrTimeStep = timeStepPtr->dGetNewStepTime(CurrStep, iStIter);
  369. + /*dCurrTimeStep = NewTimeStep(dOldCurrTimeStep,
  370. iStIter,
  371. - CurrStep);
  372. + CurrStep);*/
  373. if (dCurrTimeStep < dOldCurrTimeStep) {
  374. DEBUGCOUT("Changing time step"
  375. " from " << dOldCurrTimeStep
  376. @@ -1343,7 +1340,7 @@
  377. throw ErrGeneric(MBDYN_EXCEPT_ARGS);
  378. }
  379.  
  380. - StepIntegrator::StepChange CurrStep = StepIntegrator::NEWSTEP;
  381. + CurrStep = StepIntegrator::NEWSTEP;
  382.  
  383. if (pDM->EndOfSimulation() || dTime >= dFinalTime) {
  384. if (pRTSolver) {
  385. @@ -1432,9 +1429,10 @@
  386. /* Riduce il passo */
  387. CurrStep = StepIntegrator::REPEATSTEP;
  388. doublereal dOldCurrTimeStep = dCurrTimeStep;
  389. - dCurrTimeStep = NewTimeStep(dOldCurrTimeStep,
  390. + dCurrTimeStep = timeStepPtr->dGetNewStepTime(CurrStep , iStIter);
  391. + /*dCurrTimeStep = NewTimeStep(dOldCurrTimeStep,
  392. iStIter,
  393. - CurrStep);
  394. + CurrStep);*/
  395. if (dCurrTimeStep < dOldCurrTimeStep) {
  396. DEBUGCOUT("Changing time step"
  397. " from " << dOldCurrTimeStep
  398. @@ -1463,9 +1461,10 @@
  399. /* Riduce il passo */
  400. CurrStep = StepIntegrator::REPEATSTEP;
  401. doublereal dOldCurrTimeStep = dCurrTimeStep;
  402. - dCurrTimeStep = NewTimeStep(dOldCurrTimeStep,
  403. + dCurrTimeStep = timeStepPtr->dGetNewStepTime(CurrStep , iStIter);
  404. + /*dCurrTimeStep = NewTimeStep(dOldCurrTimeStep,
  405. iStIter,
  406. - CurrStep);
  407. + CurrStep);*/
  408. if (dCurrTimeStep < dOldCurrTimeStep) {
  409. DEBUGCOUT("Changing time step"
  410. " from " << dOldCurrTimeStep
  411. @@ -1587,7 +1586,8 @@
  412. }
  413.  
  414. /* Calcola il nuovo timestep */
  415. - dCurrTimeStep = NewTimeStep(dCurrTimeStep, iStIter, CurrStep);
  416. + dCurrTimeStep = timeStepPtr->dGetNewStepTime(CurrStep , iStIter);
  417. + //dCurrTimeStep = NewTimeStep(dCurrTimeStep, iStIter, CurrStep);
  418. DEBUGCOUT("Current time step: " << dCurrTimeStep << std::endl);
  419.  
  420. return true;
  421. @@ -1669,9 +1669,10 @@
  422. SAFEDELETE(pNLS);
  423. }
  424.  
  425. - if (pStrategyChangeDrive) {
  426. + /*if (pStrategyChangeDrive) {
  427. SAFEDELETE(pStrategyChangeDrive);
  428. - }
  429. + }*/
  430. + DestroyTimeStepData();
  431. }
  432.  
  433. /* Nuovo delta t */
  434. @@ -1680,7 +1681,7 @@
  435. integer iPerformedIters,
  436. StepIntegrator::StepChange Why)
  437. {
  438. - DEBUGCOUTFNAME("Solver::NewTimeStep");
  439. + /*DEBUGCOUTFNAME("Solver::NewTimeStep");
  440.  
  441. switch (CurrStrategy) {
  442. case NOCHANGE:
  443. @@ -1714,7 +1715,7 @@
  444. /*
  445. * Fuori viene intercettato
  446. * il valore illegale
  447. - */
  448. + *
  449. return std::min(dCurrTimeStep*StrategyFactor.dReductionFactor, MaxTimeStep.dGet());
  450. }
  451. }
  452. @@ -1753,8 +1754,9 @@
  453. silent_cerr("You shouldn't have reached this point!" << std::endl);
  454. throw Solver::ErrGeneric(MBDYN_EXCEPT_ARGS);
  455. }
  456. + */
  457.  
  458. - return dCurrTimeStep;
  459. + return 0.;
  460. }
  461.  
  462. /*scrive il contributo al file di restart*/
  463. @@ -2149,7 +2151,7 @@
  464.  
  465. doublereal dTol = ::dDefaultTol;
  466. doublereal dSolutionTol = 0.;
  467. - integer iMaxIterations = ::iDefaultMaxIterations;
  468. + iMaxIterations = ::iDefaultMaxIterations;
  469. bool bModResTest = false;
  470. bool bSetScaleAlgebraic = false;
  471.  
  472. @@ -2938,8 +2940,14 @@
  473. throw ErrGeneric(MBDYN_EXCEPT_ARGS);
  474. }
  475. goto EndOfCycle;
  476. -
  477. + ///Start over here
  478. case STRATEGY: {
  479. +
  480. + timeStepPtr = ReadTimeStepData(this,HP);
  481. + /*if(typeid(timeStepPtr) == typeid(ChangeStep)){
  482. + pStrategyChangeDrive = HP.GetDriveCaller(true);
  483. + }
  484. + // call the read function for the TimeStepRead
  485. switch (KeyWords(HP.GetWord())) {
  486. case STRATEGYFACTOR: {
  487. CurrStrategy = FACTOR;
  488. @@ -2954,7 +2962,7 @@
  489. * <max iterations> ;
  490. */
  491.  
  492. - StrategyFactor.dReductionFactor = HP.GetReal();
  493. + /*StrategyFactor.dReductionFactor = HP.GetReal();
  494. if (StrategyFactor.dReductionFactor >= 1.) {
  495. silent_cerr("warning, "
  496. "illegal reduction factor "
  497. @@ -3060,7 +3068,7 @@
  498. "strategy at line "
  499. << HP.GetLineData() << std::endl);
  500. throw ErrGeneric(MBDYN_EXCEPT_ARGS);
  501. - }
  502. + }*/
  503. break;
  504. }
  505.  
  506. @@ -3811,86 +3819,18 @@
  507. SAFENEWWITHCONSTRUCTOR(pDC, ConstDriveCaller, ConstDriveCaller(::dDefaultMaxTimeStep));
  508. MaxTimeStep.Set(pDC);
  509. }
  510. -
  511. - switch (CurrStrategy) {
  512. - case FACTOR:
  513. - if (StrategyFactor.iMaxIters <= StrategyFactor.iMinIters) {
  514. - silent_cerr("warning, "
  515. - << "strategy maximum number "
  516. - << "of iterations "
  517. - << "is <= minimum: "
  518. - << StrategyFactor.iMaxIters << " <= "
  519. - << StrategyFactor.iMinIters << "; "
  520. - << "the maximum global iteration value "
  521. - << iMaxIterations << " "
  522. - << "will be used"
  523. - << std::endl);
  524. - StrategyFactor.iMaxIters = iMaxIterations;
  525. - }
  526. - if (typeid(*MaxTimeStep.pGetDriveCaller()) == typeid(ConstDriveCaller)
  527. - && MaxTimeStep.dGet() == ::dDefaultMaxTimeStep) {
  528. - silent_cerr("warning, "
  529. - << "maximum time step not set and strategy "
  530. - << "factor selected:\n"
  531. - << "the initial time step value will be used as "
  532. - << "maximum time step: "
  533. - << "max time step = "
  534. - << dInitialTimeStep
  535. - << std::endl);
  536. - MaxTimeStep.Set(new ConstDriveCaller(dInitialTimeStep));
  537. - }
  538. - if (dMinTimeStep == dDefaultMinTimeStep) {
  539. - silent_cerr("warning, "
  540. - << "minimum time step not set and strategy "
  541. - << "factor selected:\n"
  542. - << "the initial time step value will be used as "
  543. - << "minimum time step: "
  544. - << "min time step = "
  545. - << dInitialTimeStep
  546. - << std::endl);
  547. - dMinTimeStep = dInitialTimeStep;
  548. - }
  549. - if (dMinTimeStep == dGetInitialMaxTimeStep()) {
  550. - silent_cerr("error, "
  551. - << "minimum and maximum time step are equal, but "
  552. - << "strategy factor has been selected:\n"
  553. - << "this is almost meaningless"
  554. - << std::endl);
  555. - }
  556. - if (dMinTimeStep > dGetInitialMaxTimeStep()) {
  557. - silent_cerr("error, "
  558. - << "minimum and maximum time step are equal, but "
  559. - << "strategy factor has been selected:\n"
  560. - << "this is meaningless - bailing out"
  561. - << std::endl);
  562. - throw ErrGeneric(MBDYN_EXCEPT_ARGS);
  563. - }
  564. - break;
  565. -
  566. - case CHANGE:
  567. - if (dMinTimeStep > dGetInitialMaxTimeStep()) {
  568. - silent_cerr("inconsistent min/max time step"
  569. - << std::endl);
  570. - throw ErrGeneric(MBDYN_EXCEPT_ARGS);
  571. - }
  572. - break;
  573. -
  574. - default:
  575. - if (dMinTimeStep != ::dDefaultMinTimeStep) {
  576. - silent_cerr("\"min time step\" only allowed with variable time step (ignored)." <<std::endl);
  577. - }
  578. - dMinTimeStep = dInitialTimeStep;
  579. -
  580. - if (typeid(*MaxTimeStep.pGetDriveCaller()) == typeid(ConstDriveCaller)) {
  581. - if (dGetInitialMaxTimeStep() != dDefaultMaxTimeStep) {
  582. - silent_cerr("\"max time step\" only allowed with variable time step (ignored)." <<std::endl);
  583. - }
  584. - MaxTimeStep.Set(new ConstDriveCaller(dInitialTimeStep));
  585. - }
  586. -
  587. - break;
  588. +
  589. + if (typeid(*MaxTimeStep.pGetDriveCaller()) == typeid(ConstDriveCaller)) {
  590. + MaxTimeStep.Set(new ConstDriveCaller(dInitialTimeStep));
  591. }
  592.  
  593. + if(timeStepPtr == NULL){
  594. + silent_cout("TimeStepPtr is NULL Creating NoChange \n" );
  595. + timeStepPtr = new NoChange(this);
  596. + }
  597. +
  598. + //timeStepPtr->SetUpMaxTimeStep(MaxTimeStep , dInitialTimeStep);
  599. +
  600. if (dFinalTime < dInitialTime) {
  601. eAbortAfter = AFTER_ASSEMBLY;
  602. }
  603. diff -uNr ../../mbdyn-1.7.1/mbdyn/base/solver.h base/solver.h
  604. --- ../../mbdyn-1.7.1/mbdyn/base/solver.h 2016-04-25 00:40:43.000000000 +0530
  605. +++ base/solver.h 2016-08-04 00:10:27.794806075 +0530
  606. @@ -65,9 +65,10 @@
  607. #include "nonlin.h"
  608. #include "linesearch.h"
  609. #include "mfree.h"
  610. +#include "cstring"
  611. #include "precond.h"
  612. #include "rtsolver.h"
  613. -
  614. +#include "TimeStepControl.h"
  615. extern "C" int mbdyn_stop_at_end_of_iteration(void);
  616. extern "C" int mbdyn_stop_at_end_of_time_step(void);
  617. extern "C" void mbdyn_set_stop_at_end_of_iteration(void);
  618. @@ -101,32 +102,31 @@
  619.  
  620. void ThreadPrepare(void);
  621. #endif /* USE_MULTITHREAD */
  622. -
  623. - enum Strategy {
  624. - NOCHANGE,
  625. - CHANGE,
  626. - FACTOR
  627. - } CurrStrategy;
  628. -
  629. + TimeStepControl * timeStepPtr;
  630. + doublereal dCurrTimeStep;
  631. + integer iStIter;
  632. + doublereal dTime;
  633. + DriveOwner MaxTimeStep;
  634. + doublereal dMinTimeStep;
  635. + StepIntegrator::StepChange CurrStep = StepIntegrator::NEWSTEP;
  636. std::string sInputFileName;
  637. std::string sOutputFileName;
  638. MBDynParser& HP;
  639. -
  640. - /* Dati per strategia FACTOR */
  641. - struct {
  642. - doublereal dReductionFactor;
  643. - doublereal dRaiseFactor;
  644. - integer iStepsBeforeReduction;
  645. - integer iStepsBeforeRaise;
  646. - integer iMinIters;
  647. - integer iMaxIters;
  648. - } StrategyFactor;
  649. -
  650. - /* Dati per strategia DRIVER_CHANGE */
  651. - DriveCaller* pStrategyChangeDrive;
  652. -
  653. + integer iMaxIterations;
  654. +//***** Method for StepTime ****/
  655. +public:
  656. +
  657. + doublereal dGetdMinTimeStep() {
  658. + return dMinTimeStep;
  659. + }
  660. +
  661. + void dSetMinTimeStep(doublereal val) {
  662. + dMinTimeStep = val;
  663. + }
  664. +
  665. public:
  666. /* Dati per esecuzione di eigenanalysis */
  667. +
  668. struct EigenAnalysis {
  669. bool bAnalysis;
  670. enum {
  671. @@ -234,13 +234,13 @@
  672. MyVectorHandler* pXPrime; /* queque vett. stati d. inc. */
  673.  
  674. /* Dati della simulazione */
  675. - doublereal dTime;
  676. +
  677. doublereal dInitialTime;
  678. doublereal dFinalTime;
  679. doublereal dRefTimeStep;
  680. doublereal dInitialTimeStep;
  681. - doublereal dMinTimeStep;
  682. - DriveOwner MaxTimeStep;
  683. +
  684. +
  685. doublereal dMaxResidual;
  686. doublereal dMaxResidualDiff;
  687.  
  688. @@ -263,12 +263,6 @@
  689. };
  690. AbortAfter eAbortAfter;
  691.  
  692. - /* Parametri per la variazione passo */
  693. - integer iStepsAfterReduction;
  694. - integer iStepsAfterRaise;
  695. - integer iWeightedPerformedIters;
  696. - bool bLastChance;
  697. -
  698. /* Parametri per il metodo */
  699. enum StepIntegratorType {
  700. INT_CRANKNICOLSON,
  701. @@ -367,12 +361,12 @@
  702. SOLVER_STATUS_PREPARED,
  703. SOLVER_STATUS_STARTED
  704. } eStatus;
  705. - doublereal dCurrTimeStep;
  706. +
  707. bool bOutputCounter;
  708. std::string outputCounterPrefix;
  709. std::string outputCounterPostfix;
  710. integer iTotIter;
  711. - integer iStIter;
  712. +
  713. doublereal dTotErr;
  714. doublereal dTest;
  715. doublereal dSolTest;
  716. diff -uNr ../../mbdyn-1.7.1/mbdyn/base/TimeStepControl.cc base/TimeStepControl.cc
  717. --- ../../mbdyn-1.7.1/mbdyn/base/TimeStepControl.cc 1970-01-01 05:30:00.000000000 +0530
  718. +++ base/TimeStepControl.cc 2016-08-04 00:13:18.769079398 +0530
  719. @@ -0,0 +1,383 @@
  720. +#include "mbconfig.h"
  721. +#include "TimeStepControl.h"
  722. +
  723. +typedef std::map<std::string,TimeStepRead * > TimeStepFuncMapType;
  724. +
  725. +TimeStepFuncMapType TimeStepReadMap;
  726. +
  727. +struct TimeStepWordSetType : public HighParser::WordSet{
  728. +
  729. + bool IsWord(const std::string& s) const{
  730. + return TimeStepReadMap.find(s) != TimeStepReadMap.end();
  731. + };
  732. +};
  733. +
  734. +TimeStepWordSetType TimeStepWordSet;
  735. +
  736. +bool
  737. +SetTimeStepData(const char *name , TimeStepRead * sr){
  738. + return TimeStepReadMap.insert(std::make_pair(name,sr)).second;
  739. +}
  740. +
  741. +
  742. +NoChange::NoChange(Solver * s): s(s){
  743. +}
  744. +
  745. +doublereal
  746. +NoChange::dGetNewStepTime(StepIntegrator::StepChange currStep , doublereal iPerformedIters) {
  747. +
  748. + return dCurrTimeStep;
  749. +}
  750. +
  751. +void
  752. +NoChange::Init(doublereal iMaxIterations,doublereal dCurrTimeStep ,DriveOwner & MaxTimeStep , doublereal dInitialTimeStep){
  753. +
  754. + this->dCurrTimeStep = dCurrTimeStep;
  755. + doublereal dMinTimeStep = s->dGetdMinTimeStep();
  756. + doublereal dDefaultMinTimeStep = -1.;
  757. + if (dMinTimeStep != dDefaultMinTimeStep) {
  758. + silent_cerr("\"min time step\" only allowed with variable time step (ignored)." <<std::endl);
  759. + }
  760. + dMinTimeStep = dInitialTimeStep;
  761. +
  762. + doublereal dInitialMaxTimeStep ;
  763. + if (typeid(*MaxTimeStep.pGetDriveCaller()) == typeid(PostponedDriveCaller)) {
  764. + dInitialMaxTimeStep = std::numeric_limits<doublereal>::max();
  765. + }
  766. + else{
  767. + dInitialMaxTimeStep = MaxTimeStep.dGet();
  768. + }
  769. +
  770. + if (dInitialMaxTimeStep != std::numeric_limits<doublereal>::max()) {
  771. + silent_cerr("\"max time step\" only allowed with variable time step (ignored)." <<std::endl);
  772. + }
  773. + s->dSetMinTimeStep(dMinTimeStep);
  774. +
  775. +}
  776. +
  777. +struct NoChangeSTR : public TimeStepRead {
  778. + TimeStepControl *
  779. + Read(Solver * s, MBDynParser& HP);
  780. +};
  781. +
  782. +TimeStepControl *
  783. +NoChangeSTR::Read(Solver * s, MBDynParser& HP){
  784. + return new NoChange(s);
  785. +}
  786. +
  787. +ChangeStep::ChangeStep(Solver *s , DriveCaller* pStrategyChangeDrive):
  788. +s(s),
  789. +pStrategyChangeDrive(pStrategyChangeDrive)
  790. +{}
  791. +
  792. +doublereal
  793. +ChangeStep::dGetNewStepTime(StepIntegrator::StepChange currStep , doublereal iPerformedIters){
  794. + silent_cout("Reached in dGetdMinTimeStep of ChangeStep \n");
  795. + doublereal dNewStep = pStrategyChangeDrive->dGet();
  796. + doublereal maxTimeStepval = MaxTimeStep.dGet();;
  797. +
  798. + doublereal dMinTimeStep = s->dGetdMinTimeStep();
  799. +
  800. + if (currStep == StepIntegrator::REPEATSTEP
  801. + && dNewStep == dCurrTimeStep){
  802. + return dMinTimeStep/2.;
  803. + }
  804. + return std::max(std::min(dNewStep, maxTimeStepval), dMinTimeStep);
  805. +}
  806. +
  807. +void
  808. +ChangeStep::SetDriveHandler(const DriveHandler* driveHandler){
  809. + pStrategyChangeDrive->SetDrvHdl(driveHandler);
  810. +}
  811. +
  812. +
  813. +void
  814. +ChangeStep::Init(doublereal iMaxIterations,doublereal dCurrTimeStep ,DriveOwner & MaxTimeStep , doublereal dInitialTimeStep){
  815. + this->dCurrTimeStep = dCurrTimeStep;
  816. + this->MaxTimeStep = MaxTimeStep;
  817. + doublereal dMinTimeStep = s->dGetdMinTimeStep();
  818. + doublereal dInitialMaxTimeStep ;
  819. + if (typeid(*MaxTimeStep.pGetDriveCaller()) == typeid(PostponedDriveCaller)) {
  820. + dInitialMaxTimeStep = std::numeric_limits<doublereal>::max();
  821. + }
  822. + else{
  823. + dInitialMaxTimeStep = MaxTimeStep.dGet();
  824. + }
  825. + if (dMinTimeStep > dInitialMaxTimeStep) {
  826. + silent_cerr("inconsistent min/max time step"
  827. + << std::endl);
  828. + throw ErrGeneric(MBDYN_EXCEPT_ARGS);
  829. + }
  830. +}
  831. +
  832. +class ChangeStepSTR : public TimeStepRead{
  833. +
  834. +public:
  835. + TimeStepControl *
  836. + Read(Solver * s, MBDynParser& HP);
  837. +};
  838. +
  839. +TimeStepControl *
  840. +ChangeStepSTR::Read(Solver * s, MBDynParser& HP){
  841. + return new ChangeStep(s , HP.GetDriveCaller(true));
  842. +}
  843. +
  844. +Factor::Factor(Solver * s ,doublereal dReductionFactor,
  845. + doublereal iStepsBeforeReduction,
  846. + doublereal dRaiseFactor,
  847. + doublereal iStepsBeforeRaise,
  848. + doublereal iMinIters,
  849. + doublereal iMaxIters ):
  850. +s(s),
  851. +dReductionFactor(dReductionFactor),
  852. +iStepsBeforeReduction(iStepsBeforeReduction),
  853. +dRaiseFactor(dRaiseFactor),
  854. +iStepsBeforeRaise(iStepsBeforeRaise),
  855. +iMinIters(iMinIters),
  856. +iMaxIters(iMaxIters),
  857. +bLastChance(false),
  858. +iStepsAfterReduction(0),
  859. +iStepsAfterRaise(0),
  860. +iWeightedPerformedIters(0)
  861. +{}
  862. +
  863. +doublereal
  864. +Factor::dGetNewStepTime(StepIntegrator::StepChange Why , doublereal iPerformedIters){
  865. + doublereal dMinTimeStep = s->dGetdMinTimeStep();
  866. + doublereal maxTimeStepval = MaxTimeStep.dGet();
  867. +
  868. + if (Why == StepIntegrator::REPEATSTEP) {
  869. + if (dCurrTimeStep*dReductionFactor > dMinTimeStep){
  870. + if (bLastChance == true) {
  871. + bLastChance = false;
  872. + }
  873. + iStepsAfterReduction = 0;
  874. + return std::min(dCurrTimeStep*dReductionFactor, maxTimeStepval);
  875. +
  876. + } else {
  877. + if (bLastChance == false) {
  878. + bLastChance = true;
  879. + return dMinTimeStep;
  880. + } else {
  881. + return std::min(dCurrTimeStep*dReductionFactor, maxTimeStepval);
  882. + }
  883. + }
  884. + }
  885. +
  886. + if (Why == StepIntegrator::NEWSTEP) {
  887. + iStepsAfterReduction++;
  888. + iStepsAfterRaise++;
  889. +
  890. + iWeightedPerformedIters = (10*iPerformedIters + 9*iWeightedPerformedIters)/10;
  891. +
  892. + if (iPerformedIters > iMaxIters) {
  893. + iStepsAfterReduction = 0;
  894. + bLastChance = false;
  895. + return std::min(std::max(dCurrTimeStep*dReductionFactor, dMinTimeStep), maxTimeStepval);
  896. +
  897. + } else if (iPerformedIters <= iMinIters
  898. + && iStepsAfterReduction >iStepsBeforeReduction
  899. + && iStepsAfterRaise > iStepsBeforeRaise
  900. + && dCurrTimeStep < maxTimeStepval)
  901. + {
  902. + iStepsAfterRaise = 0;
  903. + iWeightedPerformedIters = 0;
  904. + return std::min(dCurrTimeStep*dRaiseFactor, maxTimeStepval);
  905. + }
  906. + return dCurrTimeStep;
  907. + }
  908. + //Should Not Reach Over here
  909. + return 0.;
  910. +}
  911. +
  912. +
  913. +void
  914. +Factor::Init(doublereal iMaxIterations , doublereal dCurrTimeStep ,DriveOwner & MaxTimeStep , doublereal dInitialTimeStep){
  915. +
  916. + this->dCurrTimeStep = dCurrTimeStep;
  917. + this->MaxTimeStep = MaxTimeStep;
  918. + doublereal dDefaultMinTimeStep = -1.;
  919. + doublereal dInitialMaxTimeStep ;
  920. + doublereal dMinTimeStep = s->dGetdMinTimeStep();
  921. +
  922. + if(iMaxIters <= iMinIters) {
  923. + silent_cerr("warning, "
  924. + << "strategy maximum number "
  925. + << "of iterations "
  926. + << "is <= minimum: "
  927. + << iMaxIters << " <= "
  928. + << iMinIters << "; "
  929. + << "the maximum global iteration value "
  930. + << iMaxIterations << " "
  931. + << "will be used"
  932. + << std::endl);
  933. + iMaxIters = iMaxIterations;
  934. + }
  935. +
  936. + if (typeid(*MaxTimeStep.pGetDriveCaller()) == typeid(PostponedDriveCaller)) {
  937. + dInitialMaxTimeStep = std::numeric_limits<doublereal>::max();
  938. + }
  939. + else{
  940. + dInitialMaxTimeStep = MaxTimeStep.dGet();
  941. + }
  942. +
  943. + if (typeid(*MaxTimeStep.pGetDriveCaller()) == typeid(ConstDriveCaller)
  944. + && MaxTimeStep.dGet() == std::numeric_limits<doublereal>::max()) {
  945. + silent_cerr("warning, "
  946. + << "maximum time step not set and strategy "
  947. + << "factor selected:\n"
  948. + << "the initial time step value will be used as "
  949. + << "maximum time step: "
  950. + << "max time step = "
  951. + << dInitialTimeStep
  952. + << std::endl);
  953. + }
  954. + if (dMinTimeStep == dDefaultMinTimeStep) {
  955. + silent_cerr("warning, "
  956. + << "minimum time step not set and strategy "
  957. + << "factor selected:\n"
  958. + << "the initial time step value will be used as "
  959. + << "minimum time step: "
  960. + << "min time step = "
  961. + << dInitialTimeStep
  962. + << std::endl);
  963. + dMinTimeStep = dInitialTimeStep;
  964. + }
  965. + if (dMinTimeStep == dInitialMaxTimeStep) {
  966. + silent_cerr("error, "
  967. + << "minimum and maximum time step are equal, but "
  968. + << "strategy factor has been selected:\n"
  969. + << "this is almost meaningless"
  970. + << std::endl);
  971. + }
  972. + if (dMinTimeStep > dInitialMaxTimeStep) {
  973. + silent_cerr("error, "
  974. + << "minimum and maximum time step are equal, but "
  975. + << "strategy factor has been selected:\n"
  976. + << "this is meaningless - bailing out"
  977. + << std::endl);
  978. + throw ErrGeneric(MBDYN_EXCEPT_ARGS);
  979. + }
  980. + s->dSetMinTimeStep(dMinTimeStep);
  981. +}
  982. +
  983. +class FactorSTR: public TimeStepRead {
  984. +
  985. +public:
  986. + TimeStepControl *
  987. + Read(Solver * s, MBDynParser& HP);
  988. +};
  989. +
  990. +TimeStepControl *
  991. +FactorSTR::Read( Solver * s, MBDynParser& HP){
  992. +
  993. + integer iMinIters = 1;
  994. + integer iMaxIters = 0;
  995. + doublereal dReductionFactor = HP.GetReal();
  996. + if (dReductionFactor >= 1.) {
  997. + silent_cerr("warning, "
  998. + "illegal reduction factor "
  999. + "at line " << HP.GetLineData()
  1000. + << "; default value 1. "
  1001. + "(no reduction) will be used"
  1002. + << std::endl);
  1003. + dReductionFactor = 1.;
  1004. + }
  1005. +
  1006. + doublereal iStepsBeforeReduction = HP.GetInt();
  1007. + if (iStepsBeforeReduction <= 0) {
  1008. + silent_cerr("warning, "
  1009. + "illegal number of steps "
  1010. + "before reduction at line "
  1011. + << HP.GetLineData()
  1012. + << "; default value 1 will be "
  1013. + "used (it may be dangerous)"
  1014. + << std::endl);
  1015. + iStepsBeforeReduction = 1;
  1016. + }
  1017. +
  1018. + doublereal dRaiseFactor = HP.GetReal();
  1019. + if (dRaiseFactor <= 1.) {
  1020. + silent_cerr("warning, "
  1021. + "illegal raise factor at line "
  1022. + << HP.GetLineData()
  1023. + << "; default value 1. "
  1024. + "(no raise) will be used"
  1025. + << std::endl);
  1026. + dRaiseFactor = 1.;
  1027. + }
  1028. +
  1029. + doublereal iStepsBeforeRaise = HP.GetInt();
  1030. + if (iStepsBeforeRaise <= 0) {
  1031. + silent_cerr("warning, "
  1032. + "illegal number of steps "
  1033. + "before raise at line "
  1034. + << HP.GetLineData()
  1035. + << "; default value 1 will be "
  1036. + "used (it may be dangerous)"
  1037. + << std::endl);
  1038. + iStepsBeforeRaise = 1;
  1039. + }
  1040. +
  1041. + iMinIters = HP.GetInt();
  1042. + if (iMinIters <= 0) {
  1043. + silent_cerr("warning, "
  1044. + "illegal minimum number "
  1045. + "of iterations at line "
  1046. + << HP.GetLineData()
  1047. + << "; default value 0 will be "
  1048. + "used (never raise)"
  1049. + << std::endl);
  1050. + iMinIters = 1;
  1051. + }
  1052. + iMaxIters = 0;
  1053. + if (HP.IsArg()) {
  1054. + iMaxIters = HP.GetInt();
  1055. + if (iMaxIters <= 0) {
  1056. + silent_cerr("warning, "
  1057. + "illegal mmaximim number "
  1058. + "of iterations at line "
  1059. + << HP.GetLineData()
  1060. + << "; default value will be "
  1061. + "used"
  1062. + << std::endl);
  1063. + }
  1064. + }
  1065. +
  1066. + // RETURN THE new FACTOR
  1067. + return new Factor(s,dReductionFactor,
  1068. + iStepsBeforeReduction,
  1069. + dRaiseFactor,
  1070. + iStepsBeforeRaise,
  1071. + iMinIters,
  1072. + iMaxIters);
  1073. +
  1074. +}
  1075. +
  1076. +void
  1077. +InitTimeStepData(void){
  1078. + SetTimeStepData("nochange", new NoChangeSTR);
  1079. + SetTimeStepData("change", new ChangeStepSTR);
  1080. + SetTimeStepData("factor", new FactorSTR);
  1081. +}
  1082. +
  1083. +void
  1084. +DestroyTimeStepData(void){
  1085. + for(TimeStepFuncMapType::iterator it = TimeStepReadMap.begin(); it != TimeStepReadMap.end(); it++){
  1086. + delete it->second;
  1087. + }
  1088. + TimeStepReadMap.clear();
  1089. +}
  1090. +
  1091. +
  1092. +TimeStepControl *
  1093. +ReadTimeStepData( Solver * s, MBDynParser& HP){
  1094. + const char *str = HP.IsWord(TimeStepWordSet);
  1095. + TimeStepFuncMapType::iterator func = TimeStepReadMap.find(std::string(str));
  1096. + if(func == TimeStepReadMap.end()){
  1097. + silent_cerr("unknown Time step type " << s <<std::endl);
  1098. + func = TimeStepReadMap.find(std::string("nochange"));
  1099. + }
  1100. + return func->second->Read(s , HP );
  1101. +}
  1102. +
  1103. diff -uNr ../../mbdyn-1.7.1/mbdyn/base/TimeStepControl.h base/TimeStepControl.h
  1104. --- ../../mbdyn-1.7.1/mbdyn/base/TimeStepControl.h 1970-01-01 05:30:00.000000000 +0530
  1105. +++ base/TimeStepControl.h 2016-08-04 00:13:02.192861262 +0530
  1106. @@ -0,0 +1,99 @@
  1107. +#ifndef TIME_STEP_H
  1108. +#define TIME_STEP_H
  1109. +
  1110. +class TimeStepControl;
  1111. +#include "mbconfig.h"
  1112. +#include "output.h"
  1113. +#include "solman.h"
  1114. +#include <map>
  1115. +#include "solver.h"
  1116. +#include "drive_.h"
  1117. +
  1118. +extern void InitTimeStepData(void);
  1119. +extern void DestroyTimeStepData(void);
  1120. +class TimeStepControl {
  1121. +
  1122. +public:
  1123. + TimeStepControl(){};
  1124. + virtual ~TimeStepControl(void){};
  1125. + virtual doublereal dGetNewStepTime(StepIntegrator::StepChange currStep , doublereal iPerformedIters) = 0;
  1126. + virtual void SetDriveHandler(const DriveHandler* driveHandler) = 0;
  1127. + virtual void Init(doublereal iMaxIterations,doublereal dCurrTimeStep ,DriveOwner & MaxTimeStep , doublereal dInitialTimeStep) = 0;
  1128. +};
  1129. +
  1130. +extern TimeStepControl * ReadTimeStepData(Solver * s, MBDynParser& HP);
  1131. +
  1132. +class TimeStepRead {
  1133. +
  1134. +public:
  1135. + virtual ~TimeStepRead(void){};
  1136. + virtual TimeStepControl *
  1137. + Read( Solver * s, MBDynParser& HP) = 0;
  1138. +};
  1139. +
  1140. +class NoChange : public TimeStepControl {
  1141. +private:
  1142. + Solver * s;
  1143. + doublereal dCurrTimeStep;
  1144. +public:
  1145. + NoChange(Solver * s);
  1146. + doublereal dGetNewStepTime(StepIntegrator::StepChange currStep , doublereal iPerformedIters);
  1147. + void SetDriveHandler(const DriveHandler* driveHandler){}
  1148. + void Init(doublereal iMaxIterations,doublereal dCurrTimeStep ,DriveOwner & MaxTimeStep , doublereal dInitialTimeStep);
  1149. + ~NoChange(){};
  1150. +};
  1151. +
  1152. +
  1153. +class ChangeStep : public TimeStepControl {
  1154. +private:
  1155. + Solver * s;
  1156. + DriveCaller* pStrategyChangeDrive;
  1157. + DriveOwner MaxTimeStep;
  1158. + doublereal dCurrTimeStep;
  1159. +public:
  1160. + ChangeStep(Solver * s,DriveCaller* pStrategyChangeDrive);
  1161. + doublereal dGetNewStepTime(StepIntegrator::StepChange currStep , doublereal iPerformedIters);
  1162. +
  1163. + void SetDriveHandler(const DriveHandler* driveHandler);
  1164. +
  1165. + void Init(doublereal iMaxIterations,doublereal dCurrTimeStep ,DriveOwner & MaxTimeStep , doublereal dInitialTimeStep);
  1166. + ~ChangeStep(){
  1167. + SAFEDELETE(pStrategyChangeDrive);
  1168. + };
  1169. +};
  1170. +
  1171. +class Factor : public TimeStepControl {
  1172. +private:
  1173. + Solver * s;
  1174. + doublereal dReductionFactor;
  1175. + doublereal iStepsBeforeReduction;
  1176. + doublereal dRaiseFactor;
  1177. + doublereal iStepsBeforeRaise;
  1178. + doublereal iMinIters;
  1179. + doublereal iMaxIters;
  1180. + bool bLastChance;
  1181. + doublereal iStepsAfterReduction;
  1182. + doublereal iStepsAfterRaise;
  1183. + doublereal iWeightedPerformedIters;
  1184. + DriveOwner MaxTimeStep;
  1185. +
  1186. + doublereal dCurrTimeStep;
  1187. +
  1188. +public:
  1189. + Factor( Solver * s ,doublereal dReductionFactor,
  1190. + doublereal iStepsBeforeReduction,
  1191. + doublereal dRaiseFactor,
  1192. + doublereal iStepsBeforeRaise,
  1193. + doublereal iMinIters,
  1194. + doublereal iMaxIters );
  1195. + doublereal dGetNewStepTime(StepIntegrator::StepChange Why , doublereal iPerformedIters);
  1196. + void SetDriveHandler(const DriveHandler* driveHandler){}
  1197. + void Init(doublereal iMaxIterations,doublereal dCurrTimeStep ,DriveOwner & MaxTimeStep , doublereal dInitialTimeStep);
  1198. + ~Factor(){};
  1199. +};
  1200. +
  1201. +/********** READER FOR FACTOR **************/
  1202. +
  1203. +/***************SET AND CLEAR FOR MAP ************/
  1204. +
  1205. +#endif
Advertisement
Add Comment
Please, Sign In to add comment