9 #ifndef Tempus_TimeStepControlStrategy_Constant_hpp
10 #define Tempus_TimeStepControlStrategy_Constant_hpp
12 #include "Tempus_config.hpp"
14 #include "Tempus_SolutionState.hpp"
15 #include "Tempus_SolutionHistory.hpp"
24 template<
class Scalar>
42 std::string name =
"Constant")
57 Status & integratorStatus)
override
63 RCP<SolutionState<Scalar> >workingState=solutionHistory->getWorkingState();
64 const Scalar errorAbs = workingState->getErrorAbs();
65 const Scalar errorRel = workingState->getErrorRel();
66 Scalar dt = workingState->getTimeStep();
68 RCP<Teuchos::FancyOStream> out = tsc.
getOStream();
75 "Resetting constant dt.");
81 *out <<
"Failure - Stepper failed and can not change time step size!\n"
82 <<
" Time step type == CONSTANT_STEP_SIZE\n" << std::endl;
89 *out <<
"Failure - Absolute error failed and can not change time step!\n"
90 <<
" Time step type == CONSTANT_STEP_SIZE\n"
91 <<
" (errorAbs ="<<errorAbs<<
") > (errorMaxAbs ="
99 *out <<
"Failure - Relative error failed and can not change time step!\n"
100 <<
" Time step type == CONSTANT_STEP_SIZE\n"
101 <<
" (errorRel ="<<errorRel<<
") > (errorMaxRel ="
103 integratorStatus =
FAILED;
108 workingState->setTimeStep(dt);
113 const int index = workingState->getIndex();
114 const Scalar time = (index-initIndex)*dt + initTime;
115 workingState->setTime(time);
122 {
return "Tempus::TimeStepControlStrategyConstant"; }
130 <<
"Step Type = " << this->
getStepType() << std::endl
139 Teuchos::parameterList(
"Time Step Control Strategy");
167 template <
class Scalar>
171 std::string name =
"Constant")
174 if (pList == Teuchos::null)
return tscs;
177 pList->
get<std::string>(
"Strategy Type",
"Constant") !=
"Constant",
179 "Error - Strategy Type != 'Constant'. (='"
180 +pList->
get<std::string>(
"Strategy Type")+
"')\n");
184 tscs->setConstantTimeStep(pList->
get<
double>(
"Time Step"));
194 template<
class Scalar>
203 #endif // Tempus_TimeStepControlStrategy_Constant_hpp
virtual Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const override
Return ParameterList with current values.
virtual void initialize() const override
virtual int getInitIndex() const
T & get(const std::string &name, T def_value)
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
virtual Scalar getMaxRelError() const
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
virtual void checkInitialized()
virtual std::string getStrategyType() const
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const override
TimeStepControlStrategyConstant(Scalar constantTimeStep, std::string name="Constant")
Full Constructor.
virtual Scalar getInitTimeStep() const
virtual void printDtChanges(int istep, Scalar dt_old, Scalar dt_new, std::string reason) const
virtual void setNextTimeStep(const TimeStepControl< Scalar > &tsc, Teuchos::RCP< SolutionHistory< Scalar > > solutionHistory, Status &integratorStatus) override
Determine the time step size.
Teuchos::RCP< TimeStepControlStrategyConstant< Scalar > > createTimeStepControlStrategyConstant(const Teuchos::RCP< Teuchos::ParameterList > &pList, std::string name="Constant")
Nonmember constructor.
TimeStepControlStrategyConstant()
Default Constructor.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Status
Status for the Integrator, the Stepper and the SolutionState.
virtual void setStepType(std::string s)
virtual ~TimeStepControlStrategyConstant()
Destructor.
bool isInitialized_
Bool if strategy is initialized.
virtual Scalar getMaxAbsError() const
TimeStepControl manages the time step size. There several mechanisms that effect the time step size a...
void validateParametersAndSetDefaults(ParameterList const &validParamList, int const depth=1000)
Teuchos::RCP< Teuchos::ParameterList > getTimeStepControlStrategyConstantPL()
Nonmember function to return ParameterList with default values.
virtual void setConstantTimeStep(Scalar dt)
virtual void setName(std::string s)
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
StepControlStrategy class for TimeStepControl.
Scalar constantTimeStep_
Constant time step size.
std::string description() const override
virtual Scalar getConstantTimeStep() const
virtual void setStrategyType(std::string s)
TimeStepControlStrategy class for TimeStepControl.
virtual Scalar getInitTime() const
virtual std::string getStepType() const
virtual RCP< FancyOStream > getOStream() const