LifeV
BDFSecondOrderDerivative.cpp
Go to the documentation of this file.
1 #include <lifev/core/fem/BDFSecondOrderDerivative.hpp>
2 
3 namespace LifeV
4 {
5 
7  M_BDForder(0),
8  M_states(),
9  M_timeStep(0.0)
10 {}
11 
13  M_BDForder(orderBDF),
14  M_states(),
15  M_timeStep(0.0)
16 {}
17 
19 {}
20 
21 void
23 {
24  M_BDForder = order;
25 }
26 
27 void
29 {
30  M_timeStep = dt;
31 }
32 
33 void
34 BDFSecondOrderDerivative::initialize(const std::vector<vector_Type> InitialData)
35 {
36  ASSERT( M_BDForder != 0, "Order of the BDF scheme has not been set, please use BDFSecondOrderDerivative::setBDForder(const UInt order)");
37 
39 
40  for ( int i = 0; i < M_sizeStencil; ++i )
41  M_states.push_back(InitialData[i]);
42 }
43 
44 void
46 {
47  switch (M_BDForder) {
48  case 1: // size 1: we just replace the last entry by the new vector
49  M_states[M_sizeStencil-2] = M_states[M_sizeStencil-1];
50  M_states[M_sizeStencil-1] = newVector;
51  break;
52  case 2: // size 2
53  M_states[M_sizeStencil-3] = M_states[M_sizeStencil-2];
54  M_states[M_sizeStencil-2] = M_states[M_sizeStencil-1];
55  M_states[M_sizeStencil-1] = newVector;
56  break;
57  default:
58  break;
59  }
60 }
61 
62 Real
63 BDFSecondOrderDerivative::massCoefficient() // Note: there is no division by dt^2!!!!
64 {
65  switch (M_BDForder) {
66  case 1:
67  return 1.0;
68  break;
69  case 2:
70  return 2.0;
71  break;
72  default:
73  break;
74  }
76 }
77 
78 Real
79 BDFSecondOrderDerivative::coefficientFirstDerivative() // Note: there is no division by dt!!!!
80 {
81  switch (M_BDForder) {
82  case 1:
83  return 1.0;
84  break;
85  case 2:
86  return 1.5;
87  break;
88  default:
89  break;
90  }
92 }
93 
94 void
95 BDFSecondOrderDerivative::first_der_old_dts(vector_Type& vec_old_timesteps) // Note: there is no division by dt!!!!
96 {
97  ASSERT( M_timeStep != 0, "Timestep has not been set, please use BDFSecondOrderDerivative::setTimeStep(const Real dt) ");
98 
99  switch (M_BDForder) {
100  case 1:
101  vec_old_timesteps = -1.0 * M_states[M_sizeStencil-1]; // vec = -1.0 * d_n
102  break;
103  case 2:
104  vec_old_timesteps = -2.0 * M_states[M_sizeStencil-1] + 0.5 * M_states[M_sizeStencil-2]; // vec = -2.0 * d_n + 0.5 * d_{n-1}
105  break;
106  default:
107  break;
108  }
109 }
110 
111 void
112 BDFSecondOrderDerivative::second_der_old_dts(vector_Type& vec_old_timesteps) // Note: there is no division by dt^2!!!!
113 {
114  ASSERT( M_timeStep != 0, "Timestep has not been set, please use BDFSecondOrderDerivative::setTimeStep(const Real dt) ");
115 
116  switch (M_BDForder) {
117  case 1:
118  vec_old_timesteps = -2.0 * M_states[M_sizeStencil-1] + 1.0 * M_states[M_sizeStencil-2]; // vec = -2 * d_n + 1.0 * d_{n-1}
119  break;
120  case 2:
121  vec_old_timesteps = -5.0 * M_states[M_sizeStencil-1] + 4.0 * M_states[M_sizeStencil-2] - 1.0 * M_states[M_sizeStencil-3]; // vec = -5 * d_n + 4.0 * d_{n-1} - 1.0 * d_{n-2}
122  break;
123  default:
124  break;
125  }
126 }
127 
128 }
void initialize(const std::vector< vector_Type > InitialData)
#define RETURN_UNDEFINED
Definition: LifeAssert.hpp:70
void first_der_old_dts(vector_Type &vec_old_timesteps)
void updateInverseJacobian(const UInt &iQuadPt)
void second_der_old_dts(vector_Type &vec_old_timesteps)
#define ASSERT(X, A)
Definition: LifeAssert.hpp:90
void shift(const vector_Type newVector)
double Real
Generic real data.
Definition: LifeV.hpp:175
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191