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  * - Requires subsequent setModel() and initialize() calls before calling
60  * takeStep().
61  */
63 
64  /// Constructor
66  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
67  const Teuchos::RCP<StepperObserver<Scalar> >& obs,
68  bool useFSAL,
69  std::string ICConsistency,
70  bool ICConsistencyCheck);
71 
72  /// \name Basic stepper methods
73  //@{
74  virtual void setObserver(
75  Teuchos::RCP<StepperObserver<Scalar> > obs = Teuchos::null);
76 
77  virtual Teuchos::RCP<StepperObserver<Scalar> > getObserver() const
78  { return this->stepperFEObserver_; }
79 
80  /// Initialize during construction and after changing input parameters.
81  virtual void initialize();
82 
83  /// Set the initial conditions, make them consistent, and set needed memory.
84  virtual void setInitialConditions (
85  const Teuchos::RCP<SolutionHistory<Scalar> >& solutionHistory);
86 
87  /// Take the specified timestep, dt, and return true if successful.
88  virtual void takeStep(
89  const Teuchos::RCP<SolutionHistory<Scalar> >& solutionHistory);
90 
91  /// Get a default (initial) StepperState
92  virtual Teuchos::RCP<Tempus::StepperState<Scalar> > getDefaultStepperState();
93  virtual Scalar getOrder() const {return 1.0;}
94  virtual Scalar getOrderMin() const {return 1.0;}
95  virtual Scalar getOrderMax() const {return 1.0;}
96 
97  virtual OrderODE getOrderODE() const {return FIRST_ORDER_ODE;}
98  //@}
99 
100  Teuchos::RCP<const Teuchos::ParameterList> getValidParameters() const;
101 
102  /// \name Overridden from Teuchos::Describable
103  //@{
104  virtual void describe(Teuchos::FancyOStream & out,
105  const Teuchos::EVerbosityLevel verbLevel) const;
106  //@}
107 
108 protected:
109 
110  Teuchos::RCP<StepperForwardEulerObserver<Scalar> > stepperFEObserver_;
111 
112 };
113 
114 } // namespace Tempus
115 
116 #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 void initialize()
Initialize during construction and after changing input parameters.
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.
virtual Teuchos::RCP< StepperObserver< Scalar > > getObserver() const
Get Observer.