MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
Factor Class Reference

#include <TimeStepControl.h>

Inheritance diagram for Factor:
Collaboration diagram for Factor:

Public Member Functions

 Factor (Solver *s, doublereal dReductionFactor, doublereal iStepsBeforeReduction, doublereal dRaiseFactor, doublereal iStepsBeforeRaise, doublereal iMinIters, doublereal iMaxIters)
 
 ~Factor (void)
 
doublereal dGetNewStepTime (StepIntegrator::StepChange Why, doublereal iPerformedIters)
 
void SetDriveHandler (const DriveHandler *driveHandler)
 
void Init (integer iMaxIterations, doublereal dMinTimeStep, const DriveOwner &MaxTimeStep, doublereal dInitialTimeStep)
 
- Public Member Functions inherited from TimeStepControl
 TimeStepControl (void)
 
virtual ~TimeStepControl (void)
 

Private Attributes

Solvers
 
doublereal dReductionFactor
 
doublereal iStepsBeforeReduction
 
doublereal dRaiseFactor
 
doublereal iStepsBeforeRaise
 
doublereal iMinIters
 
doublereal iMaxIters
 
bool bLastChance
 
doublereal iStepsAfterReduction
 
doublereal iStepsAfterRaise
 
doublereal iWeightedPerformedIters
 
doublereal dMinTimeStep
 
DriveOwner MaxTimeStep
 

Additional Inherited Members

- Protected Attributes inherited from TimeStepControl
doublereal dCurrTimeStep
 

Detailed Description

Definition at line 102 of file TimeStepControl.h.

Constructor & Destructor Documentation

Factor::Factor ( Solver s,
doublereal  dReductionFactor,
doublereal  iStepsBeforeReduction,
doublereal  dRaiseFactor,
doublereal  iStepsBeforeRaise,
doublereal  iMinIters,
doublereal  iMaxIters 
)

Definition at line 176 of file TimeStepControl.cc.

References NO_OP.

183 : s(s),
190 bLastChance(false),
195 {
196  NO_OP;
197 }
static const doublereal dDefaultMinTimeStep
Definition: solver_impl.h:100
doublereal dReductionFactor
doublereal iStepsAfterRaise
doublereal iStepsAfterReduction
doublereal dMinTimeStep
#define NO_OP
Definition: myassert.h:74
Solver * s
bool bLastChance
doublereal iStepsBeforeReduction
doublereal iMaxIters
doublereal iWeightedPerformedIters
doublereal iMinIters
doublereal dRaiseFactor
doublereal iStepsBeforeRaise
Factor::~Factor ( void  )
inline

Definition at line 126 of file TimeStepControl.h.

References NO_OP.

126 { NO_OP; };
#define NO_OP
Definition: myassert.h:74

Member Function Documentation

doublereal Factor::dGetNewStepTime ( StepIntegrator::StepChange  Why,
doublereal  iPerformedIters 
)
virtual

Implements TimeStepControl.

Definition at line 200 of file TimeStepControl.cc.

References ASSERT, bLastChance, TimeStepControl::dCurrTimeStep, DriveOwner::dGet(), dMinTimeStep, dRaiseFactor, dReductionFactor, iMaxIters, iMinIters, iStepsAfterRaise, iStepsAfterReduction, iStepsBeforeRaise, iStepsBeforeReduction, iWeightedPerformedIters, MaxTimeStep, MBDYN_EXCEPT_ARGS, StepIntegrator::NEWSTEP, and StepIntegrator::REPEATSTEP.

201 {
202  doublereal dMaxTimeStep = MaxTimeStep.dGet();
203 
204  switch (Why) {
207  if (bLastChance) {
208  bLastChance = false;
209  }
211  return (dCurrTimeStep = std::min(dCurrTimeStep*dReductionFactor, dMaxTimeStep));
212  }
213 
214  if (!bLastChance) {
215  bLastChance = true;
216  return (dCurrTimeStep = dMinTimeStep);
217  }
218 
219  return (dCurrTimeStep = std::min(dCurrTimeStep*dReductionFactor, dMaxTimeStep));
220 
224 
225  iWeightedPerformedIters = (10*iPerformedIters + 9*iWeightedPerformedIters)/10;
226 
227  if (iPerformedIters > iMaxIters) {
229  bLastChance = false;
230  return (dCurrTimeStep = std::min(std::max(dCurrTimeStep*dReductionFactor, dMinTimeStep), dMaxTimeStep));
231 
232  }
233 
234  if (iPerformedIters <= iMinIters
237  && dCurrTimeStep < dMaxTimeStep)
238  {
239  iStepsAfterRaise = 0;
241  return (dCurrTimeStep = std::min(dCurrTimeStep*dRaiseFactor, dMaxTimeStep));
242  }
243 
244  return dCurrTimeStep;
245 
246  default:
247  // Should Not Reach Over here
248  ASSERT(0);
250  }
251 }
doublereal dReductionFactor
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
doublereal iStepsAfterRaise
doublereal iStepsAfterReduction
doublereal dMinTimeStep
bool bLastChance
doublereal iStepsBeforeReduction
doublereal iMaxIters
#define ASSERT(expression)
Definition: colamd.c:977
doublereal dCurrTimeStep
doublereal iWeightedPerformedIters
doublereal dGet(const doublereal &dVar) const
Definition: drive.cc:664
DriveOwner MaxTimeStep
doublereal iMinIters
doublereal dRaiseFactor
doublereal iStepsBeforeRaise
double doublereal
Definition: colamd.c:52

