10 #ifndef Tempus_StepperLeapfrog_impl_hpp
11 #define Tempus_StepperLeapfrog_impl_hpp
13 #include "Thyra_VectorStdOps.hpp"
19 template <
class Scalar>
22 this->setStepperName(
"Leapfrog");
23 this->setStepperType(
"Leapfrog");
24 this->setUseFSAL(
false);
25 this->setICConsistency(
"Consistent");
26 this->setICConsistencyCheck(
false);
28 this->setAppAction(Teuchos::null);
31 template <
class Scalar>
34 bool useFSAL, std::string ICConsistency,
bool ICConsistencyCheck,
37 this->setStepperName(
"Leapfrog");
38 this->setStepperType(
"Leapfrog");
39 this->setUseFSAL(useFSAL);
40 this->setICConsistency(ICConsistency);
41 this->setICConsistencyCheck(ICConsistencyCheck);
42 this->setAppAction(stepperLFAppAction);
43 if (appModel != Teuchos::null) {
44 this->setModel(appModel);
49 template <
class Scalar>
53 if (appAction == Teuchos::null) {
59 stepperLFAppAction_ = appAction;
63 template <
class Scalar>
69 RCP<SolutionState<Scalar> > initialState = solutionHistory->getCurrentState();
72 if (initialState->getXDotDot() == Teuchos::null)
73 this->setStepperXDotDot(initialState->getX()->clone_v());
75 this->setStepperXDotDot(initialState->getXDotDot());
79 if (this->getUseFSAL()) {
81 Teuchos::OSTab ostab(out, 1,
"StepperLeapfrog::setInitialConditions()");
82 *out <<
"Warning -- The First-Same-As-Last (FSAL) principle is not "
83 <<
"used with Leapfrog because of the algorithm's prescribed "
84 <<
"order of solution update. The default is to set useFSAL=false, "
85 <<
"however useFSAL=true will also work but have no affect "
91 template <
class Scalar>
95 this->checkInitialized();
99 TEMPUS_FUNC_TIME_MONITOR(
"Tempus::StepperLeapfrog::takeStep()");
102 solutionHistory->getNumStates() < 2, std::logic_error,
103 "Error - StepperLeapfrog<Scalar>::takeStep(...)\n"
104 <<
"Need at least two SolutionStates for Leapfrog.\n"
105 <<
" Number of States = " << solutionHistory->getNumStates()
106 <<
"\nTry setting in \"Solution History\" \"Storage Type\" = "
108 <<
" or \"Storage Type\" = \"Static\" and \"Storage Limit\" = "
111 RCP<SolutionState<Scalar> > currentState =
112 solutionHistory->getCurrentState();
113 RCP<SolutionState<Scalar> > workingState =
114 solutionHistory->getWorkingState();
115 const Scalar time = currentState->getTime();
116 const Scalar dt = workingState->getTimeStep();
118 RCP<StepperLeapfrog<Scalar> > thisStepper = Teuchos::rcpFromRef(*
this);
120 stepperLFAppAction_->execute(
121 solutionHistory, thisStepper,
126 if (workingState->getIsSynced() ==
true) {
128 Thyra::V_VpStV(Teuchos::outArg(*(workingState->getXDot())),
129 *(currentState->getXDot()), 0.5 * dt,
130 *(currentState->getXDotDot()));
132 stepperLFAppAction_->execute(
133 solutionHistory, thisStepper,
136 Thyra::V_VpStV(Teuchos::outArg(*(workingState->getX())),
137 *(currentState->getX()), dt, *(workingState->getXDot()));
139 stepperLFAppAction_->execute(
140 solutionHistory, thisStepper,
142 Scalar>::ACTION_LOCATION::BEFORE_EXPLICIT_EVAL);
146 this->evaluateExplicitODE(workingState->getXDotDot(), workingState->getX(),
147 Teuchos::null, time + dt, p);
148 stepperLFAppAction_->execute(
149 solutionHistory, thisStepper,
151 if (workingState->getOutput() ==
true) {
153 Thyra::V_VpStV(Teuchos::outArg(*(workingState->getXDot())),
154 *(workingState->getXDot()), 0.5 * dt,
155 *(workingState->getXDotDot()));
156 workingState->setIsSynced(
true);
160 Thyra::V_VpStV(Teuchos::outArg(*(workingState->getXDot())),
161 *(workingState->getXDot()), dt,
162 *(workingState->getXDotDot()));
163 workingState->setIsSynced(
false);
167 workingState->setOrder(this->getOrder());
168 workingState->computeNorms(currentState);
170 stepperLFAppAction_->execute(
171 solutionHistory, thisStepper,
183 template <
class Scalar>
192 template <
class Scalar>
201 out <<
"--- StepperLeapfrog ---\n";
202 out <<
" stepperLFAppAction_ = " << stepperLFAppAction_
204 out <<
"-----------------------" << std::endl;
207 template <
class Scalar>
211 bool isValidSetup =
true;
215 if (stepperLFAppAction_ == Teuchos::null) {
216 isValidSetup =
false;
217 out <<
"The Leapfrog AppAction is not set!\n";
225 template <
class Scalar>
231 stepper->setStepperExplicitValues(pl);
233 if (model != Teuchos::null) {
234 stepper->setModel(model);
235 stepper->initialize();
242 #endif // Tempus_StepperLeapfrog_impl_hpp
virtual void setInitialConditions(const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory)
Set the initial conditions and make them consistent.
Teuchos::RCP< StepperLeapfrog< Scalar > > createStepperLeapfrog(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
Default modifier for StepperLeapfrog.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
virtual void takeStep(const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory)
Take the specified timestep, dt, and return true if successful.
Thyra Base interface for time steppers.
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)
Application Action for StepperLeapfrog.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
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.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
virtual Teuchos::RCP< Tempus::StepperState< Scalar > > getDefaultStepperState()
Get a default (initial) StepperState.
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
basic_FancyOStream & setOutputToRootOnly(const int rootRank)
virtual bool isValidSetup(Teuchos::FancyOStream &out) const
StepperLeapfrog()
Default constructor.
virtual void setAppAction(Teuchos::RCP< StepperLeapfrogAppAction< Scalar > > appAction)
Thyra Base interface for implicit time steppers.