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_SolutionStateMetaData.hpp"
16 #include "Tempus_SolutionHistory.hpp"
25 template<
class Scalar>
40 Status & integratorStatus)
override
43 RCP<SolutionState<Scalar> >workingState=
solutionHistory->getWorkingState();
44 RCP<SolutionStateMetaData<Scalar> > metaData = workingState->getMetaData();
45 const Scalar errorAbs = metaData->getErrorAbs();
46 const Scalar errorRel = metaData->getErrorRel();
47 int order = metaData->getOrder();
48 Scalar dt = metaData->getDt();
50 Teuchos::as<int>(Teuchos::VERB_NONE);
54 RCP<Teuchos::FancyOStream> out = tsc.getOStream();
55 Teuchos::OSTab ostab(out,1,
"getNextTimeStep");
57 auto changeOrder = [] (
int order_old,
int order_new, std::string reason) {
58 std::stringstream message;
59 message <<
" (order = " << std::setw(2) << order_old
60 <<
", new = " << std::setw(2) << order_new
61 <<
") " << reason << std::endl;
68 if (printChanges) *out << changeOrder(order, order+1,
69 "Stepper failure, increasing order.");
72 *out <<
"Failure - Stepper failed and can not change time step size "
74 <<
" Time step type == CONSTANT_STEP_SIZE\n"
75 <<
" order = " << order << std::endl;
84 if (printChanges) *out << changeOrder(order, order+1,
85 "Absolute error is too large. Increasing order.");
89 <<
"Failure - Absolute error failed and can not change time step "
91 <<
" Time step type == CONSTANT_STEP_SIZE\n"
92 <<
" order = " << order
93 <<
" (errorAbs ="<<errorAbs<<
") > (errorMaxAbs ="
104 if (printChanges) *out << changeOrder(order, order+1,
105 "Relative error is too large. Increasing order.");
109 <<
"Failure - Relative error failed and can not change time step "
110 <<
"size or order!\n"
111 <<
" Time step type == CONSTANT_STEP_SIZE\n"
112 <<
" order = " << order
113 <<
" (errorRel ="<<errorRel<<
") > (errorMaxRel ="
116 integratorStatus =
FAILED;
122 TEUCHOS_TEST_FOR_EXCEPTION(
125 "Error - Solution order is out of range and can not change "
127 " Time step type == CONSTANT_STEP_SIZE\n"
128 " [order_min, order_max] = [" <<tsc.
getMinOrder()<<
", "
130 " order = " << order <<
"\n");
133 metaData->setOrder(order);
139 #endif // Tempus_TimeStepControlStrategy_Constant_hpp
virtual Scalar getMaxRelError() const
virtual Scalar getInitTimeStep() const
virtual int getMinOrder() const
TimeStepControlStrategyConstant()
Constructor.
Status
Status for the Integrator, the Stepper and the SolutionState.
virtual ~TimeStepControlStrategyConstant()
Destructor.
virtual Scalar getMaxAbsError() const
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...
virtual void getNextTimeStep(const TimeStepControl< Scalar > tsc, Teuchos::RCP< SolutionHistory< Scalar > > solutionHistory, Status &integratorStatus) override
Determine the time step size.
StepControlStrategy class for TimeStepControl.
virtual int getMaxOrder() const
StepControlStrategy class for TimeStepControl.