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 template<class Scalar>
18 {
19  public:
20  /// Constructor
22  : timeStepSize_(Scalar(0.0)), stageNumber_(0)
23  {}
24  /// Constructor
25  ExplicitODEParameters(Scalar timeStepSize, int stageNumber = 0)
26  : timeStepSize_(timeStepSize), stageNumber_(stageNumber)
27  {}
28 
29  Scalar timeStepSize_;
31 };
32 
33 
34 namespace Tempus {
35 
36 
37 /** \brief Thyra Base interface for implicit time steppers.
38  *
39  */
40 template<class Scalar>
41 class StepperExplicit : virtual public Tempus::Stepper<Scalar>
42 {
43 public:
44 
45  /// \name Basic explicit stepper methods
46  //@{
47  virtual void setModel(
48  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel);
49  virtual void setNonConstModel(
50  const Teuchos::RCP<Thyra::ModelEvaluator<Scalar> >& appModel);
51  virtual Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >
52  getModel(){return appModel_;}
53 
54  virtual Scalar getInitTimeStep(
55  const Teuchos::RCP<SolutionHistory<Scalar> >& /* solutionHistory */) const
56  {return std::numeric_limits<Scalar>::max();}
57 
58  /// Set the initial conditions, make them consistent, and set needed memory.
59  virtual void setInitialConditions (
60  const Teuchos::RCP<SolutionHistory<Scalar> >& solutionHistory);
61 
62  virtual void setSolver(
63  Teuchos::RCP<Thyra::NonlinearSolverBase<Scalar> > solver = Teuchos::null);
64 
65  virtual Teuchos::RCP<Thyra::NonlinearSolverBase<Scalar> > getSolver() const
66  { return Teuchos::null; }
67 
68  /// Pass initial guess to Newton solver (only relevant for implicit solvers)
69  // thus a no-op for explicit steppers.
70  virtual void setInitialGuess(
71  Teuchos::RCP<const Thyra::VectorBase<Scalar> > /* initial_guess */){}
72 
73  virtual bool isExplicit() const {return true;}
74  virtual bool isImplicit() const {return false;}
75  virtual bool isExplicitImplicit() const
76  {return isExplicit() and isImplicit();}
77  virtual bool isOneStepMethod() const {return true;}
78  virtual bool isMultiStepMethod() const {return !isOneStepMethod();}
79 
80  /// Set x for Stepper storage.
81  virtual void setStepperX(Teuchos::RCP<Thyra::VectorBase<Scalar> > x)
82  { stepperX_ = x; }
83  /// Set xDot for Stepper storage.
84  virtual void setStepperXDot(Teuchos::RCP<Thyra::VectorBase<Scalar> > xDot)
85  { stepperXDot_ = xDot; }
86  /// Set x for Stepper storage.
87  virtual void setStepperXDotDot(Teuchos::RCP<Thyra::VectorBase<Scalar> > xDotDot)
88  { stepperXDotDot_ = xDotDot; }
89 
90  /// Get x from SolutionState or Stepper storage.
91  virtual Teuchos::RCP<Thyra::VectorBase<Scalar> > getStepperX(
92  Teuchos::RCP<SolutionState<Scalar> > state);
93  /// Get xDot from SolutionState or Stepper storage.
94  virtual Teuchos::RCP<Thyra::VectorBase<Scalar> > getStepperXDot(
95  Teuchos::RCP<SolutionState<Scalar> > state);
96  /// Get xDotDot from SolutionState or Stepper storage.
97  virtual Teuchos::RCP<Thyra::VectorBase<Scalar> > getStepperXDotDot(
98  Teuchos::RCP<SolutionState<Scalar> > state);
99 
100  /// Evaluate xDot = f(x,t).
101  virtual void evaluateExplicitODE(
102  Teuchos::RCP< Thyra::VectorBase<Scalar> > xDot,
103  Teuchos::RCP<const Thyra::VectorBase<Scalar> > x,
104  const Scalar time,
105  const Teuchos::RCP<ExplicitODEParameters<Scalar> > & p );
106 
107  /// Evaluate xDotDot = f(x, xDot, t).
108  virtual void evaluateExplicitODE(
109  Teuchos::RCP< Thyra::VectorBase<Scalar> > xDotDot,
110  Teuchos::RCP<const Thyra::VectorBase<Scalar> > x,
111  Teuchos::RCP<const Thyra::VectorBase<Scalar> > xDot,
112  const Scalar time,
113  const Teuchos::RCP<ExplicitODEParameters<Scalar> > & p );
114  //@}
115 
116 protected:
117 
118  /// Explicit ODE ModelEvaluator
119  Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> > appModel_;
120 
121  Thyra::ModelEvaluatorBase::InArgs<Scalar> inArgs_;
122  Thyra::ModelEvaluatorBase::OutArgs<Scalar> outArgs_;
123 
124  Teuchos::RCP<StepperObserver<Scalar> > stepperObserver_;
125 
126  // RCP to state or temporary storage if needed.
127  Teuchos::RCP<Thyra::VectorBase<Scalar> > stepperX_;
128  Teuchos::RCP<Thyra::VectorBase<Scalar> > stepperXDot_;
129  Teuchos::RCP<Thyra::VectorBase<Scalar> > stepperXDotDot_;
130 };
131 
132 } // namespace Tempus
133 #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.
Teuchos::RCP< Thyra::VectorBase< Scalar > > stepperXDot_
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.
ExplicitODEParameters(Scalar timeStepSize, int stageNumber=0)
Constructor.
virtual Teuchos::RCP< Thyra::VectorBase< Scalar > > getStepperXDotDot(Teuchos::RCP< SolutionState< Scalar > > state)
Get xDotDot from SolutionState or Stepper storage.
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 setNonConstModel(const Teuchos::RCP< Thyra::ModelEvaluator< Scalar > > &appModel)
virtual void evaluateExplicitODE(Teuchos::RCP< Thyra::VectorBase< Scalar > > xDot, Teuchos::RCP< const Thyra::VectorBase< Scalar > > x, const Scalar time, const Teuchos::RCP< ExplicitODEParameters< Scalar > > &p)
Evaluate xDot = f(x,t).
virtual void setSolver(Teuchos::RCP< Thyra::NonlinearSolverBase< Scalar > > solver=Teuchos::null)
Set solver.
virtual bool isExplicitImplicit() const
virtual bool isMultiStepMethod() const
Thyra::ModelEvaluatorBase::InArgs< Scalar > inArgs_
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.