Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Tempus::StepperBDF2< Scalar > Class Template Reference

BDF2 (Backward-Difference-Formula-2) time stepper. More...

#include <Tempus_StepperBDF2_decl.hpp>

Inheritance diagram for Tempus::StepperBDF2< Scalar >:
Tempus::StepperImplicit< Scalar > Tempus::Stepper< Scalar >

Public Member Functions

 StepperBDF2 ()
 Default constructor. More...
 
 StepperBDF2 (const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, const Teuchos::RCP< StepperObserver< Scalar > > &obs, const Teuchos::RCP< Thyra::NonlinearSolverBase< Scalar > > &solver, const Teuchos::RCP< Stepper< Scalar > > &startUpStepper, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool zeroInitialGuess)
 Constructor. More...
 
virtual Scalar getAlpha (const Scalar dt) const
 Return alpha = d(xDot)/dx. More...
 
virtual Scalar getAlpha (const Scalar dt, const Scalar dtOld) const
 
virtual Scalar getBeta (const Scalar) const
 Return beta = d(x)/dx. More...
 
virtual void computeStartUp (const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory)
 Compute the first time step given the supplied startup stepper. More...
 
virtual bool getICConsistencyCheckDefault () const
 
Teuchos::RCP< const
Teuchos::ParameterList > 
getValidParameters () const
 
virtual bool isValidSetup (Teuchos::FancyOStream &out) const
 
Basic stepper methods
virtual void setModel (const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel)
 
virtual void setObserver (Teuchos::RCP< StepperObserver< Scalar > > obs=Teuchos::null)
 Set Observer. More...
 
virtual Teuchos::RCP
< StepperObserver< Scalar > > 
getObserver () const
 Get Observer. More...
 
void setStartUpStepper (std::string startupStepperType)
 Set the stepper to use in first step. More...
 
void setStartUpStepper (Teuchos::RCP< Stepper< Scalar > > startupStepper)
 Set the start up stepper. More...
 
virtual void initialize ()
 Initialize during construction and after changing input parameters. More...
 
virtual void setInitialConditions (const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory)
 Set the initial conditions and make them consistent. More...
 
virtual void takeStep (const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory)
 Take the specified timestep, dt, and return true if successful. More...
 
virtual Teuchos::RCP
< Tempus::StepperState< Scalar > > 
getDefaultStepperState ()
 Get a default (initial) StepperState. More...
 
virtual Scalar getOrder () const
 
virtual Scalar getOrderMin () const
 
virtual Scalar getOrderMax () const
 
virtual bool isExplicit () const
 
virtual bool isImplicit () const
 
virtual bool isExplicitImplicit () const
 
virtual bool isOneStepMethod () const
 
virtual bool isMultiStepMethod () const
 
virtual OrderODE getOrderODE () const
 
