9#ifndef Tempus_StepperForwardEuler_impl_hpp
10#define Tempus_StepperForwardEuler_impl_hpp
12#include "Thyra_VectorStdOps.hpp"
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);
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);
55 if (appAction == Teuchos::null) {
61 stepperFEAppAction_ = appAction;
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());
87 this->checkInitialized();
91 TEMPUS_FUNC_TIME_MONITOR(
"Tempus::StepperForwardEuler::takeStep()");
93 TEUCHOS_TEST_FOR_EXCEPTION(solutionHistory->getNumStates() < 2,
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);
153 assign(xDot.ptr(), Teuchos::ScalarTraits<Scalar>::zero());
154 workingState->setIsSynced(
false);
158 workingState->setOrder(this->getOrder());
159 workingState->computeNorms(currentState);
160 stepperFEAppAction_->execute(solutionHistory, thisStepper,
173template<
class Scalar>
177 Teuchos::RCP<Tempus::StepperState<Scalar> > stepperState =
183template<
class Scalar>
185 Teuchos::FancyOStream &out,
186 const Teuchos::EVerbosityLevel verbLevel)
const
188 auto l_out = Teuchos::fancyOStream( out.getOStream() );
189 Teuchos::OSTab ostab(*l_out, 2, this->description());
190 l_out->setOutputToRootOnly(0);
195 *l_out <<
" stepperFEAppAction_ = "
196 << stepperFEAppAction_ << std::endl
197 <<
"----------------------------" << std::endl;
201template<
class Scalar>
204 out.setOutputToRootOnly(0);
206 bool isValidSetup =
true;
210 if (stepperFEAppAction_ == Teuchos::null) {
211 isValidSetup =
false;
212 out <<
"The Forward Euler AppAction is not set!\n";
220template<
class Scalar>
221Teuchos::RCP<StepperForwardEuler<Scalar> >
224 Teuchos::RCP<Teuchos::ParameterList> pl)
227 stepper->setStepperExplicitValues(pl);
229 if (model != Teuchos::null) {
230 stepper->setModel(model);
231 stepper->initialize();
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
Thyra Base interface for implicit time steppers.
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
Application Action for StepperForwardEuler.
Default modifier for StepperForwardEuler.
Forward Euler time stepper.
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
virtual bool isValidSetup(Teuchos::FancyOStream &out) const
virtual Teuchos::RCP< Tempus::StepperState< Scalar > > getDefaultStepperState()
Get a default (initial) StepperState.
StepperForwardEuler()
Default constructor.
virtual void takeStep(const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory)
Take the specified timestep, dt, and return true if successful.
virtual void setAppAction(Teuchos::RCP< StepperForwardEulerAppAction< Scalar > > appAction)
StepperState is a simple class to hold state information about the stepper.
Thyra Base interface for time steppers.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Teuchos::RCP< StepperForwardEuler< Scalar > > createStepperForwardEuler(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.