5 #ifndef MANUFACTUREDSOLUTION_HPP 6 #define MANUFACTUREDSOLUTION_HPP 23 Mesh =
new mesh(comm, mesh_file, 1.0);
38 mu1 = x(0); mu2 = x(1); mu3 = x(2); mu4 = x(3); mu5 = x(4);
39 beta3 = -0.5; beta4 = x(5); beta5 = x(6);
40 mu = 2.0*mu1 + 4.0*mu2 + 2.0*
mu3;
42 ptrmbeta4 = std::pow(trm,beta4);
43 ptrmbeta5 = std::pow(trm,beta5);
45 cos_plyagl = std::cos(plyagl);
46 sin_plyagl = std::sin(plyagl);
89 Epetra_SerialDenseVector
u(3);
100 u.Scale(displacement);
107 u.Scale(displacement);
115 F.Update(-1.0,rhs_dir,1.0);
133 Epetra_SerialDenseVector
get_neumannBc(Epetra_SerialDenseMatrix & matrix_X, Epetra_SerialDenseMatrix & xg,
unsigned int & gp){
134 Epetra_SerialDenseVector h(3), normal(3);
142 normal(0) = dxi_matrix_x(1,0)*dxi_matrix_x(2,1) - dxi_matrix_x(2,0)*dxi_matrix_x(1,1);
143 normal(1) = dxi_matrix_x(2,0)*dxi_matrix_x(0,1) - dxi_matrix_x(0,0)*dxi_matrix_x(2,1);
144 normal(2) = dxi_matrix_x(0,0)*dxi_matrix_x(1,1) - dxi_matrix_x(1,0)*dxi_matrix_x(0,1);
148 h.Multiply(
'N',
'N',1.0,piola,normal,0.0);
152 Epetra_SerialDenseVector
get_forcing(
double & x1,
double & x2,
double & x3,
unsigned int & e_lid,
unsigned int & gp){
153 Epetra_SerialDenseVector f(3);
162 void get_constitutive_tensors(Epetra_SerialDenseMatrix & deformation_gradient, Epetra_SerialDenseVector & piola_stress, Epetra_SerialDenseMatrix & tangent_piola){
164 double det = deformation_gradient(0,0)*deformation_gradient(1,1)*deformation_gradient(2,2)-deformation_gradient(0,0)*deformation_gradient(1,2)*deformation_gradient(2,1)-deformation_gradient(0,1)*deformation_gradient(1,0)*deformation_gradient(2,2)+deformation_gradient(0,1)*deformation_gradient(1,2)*deformation_gradient(2,0)+deformation_gradient(0,2)*deformation_gradient(1,0)*deformation_gradient(2,1)-deformation_gradient(0,2)*deformation_gradient(1,1)*deformation_gradient(2,0);
166 Epetra_SerialDenseMatrix C(3,3);
167 Epetra_SerialDenseMatrix CC(3,3);
168 Epetra_SerialDenseMatrix ddJ5(6,6);
169 Epetra_SerialDenseVector LML(6);
170 Epetra_SerialDenseVector eye(6);
171 Epetra_SerialDenseVector dJ5(6);
172 Epetra_SerialDenseVector M(6);
173 Epetra_SerialDenseVector
L(6);
174 Epetra_SerialDenseVector c(6);
176 C.Multiply(
'T',
'N',1.0,deformation_gradient,deformation_gradient,0.0);
177 CC.Multiply(
'N',
'N',1.0,C,C,0.0);
179 c(0) = C(0,0); c(1) = C(1,1); c(2) = C(2,2); c(3) = C(1,2); c(4) = C(0,2); c(5) = C(0,1);
181 L(0) = (1.0/(det*det))*(C(1,1)*C(2,2)-C(1,2)*C(2,1));
182 L(1) = (1.0/(det*det))*(C(0,0)*C(2,2)-C(0,2)*C(2,0));
183 L(2) = (1.0/(det*det))*(C(0,0)*C(1,1)-C(0,1)*C(1,0));
184 L(3) = (1.0/(det*det))*(C(0,2)*C(1,0)-C(0,0)*C(1,2));
185 L(4) = (1.0/(det*det))*(C(0,1)*C(1,2)-C(0,2)*C(1,1));
186 L(5) = (1.0/(det*det))*(C(0,2)*C(2,1)-C(0,1)*C(2,2));
188 M(0) = mu4*sin_plyagl*sin_plyagl+mu5*cos_plyagl*
cos_plyagl;
189 M(1) = mu4*cos_plyagl*cos_plyagl+mu5*sin_plyagl*
sin_plyagl;
193 M(5) = (mu4-
mu5)*cos_plyagl*sin_plyagl;
195 LML(0) = M(0)*
L(0)*
L(0)+2.0*M(4)*
L(0)*
L(4)+2.0*M(5)*
L(0)*
L(5)+M(2)*
L(4)*
L(4)+2.0*M(3)*
L(4)*
L(5)+M(1)*
L(5)*
L(5);
196 LML(1) = M(1)*
L(1)*
L(1)+2.0*M(4)*
L(1)*
L(3)+2.0*M(5)*
L(1)*
L(5)+M(2)*
L(3)*
L(3)+2.0*M(4)*
L(3)*
L(5)+M(0)*
L(5)*
L(5);
197 LML(2) = M(2)*
L(2)*
L(2)+2.0*M(3)*
L(2)*
L(3)+2.0*M(4)*
L(2)*
L(4)+M(1)*
L(3)*
L(3)+2.0*M(5)*
L(3)*
L(4)+M(0)*
L(4)*
L(4);
198 LML(3) =
L(2)*(
L(1)*M(3)+
L(3)*M(2)+
L(5)*M(4))+
L(3)*(
L(1)*M(1)+
L(3)*M(3)+
L(5)*M(5))+
L(4)*(
L(5)*M(0)+
L(1)*M(5)+
L(3)*M(4));
199 LML(4) =
L(2)*(
L(0)*M(4)+
L(4)*M(2)+
L(5)*M(3))+
L(3)*(
L(0)*M(5)+
L(5)*M(1)+
L(4)*M(3))+
L(4)*(
L(0)*M(0)+
L(4)*M(4)+
L(5)*M(5));
200 LML(5) =
L(1)*(
L(0)*M(5)+
L(5)*M(1)+
L(4)*M(3))+
L(3)*(
L(0)*M(4)+
L(4)*M(2)+
L(5)*M(3))+
L(5)*(
L(0)*M(0)+
L(4)*M(4)+
L(5)*M(5));
202 eye(0) = 1.0; eye(1) = 1.0; eye(2) = 1.0; eye(3) = 0.0; eye(4) = 0.0; eye(5) = 0.0;
204 double I1 = C(0,0) + C(1,1) + C(2,2);
205 double II1 = C(0,0)*C(0,0) + C(1,1)*C(1,1) + C(2,2)*C(2,2) + 2.0*C(1,2)*C(1,2) + 2.0*C(0,2)*C(0,2) + 2.0*C(0,1)*C(0,1);
206 double I2 = (1.0/2.0)*(I1*I1-II1);
208 double I4 = C(0,0)*M(0) + C(1,1)*M(1) + C(2,2)*M(2) + 2.0*C(0,1)*M(5) + 2.0*C(0,2)*M(4) + 2.0*C(1,2)*M(3);
209 double I5 = CC(0,0)*M(0) + CC(1,1)*M(1) + CC(2,2)*M(2) + 2.0*CC(0,1)*M(5) + 2.0*CC(0,2)*M(4) + 2.0*CC(1,2)*M(3);
210 double J5 = I5 - I1*I4 + I2*
trm;
211 double pI3 = std::pow(I3,-beta3);
212 double pI4 = std::pow(I4,beta4);
213 double pJ5 = std::pow(J5,beta5);
215 for (
unsigned int i=0;
i<6; ++
i){
216 dJ5(
i) = J5*
L(
i) - I3*LML(
i);
217 piola_stress(
i) = 2.0*mu1*eye(
i) + 2.0*mu2*(I1*eye(
i)-c(
i)) + (2.0*mu3*det*det-mu)*
L(
i) + (2.0/
ptrmbeta4)*pI4*M(
i) + (2.0/
ptrmbeta5)*pJ5*dJ5(
i) - 2.0*trm*pI3*
L(
i);
220 double scalarAB = 4.0*
mu2;
226 scalarAB = 4.0*mu3*det*det;
229 scalarAB = -4.0*mu3*det*det+2.0*
mu;
249 scalarAB = 4.0*trm*beta3*pI3;
251 scalarAB = 4.0*trm*pI3;
254 ddJ5.Scale(4.0*pJ5/ptrmbeta5);
255 tangent_piola += ddJ5;
260 Epetra_SerialDenseVector
u(3);
261 double c1 = 2.0e-4;
double c2 = 1.0e-4;
double c3 = 2.0e-4;
263 u(1) = x2*x2*1.1/(25.0*25.0);
273 Epetra_SerialDenseMatrix F(3,3), C(3,3), CC(3,3), ML(3,3), LML(3,3),
L(3,3), M(3,3), eye(3,3), S(3,3), P(3,3);
274 double c1 = 2.0e-4;
double c2 = 1.0e-4;
double c3 = 2.0e-4;
279 F(0,0) = 1.0; F(0,1) = 0.0; F(0,2) = 0.0;
280 F(1,0) = 0.0; F(1,1) = 1.0+2.0*1.1*x2/(25.0*25.0); F(1,2) = 0.0;
281 F(2,0) = 0.0; F(2,1) = 0.0; F(2,2) = 1.0;
282 double det = F(0,0)*F(1,1)*F(2,2)-F(0,0)*F(1,2)*F(2,1)-F(0,1)*F(1,0)*F(2,2)+F(0,1)*F(1,2)*F(2,0)+F(0,2)*F(1,0)*F(2,1)-F(0,2)*F(1,1)*F(2,0);
284 M(0,0) = mu4*sin_plyagl*sin_plyagl+mu5*cos_plyagl*
cos_plyagl;
285 M(1,1) = mu4*cos_plyagl*cos_plyagl+mu5*sin_plyagl*
sin_plyagl;
287 M(1,2) = 0.0; M(2,1) = 0.0;
288 M(0,2) = 0.0; M(2,0) = 0.0;
289 M(0,1) = (mu4-
mu5)*cos_plyagl*sin_plyagl; M(1,0) = M(0,1);
291 C.Multiply(
'T',
'N',1.0,F,F,0.0);
292 CC.Multiply(
'N',
'N',1.0,C,C,0.0);
294 L(0,0) = (1.0/(det*det))*(C(1,1)*C(2,2)-C(1,2)*C(2,1));
295 L(1,1) = (1.0/(det*det))*(C(0,0)*C(2,2)-C(0,2)*C(2,0));
296 L(2,2) = (1.0/(det*det))*(C(0,0)*C(1,1)-C(0,1)*C(1,0));
297 L(1,2) = (1.0/(det*det))*(C(0,2)*C(1,0)-C(0,0)*C(1,2));
L(2,1) =
L(1,2);
298 L(0,2) = (1.0/(det*det))*(C(0,1)*C(1,2)-C(0,2)*C(1,1));
L(2,0) =
L(0,2);
299 L(0,1) = (1.0/(det*det))*(C(0,2)*C(2,1)-C(0,1)*C(2,2));
L(1,0) =
L(0,1);
301 ML.Multiply(
'N',
'N',1.0,M,
L,0.0);
302 LML.Multiply(
'N',
'N',1.0,
L,ML,0.0);
304 double I1 = C(0,0) + C(1,1) + C(2,2);
305 double II1 = C(0,0)*C(0,0) + C(1,1)*C(1,1) + C(2,2)*C(2,2) + 2.0*C(1,2)*C(1,2) + 2.0*C(0,2)*C(0,2) + 2.0*C(0,1)*C(0,1);
306 double I2 = (1.0/2.0)*(I1*I1-II1);
308 double I4 = C(0,0)*M(0,0) + C(1,1)*M(1,1) + C(2,2)*M(2,2) + 2.0*C(0,1)*M(0,1) + 2.0*C(0,2)*M(0,2) + 2.0*C(1,2)*M(1,2);
309 double I5 = CC(0,0)*M(0,0) + CC(1,1)*M(1,1) + CC(2,2)*M(2,2) + 2.0*CC(0,1)*M(0,1) + 2.0*CC(0,2)*M(0,2) + 2.0*CC(1,2)*M(1,2);
310 double J5 = I5 - I1*I4 + I2*
trm;
311 double pI3 = std::pow(I3,-beta3);
312 double pI4 = std::pow(I4,beta4);
313 double pJ5 = std::pow(J5,beta5);
315 eye(0,0) = 1.0; eye(0,1) = 0.0; eye(0,2) = 0.0;
316 eye(1,0) = 0.0; eye(1,1) = 1.0; eye(1,2) = 0.0;
317 eye(2,0) = 0.0; eye(2,1) = 0.0; eye(2,2) = 1.0;
319 for (
unsigned int i=0;
i<3; ++
i){
320 for (
unsigned int j=0;
j<3; ++
j){
324 P.Multiply(
'N',
'N',1.0,F,S,0.0);
329 Epetra_SerialDenseVector f(3);
357 double M11 = mu4*sin_plyagl*sin_plyagl+mu5*cos_plyagl*
cos_plyagl;
358 double M22 = mu4*cos_plyagl*cos_plyagl+mu5*sin_plyagl*
sin_plyagl;
360 double M23 = 0.0;
double M32 = 0.0;
361 double M13 = 0.0;
double M31 = 0.0;
362 double M12 = (mu4-
mu5)*cos_plyagl*sin_plyagl;
double M21 = M12;
364 double ud = 1.1/(25.0*25.0);
366 f(0) = (8*M12*M22*beta4*ud*(2*ud*x2+1)*std::pow(4*M22*ud*ud*x2*x2+4*M22*ud*x2+M11+M22+M33,beta4-1))/std::pow(M11+M22+M33,beta4) - (8*M12*beta5*ud*(2*ud*x2+1)*(M11+M33)*std::pow(M11+M22+M33 + 4*M11*ud*ud*x2*x2 + 4*M33*ud*ud*x2*x2 + 4*M11*ud*x2 + 4*M33*ud*x2,beta5-1))/std::pow(M11+M22+M33,beta5);
367 f(1) = 2*ud*(2*mu1 + 4*mu2 - (- 8*mu3*ud*ud*x2*x2 - 8*mu3*ud*x2 + 2*mu1 + 4*
mu2)/(2*ud*x2 + 1)*(2*ud*x2 + 1) + (2*M22*std::pow(4*M22*ud*ud*x2*x2 + 4*M22*ud*x2 + M11 + M22 + M33,beta4))/std::pow(M11 + M22 + M33,beta4) + (2*(M11 + M33)*std::pow(M11 + M22 + M33 + 4*M11*ud*ud*x2*x2 + 4*M33*ud*ud*x2*x2 + 4*M11*ud*x2 + 4*M33*ud*x2,beta5))/std::pow(M11 + M22 + M33,beta5) - (
sign(2*ud*x2 + 1)*(2*M11 + 2*M22 + 2*M33))/(2*ud*x2 + 1)) + (2*ud*x2 + 1)*((4*ud*(- 8*mu3*ud*ud*x2*x2 - 8*mu3*ud*x2 + 2*mu1 + 4*mu2))/std::pow(2*ud*x2 + 1,3) + (8*mu3*ud)/(2*ud*x2 + 1) + (2*ud*
sign(2*ud*x2 + 1)*(2*M11 + 2*M22 + 2*M33))/(2*ud*x2 + 1)*(2*ud*x2 + 1) + (8*M22*M22*beta4*ud*(2*ud*x2 + 1)*std::pow(4*M22*ud*ud*x2*x2 + 4*M22*ud*x2 + M11 + M22 + M33,beta4 - 1))/std::pow(M11 + M22 + M33,beta4) + (8*beta5*ud*(2*ud*x2 + 1)*(M11 + M33)*(M11 + M33)*std::pow(M11 + M22 + M33 + 4*M11*ud*ud*x2*x2 + 4*M33*ud*ud*x2*x2 + 4*M11*ud*x2 + 4*M33*ud*x2,beta5 - 1))/std::pow(M11 + M22 + M33,beta5));
374 template <
typename T>
375 int sign (
const T &val) {
return (val > 0) - (val < 0); }
378 std::cout <<
"**Err: Not using that method in this example!\n";
381 void get_stress_for_recover(Epetra_SerialDenseMatrix & deformation_gradient,
double & det, Epetra_SerialDenseMatrix & piola_stress){
382 std::cout <<
"**Err: Not using that method in this example!\n";
389 double totalError = 0.0;
398 Epetra_SerialDenseVector uExact(3), vH(3);
400 Epetra_SerialDenseMatrix u_G(3,n_gauss_points), x_G(3,n_gauss_points);
404 for (
unsigned int inode=0; inode<
Mesh->
el_type; ++inode){
415 for (
unsigned int gp=0; gp<n_gauss_points; ++gp){
418 vH(0) = uExact(0) - u_G(0,gp);
419 vH(1) = uExact(1) - u_G(1,gp);
420 vH(2) = uExact(2) - u_G(2,gp);
432 Comm->SumAll(&error,&totalError,1);
433 totalError = std::sqrt(totalError);
Epetra_SerialDenseVector get_forcing(double &x1, double &x2, double &x3, unsigned int &e_lid, unsigned int &gp)
std::vector< int > local_nodes
void tensor_product(double scalarAB, Epetra_SerialDenseVector &A, Epetra_SerialDenseVector &B, Epetra_SerialDenseMatrix &AoB, double scalarThis)
double errorL2(Epetra_Vector &uStandardMap)
std::vector< double > nodes_coord
std::vector< int > local_dof
Epetra_SerialDenseVector manufacturedForcing(double &x1, double &x2, double &x3)
Epetra_SerialDenseMatrix D2_N_faces
Epetra_SerialDenseVector N_cells
void assembleMixedDirichletNeumann_inhomogeneousForcing(Epetra_Vector &x, Epetra_FECrsMatrix &K, Epetra_FEVector &F)
Epetra_SerialDenseVector detJac_cells
std::vector< int > local_cells
clc clear all close all mesh
int n_local_nodes_without_ghosts
void apply_dirichlet_conditions(Epetra_FECrsMatrix &K, Epetra_FEVector &F, double &displacement)
std::vector< int > cells_nodes
Epetra_Import * ImportToOverlapMap
Epetra_SerialDenseMatrix D1_N_faces
Epetra_SerialDenseMatrix getManufacturedPiola(double &x1, double &x2, double &x3)
unsigned int n_gauss_cells
void get_matrix_and_rhs(Epetra_Vector &x, Epetra_FECrsMatrix &K, Epetra_FEVector &F)
void sym_tensor_product(double scalarAB, Epetra_SerialDenseVector &A, Epetra_SerialDenseVector &B, Epetra_SerialDenseMatrix &AoB, double scalarThis)
void set_parameters(Epetra_SerialDenseVector &x, double &angle)
void get_stress_for_recover(Epetra_SerialDenseMatrix &deformation_gradient, double &det, Epetra_SerialDenseMatrix &piola_stress)
std::vector< int > local_dof_without_ghosts
void get_material_parameters_for_recover(unsigned int &e_lid)
void setup_dirichlet_conditions()
void get_material_parameters(unsigned int &e_lid, unsigned int &gp)
void d_shape_functions(Epetra_SerialDenseMatrix &D, double &xi, double &eta)
void get_constitutive_tensors(Epetra_SerialDenseMatrix &deformation_gradient, Epetra_SerialDenseVector &piola_stress, Epetra_SerialDenseMatrix &tangent_piola)
Epetra_SerialDenseVector getManufacturedSolution(double &x1, double &x2, double &x3)
Epetra_SerialDenseVector get_neumannBc(Epetra_SerialDenseMatrix &matrix_X, Epetra_SerialDenseMatrix &xg, unsigned int &gp)
manufacturedSolution(Epetra_Comm &comm, Teuchos::ParameterList &Parameters, std::string &mesh_file)
Epetra_SerialDenseVector gauss_weight_cells