Here is the call graph for this function:

void Factor::Init ( integer  iMaxIterations,
doublereal  dMinTimeStep,
const DriveOwner MaxTimeStep,
doublereal  dInitialTimeStep 
)
virtual

Implements TimeStepControl.

Definition at line 255 of file TimeStepControl.cc.

References TimeStepControl::dCurrTimeStep, dDefaultMinTimeStep, DriveOwner::dGet(), dMinTimeStep, iMaxIters, iMinIters, MBDYN_EXCEPT_ARGS, DriveCaller::pCopy(), DriveOwner::pGetDriveCaller(), and DriveOwner::Set().

256 {
257  this->dCurrTimeStep = dInitialTimeStep;
258  this->MaxTimeStep.Set(MaxTimeStep.pGetDriveCaller()->pCopy());
259  this->dMinTimeStep = dMinTimeStep;
260 
261  if (iMaxIters <= iMinIters) {
262  silent_cerr("error: maximum number of iterations " << iMaxIters << " less than or equal to minimum " << iMinIters << std::endl);
264  }
265 
266  doublereal dInitialMaxTimeStep = MaxTimeStep.dGet();
267 
268  if (typeid(*MaxTimeStep.pGetDriveCaller()) == typeid(ConstDriveCaller)
269  && dInitialMaxTimeStep == std::numeric_limits<doublereal>::max())
270  {
271  silent_cerr("warning: maximum time step not set; the initial time step value " << dInitialTimeStep << " will be used" << std::endl);
272  }
273 
275  silent_cerr("warning: minimum time step not set; the initial time step value " << dInitialTimeStep << " will be used" << std::endl);
276  dMinTimeStep = dInitialTimeStep;
277  }
278 
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);
281 
282  } else if (dMinTimeStep == dInitialMaxTimeStep) {
283  silent_cerr("error: minimum time step " << dMinTimeStep << "is greater than (initial) maximum time step " << dInitialMaxTimeStep << std::endl);
285  }
286 }
static const doublereal dDefaultMinTimeStep
Definition: solver_impl.h:100
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
doublereal dMinTimeStep
doublereal iMaxIters
DriveCaller * pGetDriveCaller(void) const
Definition: drive.cc:658
doublereal dCurrTimeStep
virtual DriveCaller * pCopy(void) const =0
void Set(const DriveCaller *pDC)
Definition: drive.cc:647
doublereal dGet(const doublereal &dVar) const
Definition: drive.cc:664
doublereal iMinIters
double doublereal
Definition: colamd.c:52

Here is the call graph for this function:

void Factor::SetDriveHandler ( const DriveHandler driveHandler)
inlinevirtual

Implements TimeStepControl.

Definition at line 128 of file TimeStepControl.h.

References NO_OP.

128 { NO_OP; };
#define NO_OP
Definition: myassert.h:74

Member Data Documentation

bool Factor::bLastChance
private

Definition at line 111 of file TimeStepControl.h.

Referenced by dGetNewStepTime().

doublereal Factor::dMinTimeStep
private

Definition at line 115 of file TimeStepControl.h.

Referenced by dGetNewStepTime(), and Init().

doublereal Factor::dRaiseFactor
private

Definition at line 107 of file TimeStepControl.h.

Referenced by dGetNewStepTime().

doublereal Factor::dReductionFactor
private

Definition at line 105 of file TimeStepControl.h.

Referenced by dGetNewStepTime().

doublereal Factor::iMaxIters
private

Definition at line 110 of file TimeStepControl.h.

Referenced by dGetNewStepTime(), and Init().

doublereal Factor::iMinIters
private

Definition at line 109 of file TimeStepControl.h.

Referenced by dGetNewStepTime(), and Init().

doublereal Factor::iStepsAfterRaise
private

Definition at line 113 of file TimeStepControl.h.

Referenced by dGetNewStepTime().

doublereal Factor::iStepsAfterReduction
private

Definition at line 112 of file TimeStepControl.h.

Referenced by dGetNewStepTime().

doublereal Factor::iStepsBeforeRaise
private

Definition at line 108 of file TimeStepControl.h.

Referenced by dGetNewStepTime().

doublereal Factor::iStepsBeforeReduction
private

Definition at line 106 of file TimeStepControl.h.

Referenced by dGetNewStepTime().

doublereal Factor::iWeightedPerformedIters
private

Definition at line 114 of file TimeStepControl.h.

Referenced by dGetNewStepTime().

DriveOwner Factor::MaxTimeStep
private

Definition at line 116 of file TimeStepControl.h.

Referenced by dGetNewStepTime().

Solver* Factor::s
private

Definition at line 104 of file TimeStepControl.h.


The documentation for this class was generated from the following files: