Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Tempus_Stepper_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_Stepper_decl_hpp
11 #define Tempus_Stepper_decl_hpp
12 
13 #include "Teuchos_TimeMonitor.hpp"
14 
15 #include "Thyra_ModelEvaluator.hpp"
16 #include "Thyra_NonlinearSolverBase.hpp"
17 
18 #include "Tempus_config.hpp"
19 #include "Tempus_SolutionHistory.hpp"
20 
21 namespace Tempus {
22 
23 enum OrderODE {
26 };
27 
56 template <class Scalar>
57 class Stepper : virtual public Teuchos::Describable,
58  virtual public Teuchos::VerboseObject<Stepper<Scalar> > {
59  public:
61 
62  virtual void setModel(
63  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel)
64  {
65  }
66 
68  {
69  return Teuchos::null;
70  }
71 
73  virtual void setSolver(
75  {
76  }
77 
80  {
81  return Teuchos::null;
82  }
83 
85  virtual void initialize();
86 
88  virtual bool isInitialized() { return isInitialized_; }
89 
91  virtual void checkInitialized();
92 
94  virtual void setInitialConditions(
95  const Teuchos::RCP<SolutionHistory<Scalar> >& solutionHistory) = 0;
96 
98  virtual void takeStep(
99  const Teuchos::RCP<SolutionHistory<Scalar> >& solutionHistory) = 0;
100 
103  initialGuess = Teuchos::null) = 0;
104 
107  virtual Scalar getOrder() const = 0;
108  virtual Scalar getOrderMin() const = 0;
109  virtual Scalar getOrderMax() const = 0;
110  virtual Scalar getInitTimeStep(
111  const Teuchos::RCP<SolutionHistory<Scalar> >& solutionHistory) const = 0;
112 
113  virtual bool isExplicit() const = 0;
114  virtual bool isImplicit() const = 0;
115  virtual bool isExplicitImplicit() const = 0;
116 
117  virtual bool isOneStepMethod() const = 0;
118  virtual bool isMultiStepMethod() const = 0;
119 
121  void setStepperName(std::string s)
122  {
123  stepperName_ = s;
124  isInitialized_ = false;
125  }
126 
137  std::string getStepperName() const { return stepperName_; }
138 
139  protected:
141  void setStepperType(std::string s)
142  {
143  stepperType_ = s;
144  isInitialized_ = false;
145  }
146 
147  public:
152  std::string getStepperType() const { return stepperType_; }
153 
154  virtual void setUseFSAL(bool a) { setUseFSALFalseOnly(a); }
155  void setUseFSALTrueOnly(bool a);
156  void setUseFSALFalseOnly(bool a);
157  bool getUseFSAL() const { return useFSAL_; }
158 
159  void setICConsistency(std::string s)
160  {
161  ICConsistency_ = s;
162  isInitialized_ = false;
163  }
164  std::string getICConsistency() const { return ICConsistency_; }
165 
167  {
169  isInitialized_ = false;
170  }
172 
173  virtual OrderODE getOrderODE() const = 0;
174 
177 
180 
183 
188 
190 
191  virtual std::string description() const { return stepperType_; }
193 
195 
196  virtual void describe(Teuchos::FancyOStream& out,
197  const Teuchos::EVerbosityLevel verbLevel) const;
199 
200  virtual bool isValidSetup(Teuchos::FancyOStream& out) const;
201 
204 
206 
209 
210  private:
211  std::string stepperName_;
212  std::string stepperType_;
213  std::string ICConsistency_ =
214  std::string("None");
216  false;
217 
218  // RCP to SolutionState memory or Stepper temporary memory (if needed).
222 
223  protected:
226  {
227  stepperX_ = x;
228  }
229 
232  {
233  stepperXDot_ = xDot;
234  }
235 
237  virtual void setStepperXDotDot(
239  {
240  stepperXDotDot_ = xDotDot;
241  }
242 
243  bool useFSAL_ = false;
245  false;
246 };
247 
249 
250 
255 template <class Scalar>
256 void validExplicitODE(
257  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model);
258 
261 
265 template <class Scalar>
267  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model);
268 
270 template <class Scalar>
272  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model);
273 
276 template <class Scalar>
278  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model);
279 
283 
284 } // namespace Tempus
285 #endif // Tempus_Stepper_decl_hpp
virtual bool isInitialized()
True if stepper&#39;s member data is initialized.
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 bool isValidSetup(Teuchos::FancyOStream &out) const
std::string getStepperName() const
Get the stepper name.
virtual OrderODE getOrderODE() const =0
std::string getStepperType() const
Get the stepper type. The stepper type is used as an identifier for the stepper, and can only be set ...
bool getUseFSAL() const
virtual Teuchos::RCP< Thyra::NonlinearSolverBase< Scalar > > getSolver() const
Get solver.
virtual void setSolver(Teuchos::RCP< Thyra::NonlinearSolverBase< Scalar > > solver)
Set solver.
void setStepperName(std::string s)
Set the stepper name.
bool getICConsistencyCheck() const
virtual bool isExplicit() const =0
Teuchos::RCP< Teuchos::ParameterList > defaultSolverParameters()
Returns the default solver ParameterList for implicit Steppers.
virtual void setStepperXDot(Teuchos::RCP< Thyra::VectorBase< Scalar > > xDot)
Set xDot for Stepper storage.
void validExplicitODE(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model)
Validate that the model supports explicit ODE evaluation, f(x,t) [=xdot].
virtual void initialize()
Initialize after construction and changing input parameters.
bool isInitialized_
True if stepper&#39;s member data is initialized.
Teuchos::RCP< Teuchos::ParameterList > getValidParametersBasic() const
Add basic parameters to Steppers ParameterList.
virtual bool isOneStepMethod() const =0
std::string stepperName_
Name used for output and ParameterLists.
virtual void setModel(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel)
virtual Scalar getOrderMin() const =0
std::string getICConsistency() const
virtual bool isMultiStepMethod() const =0
void setUseFSALFalseOnly(bool a)
Stepper integrates second-order ODEs.
virtual void checkInitialized()
Check initialization, and error out on failure.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Teuchos::RCP< Thyra::VectorBase< Scalar > > stepperXDot_
void setUseFSALTrueOnly(bool a)
bool useFSAL_
Use First-Same-As-Last (FSAL) principle.
virtual void setStepperX(Teuchos::RCP< Thyra::VectorBase< Scalar > > x)
Set x for Stepper storage.
virtual std::string description() const
virtual Scalar getInitTimeStep(const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory) const =0
virtual void setInitialGuess(Teuchos::RCP< const Thyra::VectorBase< Scalar > > initialGuess=Teuchos::null)=0
Pass initial guess to Newton solver (for implicit schemes)
void setICConsistencyCheck(bool c)
Teuchos::RCP< Thyra::VectorBase< Scalar > > stepperXDotDot_
virtual Teuchos::RCP< Thyra::VectorBase< Scalar > > getStepperX()
Get Stepper x.
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
virtual void setStepperXDotDot(Teuchos::RCP< Thyra::VectorBase< Scalar > > xDotDot)
Set x for Stepper storage.
void setStepperValues(const Teuchos::RCP< Teuchos::ParameterList > pl)
Set Stepper member data from ParameterList.
virtual Teuchos::RCP< Tempus::StepperState< Scalar > > getDefaultStepperState()=0
std::string ICConsistency_
Type of consistency to apply to ICs.
Stepper integrates first-order ODEs.
void validSecondOrderExplicitODE(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model)
virtual void setInitialConditions(const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory)=0
Set initial conditions, make them consistent, and set stepper memory.
void validSecondOrderODE_DAE(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model)
bool ICConsistencyCheck_
Check if the initial condition is consistent.
virtual Teuchos::RCP< Thyra::VectorBase< Scalar > > getStepperXDotDot()
Get Stepper xDotDot.
Teuchos::RCP< Thyra::VectorBase< Scalar > > stepperX_
std::string stepperType_
Name of stepper type.
virtual void setUseFSAL(bool a)
void validImplicitODE_DAE(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model)
Validate ME supports implicit ODE/DAE evaluation, f(xdot,x,t) [= 0].
virtual bool isImplicit() const =0
virtual Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > getModel() const
void setStepperType(std::string s)
Set the stepper type.
Solution state for integrators and steppers.
virtual bool isExplicitImplicit() const =0
virtual Teuchos::RCP< Thyra::VectorBase< Scalar > > getStepperXDot()
Get Stepper xDot.
virtual Scalar getOrder() const =0
void setICConsistency(std::string s)
virtual Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const