46 bool IsWord(
const std::string& s)
const {
75 dInitialMaxTimeStep = std::numeric_limits<doublereal>::max();
78 dInitialMaxTimeStep = MaxTimeStep.
dGet();
81 if (dMinTimeStep > dInitialMaxTimeStep) {
82 silent_cerr(
"warning: minimum time step " << dMinTimeStep <<
" greater than maximum (initial) time step " << dInitialMaxTimeStep <<
" (ignored)" << std::endl);
85 if (dInitialTimeStep < dMinTimeStep) {
86 silent_cerr(
"warning: (constant) time step " << dInitialTimeStep <<
" less than minimum time step " << dMinTimeStep <<
" (ignored)" << std::endl);
89 if (dInitialTimeStep > dInitialMaxTimeStep) {
90 silent_cerr(
"warning: (constant) time step " << dInitialTimeStep <<
" greater than maximum (initial) time step " << dInitialMaxTimeStep <<
" (ignored)" << std::endl);
108 pStrategyChangeDrive(pStrategyChangeDrive),
143 dInitialMaxTimeStep = std::numeric_limits<doublereal>::max();
146 dInitialMaxTimeStep = MaxTimeStep.
dGet();
149 if (dMinTimeStep > dInitialMaxTimeStep) {
150 silent_cerr(
"error: minimum time step " << dMinTimeStep <<
" greater than maximum (initial) time step " << dInitialMaxTimeStep << std::endl);
154 if (dInitialTimeStep < dMinTimeStep) {
155 silent_cerr(
"error: initial time step " << dInitialTimeStep <<
" less than minimum time step " << dMinTimeStep << std::endl);
159 if (dInitialTimeStep > dInitialMaxTimeStep) {
160 silent_cerr(
"error: initial time step " << dInitialTimeStep <<
" greater than maximum (initial) time step " << dInitialMaxTimeStep << std::endl);
184 dReductionFactor(dReductionFactor),
185 iStepsBeforeReduction(iStepsBeforeReduction),
186 dRaiseFactor(dRaiseFactor),
187 iStepsBeforeRaise(iStepsBeforeRaise),
188 iMinIters(iMinIters),
189 iMaxIters(iMaxIters),
191 iStepsAfterReduction(0),
193 iWeightedPerformedIters(0),
262 silent_cerr(
"error: maximum number of iterations " <<
iMaxIters <<
" less than or equal to minimum " <<
iMinIters << std::endl);
269 && dInitialMaxTimeStep == std::numeric_limits<doublereal>::max())
271 silent_cerr(
"warning: maximum time step not set; the initial time step value " << dInitialTimeStep <<
" will be used" << std::endl);
275 silent_cerr(
"warning: minimum time step not set; the initial time step value " << dInitialTimeStep <<
" will be used" << std::endl);
276 dMinTimeStep = dInitialTimeStep;
279 if (dMinTimeStep == dInitialMaxTimeStep) {
280 silent_cerr(
"warning: minimum time step " << dMinTimeStep <<
"is equal to (initial) maximum time step " << dInitialMaxTimeStep <<
"; no time step adaptation will take place" << std::endl);
282 }
else if (dMinTimeStep == dInitialMaxTimeStep) {
283 silent_cerr(
"error: minimum time step " << dMinTimeStep <<
"is greater than (initial) maximum time step " << dInitialMaxTimeStep << std::endl);
303 silent_cerr(
"error: invalid reduction factor " << e.
Get() <<
" (must be positive and less than (or equal to) one) [" << e.
what() <<
"] at line " << HP.
GetLineData() << std::endl);
307 integer iStepsBeforeReduction = 1;
312 silent_cerr(
"error: invalid number of steps before reduction " << e.
Get() <<
" (must be greater than zero) [" << e.
what() <<
"] at line " << HP.
GetLineData() << std::endl);
321 silent_cerr(
"error: invalid increase factor " << e.
Get() <<
" (must be greater than (or equal to) one) [" << e.
what() <<
"] at line " << HP.
GetLineData() << std::endl);
330 silent_cerr(
"error: invalid number of steps before increase " << e.
Get() <<
" (must be greater than zero) [" << e.
what() <<
"] at line " << HP.
GetLineData() << std::endl);
338 silent_cerr(
"error: invalid number of minimum iterations " << e.
Get() <<
" (must be greater than zero) [" << e.
what() <<
"] at line " << HP.
GetLineData() << std::endl);
348 silent_cerr(
"error: invalid number of maximum iterations " << e.
Get() <<
" (must be greater than zero) [" << e.
what() <<
"] at line " << HP.
GetLineData() << std::endl);
354 return new Factor(s, dReductionFactor,
355 iStepsBeforeReduction,
382 const char *str = HP.
IsWord(TimeStepWordSet);
385 silent_cerr(
"unknown TimeStepControl type " << s <<
"; using \"no change\"" << std::endl);
389 return func->second->Read(s, HP);
void Init(integer iMaxIterations, doublereal dMinTimeStep, const DriveOwner &MaxTimeStep, doublereal dInitialTimeStep)
static const doublereal dDefaultMinTimeStep
doublereal dGetNewStepTime(StepIntegrator::StepChange Why, doublereal iPerformedIters)
void InitTimeStepData(void)
doublereal dReductionFactor
#define MBDYN_EXCEPT_ARGS
virtual integer GetInt(integer iDefval=0)
void Init(integer iMaxIterations, doublereal dMinTimeStep, const DriveOwner &MaxTimeStep, doublereal dInitialTimeStep)
virtual const char * IsWord(const HighParser::WordSet &ws)
doublereal iStepsAfterRaise
Factor(Solver *s, doublereal dReductionFactor, doublereal iStepsBeforeReduction, doublereal dRaiseFactor, doublereal iStepsBeforeRaise, doublereal iMinIters, doublereal iMaxIters)
const char * what(void) const
ChangeStep(Solver *s, DriveCaller *pStrategyChangeDrive)
TimeStepControl * Read(Solver *s, MBDynParser &HP)
doublereal iStepsAfterReduction
TimeStepFuncMapType TimeStepReadMap
TimeStepControl * Read(Solver *s, MBDynParser &HP)
DriveCaller * pStrategyChangeDrive
void DestroyTimeStepData(void)
void func(const T &u, const T &v, const T &w, doublereal e, T &f)
void Init(integer iMaxIterations, doublereal dMinTimeStep, const DriveOwner &MaxTimeStep, doublereal dInitialTimeStep)
doublereal iStepsBeforeReduction
virtual void SetDrvHdl(const DriveHandler *pDH)
doublereal dGetNewStepTime(StepIntegrator::StepChange currStep, doublereal iPerformedIters)
doublereal dGetNewStepTime(StepIntegrator::StepChange currStep, doublereal iPerformedIters)
#define ASSERT(expression)
DriveCaller * pGetDriveCaller(void) const
virtual DriveCaller * pCopy(void) const =0
virtual doublereal dGet(const doublereal &dVar) const =0
doublereal iWeightedPerformedIters
std::map< std::string, TimeStepRead * > TimeStepFuncMapType
void Set(const DriveCaller *pDC)
doublereal dGet(const doublereal &dVar) const
bool SetTimeStepData(const char *name, TimeStepRead *sr)
void SetDriveHandler(const DriveHandler *driveHandler)
TimeStepControl * ReadTimeStepData(Solver *s, MBDynParser &HP)
DriveCaller * GetDriveCaller(bool bDeferred=false)
doublereal iStepsBeforeRaise
bool IsWord(const std::string &s) const
virtual HighParser::ErrOut GetLineData(void) const
TimeStepWordSetType TimeStepWordSet
virtual doublereal GetReal(const doublereal &dDefval=0.0)
TimeStepControl * Read(Solver *s, MBDynParser &HP)