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"
15 
16 
17 namespace Tempus {
18 
19 /** \brief Forward Euler time stepper.
20  *
21  * For the explicit ODE system,
22  * \f[
23  * \dot{x} = \bar{f}(x,t),
24  * \f]
25  * the Forward Euler stepper can be written as
26  * \f[
27  * x_{n} = x_{n-1} + \Delta t\, \bar{f}(x_{n-1},t_{n-1})
28  * \f]
29  * Forward Euler is an explicit time stepper (i.e., no solver used).
30  * Note that the time derivative by definition is
31  * \f[
32  * \dot{x}_{n} = \bar{f}(x_{n},t_{n}),
33  * \f]
34  *
35  * <b> Algorithm </b>
36  * The single-timestep algorithm for Forward Euler is simply,
37  * - \f$\dot{x}_{n-1} \leftarrow \bar{f}(x_{n-1},t_{n-1})\f$
38  * - \f$x_{n} \leftarrow x_{n-1} + \Delta t\, \dot{x}_{n-1}\f$
39  *
40  * Note that \f$x_n\f$ and \f$\dot{x}_{n-1}\f$ are not at the same time
41  * level at the end of the time step (i.e., they are not sync'ed).
42  *
43  * To have them at the same time level, we can use the First-Step-As-Last
44  * (FSAL) principle where the function evaulation from the last time step
45  * can be used as the first function evalulation of the current step.
46  * For the Forward Euler, the FSAL algorithm is
47  * - \f$x_{n} \leftarrow x_{n-1} + \Delta t\, \dot{x}_{n-1}\f$
48  * - \f$\dot{x}_n \leftarrow \bar{f}(x_{n},t_{n})\f$
49  *
50  * The default for Forward Euler is to use FSAL (useFSAL=true).
51  */
52 template<class Scalar>
53 class StepperForwardEuler : virtual public Tempus::StepperExplicit<Scalar>
54 {
55 public:
56 
57  /** \brief Default constructor.
58  *
59  * - Constructs with a default ParameterList.
60  * - Can reset ParameterList with setParameterList().
61  * - Requires subsequent setModel() and initialize() calls before calling
62  * takeStep().
63  */
65 
66  /// Constructor
68  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
69  Teuchos::RCP<Teuchos::ParameterList> pList = Teuchos::null);
70 
71  /// \name Basic stepper methods
72  //@{
73  virtual void setObserver(
74  Teuchos::RCP<StepperObserver<Scalar> > obs = Teuchos::null);
75 
76  /// Initialize during construction and after changing input parameters.
77  virtual void initialize();
78 
79  /// Set the initial conditions, make them consistent, and set needed memory.
80  virtual void setInitialConditions (
81  const Teuchos::RCP<SolutionHistory<Scalar> >& solutionHistory);
82 
83  /// Take the specified timestep, dt, and return true if successful.
84  virtual void takeStep(
85  const Teuchos::RCP<SolutionHistory<Scalar> >& solutionHistory);
86 
87  /// Get a default (initial) StepperState
88  virtual Teuchos::RCP<Tempus::StepperState<Scalar> > getDefaultStepperState();
89  virtual Scalar getOrder() const {return 1.0;}
90  virtual Scalar getOrderMin() const {return 1.0;}
91  virtual Scalar getOrderMax() const {return 1.0;}
92 
93  virtual OrderODE getOrderODE() const {return FIRST_ORDER_ODE;}
94  //@}
95 
96  /// \name ParameterList methods
97  //@{
98  void setParameterList(const Teuchos::RCP<Teuchos::ParameterList> & pl);
99  Teuchos::RCP<Teuchos::ParameterList> getNonconstParameterList();
100  Teuchos::RCP<Teuchos::ParameterList> unsetParameterList();
101  Teuchos::RCP<const Teuchos::ParameterList> getValidParameters() const;
102  Teuchos::RCP<Teuchos::ParameterList> getDefaultParameters() const;
103  //@}
104 
105  /// \name Overridden from Teuchos::Describable
106  //@{
107  virtual std::string description() const;
108  virtual void describe(Teuchos::FancyOStream & out,
109  const Teuchos::EVerbosityLevel verbLevel) const;
110  //@}
111 
112 protected:
113 
114  Teuchos::RCP<StepperForwardEulerObserver<Scalar> > stepperFEObserver_;
115 
116 };
117 
118 } // namespace Tempus
119 
120 #endif // Tempus_StepperForwardEuler_decl_hpp
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > &pl)
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 void initialize()
Initialize during construction and after changing input parameters.
Teuchos::RCP< Teuchos::ParameterList > unsetParameterList()
Teuchos::RCP< Teuchos::ParameterList > getNonconstParameterList()
Teuchos::RCP< Teuchos::ParameterList > getDefaultParameters() const
Teuchos::RCP< StepperForwardEulerObserver< Scalar > > stepperFEObserver_
StepperObserver class for Stepper class.
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 Teuchos::RCP< Tempus::StepperState< Scalar > > getDefaultStepperState()
Get a default (initial) StepperState.
Stepper integrates first-order ODEs.
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
Thyra Base interface for implicit time steppers.