9 #ifndef Tempus_TimeStepControlStrategy_BasicVS_hpp
10 #define Tempus_TimeStepControlStrategy_BasicVS_hpp
12 #include "Thyra_VectorStdOps.hpp"
14 #include "Tempus_config.hpp"
16 #include "Tempus_SolutionState.hpp"
17 #include "Tempus_SolutionHistory.hpp"
103 template<
class Scalar>
121 Scalar maxEta, std::string name =
"Basic VS")
143 RCP<SolutionState<Scalar> > workingState=solutionHistory->getWorkingState();
144 const Scalar errorAbs = workingState->getErrorAbs();
145 const Scalar errorRel = workingState->getErrorRel();
146 const int iStep = workingState->getIndex();
147 Scalar dt = workingState->getTimeStep();
151 Scalar eta = solutionHistory->getCurrentState()->getDxNormL2Rel();
157 "Stepper failure - Decreasing dt.");
164 + std::to_string(eta) +
" < " + std::to_string(
getMinEta())
165 +
"). Increasing dt.");
171 + std::to_string(eta) +
" > " + std::to_string(
getMaxEta())
172 +
"). Decreasing dt.");
177 "Absolute error is too large ("
178 + std::to_string(errorAbs)+
" > "+std::to_string(tsc.
getMaxAbsError())
179 +
"). Decreasing dt.");
184 "Relative error is too large ("
185 + std::to_string(errorRel)+
" > "+std::to_string(tsc.
getMaxRelError())
186 +
"). Decreasing dt.");
193 "dt is too small. Resetting to minimum dt.");
198 "dt is too large. Resetting to maximum dt.");
202 workingState->setTimeStep(dt);
203 workingState->setTime(solutionHistory->getCurrentState()->getTime() + dt);
204 workingState->setComputeNorms(
true);
210 {
return "Tempus::TimeStepControlStrategyBasicVS"; }
220 <<
"Minimum Value Monitoring Function = " <<
getMinEta() << std::endl
221 <<
"Maximum Value Monitoring Function = " <<
getMaxEta() << std::endl;
229 Teuchos::parameterList(
"Time Step Control Strategy");
232 pl->
set<
double>(
"Amplification Factor",
getAmplFactor(),
"Amplification factor");
234 pl->
set<
double>(
"Minimum Value Monitoring Function",
getMinEta(),
"Min value eta");
235 pl->
set<
double>(
"Maximum Value Monitoring Function",
getMaxEta(),
"Max value eta");
243 "Error - Invalid value of Amplification Factor = " <<
getAmplFactor()
244 <<
"! \n" <<
"Amplification Factor must be > 1.0.\n");
248 <<
"! \n" <<
"Reduction Factor must be < 1.0.\n");
251 "Error - Invalid values of 'Minimum Value Monitoring Function' = "
252 <<
getMinEta() <<
"\n and 'Maximum Value Monitoring Function' = "
253 <<
getMaxEta() <<
"! \n Mininum Value cannot be > Maximum Value! \n");
281 template <
class Scalar>
285 std::string name =
"Basic VS")
288 if (pList == Teuchos::null)
return tscs;
291 pList->
get<std::string>(
"Strategy Type",
"Basic VS") !=
"Basic VS",
293 "Error - Strategy Type != 'Basic VS'. (='"
294 +pList->
get<std::string>(
"Strategy Type")+
"')\n");
298 tscs->setAmplFactor( pList->
get<
double>(
"Amplification Factor"));
299 tscs->setReductFactor(pList->
get<
double>(
"Reduction Factor"));
300 tscs->setMinEta(pList->
get<
double>(
"Minimum Value Monitoring Function"));
301 tscs->setMaxEta(pList->
get<
double>(
"Maximum Value Monitoring Function"));
311 template<
class Scalar>
320 #endif // Tempus_TimeStepControlStrategy_BasicVS_hpp
Teuchos::RCP< Teuchos::ParameterList > getTimeStepControlStrategyBasicVS_PL()
Nonmember function to return ParameterList with default values.
virtual void setMaxEta(Scalar maxEta)
virtual void initialize() const override
T & get(const std::string &name, T def_value)
StepControlStrategy class for TimeStepControl.
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 Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const override
Return ParameterList with current values.
virtual ~TimeStepControlStrategyBasicVS()
Destructor.
virtual void checkInitialized()
Scalar minEta_
Minimum Value Monitoring Function.
virtual Scalar getReductFactor() const
virtual std::string getStrategyType() const
virtual void printDtChanges(int istep, Scalar dt_old, Scalar dt_new, std::string reason) const
virtual Scalar getMinEta() const
virtual Scalar getAmplFactor() const
virtual void setAmplFactor(Scalar rho)
Teuchos::RCP< TimeStepControlStrategyBasicVS< Scalar > > createTimeStepControlStrategyBasicVS(const Teuchos::RCP< Teuchos::ParameterList > &pList, std::string name="Basic VS")
Nonmember constructor.
Scalar sigma_
Reduction Factor.
Scalar rho_
Amplification Factor.
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 void setNextTimeStep(const TimeStepControl< Scalar > &tsc, Teuchos::RCP< SolutionHistory< Scalar > > solutionHistory, Status &) override
Set the time step size.
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...
virtual void setMinEta(Scalar minEta)
void validateParametersAndSetDefaults(ParameterList const &validParamList, int const depth=1000)
virtual void setName(std::string s)
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
virtual void setReductFactor(Scalar sigma)
virtual Scalar getMaxTimeStep() const
virtual Scalar getMinTimeStep() const
Scalar maxEta_
Maximum Value Monitoring Function.
virtual Scalar getMaxEta() const
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const override
virtual void setStrategyType(std::string s)
TimeStepControlStrategy class for TimeStepControl.
std::string description() const override
TimeStepControlStrategyBasicVS()
Default Constructor.
TimeStepControlStrategyBasicVS(Scalar rho, Scalar sigma, Scalar minEta, Scalar maxEta, std::string name="Basic VS")
Full Constructor.