16 asmeSBVP(Epetra_Comm & comm, Teuchos::ParameterList & Parameters){
18 Krylov = &Parameters.sublist(
"Krylov");
20 std::string mesh_file = Teuchos::getParameter<std::string>(Parameters.sublist(
"Mesh"),
"mesh_file");
21 Mesh =
new mesh(comm, mesh_file, 1.0);
24 StandardMap =
new Epetra_Map(-1,3*Mesh->n_local_nodes_without_ghosts,&Mesh->local_dof_without_ghosts[0],0,*
Comm);
25 OverlapMap =
new Epetra_Map(-1,3*Mesh->n_local_nodes,&Mesh->local_dof[0],0,*
Comm);
30 for (
unsigned int e=0;
e<Mesh->n_cells/32; ++
e){
31 for (
unsigned int j=0;
j<32; ++
j){
36 int order = Teuchos::getParameter<int>(Parameters.sublist(
"Shinozuka"),
"order");
37 double L1 = Teuchos::getParameter<double>(Parameters.sublist(
"Shinozuka"),
"lx");
38 double L2 = Teuchos::getParameter<double>(Parameters.sublist(
"Shinozuka"),
"ly");
39 double L3 = Teuchos::getParameter<double>(Parameters.sublist(
"Shinozuka"),
"lz");
49 Epetra_SerialDenseVector
get_neumannBc(Epetra_SerialDenseMatrix & matrix_X, Epetra_SerialDenseMatrix & xg,
unsigned int & gp){
50 std::cout <<
"Not using this method in this application.\n";
51 Epetra_SerialDenseVector f(3);
54 Epetra_SerialDenseVector
get_forcing(
double & x1,
double & x2,
double & x3,
unsigned int & e_lid,
unsigned int & gp){
55 std::cout <<
"Not using this method in this application.\n";
56 Epetra_SerialDenseVector f(3);
89 double deltaN = 0.0970;
90 double deltaM4 = 0.0461;
91 double deltaM5 = 0.0952;
92 double alpha;
double beta = 1.0;
95 for (
unsigned int i=0;
i<w1_shino.Length(); ++
i){
97 alpha = 3.0/(2.0*deltaN*deltaN); beta = 1.0;
99 m1(
i) = (deltaN*deltaN/3.0)*2.0*Psi1;
101 alpha = 3.0/(2.0*deltaN*deltaN) - 1.0/2.0;
103 m2(
i) = (deltaN*deltaN/3.0)*( 2.0*Psi2 + w3_shino(
i)*w3_shino(
i) );
105 m3(
i) = (deltaN*deltaN/3.0)*std::sqrt(2.0*Psi1)*w3_shino(
i);
107 alpha = 1.0/(deltaM4*deltaM4); beta = 1.0*deltaM4*deltaM4;
109 alpha = 1.0/(deltaM5*deltaM5); beta = 1.0*deltaM5*deltaM5;
114 Epetra_FECrsMatrix linearOperator(Copy,*
FEGraph);
124 Epetra_LinearProblem problem;
127 problem.SetOperator(&linearOperator);
128 problem.SetLHS(&lhs);
129 problem.SetRHS(&rhs);
130 solver.SetProblem(problem);
131 solver.SetParameters(*
Krylov);
133 solver.Iterate(2000,1
e-6);
140 double erfx = boost::math::erf<double>(w/std::sqrt(2.0));
141 double y = (1.0/2.0)*(1.0 + erfx);
142 double yinv = boost::math::gamma_p_inv<double,double>(alpha,y);
143 double z = yinv*
beta;
201 F.Update(-1.0,rhs_dir,1.0);
226 double epsilon = 1.0e-6;
227 Epetra_SerialDenseMatrix M(6,6);
228 double M1 =
m1(e_lid*n_gauss_cells+gp) + epsilon;
229 double M2 =
m2(e_lid*n_gauss_cells+gp) + epsilon;
230 double M3 =
m3(e_lid*n_gauss_cells+gp);
231 double M4 =
m4(e_lid*n_gauss_cells+gp) + epsilon;
232 double M5 =
m5(e_lid*n_gauss_cells+gp) + epsilon;
236 double c1 = 144.8969*1.0e3;
237 double c2 = 14.2500*1.0e3;
238 double c3 = 5.8442*1.0e3;
239 double c4 = 7.5462*1.0e3;
240 double c5 = 12.5580*1.0e3;
242 Epetra_SerialDenseMatrix sqrtmCmoy(6,6);
243 double constant = std::sqrt(c1*c1-2.0*c1*c2+c2*c2+4.0*c3*c3);
245 double d1 = (std::sqrt(2.0)*(c1-c2+constant)*std::sqrt(c1+c2+constant))/(4.0*constant) + (std::sqrt(2.0)*(c2-c1+constant)*std::sqrt(c1+c2-constant))/(4.0*constant);
246 double d2 = (std::sqrt(2.0)*(c2-c1+constant)*std::sqrt(c1+c2+constant))/(4.0*constant) + (std::sqrt(2.0)*(c1-c2+constant)*std::sqrt(c1+c2-constant))/(4.0*constant);
247 double d3 = std::sqrt(2.0)*c3*( std::sqrt(c1+c2+constant) - std::sqrt(c1+c2-constant) )/( 2.0*constant );
248 double d4 = std::sqrt(c4);
249 double d5 = std::sqrt(c5);
253 Epetra_SerialDenseMatrix AtimesB(6,6);
255 AtimesB.Multiply(
'N',
'N',1.0,M,sqrtmCmoy,0.0);
256 tangent_matrix.Multiply(
'N',
'N',1.0,sqrtmCmoy,AtimesB,0.0);
258 if(
phase[e_gid] % 2){
259 tangent_matrix(0,5) = -tangent_matrix(0,5);
260 tangent_matrix(5,0) = -tangent_matrix(5,0);
261 tangent_matrix(1,5) = -tangent_matrix(1,5);
262 tangent_matrix(5,1) = -tangent_matrix(5,1);
263 tangent_matrix(2,5) = -tangent_matrix(2,5);
264 tangent_matrix(5,2) = -tangent_matrix(5,2);
265 tangent_matrix(3,4) = -tangent_matrix(3,4);
266 tangent_matrix(4,3) = -tangent_matrix(4,3);
269 tangent_matrix.Scale(1.0/(1.0+epsilon));
287 double xi = 0.0;
double eta = 0.0;
double zeta = 0.0;
304 double deltaN = 0.0970;
305 double deltaM4 = 0.0461;
306 double deltaM5 = 0.0952;
307 double alpha;
double beta = 1.0;
310 for (
unsigned int i=0;
i<w1_shino.Length(); ++
i){
312 alpha = 3.0/(2.0*deltaN*deltaN); beta = 1.0;
314 m1(
i) = (deltaN*deltaN/3.0)*2.0*Psi1;
316 alpha = 3.0/(2.0*deltaN*deltaN) - 1.0/2.0;
318 m2(
i) = (deltaN*deltaN/3.0)*( 2.0*Psi2 + w3_shino(
i)*w3_shino(
i) );
320 m3(
i) = (deltaN*deltaN/3.0)*std::sqrt(2.0*Psi1)*w3_shino(
i);
322 alpha = 1.0/(deltaM4*deltaM4); beta = 1.0*deltaM5*deltaM5;
324 alpha = 1.0/(deltaM4*deltaM4); beta = 1.0*deltaM5*deltaM5;
335 double epsilon = 1.0e-6;
336 Epetra_SerialDenseMatrix M(6,6);
337 double M1 =
m1(e_lid) + epsilon;
338 double M2 =
m2(e_lid) + epsilon;
339 double M3 =
m3(e_lid);
340 double M4 =
m4(e_lid) + epsilon;
341 double M5 =
m5(e_lid) + epsilon;
345 double c1 = 144.8969*1.0e3;
346 double c2 = 14.2500*1.0e3;
347 double c3 = 5.8442*1.0e3;
348 double c4 = 7.5462*1.0e3;
349 double c5 = 12.5580*1.0e3;
351 Epetra_SerialDenseMatrix sqrtmCmoy(6,6);
352 double constant = std::sqrt(c1*c1-2.0*c1*c2+c2*c2+4.0*c3*c3);
354 double d1 = (std::sqrt(2.0)*(c1-c2+constant)*std::sqrt(c1+c2+constant))/(4.0*constant) + (std::sqrt(2.0)*(c2-c1+constant)*std::sqrt(c1+c2-constant))/(4.0*constant);
355 double d2 = (std::sqrt(2.0)*(c2-c1+constant)*std::sqrt(c1+c2+constant))/(4.0*constant) + (std::sqrt(2.0)*(c1-c2+constant)*std::sqrt(c1+c2-constant))/(4.0*constant);
356 double d3 = std::sqrt(2.0)*c3*( std::sqrt(c1+c2+constant) - std::sqrt(c1+c2-constant) )/( 2.0*constant );
357 double d4 = std::sqrt(c4);
358 double d5 = std::sqrt(c5);
362 Epetra_SerialDenseMatrix AtimesB(6,6);
364 AtimesB.Multiply(
'N',
'N',1.0,M,sqrtmCmoy,0.0);
365 tangent_matrix.Multiply(
'N',
'N',1.0,sqrtmCmoy,AtimesB,0.0);
367 if(
phase[e_gid] % 2){
368 tangent_matrix(0,5) = -tangent_matrix(0,5);
369 tangent_matrix(5,0) = -tangent_matrix(5,0);
370 tangent_matrix(1,5) = -tangent_matrix(1,5);
371 tangent_matrix(5,1) = -tangent_matrix(5,1);
372 tangent_matrix(2,5) = -tangent_matrix(2,5);
373 tangent_matrix(5,2) = -tangent_matrix(5,2);
374 tangent_matrix(3,4) = -tangent_matrix(3,4);
375 tangent_matrix(4,3) = -tangent_matrix(4,3);
378 tangent_matrix.Scale(1.0/(1.0+epsilon));
384 C(0,0) = c1/16.0 + (9.0*c2)/32.0 + (9.0*c4)/32.0 + (3.0*c5)/8.0 + (3.0*std::sqrt(2.0)*c3)/16.0;
385 C(0,1) = (3.0*c1)/16.0 + (3.0*c2)/32.0 + (3.0*c4)/32.0 - (3.0*c5)/8.0 + (5.0*std::sqrt(2.0)*c3)/16.0;
386 C(0,2) = (3.0*c2)/8.0 - (3.0*c4)/8.0 + (std::sqrt(2.0)*c3)/8.0;
389 C(0,5) = std::sqrt(6)*(c1/16.0 - (3.0*c2)/32.0 - (3.0*c4)/32.0 + c5/8.0 + (std::sqrt(2.0)*c3)/16.0);
391 C(1,0) = (3.0*c1)/16.0 + (3.0*c2)/32.0 + (3.0*c4)/32.0 - (3.0*c5)/8.0 + (5*std::sqrt(2.0)*c3)/16.0;
392 C(1,1) = (9.0*c1)/16.0 + c2/32.0 + c4/32.0 + (3.0*c5)/8.0 + (3.0*std::sqrt(2.0)*c3)/16.0;
393 C(1,2) = c2/8.0 - c4/8.0 + (3.0*std::sqrt(2.0)*c3)/8.0;
396 C(1,5) = -std::sqrt(6.0)*(c2/32.0 - (3.0*c1)/16.0 + c4/32.0 + c5/8.0 + (std::sqrt(2.0)*c3)/16.0);
398 C(2,0) = (3.0*c2)/8.0 - (3.0*c4)/8.0 + std::sqrt(2.0)*c3/8.0;
399 C(2,1) = c2/8.0 - c4/8.0 + (3.0*std::sqrt(2.0)*c3)/8.0;
400 C(2,2) = c2/2.0 + c4/2.0;
403 C(2,5) = (std::sqrt(3.0)*(2.0*c3 - std::sqrt(2.0)*c2 + std::sqrt(2.0)*c4))/8.0;
408 C(3,3) = c4/4.0 + (3.0*c5)/4.0;
409 C(3,4) = -(std::sqrt(3.0)*(c4 - c5))/4.0;
415 C(4,3) = -(std::sqrt(3.0)*(c4 - c5))/4.0;
416 C(4,4) = (3.0*c4)/4.0 + c5/4.0;
419 C(5,0) = std::sqrt(6.0)*(c1/16.0 - (3.0*c2)/32.0 - (3.0*c4)/32.0 + c5/8.0 + std::sqrt(2.0)*c3/16.0);
420 C(5,1) = -std::sqrt(6.0)*(c2/32.0 - (3.0*c1)/16.0 + c4/32.0 + c5/8.0 + (std::sqrt(2.0)*c3)/16.0);
421 C(5,2) = (std::sqrt(3.0)*(2.0*c3 - std::sqrt(2.0)*c2 + std::sqrt(2.0)*c4))/8.0;
424 C(5,5) = (3.0*c1)/8.0 + (3.0*c2)/16.0 + (3.0*c4)/16.0 + c5/4.0 - (3.0*std::sqrt(2.0)*c3)/8.0;
430 int NumTargetElements = 0;
431 if (
Comm->MyPID()==0){
434 Epetra_Map MapOnRoot(-1,NumTargetElements,0,*
Comm);
435 Epetra_Export ExportOnRoot(*
StandardMap,MapOnRoot);
436 Epetra_MultiVector lhs_root(MapOnRoot,
true);
437 lhs_root.Export(*
solution,ExportOnRoot,Insert);
439 int error = EpetraExt::MultiVectorToMatrixMarketFile(fileName.c_str(),lhs_root,0,0,
false);
449 Epetra_SerialDenseVector
m1;
450 Epetra_SerialDenseVector
m2;
451 Epetra_SerialDenseVector
m3;
452 Epetra_SerialDenseVector
m4;
453 Epetra_SerialDenseVector
m5;
Teuchos::ParameterList * Krylov
std::vector< int > local_nodes
std::vector< double > nodes_coord
void get_elasticity_tensor(unsigned int &e_lid, unsigned int &gp, Epetra_SerialDenseMatrix &tangent_matrix)
Epetra_SerialDenseVector get_forcing(double &x1, double &x2, double &x3, unsigned int &e_lid, unsigned int &gp)
Teuchos::RCP< shinozuka_layeredcomp > GRF_Generator
Epetra_SerialDenseVector m3
Epetra_FECrsGraph * FEGraph
void get_elasticity_tensor_for_recovery(unsigned int &e_lid, Epetra_SerialDenseMatrix &tangent_matrix)
asmeSBVP(Epetra_Comm &comm, Teuchos::ParameterList &Parameters)
std::vector< int > local_cells
void setup_dirichlet_conditions()
clc clear all close all mesh
int n_local_nodes_without_ghosts
Epetra_SerialDenseVector m4
void compute_center_cauchy_stress(Epetra_Vector &x, std::string &filename, bool printCauchy, bool printVM)
Epetra_SerialDenseVector m2
void assemblePureDirichlet_homogeneousForcing(Epetra_FECrsMatrix &K)
Epetra_Import * ImportToOverlapMap
void solveOneRealization(double &bcDisp, int *seeds)
unsigned int n_gauss_cells
void apply_dirichlet_conditions(Epetra_FECrsMatrix &K, Epetra_FEVector &F, double &displacement)
Epetra_SerialDenseVector get_neumannBc(Epetra_SerialDenseMatrix &matrix_X, Epetra_SerialDenseMatrix &xg, unsigned int &gp)
void recover_cauchy_stress(std::string &filename, int *seeds)
Epetra_SerialDenseVector m5
int print_solution(std::string fileName)
Epetra_SerialDenseVector m1
double icdf_gamma(double &w, double &alpha, double &beta)
void transverse_isotropic_matrix(Epetra_SerialDenseMatrix &C, double &c1, double &c2, double &c3, double &c4, double &c5)