Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
diff -uNr mbdyn-1.7.1/mbdyn/base/invsolver.cc mbdyn-1.7.1!/mbdyn/base/invsolver.cc
--- mbdyn-1.7.1/mbdyn/base/invsolver.cc 2016-04-25 00:40:43.000000000 +0530
+++ mbdyn-1.7.1!/mbdyn/base/invsolver.cc 2016-08-04 00:15:08.594514000 +0530
@@ -245,9 +245,9 @@
/* relink those known drive callers that might need
* the data manager, but were verated ahead of it */
- if (pStrategyChangeDrive) {
+ /*if (pStrategyChangeDrive) {
pStrategyChangeDrive->SetDrvHdl(pDM->pGetDrvHdl());
- }
+ }*/
ASSERT(iNumDofs > 0);
@@ -625,9 +625,11 @@
/* Riduce il passo */
CurrStep = StepIntegrator::REPEATSTEP;
doublereal dOldCurrTimeStep = dCurrTimeStep;
- dCurrTimeStep = NewTimeStep(dCurrTimeStep,
+ dCurrTimeStep = timeStepPtr -> dGetNewStepTime(CurrStep, iStIter);
+ /*dCurrTimeStep = NewTimeStep(dCurrTimeStep,
iStIter,
CurrStep);
+ */
if (dCurrTimeStep < dOldCurrTimeStep) {
DEBUGCOUT("Changing time step"
" during step "
@@ -747,7 +749,8 @@
bSolConv = false;
/* Calcola il nuovo timestep */
- dCurrTimeStep = NewTimeStep(dCurrTimeStep, iStIter, CurrStep);
+ dCurrTimeStep = timeStepPtr -> dGetNewStepTime(CurrStep,iStIter);
+ //NewTimeStep(dCurrTimeStep, iStIter, CurrStep);
DEBUGCOUT("Current time step: " << dCurrTimeStep << std::endl);
return true;
@@ -1110,7 +1113,7 @@
doublereal dTol = ::dDefaultTol;
doublereal dSolutionTol = 0.;
- integer iMaxIterations = ::iDefaultMaxIterations;
+ iMaxIterations = ::iDefaultMaxIterations;
bool bModResTest = false;
#ifdef USE_MULTITHREAD
@@ -1487,129 +1490,12 @@
goto EndOfCycle;
case STRATEGY: {
- switch (KeyWords(HP.GetWord())) {
- case STRATEGYFACTOR: {
- CurrStrategy = FACTOR;
-
- /*
- * strategy: factor ,
- * <reduction factor> ,
- * <steps before reduction> ,
- * <raise factor> ,
- * <steps before raise> ,
- * <min iterations> ,
- * <max iterations> ;
- */
-
- StrategyFactor.dReductionFactor = HP.GetReal();
- if (StrategyFactor.dReductionFactor >= 1.) {
- silent_cerr("warning, "
- "illegal reduction factor "
- "at line " << HP.GetLineData()
- << "; default value 1. "
- "(no reduction) will be used"
- << std::endl);
- StrategyFactor.dReductionFactor = 1.;
- }
-
- StrategyFactor.iStepsBeforeReduction = HP.GetInt();
- if (StrategyFactor.iStepsBeforeReduction <= 0) {
- silent_cerr("warning, "
- "illegal number of steps "
- "before reduction at line "
- << HP.GetLineData()
- << "; default value 1 will be "
- "used (it may be dangerous)"
- << std::endl);
- StrategyFactor.iStepsBeforeReduction = 1;
- }
-
- StrategyFactor.dRaiseFactor = HP.GetReal();
- if (StrategyFactor.dRaiseFactor <= 1.) {
- silent_cerr("warning, "
- "illegal raise factor at line "
- << HP.GetLineData()
- << "; default value 1. "
- "(no raise) will be used"
- << std::endl);
- StrategyFactor.dRaiseFactor = 1.;
- }
-
- StrategyFactor.iStepsBeforeRaise = HP.GetInt();
- if (StrategyFactor.iStepsBeforeRaise <= 0) {
- silent_cerr("warning, "
- "illegal number of steps "
- "before raise at line "
- << HP.GetLineData()
- << "; default value 1 will be "
- "used (it may be dangerous)"
- << std::endl);
- StrategyFactor.iStepsBeforeRaise = 1;
- }
-
- StrategyFactor.iMinIters = HP.GetInt();
- if (StrategyFactor.iMinIters <= 0) {
- silent_cerr("warning, "
- "illegal minimum number "
- "of iterations at line "
- << HP.GetLineData()
- << "; default value 0 will be "
- "used (never raise)"
- << std::endl);
- StrategyFactor.iMinIters = 1;
- }
- StrategyFactor.iMaxIters = 0;
- if (HP.IsArg()) {
- StrategyFactor.iMaxIters = HP.GetInt();
- if (StrategyFactor.iMaxIters <= 0) {
- silent_cerr("warning, "
- "illegal mmaximim number "
- "of iterations at line "
- << HP.GetLineData()
- << "; default value will be "
- "used"
- << std::endl);
- StrategyFactor.iMaxIters = 0;
- }
- }
-
- DEBUGLCOUT(MYDEBUG_INPUT,
- "Time step control strategy: "
- "Factor" << std::endl
- << "Reduction factor: "
- << StrategyFactor.dReductionFactor
- << "Steps before reduction: "
- << StrategyFactor.iStepsBeforeReduction
- << "Raise factor: "
- << StrategyFactor.dRaiseFactor
- << "Steps before raise: "
- << StrategyFactor.iStepsBeforeRaise
- << "Min iterations: "
- << StrategyFactor.iMinIters
- << "Max iterations: "
- << StrategyFactor.iMaxIters
- << std::endl);
- break;
- }
-
- case STRATEGYNOCHANGE: {
- CurrStrategy = NOCHANGE;
- break;
- }
-
- case STRATEGYCHANGE: {
- CurrStrategy = CHANGE;
+ timeStepPtr = ReadTimeStepData(this,HP);
+ /*if(typeid(timeStepPtr) == typeid(ChangeStep)){
pStrategyChangeDrive = HP.GetDriveCaller(true);
- break;
- }
-
- default:
- silent_cerr("unknown time step control "
- "strategy at line "
- << HP.GetLineData() << std::endl);
- throw ErrGeneric(MBDYN_EXCEPT_ARGS);
- }
+ }*/
+
break;
}
@@ -1948,7 +1834,7 @@
EndOfCycle: /* esce dal ciclo di lettura */
- switch (CurrStrategy) {
+ /*switch (CurrStrategy) {
case FACTOR:
if (StrategyFactor.iMaxIters <= StrategyFactor.iMinIters) {
silent_cerr("warning, "
@@ -1967,7 +1853,7 @@
default:
break;
- }
+ }*/
if (dFinalTime < dInitialTime) {
eAbortAfter = AFTER_ASSEMBLY;
diff -uNr mbdyn-1.7.1/mbdyn/base/Makefile.am mbdyn-1.7.1!/mbdyn/base/Makefile.am
--- mbdyn-1.7.1/mbdyn/base/Makefile.am 2016-04-25 00:40:43.000000000 +0530
+++ mbdyn-1.7.1!/mbdyn/base/Makefile.am 2016-07-18 23:52:53.402920000 +0530
@@ -169,6 +169,9 @@
vec3drv.h \
thirdorderstepsol.h \
thirdorderstepsol.cc \
+TimeStepControl.h \
+TimeStepControl.cc \
+TimeStepFunctorClass.h\
userelem.cc \
userelem.h \
usesock.cc \
diff -uNr mbdyn-1.7.1/mbdyn/base/Makefile.in mbdyn-1.7.1!/mbdyn/base/Makefile.in
--- mbdyn-1.7.1/mbdyn/base/Makefile.in 2016-04-25 01:03:37.000000000 +0530
+++ mbdyn-1.7.1!/mbdyn/base/Makefile.in 2016-07-18 23:54:21.578985000 +0530
@@ -194,11 +194,12 @@
solver.cc solver.h solver_impl.h solverdiagnostics.cc \
solverdiagnostics.h stepsol.cc stepsol.h stepsol.hc symcltp.h \
tpldrive.cc tpldrive.h tpldrive_impl.cc tpldrive_impl.h \
- vec3drv.h thirdorderstepsol.h thirdorderstepsol.cc userelem.cc \
- userelem.h usesock.cc usesock.h varstep.cc varstep.h \
- ScalarFunctions.h ScalarFunctionsImpl.h ScalarFunctionsImpl.cc \
- ginaccltp.h ginacdrive.cc ginacdrive.h mbrtai_utils.c \
- mbrtai_utils.h rtai_in_drive.cc rtai_in_drive.h \
+ vec3drv.h thirdorderstepsol.h thirdorderstepsol.cc \
+ TimeStepControl.h TimeStepControl.cc TimeStepFunctorClass.h \
+ userelem.cc userelem.h usesock.cc usesock.h varstep.cc \
+ varstep.h ScalarFunctions.h ScalarFunctionsImpl.h \
+ ScalarFunctionsImpl.cc ginaccltp.h ginacdrive.cc ginacdrive.h \
+ mbrtai_utils.c mbrtai_utils.h rtai_in_drive.cc rtai_in_drive.h \
rtai_out_elem.cc rtai_out_elem.h rtaisolver.cc rtaisolver.h \
eigjdqz.cc eigjdqz.h schurdataman.cc schurdataman.h
@USE_GINAC_TRUE@am__objects_1 = ginacdrive.lo
@@ -223,9 +224,10 @@
simentity.lo sockdrv.lo socketstreamdrive.lo \
socketstream_out_elem.lo streamdrive.lo streamoutelem.lo \
solver.lo solverdiagnostics.lo stepsol.lo tpldrive.lo \
- tpldrive_impl.lo thirdorderstepsol.lo userelem.lo usesock.lo \
- varstep.lo ScalarFunctionsImpl.lo $(am__objects_1) \
- $(am__objects_2) $(am__objects_3) $(am__objects_4)
+ tpldrive_impl.lo thirdorderstepsol.lo TimeStepControl.lo \
+ userelem.lo usesock.lo varstep.lo ScalarFunctionsImpl.lo \
+ $(am__objects_1) $(am__objects_2) $(am__objects_3) \
+ $(am__objects_4)
@BUILD_STATIC_MODULES_TRUE@am__objects_5 = module-nodedistdrive.lo \
@BUILD_STATIC_MODULES_TRUE@ module-minmaxdrive.lo
@BUILD_STATIC_MODULES_TRUE@@USE_OCTAVE_TRUE@am__objects_6 = \
@@ -536,11 +538,12 @@
solver.cc solver.h solver_impl.h solverdiagnostics.cc \
solverdiagnostics.h stepsol.cc stepsol.h stepsol.hc symcltp.h \
tpldrive.cc tpldrive.h tpldrive_impl.cc tpldrive_impl.h \
- vec3drv.h thirdorderstepsol.h thirdorderstepsol.cc userelem.cc \
- userelem.h usesock.cc usesock.h varstep.cc varstep.h \
- ScalarFunctions.h ScalarFunctionsImpl.h ScalarFunctionsImpl.cc \
- $(am__append_3) $(am__append_4) $(am__append_5) \
- $(am__append_6)
+ vec3drv.h thirdorderstepsol.h thirdorderstepsol.cc \
+ TimeStepControl.h TimeStepControl.cc TimeStepFunctorClass.h \
+ userelem.cc userelem.h usesock.cc usesock.h varstep.cc \
+ varstep.h ScalarFunctions.h ScalarFunctionsImpl.h \
+ ScalarFunctionsImpl.cc $(am__append_3) $(am__append_4) \
+ $(am__append_5) $(am__append_6)
nodist_libbase_la_SOURCES = $(am__append_1) $(am__append_2)
libbase_la_LIBADD = @LIBS@ @SECURITY_LIBS@ $(GINACLIB_LIBS)
libbase_la_LDFLAGS = -static
@@ -638,6 +641,7 @@
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ScalarFunctionsImpl.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TimeStepControl.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/adams_res.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/auth.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bicg.Plo@am__quote@
diff -uNr mbdyn-1.7.1/mbdyn/base/solver.cc mbdyn-1.7.1!/mbdyn/base/solver.cc
--- mbdyn-1.7.1/mbdyn/base/solver.cc 2016-04-25 00:40:43.000000000 +0530
+++ mbdyn-1.7.1!/mbdyn/base/solver.cc 2016-08-04 00:17:52.796632000 +0530
@@ -78,13 +78,14 @@
#include "Rot.hh"
#include "cleanup.h"
#include "drive_.h"
-
+#include "TimeStepControl.h"
#include "solver_impl.h"
#include "ac/lapack.h"
#include "ac/arpack.h"
#include "eigjdqz.h"
+
#ifdef HAVE_SIGNAL
/*
* MBDyn starts with mbdyn_keep_going == MBDYN_KEEP_GOING.
@@ -267,11 +268,9 @@
#ifdef USE_MULTITHREAD
nThreads(nThreads),
#endif /* USE_MULTITHREAD */
-CurrStrategy(NOCHANGE),
sInputFileName(sInFName),
sOutputFileName(sOutFName),
HP(HPar),
-pStrategyChangeDrive(NULL),
EigAn(),
pRTSolver(0),
iNumPreviousVectors(2),
@@ -294,10 +293,6 @@
iDummyStepsNumber(::iDefaultDummyStepsNumber),
dDummyStepsRatio(::dDefaultDummyStepsRatio),
eAbortAfter(AFTER_UNKNOWN),
-iStepsAfterReduction(0),
-iStepsAfterRaise(0),
-iWeightedPerformedIters(0),
-bLastChance(false),
RegularType(INT_UNKNOWN),
DummyType(INT_UNKNOWN),
pDerivativeSteps(0),
@@ -347,6 +342,7 @@
iTotIter(0),
iStIter(0),
dTotErr(0.),
+timeStepPtr(NULL),
dTest(std::numeric_limits<double>::max()),
dSolTest(std::numeric_limits<double>::max()),
bSolConv(false),
@@ -354,11 +350,8 @@
lStep(0)
{
DEBUGCOUTFNAME("Solver::Solver");
-
+ ::InitTimeStepData();
ASSERT(!sInFName.empty());
-
- StrategyFactor.iMinIters = 1;
- StrategyFactor.iMaxIters = 0;
}
#ifdef USE_MULTITHREAD
@@ -569,9 +562,10 @@
/* relink those known drive callers that might need
* the data manager, but were verated ahead of it */
- if (pStrategyChangeDrive) {
+ timeStepPtr->SetDriveHandler(pDM->pGetDrvHdl());
+ /*if (pStrategyChangeDrive) {
pStrategyChangeDrive->SetDrvHdl(pDM->pGetDrvHdl());
- }
+ }*/
ASSERT(iNumDofs > 0);
@@ -1198,8 +1192,10 @@
dCurrTimeStep = dRefTimeStep;
ASSERT(pFirstRegularStep!= NULL);
- StepIntegrator::StepChange CurrStep = StepIntegrator::NEWSTEP;
+ CurrStep = StepIntegrator::NEWSTEP;
+
+ timeStepPtr->Init(iMaxIterations,dCurrTimeStep ,MaxTimeStep ,dInitialTimeStep);
/* Setup SolutionManager(s) */
SetupSolmans(pFirstRegularStep->GetIntegratorNumUnknownStates(), true);
pCurrStepIntegrator = pFirstRegularStep;
@@ -1222,9 +1218,10 @@
/* Riduce il passo */
CurrStep = StepIntegrator::REPEATSTEP;
doublereal dOldCurrTimeStep = dCurrTimeStep;
- dCurrTimeStep = NewTimeStep(dOldCurrTimeStep,
+ dCurrTimeStep = timeStepPtr->dGetNewStepTime(CurrStep, iStIter);
+ /*dCurrTimeStep = NewTimeStep(dOldCurrTimeStep,
iStIter,
- CurrStep);
+ CurrStep);*/
if (dCurrTimeStep < dOldCurrTimeStep) {
DEBUGCOUT("Changing time step"
" from " << dOldCurrTimeStep
@@ -1343,7 +1340,7 @@
throw ErrGeneric(MBDYN_EXCEPT_ARGS);
}
- StepIntegrator::StepChange CurrStep = StepIntegrator::NEWSTEP;
+ CurrStep = StepIntegrator::NEWSTEP;
if (pDM->EndOfSimulation() || dTime >= dFinalTime) {
if (pRTSolver) {
@@ -1432,9 +1429,10 @@
/* Riduce il passo */
CurrStep = StepIntegrator::REPEATSTEP;
doublereal dOldCurrTimeStep = dCurrTimeStep;
- dCurrTimeStep = NewTimeStep(dOldCurrTimeStep,
+ dCurrTimeStep = timeStepPtr->dGetNewStepTime(CurrStep , iStIter);
+ /*dCurrTimeStep = NewTimeStep(dOldCurrTimeStep,
iStIter,
- CurrStep);
+ CurrStep);*/
if (dCurrTimeStep < dOldCurrTimeStep) {
DEBUGCOUT("Changing time step"
" from " << dOldCurrTimeStep
@@ -1463,9 +1461,10 @@
/* Riduce il passo */
CurrStep = StepIntegrator::REPEATSTEP;
doublereal dOldCurrTimeStep = dCurrTimeStep;
- dCurrTimeStep = NewTimeStep(dOldCurrTimeStep,
+ dCurrTimeStep = timeStepPtr->dGetNewStepTime(CurrStep , iStIter);
+ /*dCurrTimeStep = NewTimeStep(dOldCurrTimeStep,
iStIter,
- CurrStep);
+ CurrStep);*/
if (dCurrTimeStep < dOldCurrTimeStep) {
DEBUGCOUT("Changing time step"
" from " << dOldCurrTimeStep
@@ -1587,7 +1586,8 @@
}
/* Calcola il nuovo timestep */
- dCurrTimeStep = NewTimeStep(dCurrTimeStep, iStIter, CurrStep);
+ dCurrTimeStep = timeStepPtr->dGetNewStepTime(CurrStep , iStIter);
+ //dCurrTimeStep = NewTimeStep(dCurrTimeStep, iStIter, CurrStep);
DEBUGCOUT("Current time step: " << dCurrTimeStep << std::endl);
return true;
@@ -1669,9 +1669,10 @@
SAFEDELETE(pNLS);
}
- if (pStrategyChangeDrive) {
+ /*if (pStrategyChangeDrive) {
SAFEDELETE(pStrategyChangeDrive);
- }
+ }*/
+ DestroyTimeStepData();
}
/* Nuovo delta t */
@@ -1680,7 +1681,7 @@
integer iPerformedIters,
StepIntegrator::StepChange Why)
{
- DEBUGCOUTFNAME("Solver::NewTimeStep");
+ /*DEBUGCOUTFNAME("Solver::NewTimeStep");
switch (CurrStrategy) {
case NOCHANGE:
@@ -1714,7 +1715,7 @@
/*
* Fuori viene intercettato
* il valore illegale
- */
+ *
return std::min(dCurrTimeStep*StrategyFactor.dReductionFactor, MaxTimeStep.dGet());
}
}
@@ -1753,8 +1754,9 @@
silent_cerr("You shouldn't have reached this point!" << std::endl);
throw Solver::ErrGeneric(MBDYN_EXCEPT_ARGS);
}
+ */
- return dCurrTimeStep;
+ return 0.;
}
/*scrive il contributo al file di restart*/
@@ -2149,7 +2151,7 @@
doublereal dTol = ::dDefaultTol;
doublereal dSolutionTol = 0.;
- integer iMaxIterations = ::iDefaultMaxIterations;
+ iMaxIterations = ::iDefaultMaxIterations;
bool bModResTest = false;
bool bSetScaleAlgebraic = false;
@@ -2938,8 +2940,14 @@
throw ErrGeneric(MBDYN_EXCEPT_ARGS);
}
goto EndOfCycle;
-
+ ///Start over here
case STRATEGY: {
+
+ timeStepPtr = ReadTimeStepData(this,HP);
+ /*if(typeid(timeStepPtr) == typeid(ChangeStep)){
+ pStrategyChangeDrive = HP.GetDriveCaller(true);
+ }
+ // call the read function for the TimeStepRead
switch (KeyWords(HP.GetWord())) {
case STRATEGYFACTOR: {
CurrStrategy = FACTOR;
@@ -2954,7 +2962,7 @@
* <max iterations> ;
*/
- StrategyFactor.dReductionFactor = HP.GetReal();
+ /*StrategyFactor.dReductionFactor = HP.GetReal();
if (StrategyFactor.dReductionFactor >= 1.) {
silent_cerr("warning, "
"illegal reduction factor "
@@ -3060,7 +3068,7 @@
"strategy at line "
<< HP.GetLineData() << std::endl);
throw ErrGeneric(MBDYN_EXCEPT_ARGS);
- }
+ }*/
break;
}
@@ -3811,86 +3819,18 @@
SAFENEWWITHCONSTRUCTOR(pDC, ConstDriveCaller, ConstDriveCaller(::dDefaultMaxTimeStep));
MaxTimeStep.Set(pDC);
}
-
- switch (CurrStrategy) {
- case FACTOR:
- if (StrategyFactor.iMaxIters <= StrategyFactor.iMinIters) {
- silent_cerr("warning, "
- << "strategy maximum number "
- << "of iterations "
- << "is <= minimum: "
- << StrategyFactor.iMaxIters << " <= "
- << StrategyFactor.iMinIters << "; "
- << "the maximum global iteration value "
- << iMaxIterations << " "
- << "will be used"
- << std::endl);
- StrategyFactor.iMaxIters = iMaxIterations;
- }
- if (typeid(*MaxTimeStep.pGetDriveCaller()) == typeid(ConstDriveCaller)
- && MaxTimeStep.dGet() == ::dDefaultMaxTimeStep) {
- silent_cerr("warning, "
- << "maximum time step not set and strategy "
- << "factor selected:\n"
- << "the initial time step value will be used as "
- << "maximum time step: "
- << "max time step = "
- << dInitialTimeStep
- << std::endl);
- MaxTimeStep.Set(new ConstDriveCaller(dInitialTimeStep));
- }
- if (dMinTimeStep == dDefaultMinTimeStep) {
- silent_cerr("warning, "
- << "minimum time step not set and strategy "
- << "factor selected:\n"
- << "the initial time step value will be used as "
- << "minimum time step: "
- << "min time step = "
- << dInitialTimeStep
- << std::endl);
- dMinTimeStep = dInitialTimeStep;
- }
- if (dMinTimeStep == dGetInitialMaxTimeStep()) {
- silent_cerr("error, "
- << "minimum and maximum time step are equal, but "
- << "strategy factor has been selected:\n"
- << "this is almost meaningless"
- << std::endl);
- }
- if (dMinTimeStep > dGetInitialMaxTimeStep()) {
- silent_cerr("error, "
- << "minimum and maximum time step are equal, but "
- << "strategy factor has been selected:\n"
- << "this is meaningless - bailing out"
- << std::endl);
- throw ErrGeneric(MBDYN_EXCEPT_ARGS);
- }
- break;
-
- case CHANGE:
- if (dMinTimeStep > dGetInitialMaxTimeStep()) {
- silent_cerr("inconsistent min/max time step"
- << std::endl);
- throw ErrGeneric(MBDYN_EXCEPT_ARGS);
- }
- break;
-
- default:
- if (dMinTimeStep != ::dDefaultMinTimeStep) {
- silent_cerr("\"min time step\" only allowed with variable time step (ignored)." <<std::endl);
- }
- dMinTimeStep = dInitialTimeStep;
-
- if (typeid(*MaxTimeStep.pGetDriveCaller()) == typeid(ConstDriveCaller)) {
- if (dGetInitialMaxTimeStep() != dDefaultMaxTimeStep) {
- silent_cerr("\"max time step\" only allowed with variable time step (ignored)." <<std::endl);
- }
- MaxTimeStep.Set(new ConstDriveCaller(dInitialTimeStep));
- }
-
- break;
+
+ if (typeid(*MaxTimeStep.pGetDriveCaller()) == typeid(ConstDriveCaller)) {
+ MaxTimeStep.Set(new ConstDriveCaller(dInitialTimeStep));
}
+ if(timeStepPtr == NULL){
+ silent_cout("TimeStepPtr is NULL Creating NoChange \n" );
+ timeStepPtr = new NoChange(this);
+ }
+
+ //timeStepPtr->SetUpMaxTimeStep(MaxTimeStep , dInitialTimeStep);
+
if (dFinalTime < dInitialTime) {
eAbortAfter = AFTER_ASSEMBLY;
}
diff -uNr mbdyn-1.7.1/mbdyn/base/solver.h mbdyn-1.7.1!/mbdyn/base/solver.h
--- mbdyn-1.7.1/mbdyn/base/solver.h 2016-04-25 00:40:43.000000000 +0530
+++ mbdyn-1.7.1!/mbdyn/base/solver.h 2016-08-04 00:10:27.794806000 +0530
@@ -65,9 +65,10 @@
#include "nonlin.h"
#include "linesearch.h"
#include "mfree.h"
+#include "cstring"
#include "precond.h"
#include "rtsolver.h"
-
+#include "TimeStepControl.h"
extern "C" int mbdyn_stop_at_end_of_iteration(void);
extern "C" int mbdyn_stop_at_end_of_time_step(void);
extern "C" void mbdyn_set_stop_at_end_of_iteration(void);
@@ -101,32 +102,31 @@
void ThreadPrepare(void);
#endif /* USE_MULTITHREAD */
-
- enum Strategy {
- NOCHANGE,
- CHANGE,
- FACTOR
- } CurrStrategy;
-
+ TimeStepControl * timeStepPtr;
+ doublereal dCurrTimeStep;
+ integer iStIter;
+ doublereal dTime;
+ DriveOwner MaxTimeStep;
+ doublereal dMinTimeStep;
+ StepIntegrator::StepChange CurrStep = StepIntegrator::NEWSTEP;
std::string sInputFileName;
std::string sOutputFileName;
MBDynParser& HP;
-
- /* Dati per strategia FACTOR */
- struct {
- doublereal dReductionFactor;
- doublereal dRaiseFactor;
- integer iStepsBeforeReduction;
- integer iStepsBeforeRaise;
- integer iMinIters;
- integer iMaxIters;
- } StrategyFactor;
-
- /* Dati per strategia DRIVER_CHANGE */
- DriveCaller* pStrategyChangeDrive;
-
+ integer iMaxIterations;
+//***** Method for StepTime ****/
+public:
+
+ doublereal dGetdMinTimeStep() {
+ return dMinTimeStep;
+ }
+
+ void dSetMinTimeStep(doublereal val) {
+ dMinTimeStep = val;
+ }
+
public:
/* Dati per esecuzione di eigenanalysis */
+
struct EigenAnalysis {
bool bAnalysis;
enum {
@@ -234,13 +234,13 @@
MyVectorHandler* pXPrime; /* queque vett. stati d. inc. */
/* Dati della simulazione */
- doublereal dTime;
+
doublereal dInitialTime;
doublereal dFinalTime;
doublereal dRefTimeStep;
doublereal dInitialTimeStep;
- doublereal dMinTimeStep;
- DriveOwner MaxTimeStep;
+
+
doublereal dMaxResidual;
doublereal dMaxResidualDiff;
@@ -263,12 +263,6 @@
};
AbortAfter eAbortAfter;
- /* Parametri per la variazione passo */
- integer iStepsAfterReduction;
- integer iStepsAfterRaise;
- integer iWeightedPerformedIters;
- bool bLastChance;
-
/* Parametri per il metodo */
enum StepIntegratorType {
INT_CRANKNICOLSON,
@@ -367,12 +361,12 @@
SOLVER_STATUS_PREPARED,
SOLVER_STATUS_STARTED
} eStatus;
- doublereal dCurrTimeStep;
+
bool bOutputCounter;
std::string outputCounterPrefix;
std::string outputCounterPostfix;
integer iTotIter;
- integer iStIter;
+
doublereal dTotErr;
doublereal dTest;
doublereal dSolTest;
diff -uNr mbdyn-1.7.1/mbdyn/base/TimeStepControl.cc mbdyn-1.7.1!/mbdyn/base/TimeStepControl.cc
--- mbdyn-1.7.1/mbdyn/base/TimeStepControl.cc 1970-01-01 05:30:00.000000000 +0530
+++ mbdyn-1.7.1!/mbdyn/base/TimeStepControl.cc 2016-08-15 23:15:09.904391000 +0530
@@ -0,0 +1,417 @@
+/*
+ * MBDyn (C) is a multibody analysis code.
+ * http://www.mbdyn.org
+ *
+ * Copyright (C) 1996-2015
+ *
+ * Pierangelo Masarati <masarati@aero.polimi.it>
+ * Paolo Mantegazza <mantegazza@aero.polimi.it>
+ *
+ * Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
+ * via La Masa, 34 - 20156 Milano, Italy
+ * http://www.aero.polimi.it
+ *
+ * Changing this copyright notice is forbidden.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation (version 2 of the License).
+ *
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+ /*
+ * With the contribution of Ankit Aggarwal <ankit.ankit.aggarwal@gmail.com>
+ * during Google Summer of Code 2016
+ */
+
+#include "mbconfig.h"
+#include "TimeStepControl.h"
+
+typedef std::map<std::string,TimeStepRead * > TimeStepFuncMapType;
+
+TimeStepFuncMapType TimeStepReadMap;
+
+struct TimeStepWordSetType : public HighParser::WordSet{
+
+ bool IsWord(const std::string& s) const{
+ return TimeStepReadMap.find(s) != TimeStepReadMap.end();
+ };
+};
+
+TimeStepWordSetType TimeStepWordSet;
+
+bool
+SetTimeStepData(const char *name , TimeStepRead * sr){
+ return TimeStepReadMap.insert(std::make_pair(name,sr)).second;
+}
+
+
+NoChange::NoChange(Solver * s): s(s){
+}
+
+doublereal
+NoChange::dGetNewStepTime(StepIntegrator::StepChange currStep , doublereal iPerformedIters) {
+
+ return dCurrTimeStep;
+}
+
+void
+NoChange::Init(doublereal iMaxIterations,doublereal dCurrTimeStep ,DriveOwner & MaxTimeStep , doublereal dInitialTimeStep){
+
+ this->dCurrTimeStep = dCurrTimeStep;
+ doublereal dMinTimeStep = s->dGetdMinTimeStep();
+ doublereal dDefaultMinTimeStep = -1.;
+ if (dMinTimeStep != dDefaultMinTimeStep) {
+ silent_cerr("\"min time step\" only allowed with variable time step (ignored)." <<std::endl);
+ }
+ dMinTimeStep = dInitialTimeStep;
+
+ doublereal dInitialMaxTimeStep ;
+ if (typeid(*MaxTimeStep.pGetDriveCaller()) == typeid(PostponedDriveCaller)) {
+ dInitialMaxTimeStep = std::numeric_limits<doublereal>::max();
+ }
+ else{
+ dInitialMaxTimeStep = MaxTimeStep.dGet();
+ }
+
+ if (dInitialMaxTimeStep != std::numeric_limits<doublereal>::max()) {
+ silent_cerr("\"max time step\" only allowed with variable time step (ignored)." <<std::endl);
+ }
+ s->dSetMinTimeStep(dMinTimeStep);
+
+}
+
+struct NoChangeSTR : public TimeStepRead {
+ TimeStepControl *
+ Read(Solver * s, MBDynParser& HP);
+};
+
+TimeStepControl *
+NoChangeSTR::Read(Solver * s, MBDynParser& HP){
+ return new NoChange(s);
+}
+
+ChangeStep::ChangeStep(Solver *s , DriveCaller* pStrategyChangeDrive):
+s(s),
+pStrategyChangeDrive(pStrategyChangeDrive)
+{}
+
+doublereal
+ChangeStep::dGetNewStepTime(StepIntegrator::StepChange currStep , doublereal iPerformedIters){
+ doublereal dNewStep = pStrategyChangeDrive->dGet();
+ doublereal maxTimeStepval = MaxTimeStep.dGet();;
+
+ doublereal dMinTimeStep = s->dGetdMinTimeStep();
+
+ if (currStep == StepIntegrator::REPEATSTEP
+ && dNewStep == dCurrTimeStep){
+ return dMinTimeStep/2.;
+ }
+ return std::max(std::min(dNewStep, maxTimeStepval), dMinTimeStep);
+}
+
+void
+ChangeStep::SetDriveHandler(const DriveHandler* driveHandler){
+ pStrategyChangeDrive->SetDrvHdl(driveHandler);
+}
+
+
+void
+ChangeStep::Init(doublereal iMaxIterations,doublereal dCurrTimeStep ,DriveOwner & MaxTimeStep , doublereal dInitialTimeStep){
+ this->dCurrTimeStep = dCurrTimeStep;
+ this->MaxTimeStep = MaxTimeStep;
+ doublereal dMinTimeStep = s->dGetdMinTimeStep();
+ doublereal dInitialMaxTimeStep ;
+ if (typeid(*MaxTimeStep.pGetDriveCaller()) == typeid(PostponedDriveCaller)) {
+ dInitialMaxTimeStep = std::numeric_limits<doublereal>::max();
+ }
+ else{
+ dInitialMaxTimeStep = MaxTimeStep.dGet();
+ }
+ if (dMinTimeStep > dInitialMaxTimeStep) {
+ silent_cerr("inconsistent min/max time step"
+ << std::endl);
+ throw ErrGeneric(MBDYN_EXCEPT_ARGS);
+ }
+}
+
+class ChangeStepSTR : public TimeStepRead{
+
+public:
+ TimeStepControl *
+ Read(Solver * s, MBDynParser& HP);
+};
+
+TimeStepControl *
+ChangeStepSTR::Read(Solver * s, MBDynParser& HP){
+ return new ChangeStep(s , HP.GetDriveCaller(true));
+}
+
+Factor::Factor(Solver * s ,doublereal dReductionFactor,
+ doublereal iStepsBeforeReduction,
+ doublereal dRaiseFactor,
+ doublereal iStepsBeforeRaise,
+ doublereal iMinIters,
+ doublereal iMaxIters ):
+s(s),
+dReductionFactor(dReductionFactor),
+iStepsBeforeReduction(iStepsBeforeReduction),
+dRaiseFactor(dRaiseFactor),
+iStepsBeforeRaise(iStepsBeforeRaise),
+iMinIters(iMinIters),
+iMaxIters(iMaxIters),
+bLastChance(false),
+iStepsAfterReduction(0),
+iStepsAfterRaise(0),
+iWeightedPerformedIters(0)
+{}
+
+doublereal
+Factor::dGetNewStepTime(StepIntegrator::StepChange Why , doublereal iPerformedIters){
+ doublereal dMinTimeStep = s->dGetdMinTimeStep();
+ doublereal maxTimeStepval = MaxTimeStep.dGet();
+
+ if (Why == StepIntegrator::REPEATSTEP) {
+ if (dCurrTimeStep*dReductionFactor > dMinTimeStep){
+ if (bLastChance == true) {
+ bLastChance = false;
+ }
+ iStepsAfterReduction = 0;
+ return std::min(dCurrTimeStep*dReductionFactor, maxTimeStepval);
+
+ } else {
+ if (bLastChance == false) {
+ bLastChance = true;
+ return dMinTimeStep;
+ } else {
+ return std::min(dCurrTimeStep*dReductionFactor, maxTimeStepval);
+ }
+ }
+ }
+
+ if (Why == StepIntegrator::NEWSTEP) {
+ iStepsAfterReduction++;
+ iStepsAfterRaise++;
+
+ iWeightedPerformedIters = (10*iPerformedIters + 9*iWeightedPerformedIters)/10;
+
+ if (iPerformedIters > iMaxIters) {
+ iStepsAfterReduction = 0;
+ bLastChance = false;
+ return std::min(std::max(dCurrTimeStep*dReductionFactor, dMinTimeStep), maxTimeStepval);
+
+ } else if (iPerformedIters <= iMinIters
+ && iStepsAfterReduction >iStepsBeforeReduction
+ && iStepsAfterRaise > iStepsBeforeRaise
+ && dCurrTimeStep < maxTimeStepval)
+ {
+ iStepsAfterRaise = 0;
+ iWeightedPerformedIters = 0;
+ return std::min(dCurrTimeStep*dRaiseFactor, maxTimeStepval);
+ }
+ return dCurrTimeStep;
+ }
+ //Should Not Reach Over here
+ return 0.;
+}
+
+
+void
+Factor::Init(doublereal iMaxIterations , doublereal dCurrTimeStep ,DriveOwner & MaxTimeStep , doublereal dInitialTimeStep){
+
+ this->dCurrTimeStep = dCurrTimeStep;
+ this->MaxTimeStep = MaxTimeStep;
+ doublereal dDefaultMinTimeStep = -1.;
+ doublereal dInitialMaxTimeStep ;
+ doublereal dMinTimeStep = s->dGetdMinTimeStep();
+
+ if(iMaxIters <= iMinIters) {
+ silent_cerr("warning, "
+ << "strategy maximum number "
+ << "of iterations "
+ << "is <= minimum: "
+ << iMaxIters << " <= "
+ << iMinIters << "; "
+ << "the maximum global iteration value "
+ << iMaxIterations << " "
+ << "will be used"
+ << std::endl);
+ iMaxIters = iMaxIterations;
+ }
+
+ if (typeid(*MaxTimeStep.pGetDriveCaller()) == typeid(PostponedDriveCaller)) {
+ dInitialMaxTimeStep = std::numeric_limits<doublereal>::max();
+ }
+ else{
+ dInitialMaxTimeStep = MaxTimeStep.dGet();
+ }
+
+ if (typeid(*MaxTimeStep.pGetDriveCaller()) == typeid(ConstDriveCaller)
+ && MaxTimeStep.dGet() == std::numeric_limits<doublereal>::max()) {
+ silent_cerr("warning, "
+ << "maximum time step not set and strategy "
+ << "factor selected:\n"
+ << "the initial time step value will be used as "
+ << "maximum time step: "
+ << "max time step = "
+ << dInitialTimeStep
+ << std::endl);
+ }
+ if (dMinTimeStep == dDefaultMinTimeStep) {
+ silent_cerr("warning, "
+ << "minimum time step not set and strategy "
+ << "factor selected:\n"
+ << "the initial time step value will be used as "
+ << "minimum time step: "
+ << "min time step = "
+ << dInitialTimeStep
+ << std::endl);
+ dMinTimeStep = dInitialTimeStep;
+ }
+ if (dMinTimeStep == dInitialMaxTimeStep) {
+ silent_cerr("error, "
+ << "minimum and maximum time step are equal, but "
+ << "strategy factor has been selected:\n"
+ << "this is almost meaningless"
+ << std::endl);
+ }
+ if (dMinTimeStep > dInitialMaxTimeStep) {
+ silent_cerr("error, "
+ << "minimum and maximum time step are equal, but "
+ << "strategy factor has been selected:\n"
+ << "this is meaningless - bailing out"
+ << std::endl);
+ throw ErrGeneric(MBDYN_EXCEPT_ARGS);
+ }
+ s->dSetMinTimeStep(dMinTimeStep);
+}
+
+class FactorSTR: public TimeStepRead {
+
+public:
+ TimeStepControl *
+ Read(Solver * s, MBDynParser& HP);
+};
+
+TimeStepControl *
+FactorSTR::Read( Solver * s, MBDynParser& HP){
+
+ integer iMinIters = 1;
+ integer iMaxIters = 0;
+ doublereal dReductionFactor = HP.GetReal();
+ if (dReductionFactor >= 1.) {
+ silent_cerr("warning, "
+ "illegal reduction factor "
+ "at line " << HP.GetLineData()
+ << "; default value 1. "
+ "(no reduction) will be used"
+ << std::endl);
+ dReductionFactor = 1.;
+ }
+
+ doublereal iStepsBeforeReduction = HP.GetInt();
+ if (iStepsBeforeReduction <= 0) {
+ silent_cerr("warning, "
+ "illegal number of steps "
+ "before reduction at line "
+ << HP.GetLineData()
+ << "; default value 1 will be "
+ "used (it may be dangerous)"
+ << std::endl);
+ iStepsBeforeReduction = 1;
+ }
+
+ doublereal dRaiseFactor = HP.GetReal();
+ if (dRaiseFactor <= 1.) {
+ silent_cerr("warning, "
+ "illegal raise factor at line "
+ << HP.GetLineData()
+ << "; default value 1. "
+ "(no raise) will be used"
+ << std::endl);
+ dRaiseFactor = 1.;
+ }
+
+ doublereal iStepsBeforeRaise = HP.GetInt();
+ if (iStepsBeforeRaise <= 0) {
+ silent_cerr("warning, "
+ "illegal number of steps "
+ "before raise at line "
+ << HP.GetLineData()
+ << "; default value 1 will be "
+ "used (it may be dangerous)"
+ << std::endl);
+ iStepsBeforeRaise = 1;
+ }
+
+ iMinIters = HP.GetInt();
+ if (iMinIters <= 0) {
+ silent_cerr("warning, "
+ "illegal minimum number "
+ "of iterations at line "
+ << HP.GetLineData()
+ << "; default value 0 will be "
+ "used (never raise)"
+ << std::endl);
+ iMinIters = 1;
+ }
+ iMaxIters = 0;
+ if (HP.IsArg()) {
+ iMaxIters = HP.GetInt();
+ if (iMaxIters <= 0) {
+ silent_cerr("warning, "
+ "illegal mmaximim number "
+ "of iterations at line "
+ << HP.GetLineData()
+ << "; default value will be "
+ "used"
+ << std::endl);
+ }
+ }
+
+ // RETURN THE new FACTOR
+ return new Factor(s,dReductionFactor,
+ iStepsBeforeReduction,
+ dRaiseFactor,
+ iStepsBeforeRaise,
+ iMinIters,
+ iMaxIters);
+
+}
+
+void
+InitTimeStepData(void){
+ SetTimeStepData("nochange", new NoChangeSTR);
+ SetTimeStepData("change", new ChangeStepSTR);
+ SetTimeStepData("factor", new FactorSTR);
+}
+
+void
+DestroyTimeStepData(void){
+ for(TimeStepFuncMapType::iterator it = TimeStepReadMap.begin(); it != TimeStepReadMap.end(); it++){
+ delete it->second;
+ }
+ TimeStepReadMap.clear();
+}
+
+
+TimeStepControl *
+ReadTimeStepData( Solver * s, MBDynParser& HP){
+ const char *str = HP.IsWord(TimeStepWordSet);
+ TimeStepFuncMapType::iterator func = TimeStepReadMap.find(std::string(str));
+ if(func == TimeStepReadMap.end()){
+ silent_cerr("unknown Time step type " << s <<std::endl);
+ func = TimeStepReadMap.find(std::string("nochange"));
+ }
+ return func->second->Read(s , HP );
+}
+
diff -uNr mbdyn-1.7.1/mbdyn/base/TimeStepControl.h mbdyn-1.7.1!/mbdyn/base/TimeStepControl.h
--- mbdyn-1.7.1/mbdyn/base/TimeStepControl.h 1970-01-01 05:30:00.000000000 +0530
+++ mbdyn-1.7.1!/mbdyn/base/TimeStepControl.h 2016-08-15 23:15:06.276351000 +0530
@@ -0,0 +1,135 @@
+/*
+ * MBDyn (C) is a multibody analysis code.
+ * http://www.mbdyn.org
+ *
+ * Copyright (C) 1996-2015
+ *
+ * Pierangelo Masarati <masarati@aero.polimi.it>
+ * Paolo Mantegazza <mantegazza@aero.polimi.it>
+ *
+ * Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
+ * via La Masa, 34 - 20156 Milano, Italy
+ * http://www.aero.polimi.it
+ *
+ * Changing this copyright notice is forbidden.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation (version 2 of the License).
+ *
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+ /*
+ * With the contribution of Ankit Aggarwal <ankit.ankit.aggarwal@gmail.com>
+ * during Google Summer of Code 2016
+ */
+
+
+#ifndef TIME_STEP_H
+#define TIME_STEP_H
+
+class TimeStepControl;
+#include "mbconfig.h"
+#include "output.h"
+#include "solman.h"
+#include <map>
+#include "solver.h"
+#include "drive_.h"
+
+extern void InitTimeStepData(void);
+extern void DestroyTimeStepData(void);
+class TimeStepControl {
+
+public:
+ TimeStepControl(){};
+ virtual ~TimeStepControl(void){};
+ virtual doublereal dGetNewStepTime(StepIntegrator::StepChange currStep , doublereal iPerformedIters) = 0;
+ virtual void SetDriveHandler(const DriveHandler* driveHandler) = 0;
+ virtual void Init(doublereal iMaxIterations,doublereal dCurrTimeStep ,DriveOwner & MaxTimeStep , doublereal dInitialTimeStep) = 0;
+};
+
+extern TimeStepControl * ReadTimeStepData(Solver * s, MBDynParser& HP);
+
+class TimeStepRead {
+
+public:
+ virtual ~TimeStepRead(void){};
+ virtual TimeStepControl *
+ Read( Solver * s, MBDynParser& HP) = 0;
+};
+
+class NoChange : public TimeStepControl {
+private:
+ Solver * s;
+ doublereal dCurrTimeStep;
+public:
+ NoChange(Solver * s);
+ doublereal dGetNewStepTime(StepIntegrator::StepChange currStep , doublereal iPerformedIters);
+ void SetDriveHandler(const DriveHandler* driveHandler){}
+ void Init(doublereal iMaxIterations,doublereal dCurrTimeStep ,DriveOwner & MaxTimeStep , doublereal dInitialTimeStep);
+ ~NoChange(){};
+};
+
+
+class ChangeStep : public TimeStepControl {
+private:
+ Solver * s;
+ DriveCaller* pStrategyChangeDrive;
+ DriveOwner MaxTimeStep;
+ doublereal dCurrTimeStep;
+public:
+ ChangeStep(Solver * s,DriveCaller* pStrategyChangeDrive);
+ doublereal dGetNewStepTime(StepIntegrator::StepChange currStep , doublereal iPerformedIters);
+
+ void SetDriveHandler(const DriveHandler* driveHandler);
+
+ void Init(doublereal iMaxIterations,doublereal dCurrTimeStep ,DriveOwner & MaxTimeStep , doublereal dInitialTimeStep);
+ ~ChangeStep(){
+ SAFEDELETE(pStrategyChangeDrive);
+ };
+};
+
+class Factor : public TimeStepControl {
+private:
+ Solver * s;
+ doublereal dReductionFactor;
+ doublereal iStepsBeforeReduction;
+ doublereal dRaiseFactor;
+ doublereal iStepsBeforeRaise;
+ doublereal iMinIters;
+ doublereal iMaxIters;
+ bool bLastChance;
+ doublereal iStepsAfterReduction;
+ doublereal iStepsAfterRaise;
+ doublereal iWeightedPerformedIters;
+ DriveOwner MaxTimeStep;
+
+ doublereal dCurrTimeStep;
+
+public:
+ Factor( Solver * s ,doublereal dReductionFactor,
+ doublereal iStepsBeforeReduction,
+ doublereal dRaiseFactor,
+ doublereal iStepsBeforeRaise,
+ doublereal iMinIters,
+ doublereal iMaxIters );
+ doublereal dGetNewStepTime(StepIntegrator::StepChange Why , doublereal iPerformedIters);
+ void SetDriveHandler(const DriveHandler* driveHandler){}
+ void Init(doublereal iMaxIterations,doublereal dCurrTimeStep ,DriveOwner & MaxTimeStep , doublereal dInitialTimeStep);
+ ~Factor(){};
+};
+
+/********** READER FOR FACTOR **************/
+
+/***************SET AND CLEAR FOR MAP ************/
+
+#endif
Google Summer of Code 2016- MBDyn
Step Size Control
The basic idea of this project was to extract out the step size control methods used in the MBDyn as an Abstraction so that a third party user can use this to implements his/her own control techniques by defining his own variables and various other things.
Work Done:
Initially, till the Mid-Term evaluation, the progress was slow as there were a lot of changes that was needed to be done in the base class of the TimeStepControl Class.
After the Mid term evaluation , the final approach to the base class was decided and implemented as required and all the major components related to the step size calculation has been moved out of the solver and invsolver class resulting in Single Class
1) TimeStepControl Class
In this, a base class with the above name with the pure virtual function "dGetNewStepTime" has been created to return the new step time according to the calculations.
Another function defined is "Init" which is used to initialize the "MaxTimeStep" and other variables required.
Final Base Class is as follows:
class TimeStepControl {
public:
TimeStepControl(){};
virtual ~TimeStepControl(void){};
virtual doublereal dGetNewStepTime(StepIntegrator::StepChange currStep , doublereal iPerformedIters) = 0;
virtual void SetDriveHandler(const DriveHandler* driveHandler) = 0;
virtual void Init(doublereal iMaxIterations,doublereal dCurrTimeStep ,DriveOwner & MaxTimeStep , doublereal dInitialTimeStep) = 0;
};
Using this base class following control technique has been implemented
1) No Change
2) Change
3) Factor
The Final Patch created is shown below:
Google Summer of Code 2016- MBDyn
Step Size Control
The basic idea of this project was to extract out the step size control methods used in the MBDyn as an Abstraction so that a third party user can use this to implements his/her own control techniques by defining his own variables and various other things.
Work Done:
Initially, till the Mid-Term evaluation, the progress was slow as there were a lot of changes that was needed to be done in the base class of the TimeStepControl Class.
After the Mid term evaluation , the final approach to the base class was decided and implemented as required and all the major components related to the step size calculation has been moved out of the solver and invsolver class resulting in Single Class
1) TimeStepControl Class
In this, a base class with the above name with the pure virtual function "dGetNewStepTime" has been created to return the new step time according to the calculations.
Another function defined is "Init" which is used to initialize the "MaxTimeStep" and other variables required.
Final Base Class is as follows:
class TimeStepControl {
public:
TimeStepControl(){};
virtual ~TimeStepControl(void){};
virtual doublereal dGetNewStepTime(StepIntegrator::StepChange currStep , doublereal iPerformedIters) = 0;
virtual void SetDriveHandler(const DriveHandler* driveHandler) = 0;
virtual void Init(doublereal iMaxIterations,doublereal dCurrTimeStep ,DriveOwner & MaxTimeStep , doublereal dInitialTimeStep) = 0;
};
Using this base class following control technique has been implemented
1) No Change
2) Change
3) Factor
The Final Patch created is shown below:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.