Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Tempus_TimeStepControl_impl.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ****************************************************************************
3 // Tempus: Copyright (2017) Sandia Corporation
4 //
5 // Distributed under BSD 3-clause license (See accompanying file Copyright.txt)
6 // ****************************************************************************
7 // @HEADER
8 
9 #ifndef Tempus_TimeStepControl_impl_hpp
10 #define Tempus_TimeStepControl_impl_hpp
11 
12 // Teuchos
13 #include "Teuchos_ScalarTraits.hpp"
14 #include "Teuchos_StandardParameterEntryValidators.hpp"
15 #include "Teuchos_VerboseObjectParameterListHelpers.hpp"
16 #include "Teuchos_TimeMonitor.hpp"
17 
18 //Step control strategy
23 
24 //Thyra
25 #include "Thyra_VectorStdOps.hpp"
26 
27 namespace Tempus {
28 
29 template<class Scalar>
31  Teuchos::RCP<Teuchos::ParameterList> pList)
32  : outputAdjustedDt_(false), dtAfterOutput_(0.0)
33 {
34  this->initialize(pList);
35 }
36 
37 template<class Scalar>
39  : tscPL_ (tsc_.tscPL_ ),
40  outputIndices_ (tsc_.outputIndices_ ),
41  outputTimes_ (tsc_.outputTimes_ ),
42  outputAdjustedDt_ (tsc_.outputAdjustedDt_ ),
43  dtAfterOutput_ (tsc_.dtAfterOutput_ ),
44  stepControlStrategy_(tsc_.stepControlStrategy_ )
45 {}
46 
47 
48 template<class Scalar>
50  const Teuchos::RCP<SolutionHistory<Scalar> > & solutionHistory,
51  Status & integratorStatus)
52 {
53  using Teuchos::RCP;
54 
55  TEMPUS_FUNC_TIME_MONITOR("Tempus::TimeStepControl::getNextTimeStep()");
56  {
57  RCP<Teuchos::FancyOStream> out = this->getOStream();
58  Teuchos::OSTab ostab(out,0,"getNextTimeStep");
59  bool printChanges = solutionHistory->getVerbLevel() !=
60  Teuchos::as<int>(Teuchos::VERB_NONE);
61 
62  auto changeDT = [] (int istep, Scalar dt_old, Scalar dt_new,
63  std::string reason)
64  {
65  std::stringstream message;
66  message << std::scientific
67  <<std::setw(6)<<std::setprecision(3)<<istep
68  << " * (dt = "<<std::setw(9)<<std::setprecision(3)<<dt_old
69  << ", new = "<<std::setw(9)<<std::setprecision(3)<<dt_new
70  << ") " << reason << std::endl;
71  return message.str();
72  };
73 
74  RCP<SolutionState<Scalar> > workingState=solutionHistory->getWorkingState();
75  RCP<SolutionStateMetaData<Scalar> > metaData = workingState->getMetaData();
76  const Scalar lastTime = solutionHistory->getCurrentState()->getTime();
77  const int iStep = metaData->getIStep();
78  int order = metaData->getOrder();
79  Scalar dt = metaData->getDt();
80  bool output = false;
81 
82  RCP<StepperState<Scalar> > stepperState = workingState->getStepperState();
83 
84  if (getStepType() == "Variable") {
85  // If last time step was adjusted for output, reinstate previous dt.
86  if (outputAdjustedDt_ == true) {
87  if (printChanges) *out << changeDT(iStep, dt, dtAfterOutput_,
88  "Reset dt after output.");
89  dt = dtAfterOutput_;
90  outputAdjustedDt_ = false;
91  dtAfterOutput_ = 0.0;
92  }
93 
94  if (dt <= 0.0) {
95  if (printChanges) *out << changeDT(iStep, dt, getInitTimeStep(),
96  "Reset dt to initial dt.");
97  dt = getInitTimeStep();
98  }
99 
100  if (dt < getMinTimeStep()) {
101  if (printChanges) *out << changeDT(iStep, dt, getMinTimeStep(),
102  "Reset dt to minimum dt.");
103  dt = getMinTimeStep();
104  }
105  }
106 
107  // update dt in metaData for the step control strategy to be informed
108  metaData->setDt(dt);
109 
110  // call the step control strategy (to update order/dt if needed)
111  stepControlStrategy_->getNextTimeStep(*this, solutionHistory,
112  integratorStatus);
113 
114  // get the order and dt (probably have changed by stepControlStrategy_)
115  order = metaData->getOrder();
116  dt = metaData->getDt();
117 
118  if (getStepType() == "Variable") {
119  if (dt < getMinTimeStep()) { // decreased below minimum dt
120  if (printChanges) *out << changeDT(iStep, dt, getMinTimeStep(),
121  "dt is too small. Resetting to minimum dt.");
122  dt = getMinTimeStep();
123  }
124  if (dt > getMaxTimeStep()) { // increased above maximum dt
125  if (printChanges) *out << changeDT(iStep, dt, getMaxTimeStep(),
126  "dt is too large. Resetting to maximum dt.");
127  dt = getMaxTimeStep();
128  }
129  }
130 
131 
132  // Check if we need to output this step index
133  std::vector<int>::const_iterator it =
134  std::find(outputIndices_.begin(), outputIndices_.end(), iStep);
135  if (it != outputIndices_.end()) output = true;
136 
137  const int iInterval = tscPL_->get<int>("Output Index Interval");
138  if ( (iStep - getInitIndex()) % iInterval == 0) output = true;
139 
140  // Check if we need to output in the next timestep based on
141  // outputTimes_ or "Output Time Interval".
142  Scalar reltol = 1.0e-6;
143  const Scalar endTime = lastTime+dt+getMinTimeStep();
144  bool checkOutput = false;
145  Scalar oTime = getInitTime();
146  for (size_t i=0; i < outputTimes_.size(); ++i) {
147  oTime = outputTimes_[i];
148  if (lastTime < oTime && oTime <= endTime) {
149  checkOutput = true;
150  break;
151  }
152  }
153  const Scalar tInterval = tscPL_->get<double>("Output Time Interval");
154  Scalar oTime2 = ceil((lastTime-getInitTime())/tInterval)*tInterval
155  + getInitTime();
156  if (lastTime < oTime2 && oTime2 <= endTime) {
157  if (checkOutput == true) {
158  if (oTime2 < oTime) oTime = oTime2; // Use the first output time.
159  } else {
160  checkOutput = true;
161  oTime = oTime2;
162  }
163  }
164 
165  if (checkOutput == true) {
166  const bool outputExactly =
167  tscPL_->get<bool>("Output Exactly On Output Times");
168  if (getStepType() == "Variable" && outputExactly == true) {
169  // Adjust time step to hit output times.
170  if (std::abs((lastTime+dt-oTime)/(lastTime+dt)) < reltol) {
171  output = true;
172  if (printChanges) *out << changeDT(iStep, dt, oTime - lastTime,
173  "Adjusting dt for numerical roundoff to hit the next output time.");
174  // Next output time IS VERY near next time (<reltol away from it),
175  // e.g., adjust for numerical roundoff.
176  outputAdjustedDt_ = true;
177  dtAfterOutput_ = dt;
178  dt = oTime - lastTime;
179  } else if (lastTime*(1.0+reltol) < oTime &&
180  oTime < (lastTime+dt-getMinTimeStep())*(1.0+reltol)) {
181  output = true;
182  if (printChanges) *out << changeDT(iStep, dt, oTime - lastTime,
183  "Adjusting dt to hit the next output time.");
184  // Next output time is not near next time
185  // (>getMinTimeStep() away from it).
186  // Take time step to hit output time.
187  outputAdjustedDt_ = true;
188  dtAfterOutput_ = dt;
189  dt = oTime - lastTime;
190  } else {
191  if (printChanges) *out << changeDT(iStep, dt, (oTime - lastTime)/2.0,
192  "The next output time is within the minimum dt of the next time. "
193  "Adjusting dt to take two steps.");
194  // Next output time IS near next time
195  // (<getMinTimeStep() away from it).
196  // Take two time steps to get to next output time.
197  dt = (oTime - lastTime)/2.0;
198  }
199  } else {
200  // Stepping over output time and want this time step for output,
201  // but do not want to change dt. Either because of 'Constant' time
202  // step or user specification, "Output Exactly On Output Times"=false.
203  output = true;
204  }
205  }
206 
207  // Adjust time step to hit final time or correct for small
208  // numerical differences.
209  if ((lastTime + dt > getFinalTime() ) ||
210  (std::abs((lastTime+dt-getFinalTime())/(lastTime+dt)) < reltol)) {
211  if (printChanges) *out << changeDT(iStep, dt, getFinalTime() - lastTime,
212  "Adjusting dt to hit the final time.");
213  dt = getFinalTime() - lastTime;
214  }
215 
216  // Check for negative time step.
217  TEUCHOS_TEST_FOR_EXCEPTION( dt <= Scalar(0.0), std::out_of_range,
218  "Error - Time step is not positive. dt = " << dt <<"\n");
219 
220  // Time step always needs to keep time within range.
221  TEUCHOS_TEST_FOR_EXCEPTION(
222  (lastTime + dt < getInitTime()), std::out_of_range,
223  "Error - Time step does not move time INTO time range.\n"
224  " [timeMin, timeMax] = [" << getInitTime() << ", "
225  << getFinalTime() << "]\n"
226  " T + dt = " << lastTime <<" + "<< dt <<" = " << lastTime + dt <<"\n");
227 
228  TEUCHOS_TEST_FOR_EXCEPTION(
229  (lastTime + dt > getFinalTime()), std::out_of_range,
230  "Error - Time step move time OUT OF time range.\n"
231  " [timeMin, timeMax] = [" << getInitTime() << ", "
232  << getFinalTime() << "]\n"
233  " T + dt = " << lastTime <<" + "<< dt <<" = " << lastTime + dt <<"\n");
234 
235  metaData->setOrder(order);
236  metaData->setDt(dt);
237  metaData->setTime(lastTime + dt);
238  metaData->setOutput(output);
239  }
240  return;
241 }
242 
243 
244 /// Test if time is within range: include timeMin and exclude timeMax.
245 template<class Scalar>
246 bool TimeStepControl<Scalar>::timeInRange(const Scalar time) const{
247  const Scalar relTol = 1.0e-14;
248  bool tir = (getInitTime()*(1.0-relTol) <= time and
249  time < getFinalTime()*(1.0-relTol));
250  return tir;
251 }
252 
253 
254 template<class Scalar>
255 bool TimeStepControl<Scalar>::indexInRange(const int iStep) const{
256  bool iir = (getInitIndex() <= iStep and iStep < getFinalIndex());
257  return iir;
258 }
259 
260 
261 template<class Scalar>
263 {
264  if (numTimeSteps >= 0) {
265  tscPL_->set<int> ("Number of Time Steps", numTimeSteps);
266  const int initIndex = getInitIndex();
267  tscPL_->set<int> ("Final Time Index", initIndex + numTimeSteps);
268  const double initTime = tscPL_->get<double>("Initial Time");
269  const double finalTime = tscPL_->get<double>("Final Time");
270  double initTimeStep = (finalTime - initTime)/numTimeSteps;
271  if (numTimeSteps == 0) initTimeStep = Scalar(0.0);
272  tscPL_->set<double> ("Initial Time Step", initTimeStep);
273  tscPL_->set<double> ("Minimum Time Step", initTimeStep);
274  tscPL_->set<double> ("Maximum Time Step", initTimeStep);
275  tscPL_->set<std::string>("Integrator Step Type", "Constant");
276 
277  Teuchos::RCP<Teuchos::FancyOStream> out = this->getOStream();
278  Teuchos::OSTab ostab(out,1,"setNumTimeSteps");
279  *out << "Warning - Found 'Number of Time Steps' = " << getNumTimeSteps()
280  << " Set the following parameters: \n"
281  << " 'Final Time Index' = " << getFinalIndex() << "\n"
282  << " 'Initial Time Step' = " << getInitTimeStep() << "\n"
283  << " 'Integrator Step Type' = " << getStepType() << std::endl;
284  }
285 }
286 
287 
288 template<class Scalar>
290 {
291  std::string name = "Tempus::TimeStepControl";
292  return(name);
293 }
294 
295 
296 template<class Scalar>
298  Teuchos::FancyOStream &out,
299  const Teuchos::EVerbosityLevel verbLevel) const
300 {
301  if (verbLevel == Teuchos::VERB_EXTREME) {
302  out << description() << "::describe:" << std::endl
303  << "pList = " << tscPL_ << std::endl;
304  }
305 }
306 
307 
308 template <class Scalar>
310  Teuchos::RCP<Teuchos::ParameterList> const& pList)
311 {
312  if (pList == Teuchos::null) {
313  // Create default parameters if null, otherwise keep current parameters.
314  if (tscPL_ == Teuchos::null) {
315  tscPL_ = Teuchos::parameterList("TimeStepControl");
316  *tscPL_ = *(this->getValidParameters());
317  }
318  } else {
319  tscPL_ = pList;
320  }
321  tscPL_->validateParametersAndSetDefaults(*this->getValidParameters(), 0);
322 
323  // Override parameters
324  if (getStepType() == "Constant") {
325  const double initTimeStep = tscPL_->get<double>("Initial Time Step");
326  tscPL_->set<double> ("Minimum Time Step", initTimeStep);
327  tscPL_->set<double> ("Maximum Time Step", initTimeStep);
328  }
329  setNumTimeSteps(getNumTimeSteps());
330 
331  // set the time step control strategy
332  setTimeStepControlStrategy();
333 
334  TEUCHOS_TEST_FOR_EXCEPTION(
335  (getInitTime() > getFinalTime() ), std::logic_error,
336  "Error - Inconsistent time range.\n"
337  " (timeMin = "<<getInitTime()<<") > (timeMax = "<<getFinalTime()<<")\n");
338 
339  TEUCHOS_TEST_FOR_EXCEPTION(
340  (getMinTimeStep() < Teuchos::ScalarTraits<Scalar>::zero() ),
341  std::logic_error,
342  "Error - Negative minimum time step. dtMin = "<<getMinTimeStep()<<")\n");
343  TEUCHOS_TEST_FOR_EXCEPTION(
344  (getMaxTimeStep() < Teuchos::ScalarTraits<Scalar>::zero() ),
345  std::logic_error,
346  "Error - Negative maximum time step. dtMax = "<<getMaxTimeStep()<<")\n");
347  TEUCHOS_TEST_FOR_EXCEPTION(
348  (getMinTimeStep() > getMaxTimeStep() ), std::logic_error,
349  "Error - Inconsistent time step range.\n"
350  " (dtMin = "<<getMinTimeStep()<<") > (dtMax = "<<getMaxTimeStep()<<")\n");
351  TEUCHOS_TEST_FOR_EXCEPTION(
352  (getInitTimeStep() < Teuchos::ScalarTraits<Scalar>::zero() ),
353  std::logic_error,
354  "Error - Negative initial time step. dtInit = "<<getInitTimeStep()<<")\n");
355  TEUCHOS_TEST_FOR_EXCEPTION(
356  (getInitTimeStep() < getMinTimeStep() ||
357  getInitTimeStep() > getMaxTimeStep() ),
358  std::out_of_range,
359  "Error - Initial time step is out of range.\n"
360  << " [dtMin, dtMax] = [" << getMinTimeStep() << ", "
361  << getMaxTimeStep() << "]\n"
362  << " dtInit = " << getInitTimeStep() << "\n");
363 
364  TEUCHOS_TEST_FOR_EXCEPTION(
365  (getInitIndex() > getFinalIndex() ), std::logic_error,
366  "Error - Inconsistent time index range.\n"
367  " (iStepMin = "<<getInitIndex()<<") > (iStepMax = "
368  <<getFinalIndex()<<")\n");
369 
370  TEUCHOS_TEST_FOR_EXCEPTION(
371  (getMaxAbsError() < Teuchos::ScalarTraits<Scalar>::zero() ),
372  std::logic_error,
373  "Error - Negative maximum time step. errorMaxAbs = "
374  <<getMaxAbsError()<<")\n");
375  TEUCHOS_TEST_FOR_EXCEPTION(
376  (getMaxRelError() < Teuchos::ScalarTraits<Scalar>::zero() ),
377  std::logic_error,
378  "Error - Negative maximum time step. errorMaxRel = "
379  <<getMaxRelError()<<")\n");
380 
381  TEUCHOS_TEST_FOR_EXCEPTION(
382  (getMinOrder() < Teuchos::ScalarTraits<Scalar>::zero() ),
383  std::logic_error,
384  "Error - Negative minimum order. orderMin = "<<getMinOrder()<<")\n");
385  TEUCHOS_TEST_FOR_EXCEPTION(
386  (getMaxOrder() < Teuchos::ScalarTraits<Scalar>::zero() ), std::logic_error,
387  "Error - Negative maximum order. orderMax = "<<getMaxOrder()<<")\n");
388  TEUCHOS_TEST_FOR_EXCEPTION(
389  (getMinOrder() > getMaxOrder() ), std::logic_error,
390  "Error - Inconsistent order range.\n"
391  " (orderMin = "<<getMinOrder()<<") > (orderMax = "
392  <<getMaxOrder()<<")\n");
393  TEUCHOS_TEST_FOR_EXCEPTION(
394  (getInitOrder() < getMinOrder() || getInitOrder() > getMaxOrder()),
395  std::out_of_range,
396  "Error - Initial order is out of range.\n"
397  << " [orderMin, orderMax] = [" << getMinOrder() << ", "
398  << getMaxOrder() << "]\n"
399  << " order = " << getInitOrder() << "\n");
400 
401  TEUCHOS_TEST_FOR_EXCEPTION(
402  (getStepType() != "Constant" and getStepType() != "Variable"),
403  std::out_of_range,
404  "Error - 'Integrator Step Type' does not equal none of these:\n"
405  << " 'Constant' - Integrator will take constant time step sizes.\n"
406  << " 'Variable' - Integrator will allow changes to the time step size.\n"
407  << " stepType = " << getStepType() << "\n");
408 
409 
410  // Parse output times
411  {
412  outputTimes_.clear();
413  std::string str = tscPL_->get<std::string>("Output Time List");
414  std::string delimiters(",");
415  // Skip delimiters at the beginning
416  std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
417  // Find the first delimiter
418  std::string::size_type pos = str.find_first_of(delimiters, lastPos);
419  while ((pos != std::string::npos) || (lastPos != std::string::npos)) {
420  // Found a token, add it to the vector
421  std::string token = str.substr(lastPos,pos-lastPos);
422  outputTimes_.push_back(Scalar(std::stod(token)));
423  if(pos==std::string::npos) break;
424 
425  lastPos = str.find_first_not_of(delimiters, pos); // Skip delimiters
426  pos = str.find_first_of(delimiters, lastPos); // Find next delimiter
427  }
428 
429  // order output times
430  std::sort(outputTimes_.begin(),outputTimes_.end());
431  outputTimes_.erase(std::unique(outputTimes_.begin(),
432  outputTimes_.end() ),
433  outputTimes_.end() );
434  }
435 
436  // Parse output indices
437  {
438  outputIndices_.clear();
439  std::string str = tscPL_->get<std::string>("Output Index List");
440  std::string delimiters(",");
441  std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
442  std::string::size_type pos = str.find_first_of(delimiters, lastPos);
443  while ((pos != std::string::npos) || (lastPos != std::string::npos)) {
444  std::string token = str.substr(lastPos,pos-lastPos);
445  outputIndices_.push_back(int(std::stoi(token)));
446  if(pos==std::string::npos) break;
447 
448  lastPos = str.find_first_not_of(delimiters, pos);
449  pos = str.find_first_of(delimiters, lastPos);
450  }
451 
452  Scalar outputIndexInterval = tscPL_->get<int>("Output Index Interval");
453  Scalar output_i = getInitIndex();
454  while (output_i <= getFinalIndex()) {
455  outputIndices_.push_back(output_i);
456  output_i += outputIndexInterval;
457  }
458 
459  // order output indices
460  std::sort(outputIndices_.begin(),outputIndices_.end());
461  }
462 
463  return;
464 }
465 
466 template<class Scalar>
468  Teuchos::RCP<TimeStepControlStrategy<Scalar> > tscs)
469 {
470  using Teuchos::RCP;
471  using Teuchos::ParameterList;
472 
473  if (stepControlStrategy_ == Teuchos::null){
474  stepControlStrategy_ =
475  Teuchos::rcp(new TimeStepControlStrategyComposite<Scalar>());
476  }
477 
478  if (tscs == Teuchos::null) {
479  // Create stepControlStrategy_ if null, otherwise keep current parameters.
480 
481  if (getStepType() == "Constant"){
482  stepControlStrategy_->addStrategy(
483  Teuchos::rcp(new TimeStepControlStrategyConstant<Scalar>()));
484  } else if (getStepType() == "Variable") {
485  // add TSCS from "Time Step Control Strategy List"
486 
487  RCP<ParameterList> tscsPL =
488  Teuchos::sublist(tscPL_,"Time Step Control Strategy",true);
489  // Construct from TSCS sublist
490  std::vector<std::string> tscsLists;
491 
492  // string tokenizer
493  tscsLists.clear();
494  std::string str = tscsPL->get<std::string>("Time Step Control Strategy List");
495  std::string delimiters(",");
496  // Skip delimiters at the beginning
497  std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
498  // Find the first delimiter
499  std::string::size_type pos = str.find_first_of(delimiters, lastPos);
500  while ((pos != std::string::npos) || (lastPos != std::string::npos)) {
501  // Found a token, add it to the vector
502  std::string token = str.substr(lastPos,pos-lastPos);
503  tscsLists.push_back(token);
504  if(pos==std::string::npos) break;
505 
506  lastPos = str.find_first_not_of(delimiters, pos); // Skip delimiters
507  pos = str.find_first_of(delimiters, lastPos); // Find next delimiter
508  }
509 
510  // For each sublist name tokenized, add the TSCS
511  for( auto el: tscsLists){
512 
513  RCP<Teuchos::ParameterList> pl =
514  Teuchos::rcp(new ParameterList(tscsPL->sublist(el)));
515 
516  RCP<TimeStepControlStrategy<Scalar>> ts;
517 
518  // construct appropriate TSCS
519  if(pl->get<std::string>("Name") == "Integral Controller")
520  ts = Teuchos::rcp(new TimeStepControlStrategyIntegralController<Scalar>(pl));
521  else if(pl->get<std::string>("Name") == "Basic VS")
522  ts = Teuchos::rcp(new TimeStepControlStrategyBasicVS<Scalar>(pl));
523 
524  stepControlStrategy_->addStrategy(ts);
525  }
526  }
527 
528  } else {
529  // just add the new tscs to the vector of strategies
530  stepControlStrategy_->addStrategy(tscs);
531  }
532 
533 }
534 
535 
536 template<class Scalar>
537 Teuchos::RCP<const Teuchos::ParameterList>
539 {
540  Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
541 
542  const double stdMax = double(1.0e+99);
543  pl->set<double>("Initial Time" , 0.0 , "Initial time");
544  pl->set<double>("Final Time" , stdMax , "Final time");
545  pl->set<int> ("Initial Time Index" , 0 , "Initial time index");
546  pl->set<int> ("Final Time Index" , 1000000, "Final time index");
547  pl->set<double>("Minimum Time Step" , 0.0 , "Minimum time step size");
548  pl->set<double>("Initial Time Step" , 1.0 , "Initial time step size");
549  pl->set<double>("Maximum Time Step" , stdMax , "Maximum time step size");
550  pl->set<int> ("Minimum Order", 0,
551  "Minimum time-integration order. If set to zero (default), the\n"
552  "Stepper minimum order is used.");
553  pl->set<int> ("Initial Order", 0,
554  "Initial time-integration order. If set to zero (default), the\n"
555  "Stepper minimum order is used.");
556  pl->set<int> ("Maximum Order", 0,
557  "Maximum time-integration order. If set to zero (default), the\n"
558  "Stepper maximum order is used.");
559  pl->set<double>("Maximum Absolute Error", 1.0e-08, "Maximum absolute error");
560  pl->set<double>("Maximum Relative Error", 1.0e-08, "Maximum relative error");
561 
562  pl->set<std::string>("Integrator Step Type", "Variable",
563  "'Integrator Step Type' indicates whether the Integrator will allow "
564  "the time step to be modified.\n"
565  " 'Constant' - Integrator will take constant time step sizes.\n"
566  " 'Variable' - Integrator will allow changes to the time step size.\n");
567 
568  pl->set<bool>("Output Exactly On Output Times", true,
569  "This determines if the timestep size will be adjusted to exactly land\n"
570  "on the output times for 'Variable' timestepping (default=true).\n"
571  "When set to 'false' or for 'Constant' time stepping, the timestep\n"
572  "following the output time will be flagged for output.\n");
573 
574  pl->set<std::string>("Output Time List", "",
575  "Comma deliminated list of output times");
576  pl->set<std::string>("Output Index List","",
577  "Comma deliminated list of output indices");
578  pl->set<double>("Output Time Interval", stdMax, "Output time interval");
579  pl->set<int> ("Output Index Interval", 1000000, "Output index interval");
580 
581  pl->set<int> ("Maximum Number of Stepper Failures", 10,
582  "Maximum number of Stepper failures");
583  pl->set<int> ("Maximum Number of Consecutive Stepper Failures", 5,
584  "Maximum number of consecutive Stepper failures");
585  pl->set<int> ("Number of Time Steps", -1,
586  "The number of constant time steps. The actual step size gets computed\n"
587  "on the fly given the size of the time domain. Overides and resets\n"
588  " 'Final Time Index' = 'Initial Time Index' + 'Number of Time Steps'\n"
589  " 'Initial Time Step' = "
590  "('Final Time' - 'Initial Time')/'Number of Time Steps'\n"
591  " 'Integrator Step Type' = 'Constant'\n");
592 
593  Teuchos::RCP<Teuchos::ParameterList> tscsPL = Teuchos::parameterList("Time Step Control Strategy");
594  tscsPL->set<std::string>("Time Step Control Strategy List","");
595  pl->set("Time Step Control Strategy", *tscsPL);
596  return pl;
597 }
598 
599 
600 template <class Scalar>
601 Teuchos::RCP<Teuchos::ParameterList>
603 {
604  return(tscPL_);
605 }
606 
607 
608 template <class Scalar>
609 Teuchos::RCP<Teuchos::ParameterList>
611 {
612  Teuchos::RCP<Teuchos::ParameterList> temp_plist = tscPL_;
613  tscPL_ = Teuchos::null;
614  return(temp_plist);
615 }
616 
617 
618 } // namespace Tempus
619 #endif // Tempus_TimeStepControl_impl_hpp
StepControlStrategy class for TimeStepControl.
virtual void setNumTimeSteps(int numTimeSteps)
virtual void getNextTimeStep(const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory, Status &integratorStatus)
Determine the time step size.
Teuchos::RCP< Teuchos::ParameterList > getNonconstParameterList()
virtual void initialize(Teuchos::RCP< Teuchos::ParameterList > pList=Teuchos::null)
virtual void setTimeStepControlStrategy(Teuchos::RCP< TimeStepControlStrategy< Scalar > > tscs=Teuchos::null)
Set the TimeStepControlStrategy.
Status
Status for the Integrator, the Stepper and the SolutionState.
virtual bool indexInRange(const int iStep) const
Check if time step index is within minimum and maximum index.
TimeStepControl manages the time step size. There several mechanicisms that effect the time step size...
Teuchos::RCP< SolutionHistory< Scalar > > solutionHistory(Teuchos::RCP< Teuchos::ParameterList > pList=Teuchos::null)
Nonmember constructor.
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > &pl)
StepControlStrategy class for TimeStepControl.
StepControlStrategy class for TimeStepControl.
virtual bool timeInRange(const Scalar time) const
Check if time is within minimum and maximum time.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
StepControlStrategy class for TimeStepControl.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Teuchos::RCP< Teuchos::ParameterList > unsetParameterList()
TimeStepControl(Teuchos::RCP< Teuchos::ParameterList > pList=Teuchos::null)
Constructor.