LifeV
TimeAndExtrapolationHandler.cpp
Go to the documentation of this file.
1 #include <lifev/core/fem/TimeAndExtrapolationHandler.hpp>
2 
3 namespace LifeV
4 {
5 
7  M_BDForder(0),
9  M_states(),
10  M_timeStep(0.0)
11 {}
12 
13 TimeAndExtrapolationHandler::TimeAndExtrapolationHandler(const UInt orderBDF, const UInt maximumOrderExtrapolation):
14  M_BDForder(orderBDF),
15  M_maximumExtrapolationOrder(maximumOrderExtrapolation),
16  M_states(),
17  M_timeStep()
18 {}
19 
21 {}
22 
23 void
25 {
26  M_BDForder = order;
27 }
28 
29 void
31 {
33 }
34 
35 void
37 {
38  M_timeStep = dt;
39 }
40 
41 void
42 TimeAndExtrapolationHandler::initialize(const std::vector<vector_Type> InitialData)
43 {
44  ASSERT( M_BDForder != 0, "Order of the BDF scheme has not been set, please use TimeAndExtrapolationHandler::setBDForder(const UInt order)");
45 
46  ASSERT( M_maximumExtrapolationOrder != 0, "Maximum order for extrapolation has not been set, please use TimeAndExtrapolationHandler::setMaximumExtrapolationOrder(const UInt order)");
47 
49 
50  ASSERT( InitialData.size() == M_sizeStencil, "Wrong initial data dimension, it has to be of size equal max(M_BDForder, M_maximumExtrapolationOrder)");
51 
52  for ( int i = 0; i < M_sizeStencil; ++i )
53  M_states.push_back(InitialData[i]);
54 }
55 
56 void
58 {
59  switch (M_sizeStencil) {
60  case 1: // size 1: we just replace the last entry by the new vector
61  M_states[M_sizeStencil-1] = newVector;
62  break;
63  case 2: // size 2
64  M_states[M_sizeStencil-2] = M_states[M_sizeStencil-1];
65  M_states[M_sizeStencil-1] = newVector;
66  break;
67  case 3: // size 3
68  M_states[M_sizeStencil-3] = M_states[M_sizeStencil-2];
69  M_states[M_sizeStencil-2] = M_states[M_sizeStencil-1];
70  M_states[M_sizeStencil-1] = newVector;
71  break;
72  default:
73  break;
74  }
75 }
76 
77 void
79 {
80  ASSERT( order <= M_maximumExtrapolationOrder, "Order of extrapolation is higher than the maximum order previously set");
81  switch (order) {
82  case 1:
83  extrapolation = M_states[M_sizeStencil-1]; // u_star = u_n
84  break;
85  case 2:
86  extrapolation = 2*M_states[M_sizeStencil-1] - M_states[M_sizeStencil-2]; // u_star = 2*u_n - u_{n-1}
87  break;
88  case 3:
89  extrapolation = 3*M_states[M_sizeStencil-1] - 3*M_states[M_sizeStencil-2] + M_states[M_sizeStencil-3]; // u_star = 3*u_n - 3*u_{n-1} + u_{n-2}
90  break;
91  default:
92  break;
93  }
94 }
95 
96 void
98 {
99  ASSERT( M_timeStep != 0, "Timestep has not been set, please use TimeAndExtrapolationHandler::setTimeStep(const Real dt) ");
100 
101  switch (M_BDForder) {
102  case 1:
103  rhs_bdf = 1/M_timeStep*M_states[M_sizeStencil-1]; // u_rhs = 1/dt*u_n
104  break;
105  case 2:
106  rhs_bdf = 1/M_timeStep*(2*M_states[M_sizeStencil-1] - (1.0/2.0)*M_states[M_sizeStencil-2]); // u_rhs = 1/dt*(2*u_n - 0.5*u_{n-1})
107  break;
108  case 3:
109  rhs_bdf = 1/M_timeStep*(3*M_states[M_sizeStencil-1] - (3.0/2.0)*M_states[M_sizeStencil-2] + (1.0/3.0)*M_states[M_sizeStencil-3]); // u_rhs = 1/dt*(3*u_n - 3/2*u_{n-1} + 1/3*u_{n-2})
110  break;
111  default:
112  break;
113  }
114 }
115 
116 Real
118 {
119  switch (M_BDForder) {
120  case 1:
121  return 1.0;
122  break;
123  case 2:
124  return 1.5;
125  break;
126  case 3:
127  return 11.0/6.0;
128  break;
129  default:
130  break;
131  }
133 }
134 
135 }
void extrapolate(const UInt order, vector_Type &extrapolation)
void initialize(const std::vector< vector_Type > InitialData)
#define RETURN_UNDEFINED
Definition: LifeAssert.hpp:70
void shift(const vector_Type newVector)
void updateInverseJacobian(const UInt &iQuadPt)
TimeAndExtrapolationHandler(const UInt orderBDF, const UInt maximumOrderExtrapolation)
#define ASSERT(X, A)
Definition: LifeAssert.hpp:90
double Real
Generic real data.
Definition: LifeV.hpp:175
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191