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: 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 #include "Teuchos_TimeMonitor.hpp"
13 
14 #include "Thyra_ModelEvaluator.hpp"
15 #include "Thyra_NonlinearSolverBase.hpp"
16 
17 #include "Tempus_config.hpp"
18 #include "Tempus_SolutionHistory.hpp"
19 
20 
21 namespace Tempus {
22 
23 enum OrderODE {
26 };
27 
56 template<class Scalar>
57 class Stepper
58  : virtual public Teuchos::Describable,
59  virtual public Teuchos::VerboseObject<Stepper<Scalar> >
60 {
61 public:
62 
64 
65  virtual void setModel(
66  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel) {}
67 
68 #ifndef TEMPUS_HIDE_DEPRECATED_CODE
69  virtual void setNonConstModel(
70  const Teuchos::RCP<Thyra::ModelEvaluator<Scalar> >& /* appModel */){}
71 
72 #endif
74  { return Teuchos::null; }
75 
77  virtual void setSolver(
79 
82  { return Teuchos::null; }
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) { stepperName_ = s;
122  isInitialized_ = false; }
123 
134  std::string getStepperName() const { return stepperName_; }
135 
136 protected:
138  void setStepperType(std::string s) { stepperType_ = s;
139  isInitialized_ = false; }
140 
141 public:
146  std::string getStepperType() const { return stepperType_; }
147 
148  virtual void setUseFSAL(bool a) { setUseFSALFalseOnly(a); }
149  void setUseFSALTrueOnly(bool a);
150  void setUseFSALFalseOnly(bool a);
151  bool getUseFSAL() const { return useFSAL_; }
152 
153  void setICConsistency(std::string s) { ICConsistency_ = s;
154  isInitialized_ = false; }
155  std::string getICConsistency() const { return ICConsistency_; }
156 
158  isInitialized_ = false; }
160 
161  virtual OrderODE getOrderODE() const = 0;
162 
165 
168 
171 
176 
178 
179  virtual std::string description() const { return stepperType_; }
181 
183 
184  virtual void describe(Teuchos::FancyOStream & out,
185  const Teuchos::EVerbosityLevel verbLevel) const;
187 
188  virtual bool isValidSetup(Teuchos::FancyOStream & out) const;
189 
192 
194 
197 
198 private:
199 
200  std::string stepperName_;
201  std::string stepperType_;
202  std::string ICConsistency_ = std::string("None");
203  bool ICConsistencyCheck_ = false;
204 
205  // RCP to SolutionState memory or Stepper temporary memory (if needed).
209 
210 protected:
211 
214  { stepperX_ = x; }
215 
218  { stepperXDot_ = xDot; }
219 
222  { stepperXDotDot_ = xDotDot; }
223 
224  bool useFSAL_ = false;
225  bool isInitialized_ = false;
226 };
227 
228 
230 
231 
236  template<class Scalar>
237  void validExplicitODE(
238  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model);
239 
241 
245  template<class Scalar>
247  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model);
248 
250  template<class Scalar>
252  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model);
253 
255  template<class Scalar>
257  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model);
258 
262 
263 
264 } // namespace Tempus
265 #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 void setNonConstModel(const Teuchos::RCP< Thyra::ModelEvaluator< Scalar > > &)
virtual Teuchos::RCP< Thyra::NonlinearSolverBase< Scalar > > getSolver() const
Get solver.
virtual Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > getModel()
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)
Validate that the model supports explicit second order ODE evaluation, f(x,xdot,t) [=xdotdot]...
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)
Validate ME supports 2nd order implicit ODE/DAE evaluation, f(xdotdot,xdot,x,t) [= 0]...
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
void setStepperType(std::string s)
Set the stepper type.
Solution state for integrators and steppers. SolutionState contains the metadata for solutions and th...
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