Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Tempus_StepperTrapezoidal_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_StepperTrapezoidal_decl_hpp
11 #define Tempus_StepperTrapezoidal_decl_hpp
12 
13 #include "Tempus_config.hpp"
14 #include "Tempus_StepperImplicit.hpp"
18 
19 namespace Tempus {
20 
82 template <class Scalar>
83 class StepperTrapezoidal : virtual public Tempus::StepperImplicit<Scalar> {
84  public:
91 
94  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
96  bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
97  bool zeroInitialGuess,
99  stepperTrapAppAction);
100 
102 
103  virtual void setAppAction(
105 
107  const
108  {
109  return stepperTrapAppAction_;
110  }
111 
113  virtual void setInitialConditions(
114  const Teuchos::RCP<SolutionHistory<Scalar> >& solutionHistory);
115 
117  virtual void takeStep(
118  const Teuchos::RCP<SolutionHistory<Scalar> >& solutionHistory);
119 
122  virtual Scalar getOrder() const { return 2.0; }
123  virtual Scalar getOrderMin() const { return 2.0; }
124  virtual Scalar getOrderMax() const { return 2.0; }
125 
126  virtual bool isExplicit() const { return false; }
127  virtual bool isImplicit() const { return true; }
128  virtual bool isExplicitImplicit() const
129  {
130  return isExplicit() && isImplicit();
131  }
132  virtual bool isOneStepMethod() const { return true; }
133  virtual bool isMultiStepMethod() const { return !isOneStepMethod(); }
134  virtual void setUseFSAL(bool a) { this->setUseFSALTrueOnly(a); }
135  virtual OrderODE getOrderODE() const { return FIRST_ORDER_ODE; }
137 
139  virtual Scalar getAlpha(const Scalar dt) const { return Scalar(2.0) / dt; }
141  virtual Scalar getBeta(const Scalar) const { return Scalar(1.0); }
142 
144 
145  virtual void describe(Teuchos::FancyOStream& out,
146  const Teuchos::EVerbosityLevel verbLevel) const;
148 
149  virtual bool isValidSetup(Teuchos::FancyOStream& out) const;
150 
151  private:
153 };
154 
163 template <typename Scalar>
165  : virtual public Tempus::TimeDerivative<Scalar> {
166  public:
169  Scalar s, Teuchos::RCP<const Thyra::VectorBase<Scalar> > xOld,
170  Teuchos::RCP<const Thyra::VectorBase<Scalar> > xDotOld)
171  {
172  initialize(s, xOld, xDotOld);
173  }
174 
177 
179  virtual void compute(
182  Teuchos::RCP<Thyra::VectorBase<Scalar> > xDotDot = Teuchos::null)
183  {
184  xDotDot = Teuchos::null;
185  // Calculate the Trapezoidal method x dot vector
186  Thyra::V_StVpStV(xDot.ptr(), s_, *x, -s_, *xOld_);
187  Thyra::V_VpStV(xDot.ptr(), *xDot, Scalar(-1.0), *xDotOld_);
188  }
189 
190  virtual void initialize(
191  Scalar s, Teuchos::RCP<const Thyra::VectorBase<Scalar> > xOld,
192  Teuchos::RCP<const Thyra::VectorBase<Scalar> > xDotOld)
193  {
194  s_ = s;
195  xOld_ = xOld;
196  xDotOld_ = xDotOld;
197  }
198 
199  private:
200  Scalar s_; // = 1.0/(dt/2)
203 };
204 
206 // ------------------------------------------------------------------------
207 template <class Scalar>
209  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
211 
212 } // namespace Tempus
213 
214 #endif // Tempus_StepperTrapezoidal_decl_hpp
virtual Teuchos::RCP< Tempus::StepperState< Scalar > > getDefaultStepperState()
Get a default (initial) StepperState.
Trapezoidal method time stepper.
StepperTrapezoidalTimeDerivative(Scalar s, Teuchos::RCP< const Thyra::VectorBase< Scalar > > xOld, Teuchos::RCP< const Thyra::VectorBase< Scalar > > xDotOld)
Constructor.
virtual void initialize(Scalar s, Teuchos::RCP< const Thyra::VectorBase< Scalar > > xOld, Teuchos::RCP< const Thyra::VectorBase< Scalar > > xDotOld)
Teuchos::RCP< const Thyra::VectorBase< Scalar > > xDotOld_
Teuchos::RCP< StepperTrapezoidalAppAction< Scalar > > stepperTrapAppAction_
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.
Thyra Base interface for implicit time steppers.
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.
void setUseFSALTrueOnly(bool a)
Teuchos::RCP< const Thyra::VectorBase< Scalar > > xOld_
Application Action for StepperTrapezoidal.
virtual void setAppAction(Teuchos::RCP< StepperTrapezoidalAppAction< Scalar > > appAction)
Time-derivative interface for Trapezoidal method.
virtual Scalar getAlpha(const Scalar dt) const
Return alpha = d(xDot)/dx.
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
virtual Scalar getBeta(const Scalar) const
Return beta = d(x)/dx.
Stepper integrates first-order ODEs.
virtual bool isValidSetup(Teuchos::FancyOStream &out) const
This interface defines the time derivative connection between an implicit Stepper and WrapperModelEva...
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 Teuchos::RCP< StepperTrapezoidalAppAction< Scalar > > getAppAction() const