Overridden from Teuchos::Describable
virtual void describe (Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
 
- Public Member Functions inherited from Tempus::StepperImplicit< Scalar >
virtual Teuchos::RCP< const
Thyra::ModelEvaluator< Scalar > > 
getModel ()
 
virtual Teuchos::RCP< const
WrapperModelEvaluator< Scalar > > 
getWrapperModel ()
 
virtual void setDefaultSolver ()
 
virtual void setSolver (Teuchos::RCP< Thyra::NonlinearSolverBase< Scalar > > solver)
 Set solver. More...
 
virtual Teuchos::RCP
< Thyra::NonlinearSolverBase
< Scalar > > 
getSolver () const
 Get solver. More...
 
const Thyra::SolveStatus< Scalar > solveImplicitODE (const Teuchos::RCP< Thyra::VectorBase< Scalar > > &x)
 Solve problem using x in-place. (Needs to be deprecated!) More...
 
const Thyra::SolveStatus< Scalar > solveImplicitODE (const Teuchos::RCP< Thyra::VectorBase< Scalar > > &x, const Teuchos::RCP< Thyra::VectorBase< Scalar > > &xDot, const Scalar time, const Teuchos::RCP< ImplicitODEParameters< Scalar > > &p)
 Solve implicit ODE, f(x, xDot, t, p) = 0. More...
 
void evaluateImplicitODE (Teuchos::RCP< Thyra::VectorBase< Scalar > > &f, const Teuchos::RCP< Thyra::VectorBase< Scalar > > &x, const Teuchos::RCP< Thyra::VectorBase< Scalar > > &xDot, const Scalar time, const Teuchos::RCP< ImplicitODEParameters< Scalar > > &p)
 Evaluate implicit ODE residual, f(x, xDot, t, p). More...
 
virtual void setInitialGuess (Teuchos::RCP< const Thyra::VectorBase< Scalar > > initialGuess)
 Pass initial guess to Newton solver (only relevant for implicit solvers) More...
 
virtual void setZeroInitialGuess (bool zIG)
 Set parameter so that the initial guess is set to zero (=True) or use last timestep (=False). More...
 
virtual bool getZeroInitialGuess () const
 
virtual Scalar getInitTimeStep (const Teuchos::RCP< SolutionHistory< Scalar > > &) const
 
- Public Member Functions inherited from Tempus::Stepper< Scalar >
virtual void setNonConstModel (const Teuchos::RCP< Thyra::ModelEvaluator< Scalar > > &)
 
virtual bool isInitialized ()
 True if stepper's member data is initialized. More...
 
virtual void checkInitialized ()
 Check initialization, and error out on failure. More...
 
void setStepperType (std::string s)
 
std::string getStepperType () const
 
void setUseFSAL (bool a)
 
bool getUseFSAL () const
 
virtual bool getUseFSALDefault () const
 
void setICConsistency (std::string s)
 
std::string getICConsistency () const
 
virtual std::string getICConsistencyDefault () const
 
void setICConsistencyCheck (bool c)
 
bool getICConsistencyCheck () const
 
virtual Teuchos::RCP
< Thyra::VectorBase< Scalar > > 
getStepperX (Teuchos::RCP< SolutionState< Scalar > > state)
 Get x from SolutionState or Stepper storage. More...
 
virtual Teuchos::RCP
< Thyra::VectorBase< Scalar > > 
getStepperXDot (Teuchos::RCP< SolutionState< Scalar > > state)
 Get xDot from SolutionState or Stepper storage. More...
 
virtual Teuchos::RCP
< Thyra::VectorBase< Scalar > > 
getStepperXDotDot (Teuchos::RCP< SolutionState< Scalar > > state)
 Get xDotDot from SolutionState or Stepper storage. More...
 
virtual std::string description () const
 
virtual void createSubSteppers (std::vector< Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > >)
 

Private Attributes

Teuchos::RCP< Stepper< Scalar > > startUpStepper_
 
Teuchos::RCP
< StepperObserverComposite
< Scalar > > 
stepperObserver_
 
Teuchos::RCP
< StepperBDF2Observer< Scalar > > 
stepperBDF2Observer_
 
Scalar order_ = Scalar(2.0)
 

Additional Inherited Members

- Protected Member Functions inherited from Tempus::Stepper< Scalar >
virtual void setStepperX (Teuchos::RCP< Thyra::VectorBase< Scalar > > x)
 Set x for Stepper storage. More...
 
virtual void setStepperXDot (Teuchos::RCP< Thyra::VectorBase< Scalar > > xDot)
 Set xDot for Stepper storage. More...
 
virtual void setStepperXDotDot (Teuchos::RCP< Thyra::VectorBase< Scalar > > xDotDot)
 Set x for Stepper storage. More...
 
- Protected Attributes inherited from Tempus::StepperImplicit< Scalar >
Teuchos::RCP
< WrapperModelEvaluator
< Scalar > > 
wrapperModel_
 
Teuchos::RCP
< Thyra::NonlinearSolverBase
< Scalar > > 
solver_
 
Teuchos::RCP< const
Thyra::VectorBase< Scalar > > 
initialGuess_
 
bool zeroInitialGuess_
 
Teuchos::RCP< StepperObserver
< Scalar > > 
stepperObserver_
 
- Protected Attributes inherited from Tempus::Stepper< Scalar >
bool isInitialized_ = false
 True if stepper's member data is initialized. More...
 

Detailed Description

template<class Scalar>
class Tempus::StepperBDF2< Scalar >

BDF2 (Backward-Difference-Formula-2) time stepper.

For the implicit ODE system, $\mathcal{F}(\dot{x},x,t) = 0$, the solution, $\dot{x}$ and $x$, is determined using a solver (e.g., a non-linear solver, like NOX). This stepper allows for a variable time-step, $\Delta t$. It is a 2-step method.

Algorithm

  • For $n=0$, set the initial condition, $x_0$.
  • For $n=1$, use a one-step startup stepper, e.g., Backward Euler or RK4. The default startup stepper is 'IRK 1 Stage Theta Method' which second order.
  • For $n>1$, solve for $x_n$ via $ f\left(x_n, \dot{x}_n, t_n\right) = 0$ where $ \dot{x}_{n} = \frac{2\tau_n + \tau_{n-1}}{\tau_n + \tau_{n-1}} \left[ \frac{x_n-x_{n-1}}{\tau_n}\right] - \frac{\tau_n}{\tau_n + \tau_{n-1}} \left[ \frac{x_{n-1}-x_{n-2}}{\tau_{n-1}}\right], $ and $\Delta t_n = \tau_n = t_n - t_{n-1}$.
  • $\dot{x}_n \leftarrow \dot{x}_{n} = \frac{2\tau_n + \tau_{n-1}}{\tau_n + \tau_{n-1}} \left[ \frac{x_n-x_{n-1}}{\tau_n}\right] - \frac{\tau_n}{\tau_n + \tau_{n-1}} \left[ \frac{x_{n-1}-x_{n-2}}{\tau_{n-1}}\right], $

The First-Step-As-Last (FSAL) principle is not needed BDF2. The default is to set useFSAL=false, however useFSAL=true will also work but have no affect (i.e., no-op).

Iteration Matrix, $W$. Recalling that the definition of the iteration matrix, $W$, is

\[ W = \alpha \frac{\partial \mathcal{F}_n}{\partial \dot{x}_n} + \beta \frac{\partial \mathcal{F}_n}{\partial x_n}, \]

where $ \alpha \equiv \frac{\partial \dot{x}_n(x_n) }{\partial x_n}, $ and $ \beta \equiv \frac{\partial x_n}{\partial x_n} = 1$, and the time derivative for BDF2 is

\[ \dot{x}_n(x_n) = \frac{2\tau_n + \tau_{n-1}}{\tau_n + \tau_{n-1}} \left[ \frac{x_n-x_{n-1}}{\tau_n}\right] - \frac{\tau_n}{\tau_n + \tau_{n-1}} \left[ \frac{x_{n-1}-x_{n-2}}{\tau_{n-1}}\right], \]

where $\Delta t_n = \tau_n = t_n - t_{n-1}$, we can determine that $ \alpha = \frac{2\tau_n + \tau_{n-1}}{(\tau_n + \tau_{n-1})\tau_n}$ and $ \beta = 1 $, and therefore write

\[ W = \frac{2\tau_n + \tau_{n-1}}{(\tau_n + \tau_{n-1})\tau_n} \frac{\partial \mathcal{F}_n}{\partial \dot{x}_n} + \frac{\partial \mathcal{F}_n}{\partial x_n}. \]

Definition at line 76 of file Tempus_StepperBDF2_decl.hpp.

Constructor & Destructor Documentation

template<class Scalar >
Tempus::StepperBDF2< Scalar >::StepperBDF2 ( )

Default constructor.

Definition at line 26 of file Tempus_StepperBDF2_impl.hpp.

template<class Scalar >
Tempus::StepperBDF2< Scalar >::StepperBDF2 ( const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &  appModel,
const Teuchos::RCP< StepperObserver< Scalar > > &  obs,
const Teuchos::RCP< Thyra::NonlinearSolverBase< Scalar > > &  solver,
const Teuchos::RCP< Stepper< Scalar > > &  startUpStepper,
bool  useFSAL,
std::string  ICConsistency,
bool  ICConsistencyCheck,
bool  zeroInitialGuess 
)

Constructor.

Constructs a fully initialized stepper.

Definition at line 41 of file Tempus_StepperBDF2_impl.hpp.

Member Function Documentation

template<class Scalar >
void Tempus::StepperBDF2< Scalar >::computeStartUp ( const Teuchos::RCP< SolutionHistory< Scalar > > &  solutionHistory)
virtual

Compute the first time step given the supplied startup stepper.

Definition at line 248 of file Tempus_StepperBDF2_impl.hpp.

template<class Scalar >
void Tempus::StepperBDF2< Scalar >::describe ( Teuchos::FancyOStream &  out,
const Teuchos::EVerbosityLevel  verbLevel 
) const
virtual

Reimplemented from Tempus::StepperImplicit< Scalar >.

Definition at line 280 of file Tempus_StepperBDF2_impl.hpp.

template<class Scalar >
virtual Scalar Tempus::StepperBDF2< Scalar >::getAlpha ( const Scalar  dt) const
inlinevirtual

Return alpha = d(xDot)/dx.

Implements Tempus::StepperImplicit< Scalar >.

Definition at line 144 of file Tempus_StepperBDF2_decl.hpp.

template<class Scalar >
virtual Scalar Tempus::StepperBDF2< Scalar >::getAlpha ( const Scalar  dt,
const Scalar  dtOld 
) const
inlinevirtual

Definition at line 145 of file Tempus_StepperBDF2_decl.hpp.

template<class Scalar >
virtual Scalar Tempus::StepperBDF2< Scalar >::getBeta ( const Scalar  ) const
inlinevirtual

Return beta = d(x)/dx.

Implements Tempus::StepperImplicit< Scalar >.

Definition at line 148 of file Tempus_StepperBDF2_decl.hpp.

template<class Scalar >
Teuchos::RCP< Tempus::StepperState< Scalar > > Tempus::StepperBDF2< Scalar >::getDefaultStepperState ( )
virtual

Get a default (initial) StepperState.

Provide a StepperState to the SolutionState. This Stepper does not have any special state data, so just provide the base class StepperState with the Stepper description. This can be checked to ensure that the input StepperState can be used by this Stepper.

Implements Tempus::Stepper< Scalar >.

Definition at line 271 of file Tempus_StepperBDF2_impl.hpp.

template<class Scalar >
virtual bool Tempus::StepperBDF2< Scalar >::getICConsistencyCheckDefault ( ) const
inlinevirtual

Reimplemented from Tempus::Stepper< Scalar >.

Definition at line 154 of file Tempus_StepperBDF2_decl.hpp.

template<class Scalar >
virtual Teuchos::RCP<StepperObserver<Scalar> > Tempus::StepperBDF2< Scalar >::getObserver ( ) const
inlinevirtual

Get Observer.

Reimplemented from Tempus::Stepper< Scalar >.

Definition at line 109 of file Tempus_StepperBDF2_decl.hpp.

template<class Scalar >
virtual Scalar Tempus::StepperBDF2< Scalar >::getOrder ( ) const
inlinevirtual

Implements Tempus::Stepper< Scalar >.

Definition at line 129 of file Tempus_StepperBDF2_decl.hpp.

template<class Scalar >
virtual Scalar Tempus::StepperBDF2< Scalar >::getOrderMax ( ) const
inlinevirtual

Implements Tempus::Stepper< Scalar >.

Definition at line 131 of file Tempus_StepperBDF2_decl.hpp.

template<class Scalar >
virtual Scalar Tempus::StepperBDF2< Scalar >::getOrderMin ( ) const
inlinevirtual

Implements Tempus::Stepper< Scalar >.

Definition at line 130 of file Tempus_StepperBDF2_decl.hpp.

template<class Scalar >
virtual OrderODE Tempus::StepperBDF2< Scalar >::getOrderODE ( ) const
inlinevirtual

Implements Tempus::Stepper< Scalar >.

Definition at line 140 of file Tempus_StepperBDF2_decl.hpp.

template<class Scalar >
Teuchos::RCP< const Teuchos::ParameterList > Tempus::StepperBDF2< Scalar >::getValidParameters ( ) const
virtual

Implements Tempus::Stepper< Scalar >.

Definition at line 328 of file Tempus_StepperBDF2_impl.hpp.

template<class Scalar >
void Tempus::StepperBDF2< Scalar >::initialize ( )
virtual

Initialize during construction and after changing input parameters.

Reimplemented from Tempus::Stepper< Scalar >.

Definition at line 148 of file Tempus_StepperBDF2_impl.hpp.

template<class Scalar >
virtual bool Tempus::StepperBDF2< Scalar >::isExplicit ( ) const
inlinevirtual

Implements Tempus::Stepper< Scalar >.

Definition at line 133 of file Tempus_StepperBDF2_decl.hpp.

template<class Scalar >
virtual bool Tempus::StepperBDF2< Scalar >::isExplicitImplicit ( ) const
inlinevirtual

Implements Tempus::Stepper< Scalar >.

Definition at line 135 of file Tempus_StepperBDF2_decl.hpp.

template<class Scalar >
virtual bool Tempus::StepperBDF2< Scalar >::isImplicit ( ) const
inlinevirtual

Implements Tempus::Stepper< Scalar >.

Definition at line 134 of file Tempus_StepperBDF2_decl.hpp.

template<class Scalar >
virtual bool Tempus::StepperBDF2< Scalar >::isMultiStepMethod ( ) const
inlinevirtual

Implements Tempus::Stepper< Scalar >.

Definition at line 138 of file Tempus_StepperBDF2_decl.hpp.

template<class Scalar >
virtual bool Tempus::StepperBDF2< Scalar >::isOneStepMethod ( ) const
inlinevirtual

Implements Tempus::Stepper< Scalar >.

Definition at line 137 of file Tempus_StepperBDF2_decl.hpp.

template<class Scalar >
bool Tempus::StepperBDF2< Scalar >::isValidSetup ( Teuchos::FancyOStream &  out) const
virtual

Reimplemented from Tempus::StepperImplicit< Scalar >.

Definition at line 305 of file Tempus_StepperBDF2_impl.hpp.

template<class Scalar >
void Tempus::StepperBDF2< Scalar >::setInitialConditions ( const Teuchos::RCP< SolutionHistory< Scalar > > &  solutionHistory)
virtual

Set the initial conditions and make them consistent.

Reimplemented from Tempus::StepperImplicit< Scalar >.

Definition at line 155 of file Tempus_StepperBDF2_impl.hpp.

template<class Scalar >
void Tempus::StepperBDF2< Scalar >::setModel ( const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &  appModel)
virtual

Reimplemented from Tempus::StepperImplicit< Scalar >.

Definition at line 70 of file Tempus_StepperBDF2_impl.hpp.

template<class Scalar >
void Tempus::StepperBDF2< Scalar >::setObserver ( Teuchos::RCP< StepperObserver< Scalar > >  obs = Teuchos::null)
virtual

Set Observer.

Reimplemented from Tempus::Stepper< Scalar >.

Definition at line 125 of file Tempus_StepperBDF2_impl.hpp.

template<class Scalar >
void Tempus::StepperBDF2< Scalar >::setStartUpStepper ( std::string  startupStepperType)

Set the stepper to use in first step.

Set the startup stepper to a default stepper.

Definition at line 85 of file Tempus_StepperBDF2_impl.hpp.

template<class Scalar >
void Tempus::StepperBDF2< Scalar >::setStartUpStepper ( Teuchos::RCP< Stepper< Scalar > >  startupStepper)

Set the start up stepper.

Definition at line 103 of file Tempus_StepperBDF2_impl.hpp.

template<class Scalar >
void Tempus::StepperBDF2< Scalar >::takeStep ( const Teuchos::RCP< SolutionHistory< Scalar > > &  solutionHistory)
virtual

Take the specified timestep, dt, and return true if successful.

Implements Tempus::Stepper< Scalar >.

Definition at line 171 of file Tempus_StepperBDF2_impl.hpp.

Member Data Documentation

template<class Scalar >
Scalar Tempus::StepperBDF2< Scalar >::order_ = Scalar(2.0)
private

Definition at line 170 of file Tempus_StepperBDF2_decl.hpp.

template<class Scalar >
Teuchos::RCP<Stepper<Scalar> > Tempus::StepperBDF2< Scalar >::startUpStepper_
private

Definition at line 167 of file Tempus_StepperBDF2_decl.hpp.

template<class Scalar >
Teuchos::RCP<StepperBDF2Observer<Scalar> > Tempus::StepperBDF2< Scalar >::stepperBDF2Observer_
private

Definition at line 169 of file Tempus_StepperBDF2_decl.hpp.

template<class Scalar >
Teuchos::RCP<StepperObserverComposite<Scalar> > Tempus::StepperBDF2< Scalar >::stepperObserver_
private

Definition at line 168 of file Tempus_StepperBDF2_decl.hpp.


The documentation for this class was generated from the following files: