Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Tempus_StepperForwardEuler_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_StepperForwardEuler_decl_hpp
10 #define Tempus_StepperForwardEuler_decl_hpp
11 
12 #include "Tempus_config.hpp"
13 #include "Tempus_StepperExplicit.hpp"
14 #ifndef TEMPUS_HIDE_DEPRECATED_CODE
16 #endif
18 
19 namespace Tempus {
20 
21 /** \brief Forward Euler time stepper.
22  *
23  * For the explicit ODE system,
24  * \f[
25  * \dot{x} = \bar{f}(x,t),
26  * \f]
27  * the Forward Euler stepper can be written as
28  * \f[
29  * x_{n} = x_{n-1} + \Delta t\, \bar{f}(x_{n-1},t_{n-1})
30  * \f]
31  * Forward Euler is an explicit time stepper (i.e., no solver used).
32  * Note that the time derivative by definition is
33  * \f[
34  * \dot{x}_{n} = \bar{f}(x_{n},t_{n}),
35  * \f]
36  *
37  * <b> Algorithm </b>
38  * The single-timestep algorithm for Forward Euler is simply,
39  * - \f$\dot{x}_{n-1} \leftarrow \bar{f}(x_{n-1},t_{n-1})\f$
40  * - \f$x_{n} \leftarrow x_{n-1} + \Delta t\, \dot{x}_{n-1}\f$
41  *
42  * Note that \f$x_n\f$ and \f$\dot{x}_{n-1}\f$ are not at the same time
43  * level at the end of the time step (i.e., they are not sync'ed).
44  *
45  * To have them at the same time level, we can use the First-Step-As-Last
46  * (FSAL) principle where the function evaulation from the last time step
47  * can be used as the first function evalulation of the current step.
48  * For the Forward Euler, the FSAL algorithm is
49  * - \f$x_{n} \leftarrow x_{n-1} + \Delta t\, \dot{x}_{n-1}\f$
50  * - \f$\dot{x}_n \leftarrow \bar{f}(x_{n},t_{n})\f$
51  *
52  * The default for Forward Euler is to use FSAL (useFSAL=true).
53  */
54 template<class Scalar>
55 class StepperForwardEuler : virtual public Tempus::StepperExplicit<Scalar>
56 {
57 public:
58 
59  /** \brief Default constructor.
60  *
61  * - Requires subsequent setModel() and initialize() calls before calling
62  * takeStep().
63  */
65 
66 #ifndef TEMPUS_HIDE_DEPRECATED_CODE
67  /// Constructor
69  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
70  const Teuchos::RCP<StepperObserver<Scalar> >& obs,
71  bool useFSAL,
72  std::string ICConsistency,
73  bool ICConsistencyCheck);
74 #endif
75 
76  /// Constructor
78  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
79  bool useFSAL,
80  std::string ICConsistency,
81  bool ICConsistencyCheck,
82  const Teuchos::RCP<StepperForwardEulerAppAction<Scalar> >& stepperFEAppAction);
83 
84 #ifndef TEMPUS_HIDE_DEPRECATED_CODE
85  /// \name Basic stepper methods
86  //@{
87  virtual void setObserver(
88  Teuchos::RCP<StepperObserver<Scalar> > obs = Teuchos::null);
89 
90  virtual Teuchos::RCP<StepperObserver<Scalar> > getObserver() const
91  { return this->stepperFEObserver_; }
92 #endif
93 
94  virtual void setAppAction(
95  Teuchos::RCP<StepperForwardEulerAppAction<Scalar> > appAction);
96 
97  virtual Teuchos::RCP<StepperForwardEulerAppAction<Scalar> > getAppAction() const
98  { return stepperFEAppAction_; }
99 
100  /// Set the initial conditions, make them consistent, and set needed memory.
101  virtual void setInitialConditions (
102  const Teuchos::RCP<SolutionHistory<Scalar> >& solutionHistory);
103 
104  /// Take the specified timestep, dt, and return true if successful.
105  virtual void takeStep(
106  const Teuchos::RCP<SolutionHistory<Scalar> >& solutionHistory);
107 
108  /// Get a default (initial) StepperState
109  virtual Teuchos::RCP<Tempus::StepperState<Scalar> > getDefaultStepperState();
110  virtual Scalar getOrder() const {return 1.0;}
111  virtual Scalar getOrderMin() const {return 1.0;}
112  virtual Scalar getOrderMax() const {return 1.0;}
113 
114  virtual OrderODE getOrderODE() const {return FIRST_ORDER_ODE;}
115  //@}
116 
117  Teuchos::RCP<const Teuchos::ParameterList> getValidParameters() const;
118 
119  /// \name Overridden from Teuchos::Describable
120  //@{
121  virtual void describe(Teuchos::FancyOStream & out,
122  const Teuchos::EVerbosityLevel verbLevel) const;
123  //@}
124 
125  virtual bool isValidSetup(Teuchos::FancyOStream & out) const;
126 
127 protected:
128 
129 #ifndef TEMPUS_HIDE_DEPRECATED_CODE
130  Teuchos::RCP<StepperForwardEulerObserver<Scalar> > stepperFEObserver_;
131 #endif
132  Teuchos::RCP<StepperForwardEulerAppAction<Scalar> > stepperFEAppAction_;
133 
134 
135 };
136 
137 } // namespace Tempus
138 
139 #endif // Tempus_StepperForwardEuler_decl_hpp
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
virtual void setObserver(Teuchos::RCP< StepperObserver< Scalar > > obs=Teuchos::null)
Set Observer.
virtual void setInitialConditions(const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory)
Set the initial conditions, make them consistent, and set needed memory.
virtual Teuchos::RCP< StepperForwardEulerAppAction< Scalar > > getAppAction() const
Teuchos::RCP< StepperForwardEulerObserver< Scalar > > stepperFEObserver_
Application Action for StepperForwardEuler.
StepperObserver class for Stepper class.
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
virtual Teuchos::RCP< Tempus::StepperState< Scalar > > getDefaultStepperState()
Get a default (initial) StepperState.
virtual bool isValidSetup(Teuchos::FancyOStream &out) const
Stepper integrates first-order ODEs.
virtual void setAppAction(Teuchos::RCP< StepperForwardEulerAppAction< Scalar > > appAction)
virtual void takeStep(const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory)
Take the specified timestep, dt, and return true if successful.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Teuchos::RCP< StepperForwardEulerAppAction< Scalar > > stepperFEAppAction_
Thyra Base interface for implicit time steppers.
virtual Teuchos::RCP< StepperObserver< Scalar > > getObserver() const
Get Observer.