9 #ifndef Tempus_StepperTrapezoidal_impl_hpp
10 #define Tempus_StepperTrapezoidal_impl_hpp
13 #include "Tempus_WrapperModelEvaluatorBasic.hpp"
19 template<
class Scalar>
22 this->setStepperName(
"Trapezoidal Method");
23 this->setStepperType(
"Trapezoidal Method");
24 this->setUseFSAL(
true);
25 this->setICConsistency(
"Consistent");
26 this->setICConsistencyCheck(
false);
27 this->setZeroInitialGuess(
false);
29 this->setAppAction(Teuchos::null);
30 this->setDefaultSolver();
34 template<
class Scalar>
39 std::string ICConsistency,
40 bool ICConsistencyCheck,
41 bool zeroInitialGuess,
44 this->setStepperName(
"Trapezoidal Method");
45 this->setStepperType(
"Trapezoidal Method");
46 this->setUseFSAL( useFSAL);
47 this->setICConsistency( ICConsistency);
48 this->setICConsistencyCheck( ICConsistencyCheck);
49 this->setZeroInitialGuess( zeroInitialGuess);
51 this->setAppAction(stepperTrapAppAction);
52 this->setSolver(solver);
54 if (appModel != Teuchos::null) {
55 this->setModel(appModel);
61 template<
class Scalar>
65 if (appAction == Teuchos::null) {
67 stepperTrapAppAction_ =
70 stepperTrapAppAction_ = appAction;
72 this->isInitialized_ =
false;
76 template<
class Scalar>
82 RCP<SolutionState<Scalar> > initialState = solutionHistory->getCurrentState();
85 if (initialState->getXDot() == Teuchos::null)
86 this->setStepperXDot(initialState->getX()->clone_v());
88 this->setStepperXDot(initialState->getXDot());
93 "Error - The First-Same-As-Last (FSAL) principle is required\n"
94 " for the Trapezoidal Stepper (i.e., useFSAL=true)!\n");
105 template<
class Scalar>
109 this->checkInitialized();
113 TEMPUS_FUNC_TIME_MONITOR(
"Tempus::StepperTrapezoidal::takeStep()");
117 "Error - StepperTrapezoidal<Scalar>::takeStep(...)\n"
118 "Need at least two SolutionStates for Trapezoidal.\n"
119 " Number of States = " << solutionHistory->getNumStates() <<
"\n"
120 "Try setting in \"Solution History\" \"Storage Type\" = \"Undo\"\n"
121 " or \"Storage Type\" = \"Static\" and \"Storage Limit\" = \"2\"\n");
122 RCP<StepperTrapezoidal<Scalar> > thisStepper = Teuchos::rcpFromRef(*
this);
123 stepperTrapAppAction_->execute(solutionHistory, thisStepper,
126 RCP<SolutionState<Scalar> > workingState=solutionHistory->getWorkingState();
127 RCP<SolutionState<Scalar> > currentState=solutionHistory->getCurrentState();
129 RCP<const Thyra::VectorBase<Scalar> > xOld = currentState->getX();
130 RCP<const Thyra::VectorBase<Scalar> > xDotOld = currentState->getXDot();
131 RCP<Thyra::VectorBase<Scalar> > x = workingState->getX();
132 if (workingState->getXDot() != Teuchos::null)
133 this->setStepperXDot(workingState->getXDot());
134 RCP<Thyra::VectorBase<Scalar> > xDot = this->getStepperXDot();
136 const Scalar time = workingState->getTime();
137 const Scalar dt = workingState->getTimeStep();
138 const Scalar alpha = getAlpha(dt);
139 const Scalar beta = getBeta (dt);
144 alpha, xOld, xDotOld));
147 timeDer, dt, alpha, beta));
148 stepperTrapAppAction_->execute(solutionHistory, thisStepper,
152 this->solveImplicitODE(x, xDot, time, p);
153 stepperTrapAppAction_->execute(solutionHistory, thisStepper,
156 if (workingState->getXDot() != Teuchos::null)
157 timeDer->compute(x, xDot);
159 workingState->setSolutionStatus(sStatus);
160 workingState->setOrder(this->getOrder());
161 workingState->computeNorms(currentState);
162 stepperTrapAppAction_->execute(solutionHistory, thisStepper,
175 template<
class Scalar>
186 template<
class Scalar>
195 out <<
"--- StepperTrapezoidal ---\n";
196 out <<
" stepperTrapAppAction_ = " << stepperTrapAppAction_ << std::endl;
197 out <<
"--------------------------" << std::endl;
201 template<
class Scalar>
204 bool isValidSetup =
true;
209 if (stepperTrapAppAction_ == Teuchos::null) {
210 isValidSetup =
false;
211 out <<
"The Trapezoidal AppAction is not set!\n";
220 template<
class Scalar>
227 stepper->setStepperImplicitValues(pl);
229 if (model != Teuchos::null) {
230 stepper->setModel(model);
231 stepper->initialize();
239 #endif // Tempus_StepperTrapezoidal_impl_hpp
virtual void setInitialConditions(const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory)
Set the initial conditions and make them consistent.
virtual Teuchos::RCP< Tempus::StepperState< Scalar > > getDefaultStepperState()
Get a default (initial) StepperState.
Trapezoidal method time stepper.
Default modifier for StepperTrapezoidal.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
StepperTrapezoidal()
Default constructor.
Thyra Base interface for time steppers.
Teuchos::RCP< StepperTrapezoidal< Scalar > > createStepperTrapezoidal(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
virtual void setInitialConditions(const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory)
Set the initial conditions and make them consistent.
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)
Thyra Base interface for implicit time steppers.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Application Action for StepperTrapezoidal.
virtual void setAppAction(Teuchos::RCP< StepperTrapezoidalAppAction< Scalar > > appAction)
Time-derivative interface for Trapezoidal method.
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
virtual bool isValidSetup(Teuchos::FancyOStream &out) const
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
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.