9 #ifndef Tempus_StepperForwardEuler_impl_hpp
10 #define Tempus_StepperForwardEuler_impl_hpp
12 #include "Thyra_VectorStdOps.hpp"
18 template <
class Scalar>
21 this->setStepperName(
"Forward Euler");
22 this->setStepperType(
"Forward Euler");
23 this->setUseFSAL(
true);
24 this->setICConsistency(
"Consistent");
25 this->setICConsistencyCheck(
false);
26 this->setAppAction(Teuchos::null);
29 template <
class Scalar>
32 bool useFSAL, std::string ICConsistency,
bool ICConsistencyCheck,
36 this->setStepperName(
"Forward Euler");
37 this->setStepperType(
"Forward Euler");
38 this->setUseFSAL(useFSAL);
39 this->setICConsistency(ICConsistency);
40 this->setICConsistencyCheck(ICConsistencyCheck);
42 this->setAppAction(stepperFEAppAction);
43 if (appModel != Teuchos::null) {
44 this->setModel(appModel);
49 template <
class Scalar>
53 if (appAction == Teuchos::null) {
59 stepperFEAppAction_ = appAction;
63 template <
class Scalar>
69 RCP<SolutionState<Scalar> > initialState = solutionHistory->getCurrentState();
72 if (initialState->getXDot() == Teuchos::null)
73 this->setStepperXDot(initialState->getX()->clone_v());
75 this->setStepperXDot(initialState->getXDot());
80 template <
class Scalar>
84 this->checkInitialized();
88 TEMPUS_FUNC_TIME_MONITOR(
"Tempus::StepperForwardEuler::takeStep()");
91 solutionHistory->getNumStates() < 2, std::logic_error,
92 "Error - StepperForwardEuler<Scalar>::takeStep(...)\n"
93 <<
"Need at least two SolutionStates for Forward Euler.\n"
94 <<
" Number of States = " << solutionHistory->getNumStates()
95 <<
"\n Try setting in \"Solution History\" \"Storage Type\" = "
96 <<
"\"Undo\"\n or \"Storage Type\" = \"Static\" and \"Storage Limit\" = "
99 RCP<StepperForwardEuler<Scalar> > thisStepper = Teuchos::rcpFromRef(*
this);
100 stepperFEAppAction_->execute(
101 solutionHistory, thisStepper,
104 RCP<SolutionState<Scalar> > currentState =
105 solutionHistory->getCurrentState();
106 RCP<SolutionState<Scalar> > workingState =
107 solutionHistory->getWorkingState();
108 if (currentState->getXDot() != Teuchos::null)
109 this->setStepperXDot(currentState->getXDot());
110 RCP<Thyra::VectorBase<Scalar> > xDot = this->getStepperXDot();
111 const Scalar dt = workingState->getTimeStep();
113 if (!(this->getUseFSAL()) || workingState->getNConsecutiveFailures() != 0) {
115 stepperFEAppAction_->execute(
116 solutionHistory, thisStepper,
118 Scalar>::ACTION_LOCATION::BEFORE_EXPLICIT_EVAL);
123 this->evaluateExplicitODE(xDot, currentState->getX(),
124 currentState->getTime(), p);
128 currentState->setIsSynced(
true);
132 Thyra::V_VpStV(Teuchos::outArg(*(workingState->getX())),
133 *(currentState->getX()), dt, *(xDot));
135 if (workingState->getXDot() != Teuchos::null)
136 this->setStepperXDot(workingState->getXDot());
137 xDot = this->getStepperXDot();
139 if (this->getUseFSAL()) {
141 stepperFEAppAction_->execute(
142 solutionHistory, thisStepper,
144 Scalar>::ACTION_LOCATION::BEFORE_EXPLICIT_EVAL);
149 this->evaluateExplicitODE(xDot, workingState->getX(),
150 workingState->getTime(), p);
154 workingState->setIsSynced(
true);
158 workingState->setIsSynced(
false);
162 workingState->setOrder(this->getOrder());
163 workingState->computeNorms(currentState);
164 stepperFEAppAction_->execute(
165 solutionHistory, thisStepper,
177 template <
class Scalar>
186 template <
class Scalar>
190 auto l_out = Teuchos::fancyOStream(out.
getOStream());
192 l_out->setOutputToRootOnly(0);
197 *l_out <<
" stepperFEAppAction_ = " << stepperFEAppAction_ << std::endl
198 <<
"----------------------------" << std::endl;
201 template <
class Scalar>
206 bool isValidSetup =
true;
210 if (stepperFEAppAction_ == Teuchos::null) {
211 isValidSetup =
false;
212 out <<
"The Forward Euler AppAction is not set!\n";
219 template <
class Scalar>
225 stepper->setStepperExplicitValues(pl);
227 if (model != Teuchos::null) {
228 stepper->setModel(model);
229 stepper->initialize();
236 #endif // Tempus_StepperForwardEuler_impl_hpp
Default modifier for StepperForwardEuler.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
virtual void setInitialConditions(const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory)
Set the initial conditions, make them consistent, and set needed memory.
Forward Euler time stepper.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Thyra Base interface for time steppers.
Teuchos::RCP< StepperForwardEuler< Scalar > > createStepperForwardEuler(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
StepperState is a simple class to hold state information about the stepper.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Application Action for StepperForwardEuler.
virtual void setInitialConditions(const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory)
Set the initial conditions, make them consistent, and set needed memory.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
basic_FancyOStream & setOutputToRootOnly(const int rootRank)
virtual Teuchos::RCP< Tempus::StepperState< Scalar > > getDefaultStepperState()
Get a default (initial) StepperState.
virtual bool isValidSetup(Teuchos::FancyOStream &out) const
RCP< std::basic_ostream< char_type, traits_type > > getOStream()
virtual void setAppAction(Teuchos::RCP< StepperForwardEulerAppAction< Scalar > > appAction)
StepperForwardEuler()
Default constructor.
virtual void takeStep(const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory)
Take the specified timestep, dt, and return true if successful.
Thyra Base interface for implicit time steppers.