9 #ifndef Tempus_StepperForwardEuler_impl_hpp
10 #define Tempus_StepperForwardEuler_impl_hpp
12 #include "Teuchos_VerboseObjectParameterListHelpers.hpp"
13 #include "Thyra_VectorStdOps.hpp"
19 template<
class Scalar>
22 this->setStepperType(
"Forward Euler");
23 this->setUseFSAL( this->getUseFSALDefault());
24 this->setICConsistency( this->getICConsistencyDefault());
25 this->setICConsistencyCheck( this->getICConsistencyCheckDefault());
31 template<
class Scalar>
33 const Teuchos::RCP<
const Thyra::ModelEvaluator<Scalar> >& appModel,
36 std::string ICConsistency,
37 bool ICConsistencyCheck)
39 this->setStepperType(
"Forward Euler");
40 this->setUseFSAL( useFSAL);
41 this->setICConsistency( ICConsistency);
42 this->setICConsistencyCheck( ICConsistencyCheck);
44 this->setObserver(obs);
46 if (appModel != Teuchos::null) {
47 this->setModel(appModel);
53 template<
class Scalar>
57 if (obs == Teuchos::null) {
59 if (this->stepperObserver_ == Teuchos::null) {
62 this->stepperObserver_ =
66 this->stepperObserver_ = obs;
69 (this->stepperObserver_,
true);
73 template<
class Scalar>
76 TEUCHOS_TEST_FOR_EXCEPTION(
77 this->appModel_ == Teuchos::null, std::logic_error,
78 "Error - Need to set the model, setModel(), before calling "
79 "StepperForwardEuler::initialize()\n");
82 template<
class Scalar>
88 RCP<SolutionState<Scalar> > initialState =
solutionHistory->getCurrentState();
91 if (initialState->getXDot() == Teuchos::null)
92 this->setStepperXDot(initialState->getX()->clone_v());
97 template<
class Scalar>
103 TEMPUS_FUNC_TIME_MONITOR(
"Tempus::StepperForwardEuler::takeStep()");
107 "Error - StepperForwardEuler<Scalar>::takeStep(...)\n"
108 "Need at least two SolutionStates for Forward Euler.\n"
110 "Try setting in \"Solution History\" \"Storage Type\" = \"Undo\"\n"
111 " or \"Storage Type\" = \"Static\" and \"Storage Limit\" = \"2\"\n");
114 RCP<SolutionState<Scalar> > currentState=
solutionHistory->getCurrentState();
115 RCP<SolutionState<Scalar> > workingState=
solutionHistory->getWorkingState();
117 RCP<Thyra::VectorBase<Scalar> > xDot = this->getStepperXDot(currentState);
118 const Scalar dt = workingState->getTimeStep();
120 if ( !(this->getUseFSAL()) ) {
122 if (!Teuchos::is_null(stepperFEObserver_))
128 this->evaluateExplicitODE(xDot, currentState->getX(),
129 currentState->getTime(), p);
133 currentState->setIsSynced(
true);
138 Thyra::V_VpStV(Teuchos::outArg(*(workingState->getX())),
139 *(currentState->getX()),dt,*(xDot));
142 xDot = this->getStepperXDot(workingState);
144 if (this->getUseFSAL()) {
146 if (!Teuchos::is_null(stepperFEObserver_))
152 this->evaluateExplicitODE(xDot, workingState->getX(),
153 workingState->getTime(), p);
157 workingState->setIsSynced(
true);
159 assign(xDot.ptr(), Teuchos::ScalarTraits<Scalar>::zero());
160 workingState->setIsSynced(
false);
164 workingState->setOrder(this->getOrder());
177 template<
class Scalar>
181 Teuchos::RCP<Tempus::StepperState<Scalar> > stepperState =
187 template<
class Scalar>
189 Teuchos::FancyOStream &out,
190 const Teuchos::EVerbosityLevel )
const
192 out << this->getStepperType() <<
"::describe:" << std::endl
193 <<
"appModel_ = " << this->appModel_->description() << std::endl;
197 template<
class Scalar>
198 Teuchos::RCP<const Teuchos::ParameterList>
201 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
203 pl->set<
bool>(
"Use FSAL",
true);
204 pl->set<std::string>(
"Initial Condition Consistency",
"Consistent");
210 #endif // Tempus_StepperForwardEuler_impl_hpp
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.
virtual void initialize()
Initialize during construction and after changing input parameters.
StepperForwardEulerObserver class for StepperForwardEuler.
StepperState is a simple class to hold state information about the stepper.
virtual void setInitialConditions(const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory)
Set the initial conditions, make them consistent, and set needed memory.
StepperObserver class for Stepper class.
Teuchos::RCP< SolutionHistory< Scalar > > solutionHistory(Teuchos::RCP< Teuchos::ParameterList > pList=Teuchos::null)
Nonmember constructor.
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
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.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
void getValidParametersBasic(Teuchos::RCP< Teuchos::ParameterList > pl, std::string stepperType)
Provide basic parameters to Steppers.