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->setParameterList(Teuchos::null);
25 template<
class Scalar>
27 const Teuchos::RCP<
const Thyra::ModelEvaluator<Scalar> >& appModel,
28 Teuchos::RCP<Teuchos::ParameterList> pList)
30 this->setParameterList(pList);
32 if (appModel == Teuchos::null) {
36 this->setModel(appModel);
41 template<
class Scalar>
45 if (obs == Teuchos::null) {
47 if (this->stepperObserver_ == Teuchos::null) {
50 this->stepperObserver_ =
54 this->stepperObserver_ = obs;
57 (this->stepperObserver_);
61 template<
class Scalar>
64 TEUCHOS_TEST_FOR_EXCEPTION(
65 this->appModel_ == Teuchos::null, std::logic_error,
66 "Error - Need to set the model, setModel(), before calling "
67 "StepperForwardEuler::initialize()\n");
69 this->setParameterList(this->stepperPL_);
73 template<
class Scalar>
79 RCP<SolutionState<Scalar> > initialState =
solutionHistory->getCurrentState();
82 if (initialState->getXDot() == Teuchos::null)
83 this->setStepperXDot(initialState->getX()->clone_v());
88 template<
class Scalar>
94 TEMPUS_FUNC_TIME_MONITOR(
"Tempus::StepperForwardEuler::takeStep()");
98 "Error - StepperForwardEuler<Scalar>::takeStep(...)\n"
99 "Need at least two SolutionStates for Forward Euler.\n"
101 "Try setting in \"Solution History\" \"Storage Type\" = \"Undo\"\n"
102 " or \"Storage Type\" = \"Static\" and \"Storage Limit\" = \"2\"\n");
105 RCP<SolutionState<Scalar> > currentState=
solutionHistory->getCurrentState();
106 RCP<SolutionState<Scalar> > workingState=
solutionHistory->getWorkingState();
108 RCP<Thyra::VectorBase<Scalar> > xDot = this->getStepperXDot(currentState);
110 if ( !(this->getUseFSAL()) ) {
112 if (!Teuchos::is_null(stepperFEObserver_))
116 this->evaluateExplicitODE(xDot, currentState->getX(),
117 currentState->getTime());
121 currentState->setIsSynced(
true);
126 const Scalar dt = workingState->getTimeStep();
127 Thyra::V_VpStV(Teuchos::outArg(*(workingState->getX())),
128 *(currentState->getX()),dt,*(xDot));
131 xDot = this->getStepperXDot(workingState);
133 if (this->getUseFSAL()) {
135 if (!Teuchos::is_null(stepperFEObserver_))
139 this->evaluateExplicitODE(xDot, workingState->getX(),
140 workingState->getTime());
144 workingState->setIsSynced(
true);
146 assign(xDot.ptr(), Teuchos::ScalarTraits<Scalar>::zero());
147 workingState->setIsSynced(
false);
151 workingState->setOrder(this->getOrder());
164 template<
class Scalar>
168 Teuchos::RCP<Tempus::StepperState<Scalar> > stepperState =
174 template<
class Scalar>
177 std::string name =
"Forward Euler";
182 template<
class Scalar>
184 Teuchos::FancyOStream &out,
185 const Teuchos::EVerbosityLevel )
const
187 out << description() <<
"::describe:" << std::endl
188 <<
"appModel_ = " << this->appModel_->description() << std::endl;
192 template <
class Scalar>
194 const Teuchos::RCP<Teuchos::ParameterList> & pList)
196 if (pList == Teuchos::null) {
198 if (this->stepperPL_ == Teuchos::null)
199 this->stepperPL_ = this->getDefaultParameters();
201 this->stepperPL_ = pList;
203 this->stepperPL_->validateParametersAndSetDefaults(*this->getValidParameters());
205 std::string stepperType =
206 this->stepperPL_->template get<std::string>(
"Stepper Type");
207 TEUCHOS_TEST_FOR_EXCEPTION( stepperType !=
"Forward Euler",
209 "Error - Stepper Type is not 'Forward Euler'!\n"
210 <<
" Stepper Type = "<< pList->get<std::string>(
"Stepper Type") <<
"\n");
214 template<
class Scalar>
215 Teuchos::RCP<const Teuchos::ParameterList>
218 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
219 pl->setName(
"Default Stepper - " + this->description());
220 pl->set<std::string>(
"Stepper Type",
"Forward Euler",
221 "'Stepper Type' must be 'Forward Euler'.");
222 this->getValidParametersBasic(pl);
223 pl->set<
bool>(
"Use FSAL",
true);
224 pl->set<std::string>(
"Initial Condition Consistency",
"Consistent");
229 template<
class Scalar>
230 Teuchos::RCP<Teuchos::ParameterList>
234 using Teuchos::ParameterList;
235 using Teuchos::rcp_const_cast;
237 RCP<ParameterList> pl =
238 rcp_const_cast<ParameterList>(this->getValidParameters());
244 template <
class Scalar>
245 Teuchos::RCP<Teuchos::ParameterList>
248 return(this->stepperPL_);
252 template <
class Scalar>
253 Teuchos::RCP<Teuchos::ParameterList>
256 Teuchos::RCP<Teuchos::ParameterList> temp_plist = this->stepperPL_;
257 this->stepperPL_ = Teuchos::null;
263 #endif // Tempus_StepperForwardEuler_impl_hpp
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > &pl)
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.
Teuchos::RCP< Teuchos::ParameterList > unsetParameterList()
Teuchos::RCP< Teuchos::ParameterList > getNonconstParameterList()
StepperForwardEulerObserver class for StepperForwardEuler.
StepperState is a simple class to hold state information about the stepper.
Teuchos::RCP< Teuchos::ParameterList > getDefaultParameters() const
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
virtual std::string description() const