9 #ifndef Tempus_TimeStepControlStrategy_Constant_hpp
10 #define Tempus_TimeStepControlStrategy_Constant_hpp
12 #include "Tempus_TimeStepControl.hpp"
14 #include "Tempus_SolutionState.hpp"
15 #include "Tempus_SolutionHistory.hpp"
24 template<
class Scalar>
39 Status & integratorStatus)
override
42 RCP<SolutionState<Scalar> >workingState=solutionHistory->getWorkingState();
43 const Scalar errorAbs = workingState->getErrorAbs();
44 const Scalar errorRel = workingState->getErrorRel();
45 int order = workingState->getOrder();
46 Scalar dt = workingState->getTimeStep();
51 RCP<Teuchos::FancyOStream> out = tsc.getOStream();
52 Teuchos::OSTab ostab(out,1,
"getNextTimeStep");
54 auto changeOrder = [] (
int order_old,
int order_new, std::string reason) {
55 std::stringstream message;
56 message <<
" (order = " << std::setw(2) << order_old
57 <<
", new = " << std::setw(2) << order_new
58 <<
") " << reason << std::endl;
65 if (printDtChanges) *out << changeOrder(order, order+1,
66 "Stepper failure, increasing order.");
69 *out <<
"Failure - Stepper failed and can not change time step size "
71 <<
" Time step type == CONSTANT_STEP_SIZE\n"
72 <<
" order = " << order << std::endl;
81 if (printDtChanges) *out << changeOrder(order, order+1,
82 "Absolute error is too large. Increasing order.");
86 <<
"Failure - Absolute error failed and can not change time step "
88 <<
" Time step type == CONSTANT_STEP_SIZE\n"
89 <<
" order = " << order
90 <<
" (errorAbs ="<<errorAbs<<
") > (errorMaxAbs ="
101 if (printDtChanges) *out << changeOrder(order, order+1,
102 "Relative error is too large. Increasing order.");
106 <<
"Failure - Relative error failed and can not change time step "
107 <<
"size or order!\n"
108 <<
" Time step type == CONSTANT_STEP_SIZE\n"
109 <<
" order = " << order
110 <<
" (errorRel ="<<errorRel<<
") > (errorMaxRel ="
113 integratorStatus =
FAILED;
119 TEUCHOS_TEST_FOR_EXCEPTION(
122 "Error - Solution order is out of range and can not change "
124 " Time step type == CONSTANT_STEP_SIZE\n"
125 " [order_min, order_max] = [" <<tsc.
getMinOrder()<<
", "
127 " order = " << order <<
"\n");
130 workingState->setOrder(order);
131 workingState->setTimeStep(dt);
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
StepControlStrategy class for TimeStepControl.
virtual void getNextTimeStep(const TimeStepControl< Scalar > tsc, Teuchos::RCP< SolutionHistory< Scalar > > solutionHistory, Status &integratorStatus) override
Determine the time step size.
TimeStepControlStrategyConstant()
Constructor.
virtual ~TimeStepControlStrategyConstant()
Destructor.
StepControlStrategy class for TimeStepControl.
TimeStepControl manages the time step size. There several mechanicisms that effect the time step size...
virtual int getMaxOrder() const
virtual Scalar getMaxAbsError() const
virtual Scalar getMaxRelError() const
virtual bool getPrintDtChanges() const
virtual Scalar getInitTimeStep() const
virtual int getMinOrder() const
Status
Status for the Integrator, the Stepper and the SolutionState.