10 #ifndef Tempus_TimeStepControlStrategy_BasicVS_hpp
11 #define Tempus_TimeStepControlStrategy_BasicVS_hpp
13 #include "Thyra_VectorStdOps.hpp"
15 #include "Tempus_config.hpp"
17 #include "Tempus_SolutionState.hpp"
18 #include "Tempus_SolutionHistory.hpp"
103 template <
class Scalar>
119 Scalar maxEta, std::string name =
"Basic VS")
141 RCP<SolutionState<Scalar> > workingState =
142 solutionHistory->getWorkingState();
143 const Scalar errorAbs = workingState->getErrorAbs();
144 const Scalar errorRel = workingState->getErrorRel();
145 const int iStep = workingState->getIndex();
146 Scalar dt = workingState->getTimeStep();
150 Scalar eta = solutionHistory->getCurrentState()->getDxNormL2Rel();
156 "Stepper failure - Decreasing dt.");
162 "Change too small (" + std::to_string(eta) +
" < " +
164 "). Increasing dt.");
169 "Change too large (" + std::to_string(eta) +
" > " +
171 "). Decreasing dt.");
176 iStep, dt, dt * sigma,
177 "Absolute error is too large (" + std::to_string(errorAbs) +
" > " +
183 iStep, dt, dt * sigma,
184 "Relative error is too large (" + std::to_string(errorRel) +
" > " +
192 "dt is too small. Resetting to minimum dt.");
197 "dt is too large. Resetting to maximum dt.");
201 workingState->setTimeStep(dt);
202 workingState->setTime(solutionHistory->getCurrentState()->getTime() + dt);
203 workingState->setComputeNorms(
true);
210 return "Tempus::TimeStepControlStrategyBasicVS";
216 auto l_out = Teuchos::fancyOStream(out.
getOStream());
218 l_out->setOutputToRootOnly(0);
220 *l_out <<
"\n--- " << this->
description() <<
" ---" << std::endl;
223 *l_out <<
" StrategyType = "
231 <<
" Minimum Value Monitoring Function = " <<
getMinEta()
233 <<
" Maximum Value Monitoring Function = " <<
getMaxEta()
235 *l_out << std::string(this->
description().length() + 8,
'-') << std::endl;
245 Teuchos::parameterList(
"Time Step Control Strategy");
249 "Amplification factor");
251 pl->
set<
double>(
"Minimum Value Monitoring Function",
getMinEta(),
253 pl->
set<
double>(
"Maximum Value Monitoring Function",
getMaxEta(),
262 "Error - Invalid value of Amplification Factor = "
264 <<
"Amplification Factor must be > 1.0.\n");
267 "Error - Invalid value of Reduction Factor = "
269 <<
"Reduction Factor must be < 1.0.\n");
273 "Error - Invalid values of 'Minimum Value Monitoring Function' = "
275 <<
"\n and 'Maximum Value Monitoring Function' = " <<
getMaxEta()
276 <<
"! \n Mininum Value cannot be > Maximum Value! \n");
315 template <
class Scalar>
319 std::string name =
"Basic VS")
322 if (pList == Teuchos::null || pList->
numParams() == 0)
return tscs;
325 pList->
get<std::string>(
"Strategy Type") !=
"Basic VS", std::logic_error,
326 "Error - Strategy Type != 'Basic VS'. (='" +
327 pList->
get<std::string>(
"Strategy Type") +
"')\n");
331 tscs->setAmplFactor(pList->
get<
double>(
"Amplification Factor"));
332 tscs->setReductFactor(pList->
get<
double>(
"Reduction Factor"));
333 tscs->setMinEta(pList->
get<
double>(
"Minimum Value Monitoring Function"));
334 tscs->setMaxEta(pList->
get<
double>(
"Maximum Value Monitoring Function"));
343 template <
class Scalar>
348 t->getValidParameters());
352 #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.
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
Ordinal numParams() const
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
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.
RCP< std::basic_ostream< char_type, traits_type > > getOStream()
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.
virtual std::string getStepType() const
std::string description() const override
TimeStepControlStrategyBasicVS()
Default Constructor.
TimeStepControlStrategyBasicVS(Scalar rho, Scalar sigma, Scalar minEta, Scalar maxEta, std::string name="Basic VS")
Full Constructor.