9 #ifndef Tempus_StepperForwardEuler_impl_hpp
10 #define Tempus_StepperForwardEuler_impl_hpp
12 #include "Teuchos_VerboseObjectParameterListHelpers.hpp"
13 #include "Thyra_VectorStdOps.hpp"
18 template<
class Scalar>
21 this->setStepperType(
"Forward Euler");
22 this->setUseFSAL( this->getUseFSALDefault());
23 this->setICConsistency( this->getICConsistencyDefault());
24 this->setICConsistencyCheck( this->getICConsistencyCheckDefault());
25 #ifndef TEMPUS_HIDE_DEPRECATED_CODE
28 this->setAppAction(Teuchos::null);
31 #ifndef TEMPUS_HIDE_DEPRECATED_CODE
32 template<
class Scalar>
34 const Teuchos::RCP<
const Thyra::ModelEvaluator<Scalar> >& appModel,
37 std::string ICConsistency,
38 bool ICConsistencyCheck)
40 this->setStepperType(
"Forward Euler");
41 this->setUseFSAL( useFSAL);
42 this->setICConsistency( ICConsistency);
43 this->setICConsistencyCheck( ICConsistencyCheck);
44 this->setObserver(obs);
45 this->setAppAction(Teuchos::null);
47 if (appModel != Teuchos::null) {
48 this->setModel(appModel);
54 template<
class Scalar>
56 const Teuchos::RCP<
const Thyra::ModelEvaluator<Scalar> >& appModel,
58 std::string ICConsistency,
59 bool ICConsistencyCheck,
62 this->setStepperType(
"Forward Euler");
63 this->setUseFSAL( useFSAL);
64 this->setICConsistency( ICConsistency);
65 this->setICConsistencyCheck( ICConsistencyCheck);
68 this->setAppAction(stepperFEAppAction);
69 if (appModel != Teuchos::null) {
70 this->setModel(appModel);
75 #ifndef TEMPUS_HIDE_DEPRECATED_CODE
76 template<
class Scalar>
80 if (obs == Teuchos::null) {
82 if (this->stepperObserver_ == Teuchos::null) {
85 this->stepperObserver_ =
89 this->stepperObserver_ = obs;
92 (this->stepperObserver_,
true);
95 this->isInitialized_ =
false;
99 template<
class Scalar>
103 if (appAction == Teuchos::null) {
105 stepperFEAppAction_ =
109 stepperFEAppAction_ = appAction;
114 template<
class Scalar>
120 RCP<SolutionState<Scalar> > initialState = solutionHistory->getCurrentState();
123 if (initialState->getXDot() == Teuchos::null)
124 this->setStepperXDot(initialState->getX()->clone_v());
129 template<
class Scalar>
133 this->checkInitialized();
137 TEMPUS_FUNC_TIME_MONITOR(
"Tempus::StepperForwardEuler::takeStep()");
139 TEUCHOS_TEST_FOR_EXCEPTION(solutionHistory->getNumStates() < 2,
141 "Error - StepperForwardEuler<Scalar>::takeStep(...)\n"
142 "Need at least two SolutionStates for Forward Euler.\n"
143 " Number of States = " << solutionHistory->getNumStates() <<
"\n"
144 "Try setting in \"Solution History\" \"Storage Type\" = \"Undo\"\n"
145 " or \"Storage Type\" = \"Static\" and \"Storage Limit\" = \"2\"\n");
146 #ifndef TEMPUS_HIDE_DEPRECATED_CODE
147 this->stepperObserver_->observeBeginTakeStep(solutionHistory, *
this);
149 RCP<StepperForwardEuler<Scalar> > thisStepper = Teuchos::rcpFromRef(*
this);
150 stepperFEAppAction_->execute(solutionHistory, thisStepper,
153 RCP<SolutionState<Scalar> > currentState=solutionHistory->getCurrentState();
154 RCP<SolutionState<Scalar> > workingState=solutionHistory->getWorkingState();
155 RCP<Thyra::VectorBase<Scalar> > xDot = this->getStepperXDot(currentState);
156 const Scalar dt = workingState->getTimeStep();
158 if ( !(this->getUseFSAL()) ) {
160 #ifndef TEMPUS_HIDE_DEPRECATED_CODE
161 if (!Teuchos::is_null(stepperFEObserver_))
162 stepperFEObserver_->observeBeforeExplicit(solutionHistory, *
this);
164 stepperFEAppAction_->execute(solutionHistory, thisStepper,
170 this->evaluateExplicitODE(xDot, currentState->getX(),
171 currentState->getTime(), p);
175 currentState->setIsSynced(
true);
180 Thyra::V_VpStV(Teuchos::outArg(*(workingState->getX())),
181 *(currentState->getX()),dt,*(xDot));
184 xDot = this->getStepperXDot(workingState);
186 if (this->getUseFSAL()) {
188 #ifndef TEMPUS_HIDE_DEPRECATED_CODE
189 if (!Teuchos::is_null(stepperFEObserver_))
190 stepperFEObserver_->observeBeforeExplicit(solutionHistory, *
this);
192 stepperFEAppAction_->execute(solutionHistory, thisStepper,
198 this->evaluateExplicitODE(xDot, workingState->getX(),
199 workingState->getTime(), p);
203 workingState->setIsSynced(
true);
205 assign(xDot.ptr(), Teuchos::ScalarTraits<Scalar>::zero());
206 workingState->setIsSynced(
false);
210 workingState->setOrder(this->getOrder());
211 workingState->computeNorms(currentState);
212 #ifndef TEMPUS_HIDE_DEPRECATED_CODE
213 this->stepperObserver_->observeEndTakeStep(solutionHistory, *
this);
215 stepperFEAppAction_->execute(solutionHistory, thisStepper,
228 template<
class Scalar>
232 Teuchos::RCP<Tempus::StepperState<Scalar> > stepperState =
238 template<
class Scalar>
240 Teuchos::FancyOStream &out,
241 const Teuchos::EVerbosityLevel verbLevel)
const
246 #ifndef TEMPUS_HIDE_DEPRECATED_CODE
247 out <<
"--- StepperForwardEuler ---\n";
248 out << stepperFEObserver_ << std::endl;
249 out <<
"---------------------------" << std::endl;
251 out <<
" stepperFEAppAction_ = "
252 << stepperFEAppAction_ << std::endl;
253 out <<
"----------------------------" << std::endl;
257 template<
class Scalar>
260 bool isValidSetup =
true;
264 #ifndef TEMPUS_HIDE_DEPRECATED_CODE
265 if (stepperFEObserver_ == Teuchos::null) {
266 isValidSetup =
false;
267 out <<
"The Forward Euler observer is not set!\n";
270 if (stepperFEAppAction_ == Teuchos::null) {
271 isValidSetup =
false;
272 out <<
"The Forward Euler AppAction is not set!\n";
278 template<
class Scalar>
279 Teuchos::RCP<const Teuchos::ParameterList>
282 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
284 pl->set<
bool>(
"Use FSAL",
true);
285 pl->set<std::string>(
"Initial Condition Consistency",
"Consistent");
291 #endif // Tempus_StepperForwardEuler_impl_hpp
Default modifier for StepperForwardEuler.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
virtual void setObserver(Teuchos::RCP< StepperObserver< Scalar > > obs=Teuchos::null)
Set Observer.
virtual void setInitialConditions(const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory)
Set the initial conditions, make them consistent, and set needed memory.
StepperForwardEulerObserver class for StepperForwardEuler.
Thyra Base interface for time steppers.
StepperState is a simple class to hold state information about the stepper.
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
StepperObserver class for Stepper class.
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.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Thyra Base interface for implicit time steppers.
void getValidParametersBasic(Teuchos::RCP< Teuchos::ParameterList > pl, std::string stepperType)
Provide basic parameters to Steppers.