Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Tempus_Stepper_decl.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ****************************************************************************
3 // Tempus: Copyright (2017) Sandia Corporation
4 //
5 // Distributed under BSD 3-clause license (See accompanying file Copyright.txt)
6 // ****************************************************************************
7 // @HEADER
8 
9 #ifndef Tempus_Stepper_decl_hpp
10 #define Tempus_Stepper_decl_hpp
11 
12 //Teuchos
13 #include "Teuchos_TimeMonitor.hpp"
14 //
15 // Thyra
16 #include "Thyra_ModelEvaluator.hpp"
17 #include "Thyra_NonlinearSolverBase.hpp"
18 
19 // Tempus
20 #include "Tempus_config.hpp"
21 #include "Tempus_SolutionHistory.hpp"
23 
24 
25 namespace Tempus {
26 
27 enum OrderODE {
28  FIRST_ORDER_ODE = 1, ///< Stepper integrates first-order ODEs
29  SECOND_ORDER_ODE = 2, ///< Stepper integrates second-order ODEs
30 };
31 
32 /** \brief Thyra Base interface for time steppers.
33  *
34  * <b>Design Considerations</b>
35  * - Time steppers are designed to take a single time step.
36  * - a single implicit solve for a time step
37  * - a single solve for a IMEX time step
38  * - Multiple time steps should be managed by Integrators.
39  * - Steppers can be built from other Sub-Steppers.
40  * - An operator-split Stepper is possible with interoperable Steppers.
41  * - For explicit steppers, only one ModelEvaluator and one solution
42  * vector are required.
43  * - For implicit steppers, only one ModelEvaluator, one solution
44  * vector, and one solver are required.
45  * - Steppers will PASS/FAIL the time step based on Solver, error and
46  * order requirements, and not adjust the time step size.
47  * - Steppers can provide a suggested time step size for the next time step.
48  * - For more complex steppers, multiple ModelEvaluators, solution
49  * vectors, and solvers are possible when a common single time-integration
50  * method is desired for all solutions. Examples:
51  * - Solution A with ModelEvaluator A and Solution B with ModelEvaluator B
52  * using the same solver
53  * - Solution A with ModelEvaluator A using Solver A and Solution B with
54  * ModelEvaluator B using Solver B
55  * - Solution A with ModelEvaluator A using Solver A and Solutions A and B
56  * with ModelEvaluator C using Solver B
57  * - Steppers may maintain their own time history of the solution, e.g.,
58  * BDF steppers.
59  *
60  * <b> CS Design Considerations</b>
61  * - All input parameters (i.e., ParameterList) can be set by public methods.
62  * - The Stepper ParameterList must be consistent.
63  * - The "set" methods which update parameters in the ParameterList
64  * must update the Stepper ParameterList.
65  */
66 template<class Scalar>
67 class Stepper
68  : virtual public Teuchos::Describable,
69  virtual public Teuchos::VerboseObject<Stepper<Scalar> >,
70  virtual public Teuchos::ParameterListAcceptor
71 {
72 public:
73 
74  /// \name Basic stepper methods
75  //@{
76  virtual void setModel(
77  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel) = 0;
78  virtual void setNonConstModel(
79  const Teuchos::RCP<Thyra::ModelEvaluator<Scalar> >& appModel) = 0;
80  virtual Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> > getModel() = 0;
81 
82  /// Set solver via ParameterList solver name.
83  virtual void setSolver(std::string solverName) = 0;
84  /// Set solver via solver ParameterList.
85  virtual void setSolver(
86  Teuchos::RCP<Teuchos::ParameterList> solverPL=Teuchos::null) = 0;
87  /// Set solver.
88  virtual void setSolver(
89  Teuchos::RCP<Thyra::NonlinearSolverBase<Scalar> > solver) = 0;
90  /// Get solver
91  virtual Teuchos::RCP<Thyra::NonlinearSolverBase<Scalar> >
92  getSolver() const = 0;
93 
94  /// Set Observer
95  virtual void setObserver(
96  Teuchos::RCP<StepperObserver<Scalar> > obs = Teuchos::null) = 0;
97 
98  /// Initialize during construction and after changing input parameters.
99  virtual void initialize() = 0;
100 
101  /// Set initial conditions, make them consistent, and set stepper memory.
102  virtual void setInitialConditions (
103  const Teuchos::RCP<SolutionHistory<Scalar> >& solutionHistory) = 0;
104 
105 
106  /// Take the specified timestep, dt, and return true if successful.
107  virtual void takeStep(
108  const Teuchos::RCP<SolutionHistory<Scalar> >& solutionHistory) = 0;
109 
110  /// Pass initial guess to Newton solver (for implicit schemes)
111  virtual void setInitialGuess(
112  Teuchos::RCP<const Thyra::VectorBase<Scalar> > initial_guess = Teuchos::null) = 0;
113 
114  virtual std::string getStepperType() const = 0;
115 
116  virtual Teuchos::RCP<Tempus::StepperState<Scalar> >
118  virtual Scalar getOrder() const = 0;
119  virtual Scalar getOrderMin() const = 0;
120  virtual Scalar getOrderMax() const = 0;
121  virtual Scalar getInitTimeStep(
122  const Teuchos::RCP<SolutionHistory<Scalar> >& solutionHistory) const = 0;
123  virtual Teuchos::RCP<Teuchos::ParameterList> getDefaultParameters() const=0;
124 
125  virtual bool isExplicit() const = 0;
126  virtual bool isImplicit() const = 0;
127  virtual bool isExplicitImplicit() const = 0;
128 
129  virtual bool isOneStepMethod() const = 0;
130  virtual bool isMultiStepMethod() const = 0;
131 
132  virtual OrderODE getOrderODE() const = 0;
133 
134  virtual void setUseFSAL(bool a) = 0;
135  virtual bool getUseFSAL() const = 0;
136 
137  virtual void setICConsistency(std::string s) = 0;
138  virtual std::string getICConsistency() const = 0;
139 
140  virtual void setICConsistencyCheck(bool c) = 0;
141  virtual bool getICConsistencyCheck() const = 0;
142 
143  void getValidParametersBasic(Teuchos::RCP<Teuchos::ParameterList> pl) const;
144  //@}
145 
146  virtual void modelWarning() const;
147 
148  /// \name Functions for Steppers with subSteppers (e.g., OperatorSplit)
149  //@{
150  virtual void createSubSteppers(
151  std::vector<Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> > > /* models */){}
152  //@}
153 
154  /// \name Helper functions
155  //@{
156  /// Validate that the model supports explicit ODE evaluation, f(x,t) [=xdot]
157  /** Currently the convention to evaluate f(x,t) is to set xdot=null!
158  * There is no InArgs support to test if xdot is null, so we set
159  * xdot=null and hopefully the ModelEvaluator can handle it.
160  */
161  void validExplicitODE(
162  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model) const;
163 
164  /// Validate that the model supports explicit second order ODE evaluation, f(x,xdot,t) [=xdotdot]
165  /** Currently the convention to evaluate f(x,xdot,t) is to set xdotdot=null!
166  * There is no InArgs support to test if xdotdot is null, so we set
167  * xdotdot=null and hopefully the ModelEvaluator can handle it.
168  */
170  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model) const;
171 
172  /// Validate ME supports implicit ODE/DAE evaluation, f(xdot,x,t) [= 0]
174  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model) const;
175 
176  /// Validate ME supports 2nd order implicit ODE/DAE evaluation, f(xdotdot,xdot,x,t) [= 0]
178  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model) const;
179 
180  Teuchos::RCP<Teuchos::ParameterList> defaultSolverParameters() const;
181  //@}
182 
183 };
184 } // namespace Tempus
185 #endif // Tempus_Stepper_decl_hpp
virtual void setObserver(Teuchos::RCP< StepperObserver< Scalar > > obs=Teuchos::null)=0
Set Observer.
virtual Scalar getOrderMax() const =0
virtual void takeStep(const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory)=0
Take the specified timestep, dt, and return true if successful.
virtual Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > getModel()=0
void validSecondOrderODE_DAE(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model) const
Validate ME supports 2nd order implicit ODE/DAE evaluation, f(xdotdot,xdot,x,t) [= 0]...
virtual OrderODE getOrderODE() const =0
virtual std::string getStepperType() const =0
virtual void modelWarning() const
Teuchos::RCP< Teuchos::ParameterList > defaultSolverParameters() const
virtual std::string getICConsistency() const =0
virtual bool isExplicit() const =0
void validSecondOrderExplicitODE(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model) const
Validate that the model supports explicit second order ODE evaluation, f(x,xdot,t) [=xdotdot]...
virtual void setModel(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel)=0
virtual bool isOneStepMethod() const =0
virtual void setInitialGuess(Teuchos::RCP< const Thyra::VectorBase< Scalar > > initial_guess=Teuchos::null)=0
Pass initial guess to Newton solver (for implicit schemes)
virtual void initialize()=0
Initialize during construction and after changing input parameters.
virtual void setSolver(std::string solverName)=0
Set solver via ParameterList solver name.
virtual Scalar getOrderMin() const =0
virtual bool isMultiStepMethod() const =0
Stepper integrates second-order ODEs.
void getValidParametersBasic(Teuchos::RCP< Teuchos::ParameterList > pl) const
virtual Scalar getInitTimeStep(const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory) const =0
void validImplicitODE_DAE(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model) const
Validate ME supports implicit ODE/DAE evaluation, f(xdot,x,t) [= 0].
Teuchos::RCP< SolutionHistory< Scalar > > solutionHistory(Teuchos::RCP< Teuchos::ParameterList > pList=Teuchos::null)
Nonmember constructor.
virtual Teuchos::RCP< Thyra::NonlinearSolverBase< Scalar > > getSolver() const =0
Get solver.
virtual void setUseFSAL(bool a)=0
void validExplicitODE(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model) const
Validate that the model supports explicit ODE evaluation, f(x,t) [=xdot].
virtual void setNonConstModel(const Teuchos::RCP< Thyra::ModelEvaluator< Scalar > > &appModel)=0
virtual Teuchos::RCP< Tempus::StepperState< Scalar > > getDefaultStepperState()=0
Stepper integrates first-order ODEs.
virtual void setInitialConditions(const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory)=0
Set initial conditions, make them consistent, and set stepper memory.
virtual bool getICConsistencyCheck() const =0
virtual Teuchos::RCP< Teuchos::ParameterList > getDefaultParameters() const =0
virtual bool getUseFSAL() const =0
virtual void setICConsistencyCheck(bool c)=0
virtual bool isImplicit() const =0
virtual void createSubSteppers(std::vector< Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > >)
virtual void setICConsistency(std::string s)=0
virtual bool isExplicitImplicit() const =0
virtual Scalar getOrder() const =0