Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Tempus_StepperExplicit_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_StepperExplicit_decl_hpp
10 #define Tempus_StepperExplicit_decl_hpp
11 
12 // Tempus
13 #include "Tempus_Stepper.hpp"
14 
15 
16 namespace Tempus {
17 
18 
19 /** \brief Thyra Base interface for implicit time steppers.
20  *
21  */
22 template<class Scalar>
23 class StepperExplicit : virtual public Tempus::Stepper<Scalar>
24 {
25 public:
26 
27  /// \name Basic explicit stepper methods
28  //@{
29  virtual void setModel(
30  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel);
31  virtual void setNonConstModel(
32  const Teuchos::RCP<Thyra::ModelEvaluator<Scalar> >& appModel);
33  virtual Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >
34  getModel(){return appModel_;}
35 
36  virtual Scalar getInitTimeStep(
37  const Teuchos::RCP<SolutionHistory<Scalar> >& /* solutionHistory */) const
38  {return std::numeric_limits<Scalar>::max();}
39 
40  /// Set the initial conditions, make them consistent, and set needed memory.
41  virtual void setInitialConditions (
42  const Teuchos::RCP<SolutionHistory<Scalar> >& solutionHistory);
43 
44  /// Set solver via ParameterList solver name.
45  virtual void setSolver(std::string solverName);
46  /// Set solver via solver ParameterList.
47  virtual void setSolver(
48  Teuchos::RCP<Teuchos::ParameterList> solverPL=Teuchos::null);
49  /// Set solver.
50  virtual void setSolver(
51  Teuchos::RCP<Thyra::NonlinearSolverBase<Scalar> > solver);
52  virtual Teuchos::RCP<Thyra::NonlinearSolverBase<Scalar> > getSolver() const
53  { return Teuchos::null; }
54 
55  virtual std::string getStepperType() const
56  { return stepperPL_->get<std::string>("Stepper Type"); }
57 
58  /// Pass initial guess to Newton solver (only relevant for implicit solvers)
59  // thus a no-op for explicit steppers.
60  virtual void setInitialGuess(
61  Teuchos::RCP<const Thyra::VectorBase<Scalar> > /* initial_guess */){}
62 
63  virtual bool isExplicit() const {return true;}
64  virtual bool isImplicit() const {return false;}
65  virtual bool isExplicitImplicit() const
66  {return isExplicit() and isImplicit();}
67  virtual bool isOneStepMethod() const {return true;}
68  virtual bool isMultiStepMethod() const {return !isOneStepMethod();}
69 
70  virtual bool getEmbedded() const
71  { return stepperPL_->get<bool>("Use Embedded", false); }
72 
73  virtual void setUseFSAL(bool a) {stepperPL_->set<bool>("Use FSAL", a);}
74  virtual bool getUseFSAL() const
75  {
76  bool defaultUseFSAL =
77  this->getDefaultParameters()->template get<bool>("Use FSAL");
78  return stepperPL_->get<bool>("Use FSAL", defaultUseFSAL);
79  }
80 
81  virtual void setICConsistency(std::string s)
82  {stepperPL_->set<std::string>("Initial Condition Consistency", s);}
83  virtual std::string getICConsistency() const
84  {
85  std::string defaultICConsistency = this->getDefaultParameters()->
86  template get<std::string>("Initial Condition Consistency");
87  return stepperPL_->get<std::string>("Initial Condition Consistency",
88  defaultICConsistency);
89  }
90 
91  virtual void setICConsistencyCheck(bool c)
92  {stepperPL_->set<bool>("Initial Condition Consistency Check", c);}
93  virtual bool getICConsistencyCheck() const
94  {
95  bool defaultICConsistencyCheck = this->getDefaultParameters()->
96  template get<bool>("Initial Condition Consistency Check");
97  return stepperPL_->get<bool>("Initial Condition Consistency Check",
98  defaultICConsistencyCheck);
99  }
100 
101  /// Set x for Stepper storage.
102  virtual void setStepperX(Teuchos::RCP<Thyra::VectorBase<Scalar> > x)
103  { stepperX_ = x; }
104  /// Set xDot for Stepper storage.
105  virtual void setStepperXDot(Teuchos::RCP<Thyra::VectorBase<Scalar> > xDot)
106  { stepperXDot_ = xDot; }
107  /// Set x for Stepper storage.
108  virtual void setStepperXDotDot(Teuchos::RCP<Thyra::VectorBase<Scalar> > xDotDot)
109  { stepperXDotDot_ = xDotDot; }
110 
111  /// Get x from SolutionState or Stepper storage.
112  virtual Teuchos::RCP<Thyra::VectorBase<Scalar> > getStepperX(
113  Teuchos::RCP<SolutionState<Scalar> > state);
114  /// Get xDot from SolutionState or Stepper storage.
115  virtual Teuchos::RCP<Thyra::VectorBase<Scalar> > getStepperXDot(
116  Teuchos::RCP<SolutionState<Scalar> > state);
117  /// Get xDotDot from SolutionState or Stepper storage.
118  virtual Teuchos::RCP<Thyra::VectorBase<Scalar> > getStepperXDotDot(
119  Teuchos::RCP<SolutionState<Scalar> > state);
120 
121  /// Evaluate xDot = f(x,t).
122  virtual void evaluateExplicitODE(
123  Teuchos::RCP< Thyra::VectorBase<Scalar> > xDot,
124  Teuchos::RCP<const Thyra::VectorBase<Scalar> > x,
125  const Scalar time);
126 
127  /// Evaluate xDotDot = f(x, xDot, t).
128  virtual void evaluateExplicitODE(
129  Teuchos::RCP< Thyra::VectorBase<Scalar> > xDotDot,
130  Teuchos::RCP<const Thyra::VectorBase<Scalar> > x,
131  Teuchos::RCP<const Thyra::VectorBase<Scalar> > xDot,
132  const Scalar time);
133  //@}
134 
135 
136 protected:
137 
138  Teuchos::RCP<Teuchos::ParameterList> stepperPL_;
139 
140  /// Explicit ODE ModelEvaluator
141  Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> > appModel_;
142 
143  Thyra::ModelEvaluatorBase::InArgs<Scalar> inArgs_;
144  Thyra::ModelEvaluatorBase::OutArgs<Scalar> outArgs_;
145 
146  Teuchos::RCP<StepperObserver<Scalar> > stepperObserver_;
147 
148  // RCP to state or temporary storage if needed.
149  Teuchos::RCP<Thyra::VectorBase<Scalar> > stepperX_;
150  Teuchos::RCP<Thyra::VectorBase<Scalar> > stepperXDot_;
151  Teuchos::RCP<Thyra::VectorBase<Scalar> > stepperXDotDot_;
152 };
153 
154 } // namespace Tempus
155 #endif // Tempus_StepperExplicit_decl_hpp
Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > appModel_
Explicit ODE ModelEvaluator.
virtual void setStepperX(Teuchos::RCP< Thyra::VectorBase< Scalar > > x)
Set x for Stepper storage.
virtual Teuchos::RCP< Thyra::VectorBase< Scalar > > getStepperXDot(Teuchos::RCP< SolutionState< Scalar > > state)
Get xDot from SolutionState or Stepper storage.
virtual std::string getStepperType() const
Teuchos::RCP< Thyra::VectorBase< Scalar > > stepperXDot_
virtual std::string getICConsistency() const
virtual void setStepperXDot(Teuchos::RCP< Thyra::VectorBase< Scalar > > xDot)
Set xDot for Stepper storage.
Thyra::ModelEvaluatorBase::OutArgs< Scalar > outArgs_
Thyra Base interface for time steppers.
virtual void setICConsistency(std::string s)
virtual Teuchos::RCP< Thyra::VectorBase< Scalar > > getStepperXDotDot(Teuchos::RCP< SolutionState< Scalar > > state)
Get xDotDot from SolutionState or Stepper storage.
Teuchos::RCP< Teuchos::ParameterList > stepperPL_
virtual Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > getModel()
Teuchos::RCP< Thyra::VectorBase< Scalar > > stepperXDotDot_
virtual Scalar getInitTimeStep(const Teuchos::RCP< SolutionHistory< Scalar > > &) const
virtual void setInitialConditions(const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory)
Set the initial conditions, make them consistent, and set needed memory.
Teuchos::RCP< StepperObserver< Scalar > > stepperObserver_
Teuchos::RCP< SolutionHistory< Scalar > > solutionHistory(Teuchos::RCP< Teuchos::ParameterList > pList=Teuchos::null)
Nonmember constructor.
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
virtual void setModel(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel)
virtual Teuchos::RCP< Thyra::VectorBase< Scalar > > getStepperX(Teuchos::RCP< SolutionState< Scalar > > state)
Get x from SolutionState or Stepper storage.
virtual Teuchos::RCP< Thyra::NonlinearSolverBase< Scalar > > getSolver() const
Get solver.
virtual void setInitialGuess(Teuchos::RCP< const Thyra::VectorBase< Scalar > >)
Pass initial guess to Newton solver (only relevant for implicit solvers)
virtual void setSolver(std::string solverName)
Set solver via ParameterList solver name.
virtual void setNonConstModel(const Teuchos::RCP< Thyra::ModelEvaluator< Scalar > > &appModel)
virtual bool isExplicitImplicit() const
virtual bool getICConsistencyCheck() const
virtual Teuchos::RCP< Teuchos::ParameterList > getDefaultParameters() const =0
virtual bool isMultiStepMethod() const
virtual void setICConsistencyCheck(bool c)
Thyra::ModelEvaluatorBase::InArgs< Scalar > inArgs_
virtual void evaluateExplicitODE(Teuchos::RCP< Thyra::VectorBase< Scalar > > xDot, Teuchos::RCP< const Thyra::VectorBase< Scalar > > x, const Scalar time)
Evaluate xDot = f(x,t).
Thyra Base interface for implicit time steppers.
Solution state for integrators and steppers. SolutionState contains the metadata for solutions and th...
Teuchos::RCP< Thyra::VectorBase< Scalar > > stepperX_
virtual void setStepperXDotDot(Teuchos::RCP< Thyra::VectorBase< Scalar > > xDotDot)
Set x for Stepper storage.