LifeV
LinearElasticity.cpp
Go to the documentation of this file.
1 #include <lifev/fsi_blocks/solver/LinearElasticity.hpp>
2 
3 namespace LifeV
4 {
5 
6 LinearElasticity::LinearElasticity( const commPtr_Type& communicator ):
7  M_comm(communicator),
8  M_density(0.0),
9  M_young(0.0),
10  M_poisson(0.0),
11  M_lambda(0.0),
12  M_mu(0.0),
13  M_thinLayer(false),
14  M_thinLayerThickness(0.0),
15  M_thinLayerDensity(0.0),
16  M_thinLayerLameI(0.0),
17  M_thinLayerLameII(0.0),
18  M_interfaceFlag(0.0)
19 {}
20 
21 LinearElasticity::~LinearElasticity()
22 {}
23 
24 void
25 LinearElasticity::setCoefficients ( const Real density, const Real young, const Real poisson)
26 {
27  // Copying the parameters
28 
29  M_density = density;
30 
31  M_young = young;
32 
33  M_poisson = poisson;
34 
35  // Evaluation of the lame coefficients
36 
37  M_lambda = ( M_young * M_poisson ) / ( ( 1.0 + M_poisson ) * ( 1.0 - 2.0 * M_poisson ) );
38 
39  M_mu = M_young / ( 2.0 * ( 1.0 + M_poisson ) );
40 
41 }
42 
43 void
44 LinearElasticity::setCoefficientsThinLayer ( const Real density, const Real young, const Real poisson, const Real thickness, const UInt interface )
45 {
46  M_thinLayer = true;
47  M_thinLayerThickness = thickness;
48  M_thinLayerDensity = density;
49  M_interfaceFlag = interface;
50  M_thinLayerLameI = young / ( 2 * ( 1.0 + poisson ) );
51  M_thinLayerLameII = ( young * poisson ) / ( ( 1.0 + poisson ) * ( 1.0 - poisson ) );
52  M_mass_no_bc_thin.reset( new matrix_Type ( M_displacementFESpace->map() ) );
53  M_stiffness_no_bc_thin.reset( new matrix_Type ( M_displacementFESpace->map() ) );
54 }
55 
56 void
57 LinearElasticity::setup( const meshPtr_Type& mesh, const std::string dOrder)
58 {
59  // Create FE spaces
60 
61  M_dOrder = dOrder;
62 
63  M_displacementFESpace.reset (new FESpace<mesh_Type, map_Type> (mesh, M_dOrder, 3, M_comm) );
64 
65  M_displacementFESpace_ETA.reset( new ETFESpace_displacement ( M_displacementFESpace->mesh(), &(M_displacementFESpace->refFE()), M_comm));
66 
67  // Create matrices
68 
69  M_mass_no_bc.reset( new matrix_Type(M_displacementFESpace->map() ) );
70 
71  M_stiffness_no_bc.reset( new matrix_Type(M_displacementFESpace->map() ) );
72 
73  M_jacobian.reset( new matrix_Type(M_displacementFESpace->map() ) );
74 
75  // Initialize
76 
77  M_mass_no_bc->zero();
78 
79  M_stiffness_no_bc->zero();
80 
81  M_jacobian->zero();
82 }
83 
84 void
85 LinearElasticity::assemble_matrices ( const Real timestep, const Real coeff, bcPtr_Type & bc, bool useBDF )
86 {
87  ASSERT( M_density != 0.0, "density coefficient has not been set in LinearElasticity");
88  ASSERT( M_young != 0.0, "young coefficient has not been set in LinearElasticity");
89  ASSERT( M_poisson != 0.0, "poisson coefficient has not been set in LinearElasticity");
90 
91  using namespace ExpressionAssembly;
92 
93  // mass matrix
94  integrate ( elements (M_displacementFESpace_ETA->mesh() ),
95  M_displacementFESpace->qr(),
96  M_displacementFESpace_ETA,
97  M_displacementFESpace_ETA,
98  value(M_density) * dot ( phi_i, phi_j )
99  ) >> M_mass_no_bc;
100 
101  if ( M_thinLayer )
102  {
103  QuadratureBoundary myBDQR (buildTetraBDQR (quadRuleTria7pt) );
104  M_mass_no_bc_thin->zero();
105 
106  integrate ( boundary ( M_displacementFESpace_ETA->mesh(), M_interfaceFlag ),
107  myBDQR,
108  M_displacementFESpace_ETA,
109  M_displacementFESpace_ETA,
110  value ( M_thinLayerDensity ) * dot ( phi_i , phi_j )
111  ) >> M_mass_no_bc_thin;
112 
113  M_mass_no_bc_thin->globalAssemble();
114  *M_mass_no_bc += *M_mass_no_bc_thin;
115  }
116 
117  M_mass_no_bc->globalAssemble();
118 
119  // stiffness matrix
120  integrate ( elements (M_displacementFESpace_ETA->mesh() ),
121  M_displacementFESpace->qr(),
122  M_displacementFESpace_ETA,
123  M_displacementFESpace_ETA,
124  value( M_mu ) * dot ( grad(phi_i) , grad(phi_j) + transpose( grad(phi_j) ) ) +
125  value( M_lambda ) * div(phi_i) * div(phi_j)
126  ) >> M_stiffness_no_bc;
127 
128  if ( M_thinLayer )
129  {
130  QuadratureBoundary myBDQR (buildTetraBDQR (quadRuleTria7pt) );
131  M_stiffness_no_bc_thin->zero();
132 
133  MatrixSmall<3, 3> Eye;
134  Eye[0][0] = 1.0;
135  Eye[1][1] = 1.0;
136  Eye[2][2] = 1.0;
137 
138  using namespace ExpressionAssembly;
139 
140  integrate ( boundary ( M_displacementFESpace_ETA->mesh(), M_interfaceFlag ),
141  myBDQR,
142  M_displacementFESpace_ETA,
143  M_displacementFESpace_ETA,
144  value( M_thinLayerThickness * M_thinLayerLameII ) *
145  dot (
146  ( grad (phi_j) + (-1) * grad (phi_j) * outerProduct ( Nface, Nface ) ) +
147  transpose (grad (phi_j) + (-1) * grad (phi_j) * outerProduct ( Nface, Nface ) ),
148  ( grad (phi_i) + ( (-1) * grad (phi_i) * outerProduct ( Nface, Nface ) ) )
149  )
150  + value( M_thinLayerThickness * M_thinLayerLameI ) *
151  dot ( value ( Eye ) , ( grad (phi_j) + (-1) * grad (phi_j) * outerProduct ( Nface, Nface ) ) ) *
152  dot ( value ( Eye ) , ( grad (phi_i) + (-1) * grad (phi_i) * outerProduct ( Nface, Nface ) ) )
153  ) >> M_stiffness_no_bc_thin;
154 
155  M_stiffness_no_bc_thin->globalAssemble();
156  *M_stiffness_no_bc += *M_stiffness_no_bc_thin;
157  }
158 
159  M_stiffness_no_bc->globalAssemble();
160 
161  // jacobian matrix
162 
163  *M_jacobian += *M_mass_no_bc;
164 
165  if ( useBDF )
166  {
167  *M_jacobian *= ( 1.0/( timestep*timestep ) * coeff );
168  }
169  else
170  {
171  *M_jacobian *= ( 1.0/( timestep*timestep*coeff ) );
172  }
173 
174  *M_jacobian += *M_stiffness_no_bc;
175 
176  // Apply BC to the jacobian
177 
178  bc->bcUpdate ( *M_displacementFESpace->mesh(), M_displacementFESpace->feBd(), M_displacementFESpace->dof() );
179 
180  bcManageMatrix( *M_jacobian, *M_displacementFESpace->mesh(), M_displacementFESpace->dof(), *bc, M_displacementFESpace->feBd(), 1.0, 0.0);
181 
182  M_jacobian->globalAssemble();
183 
184  if ( M_comm->MyPID() == 0 )
185  std::cout << "\nAssembly of structure done\n\n";
186 }
187 
188 
189 }
#define ASSERT(X, A)
Definition: LifeAssert.hpp:90