LifeV
Newmark.cpp
Go to the documentation of this file.
1 #include <lifev/core/fem/Newmark.hpp>
2 
3 namespace LifeV
4 {
5 
7  M_beta(0.0),
8  M_gamma(0.0),
9  M_timeStep(0.0)
10 {}
11 
13 {}
14 
15 void
16 Newmark::initialize(const vectorPtr_Type& state, const vectorPtr_Type& first_derivative, const vectorPtr_Type& second_derivative)
17 {
18 
19  // Previous timestep - given
20  M_old_state.reset( new vector_Type ( *state, Unique ) );
21  M_old_first_derivative.reset( new vector_Type ( *first_derivative, Unique ) );
22  M_old_second_derivative.reset( new vector_Type ( *second_derivative, Unique ) );
23 
24  M_old_state->zero();
25  M_old_first_derivative->zero();
26  M_old_second_derivative->zero();
27 
28  // Current timestep - initialized to zero
29  M_current_state.reset( new vector_Type ( *state, Unique ) );
30  M_current_first_derivative.reset( new vector_Type ( *first_derivative, Unique ) );
31  M_current_second_derivative.reset( new vector_Type ( *second_derivative, Unique ) );
32 
33  M_current_state->zero();
34  M_current_first_derivative->zero();
35  M_current_second_derivative->zero();
36 
37  // Instantiate csi
38  M_csi.reset( new vector_Type ( *state, Unique ) );
39 }
40 
41 void
43 {
44  ASSERT( M_beta != 0.0, "Beta coefficient has not been set in Newmark");
45 
46  ASSERT( M_timeStep != 0.0, "Beta coefficient has not been set in Newmark");
47 
48  M_csi->zero();
49 
50  *M_csi = ( ( ( 1.0/(M_timeStep*M_timeStep*M_beta) ) * ( *M_old_state ) ) +
51  ( ( 1.0/(M_timeStep*M_beta) ) * ( *M_old_first_derivative ) ) +
52  ( ( (1.0 - 2.0 * M_beta)/(2.0 * M_beta) ) * (*M_old_second_derivative) ) );
53  }
54 
55 
56 void
57 Newmark::shift( const vectorPtr_Type& state )
58 {
59  M_current_state->zero();
60 
61  *M_current_state = *state;
62 
63  ASSERT( M_beta != 0.0, "Beta coefficient has not been set in Newmark");
64 
65  ASSERT( M_gamma != 0.0, "Gamma coefficient has not been set in Newmark");
66 
67  ASSERT( M_timeStep != 0.0, "Timestep has not been set in Newmark");
68 
69  M_current_first_derivative->zero();
70 
71  M_current_second_derivative->zero();
72 
73  *M_current_second_derivative = ( ( 1.0/(M_timeStep*M_timeStep*M_beta) * (*M_current_state) ) - *M_csi );
74 
75  *M_current_first_derivative = ( (*M_old_first_derivative) +
76  ( M_timeStep * M_gamma * (*M_current_second_derivative) ) +
77  ( M_timeStep * ( 1.0 - M_gamma ) * (*M_old_second_derivative) ) );
78 
79  // Shift
80 
81  *M_old_state = *M_current_state;
82 
83  *M_old_first_derivative = *M_current_first_derivative;
84 
85  *M_old_second_derivative = *M_current_second_derivative;
86 }
87 
88 void
89 Newmark::restart( const vectorPtr_Type& state, const vectorPtr_Type& first_derivative, const vectorPtr_Type& second_derivative )
90 {
91  // Instantiate vectors
92 
93  // Previous timestep - given
94  M_old_state.reset( new vector_Type ( *state, Unique ) );
95  M_old_first_derivative.reset( new vector_Type ( *first_derivative, Unique ) );
96  M_old_second_derivative.reset( new vector_Type ( *second_derivative, Unique ) );
97 
98  // Current timestep - initialized to zero
99  M_current_state.reset( new vector_Type ( *state, Unique ) );
100  M_current_first_derivative.reset( new vector_Type ( *first_derivative, Unique ) );
101  M_current_second_derivative.reset( new vector_Type ( *second_derivative, Unique ) );
102 
103  M_current_state->zero();
104  M_current_first_derivative->zero();
105  M_current_second_derivative->zero();
106 
107  // Instantiate csi
108  M_csi.reset( new vector_Type ( *state, Unique ) );
109  M_csi->zero();
110 }
111 
112 }
void restart(const vectorPtr_Type &state, const vectorPtr_Type &first_derivative, const vectorPtr_Type &second_derivative)
Definition: Newmark.cpp:89
void shift(const vectorPtr_Type &state)
Definition: Newmark.cpp:57
void updateInverseJacobian(const UInt &iQuadPt)
#define ASSERT(X, A)
Definition: LifeAssert.hpp:90
void compute_csi()
Definition: Newmark.cpp:42
void initialize(const vectorPtr_Type &state, const vectorPtr_Type &first_derivative, const vectorPtr_Type &second_derivative)
Definition: Newmark.cpp:16
std::shared_ptr< vector_Type > vectorPtr_Type
Definition: Newmark.hpp:22
Real M_timeStep
Definition: Newmark.hpp:62