Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Tempus_StepperBackwardEuler_decl.hpp
Go to the documentation of this file.
1 //@HEADER
2 // *****************************************************************************
3 // Tempus: Time Integration and Sensitivity Analysis Package
4 //
5 // Copyright 2017 NTESS and the Tempus contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 //@HEADER
9 
10 #ifndef Tempus_StepperBackwardEuler_decl_hpp
11 #define Tempus_StepperBackwardEuler_decl_hpp
12 
13 #include "Tempus_config.hpp"
14 #include "Tempus_StepperImplicit.hpp"
18 
19 namespace Tempus {
20 
74 template <class Scalar>
76  : virtual public Tempus::StepperImplicit<Scalar>,
77  virtual public Tempus::StepperOptimizationInterface<Scalar> {
78  public:
85 
88  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
90  const Teuchos::RCP<Stepper<Scalar> >& predictorStepper, bool useFSAL,
91  std::string ICConsistency, bool ICConsistencyCheck, bool zeroInitialGuess,
93  stepperBEAppAction);
94 
96 
97  virtual void setAppAction(
99 
101  const
102  {
103  return stepperBEAppAction_;
104  }
105 
107  void setPredictor(std::string predictorType = "None");
108  void setPredictor(Teuchos::RCP<Stepper<Scalar> > predictorStepper);
109 
111  virtual void setModel(
112  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel)
113  override;
114 
116  virtual void setInitialConditions(
117  const Teuchos::RCP<SolutionHistory<Scalar> >& solutionHistory) override;
118 
120  virtual void takeStep(
121  const Teuchos::RCP<SolutionHistory<Scalar> >& solutionHistory) override;
122 
125  override;
126  virtual Scalar getOrder() const override { return 1.0; }
127  virtual Scalar getOrderMin() const override { return 1.0; }
128  virtual Scalar getOrderMax() const override { return 1.0; }
129 
130  virtual bool isExplicit() const override { return false; }
131  virtual bool isImplicit() const override { return true; }
132  virtual bool isExplicitImplicit() const override
133  {
134  return isExplicit() && isImplicit();
135  }
136  virtual bool isOneStepMethod() const override { return true; }
137  virtual bool isMultiStepMethod() const override { return !isOneStepMethod(); }
138  virtual OrderODE getOrderODE() const override { return FIRST_ORDER_ODE; }
140 
142  virtual Scalar getAlpha(const Scalar dt) const override
143  {
144  return Scalar(1.0) / dt;
145  }
147  virtual Scalar getBeta(const Scalar) const override { return Scalar(1.0); }
148 
150  virtual void computePredictor(
151  const Teuchos::RCP<SolutionHistory<Scalar> >& solutionHistory);
152 
155  const override;
156 
158 
159  virtual void describe(
161  const Teuchos::EVerbosityLevel verbLevel) const override;
163 
164  virtual bool isValidSetup(Teuchos::FancyOStream& out) const override;
165 
167 
168  virtual int stencilLength() const override;
169  virtual void computeStepResidual(
170  Thyra::VectorBase<Scalar>& residual,
173  const int param_index) const override;
174  virtual void computeStepJacobian(
175  Thyra::LinearOpBase<Scalar>& jacobian,
178  const int param_index, const int deriv_index) const override;
179  virtual void computeStepParamDeriv(
183  const int param_index) const override;
184  virtual void computeStepSolver(
185  Thyra::LinearOpWithSolveBase<Scalar>& jacobian_solver,
188  const int param_index) const override;
190 
191  private:
197  const int param_index, const int deriv_index = 0) const;
198 
199  private:
202 };
203 
212 template <typename Scalar>
214  : virtual public Tempus::TimeDerivative<Scalar> {
215  public:
218  Scalar s, Teuchos::RCP<const Thyra::VectorBase<Scalar> > xOld)
219  {
220  initialize(s, xOld);
221  }
222 
225 
227  virtual void compute(
230  Teuchos::RCP<Thyra::VectorBase<Scalar> > xDotDot = Teuchos::null)
231  {
232  xDotDot = Teuchos::null;
233  // Calculate the Backward Euler x dot vector
234  Thyra::V_StVpStV(xDot.ptr(), s_, *x, -s_, *xOld_);
235  }
236 
237  virtual void initialize(Scalar s,
239  {
240  s_ = s;
241  xOld_ = xOld;
242  }
243 
244  private:
246  Scalar s_; // = 1.0/dt
247 };
248 
250 // ------------------------------------------------------------------------
251 template <class Scalar>
253  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
255 
256 } // namespace Tempus
257 
258 #endif // Tempus_StepperBackwardEuler_decl_hpp
Teuchos::RCP< const Thyra::VectorBase< Scalar > > xOld_
Teuchos::RCP< StepperBackwardEulerAppAction< Scalar > > stepperBEAppAction_
void computeStepResidDerivImpl(const Thyra::ModelEvaluatorBase::OutArgs< Scalar > &outArgs, const Teuchos::Array< Teuchos::RCP< const Thyra::VectorBase< Scalar > > > &x, const Teuchos::Array< Scalar > &t, const Thyra::VectorBase< Scalar > &p, const int param_index, const int deriv_index=0) const
Implementation of computeStep*() methods.
virtual void compute(Teuchos::RCP< const Thyra::VectorBase< Scalar > > x, Teuchos::RCP< Thyra::VectorBase< Scalar > > xDot, Teuchos::RCP< Thyra::VectorBase< Scalar > > xDotDot=Teuchos::null)
Compute the time derivative.
virtual OrderODE getOrderODE() const override
virtual void computePredictor(const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory)
Compute predictor given the supplied stepper.
virtual void computeStepParamDeriv(Thyra::LinearOpBase< Scalar > &deriv, const Teuchos::Array< Teuchos::RCP< const Thyra::VectorBase< Scalar > > > &x, const Teuchos::Array< Scalar > &t, const Thyra::VectorBase< Scalar > &p, const int param_index) const override
Compute time step derivative w.r.t. model parameters.
virtual Scalar getBeta(const Scalar) const override
Return beta = d(x)/dx.
virtual void computeStepResidual(Thyra::VectorBase< Scalar > &residual, const Teuchos::Array< Teuchos::RCP< const Thyra::VectorBase< Scalar > > > &x, const Teuchos::Array< Scalar > &t, const Thyra::VectorBase< Scalar > &p, const int param_index) const override
Compute time step residual.
Application Action for StepperBackwardEuler.
virtual void computeStepSolver(Thyra::LinearOpWithSolveBase< Scalar > &jacobian_solver, const Teuchos::Array< Teuchos::RCP< const Thyra::VectorBase< Scalar > > > &x, const Teuchos::Array< Scalar > &t, const Thyra::VectorBase< Scalar > &p, const int param_index) const override
Compute time step Jacobian solver.
Thyra Base interface for time steppers.
Thyra Base interface for implicit time steppers.
virtual void takeStep(const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory) override
Take the specified timestep, dt, and return true if successful.
virtual bool isValidSetup(Teuchos::FancyOStream &out) const override
virtual bool isOneStepMethod() const override
virtual bool isMultiStepMethod() const override
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const override
Return a valid ParameterList with current settings.
void setPredictor(std::string predictorType="None")
Set the predictor.
virtual Teuchos::RCP< Tempus::StepperState< Scalar > > getDefaultStepperState() override
Get a default (initial) StepperState.
virtual Scalar getOrderMin() const override
virtual Scalar getAlpha(const Scalar dt) const override
Return alpha = d(xDot)/dx.
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
Teuchos::RCP< Stepper< Scalar > > predictorStepper_
virtual void setAppAction(Teuchos::RCP< StepperBackwardEulerAppAction< Scalar > > appAction)
virtual void computeStepJacobian(Thyra::LinearOpBase< Scalar > &jacobian, const Teuchos::Array< Teuchos::RCP< const Thyra::VectorBase< Scalar > > > &x, const Teuchos::Array< Scalar > &t, const Thyra::VectorBase< Scalar > &p, const int param_index, const int deriv_index) const override
Compute time step Jacobian.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const override
virtual bool isExplicitImplicit() const override
Stepper integrates first-order ODEs.
StepperBackwardEulerTimeDerivative(Scalar s, Teuchos::RCP< const Thyra::VectorBase< Scalar > > xOld)
Constructor.
virtual void setInitialConditions(const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory) override
Set the initial conditions and make them consistent.
virtual Teuchos::RCP< StepperBackwardEulerAppAction< Scalar > > getAppAction() const
virtual Scalar getOrder() const override
virtual Scalar getOrderMax() const override
This interface defines the time derivative connection between an implicit Stepper and WrapperModelEva...
Teuchos::RCP< StepperBackwardEuler< Scalar > > createStepperBackwardEuler(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
virtual void setModel(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel) override
Set the model.
virtual void initialize(Scalar s, Teuchos::RCP< const Thyra::VectorBase< Scalar > > xOld)
Stepper interface to support full-space optimization.
Time-derivative interface for Backward Euler.
virtual int stencilLength() const override
Return the number of solution vectors in the time step stencil.