9#ifndef Tempus_StepperLeapfrog_impl_hpp
10#define Tempus_StepperLeapfrog_impl_hpp
12#include "Thyra_VectorStdOps.hpp"
23 this->setStepperName(
"Leapfrog");
24 this->setStepperType(
"Leapfrog");
25 this->setUseFSAL(
false);
26 this->setICConsistency(
"Consistent");
27 this->setICConsistencyCheck(
false);
29 this->setAppAction(Teuchos::null);
36 std::string ICConsistency,
37 bool ICConsistencyCheck,
40 this->setStepperName(
"Leapfrog");
41 this->setStepperType(
"Leapfrog");
42 this->setUseFSAL( useFSAL);
43 this->setICConsistency( ICConsistency);
44 this->setICConsistencyCheck( ICConsistencyCheck);
45 this->setAppAction(stepperLFAppAction);
46 if (appModel != Teuchos::null) {
48 this->setModel(appModel);
58 if (appAction == Teuchos::null) {
64 stepperLFAppAction_ = appAction;
75 RCP<SolutionState<Scalar> > initialState = solutionHistory->getCurrentState();
78 if (initialState->getXDotDot() == Teuchos::null)
79 this->setStepperXDotDot(initialState->getX()->clone_v());
81 this->setStepperXDotDot(initialState->getXDotDot());
85 if (this->getUseFSAL()) {
86 Teuchos::RCP<Teuchos::FancyOStream> out = this->getOStream();
87 Teuchos::OSTab ostab(out,1,
"StepperLeapfrog::setInitialConditions()");
88 *out <<
"Warning -- The First-Same-As-Last (FSAL) principle is not "
89 <<
"used with Leapfrog because of the algorithm's prescribed "
90 <<
"order of solution update. The default is to set useFSAL=false, "
91 <<
"however useFSAL=true will also work but have no affect "
92 <<
"(i.e., no-op).\n" << std::endl;
100 this->checkInitialized();
104 TEMPUS_FUNC_TIME_MONITOR(
"Tempus::StepperLeapfrog::takeStep()");
106 TEUCHOS_TEST_FOR_EXCEPTION(solutionHistory->getNumStates() < 2,
108 "Error - StepperLeapfrog<Scalar>::takeStep(...)\n"
109 "Need at least two SolutionStates for Leapfrog.\n"
110 " Number of States = " << solutionHistory->getNumStates() <<
"\n"
111 "Try setting in \"Solution History\" \"Storage Type\" = \"Undo\"\n"
112 " or \"Storage Type\" = \"Static\" and \"Storage Limit\" = \"2\"\n");
114 RCP<SolutionState<Scalar> > currentState=solutionHistory->getCurrentState();
115 RCP<SolutionState<Scalar> > workingState=solutionHistory->getWorkingState();
116 const Scalar time = currentState->getTime();
117 const Scalar dt = workingState->getTimeStep();
120 RCP<StepperLeapfrog<Scalar> > thisStepper = Teuchos::rcpFromRef(*
this);
122 stepperLFAppAction_->execute(solutionHistory, thisStepper,
127 if (workingState->getIsSynced() ==
true) {
129 Thyra::V_VpStV(Teuchos::outArg(*(workingState->getXDot())),
130 *(currentState->getXDot()),0.5*dt,*(currentState->getXDotDot()));
132 stepperLFAppAction_->execute(solutionHistory, thisStepper,
135 Thyra::V_VpStV(Teuchos::outArg(*(workingState->getX())),
136 *(currentState->getX()),dt,*(workingState->getXDot()));
138 stepperLFAppAction_->execute(solutionHistory, thisStepper,
143 this->evaluateExplicitODE(workingState->getXDotDot(),
144 workingState->getX(),
145 Teuchos::null, time+dt, p);
146 stepperLFAppAction_->execute(solutionHistory, thisStepper,
148 if (workingState->getOutput() ==
true) {
150 Thyra::V_VpStV(Teuchos::outArg(*(workingState->getXDot())),
151 *(workingState->getXDot()),0.5*dt,*(workingState->getXDotDot()));
152 workingState->setIsSynced(
true);
155 Thyra::V_VpStV(Teuchos::outArg(*(workingState->getXDot())),
156 *(workingState->getXDot()),dt,*(workingState->getXDotDot()));
157 workingState->setIsSynced(
false);
161 workingState->setOrder(this->getOrder());
162 workingState->computeNorms(currentState);
164 stepperLFAppAction_->execute(solutionHistory, thisStepper,
177template<
class Scalar>
181 Teuchos::RCP<Tempus::StepperState<Scalar> > stepperState =
187template<
class Scalar>
189 Teuchos::FancyOStream &out,
190 const Teuchos::EVerbosityLevel verbLevel)
const
192 out.setOutputToRootOnly(0);
197 out <<
"--- StepperLeapfrog ---\n";
198 out <<
" stepperLFAppAction_ = "
199 << stepperLFAppAction_ << std::endl;
200 out <<
"-----------------------" << std::endl;
204template<
class Scalar>
207 out.setOutputToRootOnly(0);
208 bool isValidSetup =
true;
212 if (stepperLFAppAction_ == Teuchos::null) {
213 isValidSetup =
false;
214 out <<
"The Leapfrog AppAction is not set!\n";
224template<
class Scalar>
225Teuchos::RCP<StepperLeapfrog<Scalar> >
228 Teuchos::RCP<Teuchos::ParameterList> pl)
231 stepper->setStepperExplicitValues(pl);
233 if (model != Teuchos::null) {
234 stepper->setModel(model);
235 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 StepperLeapfrog.
Default modifier for StepperLeapfrog.
virtual Teuchos::RCP< Tempus::StepperState< Scalar > > getDefaultStepperState()
Get a default (initial) StepperState.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
virtual void takeStep(const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory)
Take the specified timestep, dt, and return true if successful.
virtual void setAppAction(Teuchos::RCP< StepperLeapfrogAppAction< Scalar > > appAction)
StepperLeapfrog()
Default constructor.
virtual void setInitialConditions(const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory)
Set the initial conditions and make them consistent.
virtual bool isValidSetup(Teuchos::FancyOStream &out) const
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< StepperLeapfrog< Scalar > > createStepperLeapfrog(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.