LifeV
TimeAndExtrapolationHandler.hpp
Go to the documentation of this file.
1 #ifndef TIMEHANDLER_H
2 #define TIMEHANDLER_H 1
3 
4 /*
5  * author: DAVIDE FORTI, davide.forti@epfl.ch
6  * Lightweighted class to Handle the time advancing scheme (based on BDF approximation of the time derivative and for the extrapolation).
7  * It can be used for first derivatives.
8  *
9  * The formulas implemented in the methods extrapolate and rhsContribution are taken from
10  * "Algebraic fractional-step schemes with spectral methods for the incompressible Navier–Stokes equations"
11  * by Paola Gervasio, Fausto Saleri and Alessandro Veneziani. (see pag. 3 for details)
12  */
13 
14 #include <lifev/core/LifeV.hpp>
15 
16 #include <lifev/core/array/VectorEpetra.hpp>
17 
18 namespace LifeV
19 {
20 
21 class TimeAndExtrapolationHandler
22 {
23 
24  typedef VectorEpetra vector_Type;
25 
26  typedef std::shared_ptr<vector_Type> vectorPtr_Type;
27 
28 public:
29 
30  // empty constructor
31  TimeAndExtrapolationHandler();
32 
33  // constructor taking as first input the order of the Time Advancing BDF scheme, as second the maximum order of extrapolation desired (maximum 3)
34  TimeAndExtrapolationHandler(const UInt orderBDF, const UInt maximumOrderExtrapolation);
35 
36  // empty destructor
37  ~TimeAndExtrapolationHandler();
38 
39  // setup of the class taking the order of the method
40  void setBDForder(const UInt order);
41 
42  // set the maximum extrapolation order
43  void setMaximumExtrapolationOrder(const UInt order);
44 
45  // initialize the time handler class with initial data, need a vector of M_order vectorEpetra
46  void initialize(const std::vector<vector_Type> InitialData);
47 
48  // shift - to be used when a timestep is solved
49  void shift(const vector_Type newVector);
50 
51  // getter for the state
52  std::vector<vector_Type> state()
53  {
54  return M_states;
55  }
56 
57  // set the timestep
58  void setTimeStep(const Real dt);
59 
60  // extrapolation
61  void extrapolate(const UInt order, vector_Type& extrapolation);
62 
63  // get the part from the discretization of the time derivative that goes to the right hand side
64  void rhsContribution(vector_Type& rhs_bdf);
65 
66  // get the value of alpha that should go in front of the term u_(n+1) (see the paper cited at the beginning of the doc)
67  Real alpha();
68 
69 private:
70 
71  // order of the BDF scheme used
72  UInt M_BDForder;
73 
74  // maximum order used for extrapolation
75  UInt M_maximumExtrapolationOrder;
76 
77  // vector with the state variable at time n, n-1, .., n-(p-1)
78  std::vector<vector_Type> M_states;
79 
80  // variable that contains the bigger value between M_BDForder and M_maximumExtrapolationOrder
81  UInt M_sizeStencil;
82 
83  // timestep
84  Real M_timeStep;
85 
86 };
87 
88 } // end namespace LifeV
89 
90 #endif
double Real
Generic real data.
Definition: LifeV.hpp:175
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191