10 #ifndef Tempus_StepperForwardEuler_impl_hpp
11 #define Tempus_StepperForwardEuler_impl_hpp
13 #include "Thyra_VectorStdOps.hpp"
19 template <
class Scalar>
22 this->setStepperName(
"Forward Euler");
23 this->setStepperType(
"Forward Euler");
24 this->setUseFSAL(
true);
25 this->setICConsistency(
"Consistent");
26 this->setICConsistencyCheck(
false);
27 this->setAppAction(Teuchos::null);
30 template <
class Scalar>
33 bool useFSAL, std::string ICConsistency,
bool ICConsistencyCheck,
37 this->setStepperName(
"Forward Euler");
38 this->setStepperType(
"Forward Euler");
39 this->setUseFSAL(useFSAL);
40 this->setICConsistency(ICConsistency);
41 this->setICConsistencyCheck(ICConsistencyCheck);
43 this->setAppAction(stepperFEAppAction);
44 if (appModel != Teuchos::null) {
45 this->setModel(appModel);
50 template <
class Scalar>
54 if (appAction == Teuchos::null) {
60 stepperFEAppAction_ = appAction;
64 template <
class Scalar>
70 RCP<SolutionState<Scalar> > initialState = solutionHistory->getCurrentState();
73 if (initialState->getXDot() == Teuchos::null)
74 this->setStepperXDot(initialState->getX()->clone_v());
76 this->setStepperXDot(initialState->getXDot());
81 template <
class Scalar>
85 this->checkInitialized();
89 TEMPUS_FUNC_TIME_MONITOR(
"Tempus::StepperForwardEuler::takeStep()");
92 solutionHistory->getNumStates() < 2, std::logic_error,
93 "Error - StepperForwardEuler<Scalar>::takeStep(...)\n"
94 <<
"Need at least two SolutionStates for Forward Euler.\n"
95 <<
" Number of States = " << solutionHistory->getNumStates()
96 <<
"\n Try setting in \"Solution History\" \"Storage Type\" = "
97 <<
"\"Undo\"\n or \"Storage Type\" = \"Static\" and \"Storage Limit\" = "
100 RCP<StepperForwardEuler<Scalar> > thisStepper = Teuchos::rcpFromRef(*
this);
101 stepperFEAppAction_->execute(
102 solutionHistory, thisStepper,
105 RCP<SolutionState<Scalar> > currentState =
106 solutionHistory->getCurrentState();
107 RCP<SolutionState<Scalar> > workingState =
108 solutionHistory->getWorkingState();
109 if (currentState->getXDot() != Teuchos::null)
110 this->setStepperXDot(currentState->getXDot());
111 RCP<Thyra::VectorBase<Scalar> > xDot = this->getStepperXDot();
112 const Scalar dt = workingState->getTimeStep();
114 if (!(this->getUseFSAL()) || workingState->getNConsecutiveFailures() != 0) {
116 stepperFEAppAction_->execute(
117 solutionHistory, thisStepper,
119 Scalar>::ACTION_LOCATION::BEFORE_EXPLICIT_EVAL);
124 this->evaluateExplicitODE(xDot, currentState->getX(),
125 currentState->getTime(), p);
129 currentState->setIsSynced(
true);
133 Thyra::V_VpStV(Teuchos::outArg(*(workingState->getX())),
134 *(currentState->getX()), dt, *(xDot));
136 if (workingState->getXDot() != Teuchos::null)
137 this->setStepperXDot(workingState->getXDot());
138 xDot = this->getStepperXDot();
140 if (this->getUseFSAL()) {
142 stepperFEAppAction_->execute(
143 solutionHistory, thisStepper,
145 Scalar>::ACTION_LOCATION::BEFORE_EXPLICIT_EVAL);
150 this->evaluateExplicitODE(xDot, workingState->getX(),
151 workingState->getTime(), p);
155 workingState->setIsSynced(
true);
159 workingState->setIsSynced(
false);
163 workingState->setOrder(this->getOrder());
164 workingState->computeNorms(currentState);
165 stepperFEAppAction_->execute(
166 solutionHistory, thisStepper,
178 template <
class Scalar>
187 template <
class Scalar>
191 auto l_out = Teuchos::fancyOStream(out.
getOStream());
193 l_out->setOutputToRootOnly(0);
198 *l_out <<
" stepperFEAppAction_ = " << stepperFEAppAction_ << std::endl
199 <<
"----------------------------" << std::endl;
202 template <
class Scalar>
207 bool isValidSetup =
true;
211 if (stepperFEAppAction_ == Teuchos::null) {
212 isValidSetup =
false;
213 out <<
"The Forward Euler AppAction is not set!\n";
220 template <
class Scalar>
226 stepper->setStepperExplicitValues(pl);
228 if (model != Teuchos::null) {
229 stepper->setModel(model);
230 stepper->initialize();
237 #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.