26 for (
int ddl=0; ddl<3; ++ddl){
27 index[3*inode+ddl] = 3*node+ddl;
32 FEGraph->InsertGlobalIndices(1, &index[
i], 1, &index[
j]);
44 Epetra_LinearProblem problem;
46 problem.SetOperator(&A);
49 solver.SetProblem(problem);
50 solver.SetParameters(paramList);
51 double tol = Teuchos::getParameter<double>(paramList,
"AZ_tol");
52 int maxIter = Teuchos::getParameter<int>(paramList,
"AZ_max_iter");
53 solver.Iterate(maxIter,tol);
66 error=K.GlobalAssemble();
67 error=K.FillComplete();
102 int node, e_gid, error;
111 Epetra_SerialDenseMatrix tangent_matrix(6,6);
112 Epetra_SerialDenseMatrix dx_shape_functions(
Mesh->
el_type,3);
113 Epetra_SerialDenseMatrix matrix_B(6,3*
Mesh->
el_type);
114 Epetra_SerialDenseMatrix B_times_TM(3*
Mesh->
el_type,6);
119 for (
unsigned int inode=0; inode<
Mesh->
el_type; ++inode){
121 for (
int iddl=0; iddl<3; ++iddl){
122 Indices_cells[3*inode+iddl] = 3*node+iddl;
123 for (
unsigned int jnode=0; jnode<
Mesh->
el_type; ++jnode){
124 for (
int jddl=0; jddl<3; ++jddl){
125 Ke(3*inode+iddl,3*jnode+jddl) = 0.0;
131 for (
unsigned int gp=0; gp<n_gauss_points; ++gp){
133 for (
unsigned int inode=0; inode<
Mesh->
el_type; ++inode){
134 dx_shape_functions(inode,0) =
Mesh->
DX_N_cells(gp+n_gauss_points*inode,e_lid);
135 dx_shape_functions(inode,1) =
Mesh->
DY_N_cells(gp+n_gauss_points*inode,e_lid);
136 dx_shape_functions(inode,2) =
Mesh->
DZ_N_cells(gp+n_gauss_points*inode,e_lid);
142 error = B_times_TM.Multiply(
'T',
'N',gauss_weight*
Mesh->
detJac_cells(e_lid,gp),matrix_B,tangent_matrix,0.0);
143 error = Ke.Multiply(
'N',
'N',1.0,B_times_TM,matrix_B,1.0);
148 error = K.SumIntoGlobalValues(1, &Indices_cells[
i], 1, &Indices_cells[
j], &Ke(i,j));
152 delete[] Indices_cells;
157 int node, e_gid, error;
165 Epetra_SerialDenseMatrix tangent_matrix(6,6);
166 Epetra_SerialDenseMatrix dx_shape_functions(
Mesh->
el_type,3), matrix_X(3,
Mesh->
el_type), xg(3,n_gauss_points);
167 Epetra_SerialDenseMatrix matrix_B(6,3*
Mesh->
el_type);
168 Epetra_SerialDenseMatrix B_times_TM(3*
Mesh->
el_type,6);
169 Epetra_SerialDenseVector fevol(3*
Mesh->
el_type), fvol(3);
173 for (
unsigned int inode=0; inode<
Mesh->
el_type; ++inode){
178 for (
int iddl=0; iddl<3; ++iddl){
179 Indices_cells[3*inode+iddl] = 3*node+iddl;
180 fevol(3*inode+iddl) = 0.0;
181 for (
unsigned int jnode=0; jnode<
Mesh->
el_type; ++jnode){
182 for (
int jddl=0; jddl<3; ++jddl){
183 Ke(3*inode+iddl,3*jnode+jddl) = 0.0;
189 xg.Multiply(
'N',
'N',1.0,matrix_X,
Mesh->
N_cells,0.0);
190 for (
unsigned int gp=0; gp<n_gauss_points; ++gp){
192 fvol =
get_forcing(xg(0,gp),xg(1,gp),xg(2,gp),e_lid,gp);
193 for (
unsigned int inode=0; inode<
Mesh->
el_type; ++inode){
194 dx_shape_functions(inode,0) =
Mesh->
DX_N_cells(gp+n_gauss_points*inode,e_lid);
195 dx_shape_functions(inode,1) =
Mesh->
DY_N_cells(gp+n_gauss_points*inode,e_lid);
196 dx_shape_functions(inode,2) =
Mesh->
DZ_N_cells(gp+n_gauss_points*inode,e_lid);
197 for (
unsigned int iddl=0; iddl<3; ++iddl){
204 error = B_times_TM.Multiply(
'T',
'N',gauss_weight*
Mesh->
detJac_cells(e_lid,gp),matrix_B,tangent_matrix,0.0);
205 error = Ke.Multiply(
'N',
'N',1.0,B_times_TM,matrix_B,1.0);
209 error = F.SumIntoGlobalValues(1, &Indices_cells[
i], &fevol(i));
211 error = K.SumIntoGlobalValues(1, &Indices_cells[i], 1, &Indices_cells[
j], &Ke(i,j));
215 delete[] Indices_cells;
228 Epetra_SerialDenseMatrix xg(3,n_gauss_points), matrix_X(3,
Mesh->
face_type);
230 Epetra_SerialDenseVector dead_pressure(3);
236 Indexes[3*inode+0] = 3*node+0;
237 Indexes[3*inode+1] = 3*node+1;
238 Indexes[3*inode+2] = 3*node+2;
242 for (
unsigned int iddl=0; iddl<3; ++iddl){
243 force(3*inode+iddl) = 0.0;
246 xg.Multiply(
'N',
'T',1.0,matrix_X,
Mesh->
N_faces,0.0);
247 for (
unsigned int gp=0; gp<n_gauss_points; ++gp){
251 for (
unsigned int iddl=0; iddl<3; ++iddl){
252 force(3*inode+iddl) += gauss_weight*dead_pressure(iddl)*
Mesh->
N_faces(gp,inode);
258 for (
unsigned int iddl=0; iddl<3; ++iddl){
259 F.SumIntoGlobalValues(1, &Indexes[3*inode+iddl], &force(3*inode+iddl));
267 double factor = 1.0/std::sqrt(2.0);
268 for (
unsigned inode=0; inode<
Mesh->
el_type; ++inode){
269 B(0,3*inode) = dx_shape_functions(inode,0);
270 B(0,3*inode+1) = 0.0;
271 B(0,3*inode+2) = 0.0;
274 B(1,3*inode+1) = dx_shape_functions(inode,1);
275 B(1,3*inode+2) = 0.0;
278 B(2,3*inode+1) = 0.0;
279 B(2,3*inode+2) = dx_shape_functions(inode,2);
282 B(3,3*inode+1) = factor*dx_shape_functions(inode,2);
283 B(3,3*inode+2) = factor*dx_shape_functions(inode,1);
285 B(4,3*inode) = factor*dx_shape_functions(inode,2);
286 B(4,3*inode+1) = 0.0;
287 B(4,3*inode+2) = factor*dx_shape_functions(inode,0);
289 B(5,3*inode) = factor*dx_shape_functions(inode,1);
290 B(5,3*inode+1) = factor*dx_shape_functions(inode,0);
291 B(5,3*inode+2) = 0.0;
297 int NumTargetElements = 0;
298 if (
Comm->MyPID()==0){
301 Epetra_Map MapOnRoot(-1,NumTargetElements,0,*
Comm);
302 Epetra_Export ExportOnRoot(*
StandardMap,MapOnRoot);
303 Epetra_MultiVector lhs_root(MapOnRoot,
true);
304 lhs_root.Export(solution,ExportOnRoot,Insert);
306 int error = EpetraExt::MultiVectorToMatrixMarketFile(fileName.c_str(),lhs_root,0,0,
false);
318 Epetra_Vector epsilon11(CellsMap); epsilon11.PutScalar(0.0);
319 Epetra_Vector epsilon22(CellsMap); epsilon22.PutScalar(0.0);
320 Epetra_Vector epsilon33(CellsMap); epsilon33.PutScalar(0.0);
321 Epetra_Vector epsilon12(CellsMap); epsilon12.PutScalar(0.0);
322 Epetra_Vector epsilon13(CellsMap); epsilon13.PutScalar(0.0);
323 Epetra_Vector epsilon23(CellsMap); epsilon23.PutScalar(0.0);
324 Epetra_Vector vonmises(CellsMap); vonmises.PutScalar(0.0);
328 double det_jac_cells, gauss_weight,
theta;
330 Epetra_SerialDenseVector epsilon(6);
331 Epetra_SerialDenseVector vector_u(3*
Mesh->
el_type);
332 Epetra_SerialDenseMatrix matrix_B(6,3*
Mesh->
el_type);
333 Epetra_SerialDenseMatrix dx_shape_functions(
Mesh->
el_type,3);
335 Epetra_SerialDenseMatrix matrix_X(3,
Mesh->
el_type);
337 Epetra_SerialDenseMatrix JacobianMatrix(3,3);
346 for (
unsigned int inode=0; inode<
Mesh->
el_type; ++inode){
351 vector_u(3*inode+0) = u[
OverlapMap->LID(3*node+0)];
352 vector_u(3*inode+1) = u[
OverlapMap->LID(3*node+1)];
353 vector_u(3*inode+2) = u[
OverlapMap->LID(3*node+2)];
355 for (
unsigned int i=0;
i<6; ++
i){
375 epsilon.Multiply(
'N',
'N',1.0,matrix_B,vector_u,0.0);
377 epsilon11[e_lid] = epsilon(0);
378 epsilon22[e_lid] = epsilon(1);
379 epsilon33[e_lid] = epsilon(2);
380 epsilon12[e_lid] = epsilon(5);
381 epsilon13[e_lid] = epsilon(4);
382 epsilon23[e_lid] = epsilon(3);
384 vonmises[e_lid] = std::sqrt( (epsilon11[e_lid]-epsilon22[e_lid])*(epsilon11[e_lid]-epsilon22[e_lid]) + (epsilon22[e_lid]-epsilon33[e_lid])*(epsilon22[e_lid]-epsilon33[e_lid]) + (epsilon33[e_lid]-epsilon11[e_lid])*(epsilon33[e_lid]-epsilon11[e_lid]) + 6.0*(epsilon23[e_lid]*epsilon23[e_lid] + epsilon13[e_lid]*epsilon13[e_lid] + epsilon12[e_lid]*epsilon12[e_lid]) );
387 int NumTargetElements = 0;
388 if (
Comm->MyPID()==0){
391 Epetra_Map MapOnRoot(-1,NumTargetElements,0,*
Comm);
392 Epetra_Export ExportOnRoot(CellsMap,MapOnRoot);
399 Epetra_MultiVector lhs_root22(MapOnRoot,
true);
400 lhs_root22.Export(epsilon22,ExportOnRoot,Insert);
401 std::string file22 = filename +
"_epsilon22.mtx";
402 int error22 = EpetraExt::MultiVectorToMatrixMarketFile(file22.c_str(),lhs_root22,0,0,
false);
425 Epetra_MultiVector lhs_rootvm(MapOnRoot,
true);
426 lhs_rootvm.Export(vonmises,ExportOnRoot,Insert);
427 std::string filevm = filename +
"_epsilon_vm.mtx";
428 int errorvm = EpetraExt::MultiVectorToMatrixMarketFile(filevm.c_str(),lhs_rootvm,0,0,
false);
439 Epetra_Vector sigma11(CellsMap); sigma11.PutScalar(0.0);
440 Epetra_Vector sigma22(CellsMap); sigma22.PutScalar(0.0);
441 Epetra_Vector sigma33(CellsMap); sigma33.PutScalar(0.0);
442 Epetra_Vector sigma12(CellsMap); sigma12.PutScalar(0.0);
443 Epetra_Vector sigma13(CellsMap); sigma13.PutScalar(0.0);
444 Epetra_Vector sigma23(CellsMap); sigma23.PutScalar(0.0);
445 Epetra_Vector vonmises(CellsMap); vonmises.PutScalar(0.0);
449 double det_jac_cells, gauss_weight,
theta;
451 Epetra_SerialDenseVector epsilon(6);
452 Epetra_SerialDenseVector cauchy_stress(6);
453 Epetra_SerialDenseVector vector_u(3*
Mesh->
el_type);
454 Epetra_SerialDenseMatrix tangent_matrix(6,6);
455 Epetra_SerialDenseMatrix matrix_B(6,3*
Mesh->
el_type);
456 Epetra_SerialDenseMatrix dx_shape_functions(
Mesh->
el_type,3);
458 Epetra_SerialDenseMatrix matrix_X(3,
Mesh->
el_type);
460 Epetra_SerialDenseMatrix JacobianMatrix(3,3);
481 for (
unsigned int inode=0; inode<
Mesh->
el_type; ++inode){
486 vector_u(3*inode+0) = u[
OverlapMap->LID(3*node+0)];
487 vector_u(3*inode+1) = u[
OverlapMap->LID(3*node+1)];
488 vector_u(3*inode+2) = u[
OverlapMap->LID(3*node+2)];
490 for (
unsigned int i=0;
i<6; ++
i){
498 epsilon.Multiply(
'N',
'N',1.0,matrix_B,vector_u,0.0);
500 cauchy_stress.Multiply(
'N',
'N',1.0,tangent_matrix,epsilon,0.0);
502 sigma11[e_lid] = cauchy_stress(0);
503 sigma22[e_lid] = cauchy_stress(1);
504 sigma33[e_lid] = cauchy_stress(2);
505 sigma12[e_lid] = cauchy_stress(5);
506 sigma13[e_lid] = cauchy_stress(4);
507 sigma23[e_lid] = cauchy_stress(3);
509 vonmises[e_lid] = std::sqrt( (sigma11[e_lid]-sigma22[e_lid])*(sigma11[e_lid]-sigma22[e_lid]) + (sigma22[e_lid]-sigma33[e_lid])*(sigma22[e_lid]-sigma33[e_lid]) + (sigma33[e_lid]-sigma11[e_lid])*(sigma33[e_lid]-sigma11[e_lid]) + 6.0*(sigma23[e_lid]*sigma23[e_lid] + sigma13[e_lid]*sigma13[e_lid] + sigma12[e_lid]*sigma12[e_lid]) );
512 int NumTargetElements = 0;
513 if (
Comm->MyPID()==0){
516 Epetra_Map MapOnRoot(-1,NumTargetElements,0,*
Comm);
517 Epetra_Export ExportOnRoot(CellsMap,MapOnRoot);
524 Epetra_MultiVector lhs_root22(MapOnRoot,
true);
525 lhs_root22.Export(sigma22,ExportOnRoot,Insert);
526 std::string file22 = filename +
"_sigma22.mtx";
527 int error22 = EpetraExt::MultiVectorToMatrixMarketFile(file22.c_str(),lhs_root22,0,0,
false);
550 Epetra_MultiVector lhs_rootvm(MapOnRoot,
true);
551 lhs_rootvm.Export(vonmises,ExportOnRoot,Insert);
552 std::string filevm = filename +
"_vm.mtx";
553 int errorvm = EpetraExt::MultiVectorToMatrixMarketFile(filevm.c_str(),lhs_rootvm,0,0,
false);
int print_solution(Epetra_Vector &solution, std::string fileName)
void assembleMixedDirichletNeumann_inhomogeneousForcing(Epetra_FECrsMatrix &K, Epetra_FEVector &F)
std::vector< int > local_faces
Epetra_SerialDenseVector DZ_N_cells
std::vector< double > nodes_coord
virtual Epetra_SerialDenseVector get_forcing(double &x1, double &x2, double &x3, unsigned int &e_lid, unsigned int &gp)=0
Epetra_SerialDenseVector N_cells
void assembleMixedDirichletNeumann_homogeneousForcing(Epetra_FECrsMatrix &K, Epetra_FEVector &F)
void stiffness_homogeneousForcing(Epetra_FECrsMatrix &K)
Epetra_SerialDenseMatrix N_faces
void d_shape_functions(Epetra_SerialDenseMatrix &D, double &xi, double &eta, double &zeta)
unsigned int n_gauss_faces
virtual void get_elasticity_tensor(unsigned int &e_lid, unsigned int &gp, Epetra_SerialDenseMatrix &tangent_matrix)=0
void dX_shape_functions(Epetra_SerialDenseMatrix &D, Epetra_SerialDenseMatrix JacobianMatrix, double &jac, Epetra_SerialDenseMatrix &DX)
Epetra_SerialDenseVector DX_N_cells
Epetra_SerialDenseVector detJac_cells
Epetra_FECrsGraph * FEGraph
void compute_B_matrices(Epetra_SerialDenseMatrix &dx_shape_functions, Epetra_SerialDenseMatrix &B)
virtual Epetra_SerialDenseVector get_neumannBc(Epetra_SerialDenseMatrix &matrix_X, Epetra_SerialDenseMatrix &xg, unsigned int &gp)=0
std::vector< int > local_cells
void d_shape_functions(Epetra_SerialDenseMatrix &D, double &xi, double &eta, double &zeta)
void compute_deformation(Epetra_Vector &x, std::string &filename, bool printCauchy, bool printVM)
void jacobian_det(Epetra_SerialDenseMatrix &JacobianMatrix, double &jac)
std::vector< int > faces_nodes
Epetra_SerialDenseVector DY_N_cells
void compute_center_cauchy_stress(Epetra_Vector &x, std::string &filename, bool printCauchy, bool printVM)
std::vector< int > cells_nodes
void assemblePureDirichlet_homogeneousForcing(Epetra_FECrsMatrix &K)
Epetra_Import * ImportToOverlapMap
unsigned int n_gauss_cells
Epetra_SerialDenseVector gauss_weight_faces
virtual void get_elasticity_tensor_for_recovery(unsigned int &e_lid, Epetra_SerialDenseMatrix &tangent_matrix)=0
void rhs_NeumannBoundaryCondition(Epetra_FEVector &F)
void d_shape_functions(Epetra_SerialDenseMatrix &D, double &xi, double &eta, double &zeta)
void stiffness_inhomogeneousForcing(Epetra_FECrsMatrix &K, Epetra_FEVector &F)
void aztecSolver(Epetra_FECrsMatrix &A, Epetra_FEVector &b, Epetra_Vector &u, Teuchos::ParameterList ¶mList)
Epetra_SerialDenseVector gauss_weight_cells
void jacobian_matrix(Epetra_SerialDenseMatrix &X, Epetra_SerialDenseMatrix &D, Epetra_SerialDenseMatrix &JacobianMatrix)