9 #ifndef Tempus_StepperForwardEuler_impl_hpp
10 #define Tempus_StepperForwardEuler_impl_hpp
12 #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>
34 std::string ICConsistency,
35 bool ICConsistencyCheck,
38 this->setStepperName(
"Forward Euler");
39 this->setStepperType(
"Forward Euler");
40 this->setUseFSAL( useFSAL);
41 this->setICConsistency( ICConsistency);
42 this->setICConsistencyCheck( ICConsistencyCheck);
44 this->setAppAction(stepperFEAppAction);
45 if (appModel != Teuchos::null) {
46 this->setModel(appModel);
51 template<
class Scalar>
55 if (appAction == Teuchos::null) {
61 stepperFEAppAction_ = appAction;
66 template<
class Scalar>
72 RCP<SolutionState<Scalar> > initialState = solutionHistory->getCurrentState();
75 if (initialState->getXDot() == Teuchos::null)
76 this->setStepperXDot(initialState->getX()->clone_v());
78 this->setStepperXDot(initialState->getXDot());
83 template<
class Scalar>
87 this->checkInitialized();
91 TEMPUS_FUNC_TIME_MONITOR(
"Tempus::StepperForwardEuler::takeStep()");
95 "Error - StepperForwardEuler<Scalar>::takeStep(...)\n"
96 "Need at least two SolutionStates for Forward Euler.\n"
97 " Number of States = " << solutionHistory->getNumStates() <<
"\n"
98 "Try setting in \"Solution History\" \"Storage Type\" = \"Undo\"\n"
99 " or \"Storage Type\" = \"Static\" and \"Storage Limit\" = \"2\"\n");
101 RCP<StepperForwardEuler<Scalar> > thisStepper = Teuchos::rcpFromRef(*
this);
102 stepperFEAppAction_->execute(solutionHistory, thisStepper,
105 RCP<SolutionState<Scalar> > currentState=solutionHistory->getCurrentState();
106 RCP<SolutionState<Scalar> > workingState=solutionHistory->getWorkingState();
107 if (currentState->getXDot() != Teuchos::null)
108 this->setStepperXDot(currentState->getXDot());
109 RCP<Thyra::VectorBase<Scalar> > xDot = this->getStepperXDot();
110 const Scalar dt = workingState->getTimeStep();
112 if (!(this->getUseFSAL()) || workingState->getNConsecutiveFailures() != 0) {
114 stepperFEAppAction_->execute(solutionHistory, thisStepper,
120 this->evaluateExplicitODE(xDot, currentState->getX(),
121 currentState->getTime(), p);
125 currentState->setIsSynced(
true);
130 Thyra::V_VpStV(Teuchos::outArg(*(workingState->getX())),
131 *(currentState->getX()),dt,*(xDot));
134 if (workingState->getXDot() != Teuchos::null)
135 this->setStepperXDot(workingState->getXDot());
136 xDot = this->getStepperXDot();
138 if (this->getUseFSAL()) {
140 stepperFEAppAction_->execute(solutionHistory, thisStepper,
146 this->evaluateExplicitODE(xDot, workingState->getX(),
147 workingState->getTime(), p);
151 workingState->setIsSynced(
true);
154 workingState->setIsSynced(
false);
158 workingState->setOrder(this->getOrder());
159 workingState->computeNorms(currentState);
160 stepperFEAppAction_->execute(solutionHistory, thisStepper,
173 template<
class Scalar>
183 template<
class Scalar>
191 out <<
" stepperFEAppAction_ = "
192 << stepperFEAppAction_ << std::endl;
193 out <<
"----------------------------" << std::endl;
197 template<
class Scalar>
200 bool isValidSetup =
true;
204 if (stepperFEAppAction_ == Teuchos::null) {
205 isValidSetup =
false;
206 out <<
"The Forward Euler AppAction is not set!\n";
214 template<
class Scalar>
221 stepper->setStepperExplicitValues(pl);
223 if (model != Teuchos::null) {
224 stepper->setModel(model);
225 stepper->initialize();
233 #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...
virtual Teuchos::RCP< Tempus::StepperState< Scalar > > getDefaultStepperState()
Get a default (initial) StepperState.
virtual bool isValidSetup(Teuchos::FancyOStream &out) const
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.