25 ceeSBVP(Epetra_Comm & comm, Teuchos::ParameterList & Parameters){
27 Krylov = &Parameters.sublist(
"Krylov");
29 std::string mesh_file = Teuchos::getParameter<std::string>(Parameters.sublist(
"Mesh"),
"mesh_file");
30 Mesh =
new mesh(comm, mesh_file, 1.0);
33 StandardMap =
new Epetra_Map(-1,3*Mesh->n_local_nodes_without_ghosts,&Mesh->local_dof_without_ghosts[0],0,*
Comm);
34 OverlapMap =
new Epetra_Map(-1,3*Mesh->n_local_nodes,&Mesh->local_dof[0],0,*
Comm);
39 for (
unsigned int e=0;
e<Mesh->n_cells/32; ++
e){
40 for (
unsigned int j=0;
j<32; ++
j){
45 int order = Teuchos::getParameter<int>(Parameters.sublist(
"Shinozuka"),
"order");
46 double L1 = Teuchos::getParameter<double>(Parameters.sublist(
"Shinozuka"),
"lx");
47 double L2 = Teuchos::getParameter<double>(Parameters.sublist(
"Shinozuka"),
"ly");
48 _deltaN = Teuchos::getParameter<double>(Parameters.sublist(
"Shinozuka"),
"deltaN");
49 _deltaM4 = Teuchos::getParameter<double>(Parameters.sublist(
"Shinozuka"),
"deltaM4");
50 _deltaM5 = Teuchos::getParameter<double>(Parameters.sublist(
"Shinozuka"),
"deltaM5");
60 Epetra_SerialDenseVector
get_neumannBc(Epetra_SerialDenseMatrix & matrix_X, Epetra_SerialDenseMatrix & xg,
unsigned int & gp){
61 std::cout <<
"Not using this method in this application.\n";
62 Epetra_SerialDenseVector f(3);
65 Epetra_SerialDenseVector
get_forcing(
double & x1,
double & x2,
double & x3,
unsigned int & e_lid,
unsigned int & gp){
66 std::cout <<
"Not using this method in this application.\n";
67 Epetra_SerialDenseVector f(3);
85 GRF_Generator->rng.seed(seeds[0]);
86 GRF_Generator->generator_gauss_points(w1_shino,*
Mesh,phase);
88 GRF_Generator->rng.seed(seeds[1]);
89 GRF_Generator->generator_gauss_points(w2_shino,*
Mesh,phase);
91 GRF_Generator->rng.seed(seeds[2]);
92 GRF_Generator->generator_gauss_points(w3_shino,*
Mesh,phase);
94 GRF_Generator->rng.seed(seeds[3]);
95 GRF_Generator->generator_gauss_points(w4_shino,*
Mesh,phase);
97 GRF_Generator->rng.seed(seeds[4]);
98 GRF_Generator->generator_gauss_points(w5_shino,*
Mesh,phase);
100 double alpha;
double beta = 1.0;
103 for (
unsigned int i=0;
i<w1_shino.Length(); ++
i){
104 alpha = 3.0/(2.0*_deltaN*
_deltaN); beta = 1.0;
106 m1(
i) = (_deltaN*_deltaN/3.0)*2.0*Psi1;
108 alpha = 3.0/(2.0*_deltaN*
_deltaN) - 1.0/2.0;
110 m2(
i) = (_deltaN*_deltaN/3.0)*( 2.0*Psi2 + w3_shino(
i)*w3_shino(
i) );
112 m3(
i) = (_deltaN*_deltaN/3.0)*std::sqrt(2.0*Psi1)*w3_shino(
i);
120 Epetra_FECrsMatrix linearOperator(Copy,*
FEGraph);
130 Epetra_LinearProblem problem;
133 problem.SetOperator(&linearOperator);
134 problem.SetLHS(&lhs);
135 problem.SetRHS(&rhs);
136 solver.SetProblem(problem);
137 solver.SetParameters(*Krylov);
139 solver.Iterate(2000,1
e-6);
145 double erfx = boost::math::erf<double>(w/std::sqrt(2.0));
146 double y = (1.0/2.0)*(1.0 + erfx);
147 double yinv = boost::math::gamma_p_inv<double,double>(alpha,y);
148 double z = yinv*
beta;
204 F.Update(-1.0,rhs_dir,1.0);
228 double epsilon = 1.0e-6;
229 Epetra_SerialDenseMatrix M(6,6);
230 double M1 =
m1(e_lid*n_gauss_cells+gp) + epsilon;
231 double M2 =
m2(e_lid*n_gauss_cells+gp) + epsilon;
232 double M3 =
m3(e_lid*n_gauss_cells+gp);
233 double M4 =
m4(e_lid*n_gauss_cells+gp) + epsilon;
234 double M5 =
m5(e_lid*n_gauss_cells+gp) + epsilon;
238 double c1 = 144.8969*1.0e3;
239 double c2 = 14.2500*1.0e3;
240 double c3 = 5.8442*1.0e3;
241 double c4 = 7.5462*1.0e3;
242 double c5 = 12.5580*1.0e3;
244 Epetra_SerialDenseMatrix sqrtmCmoy(6,6);
245 double constant = std::sqrt(c1*c1-2.0*c1*c2+c2*c2+4.0*c3*c3);
247 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);
248 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);
249 double d3 = std::sqrt(2.0)*c3*( std::sqrt(c1+c2+constant) - std::sqrt(c1+c2-constant) )/( 2.0*constant );
250 double d4 = std::sqrt(c4);
251 double d5 = std::sqrt(c5);
255 Epetra_SerialDenseMatrix AtimesB(6,6);
257 AtimesB.Multiply(
'N',
'N',1.0,M,sqrtmCmoy,0.0);
258 tangent_matrix.Multiply(
'N',
'N',1.0,sqrtmCmoy,AtimesB,0.0);
260 if(phase[e_gid] % 2){
261 tangent_matrix(0,5) = -tangent_matrix(0,5);
262 tangent_matrix(5,0) = -tangent_matrix(5,0);
263 tangent_matrix(1,5) = -tangent_matrix(1,5);
264 tangent_matrix(5,1) = -tangent_matrix(5,1);
265 tangent_matrix(2,5) = -tangent_matrix(2,5);
266 tangent_matrix(5,2) = -tangent_matrix(5,2);
267 tangent_matrix(3,4) = -tangent_matrix(3,4);
268 tangent_matrix(4,3) = -tangent_matrix(4,3);
270 tangent_matrix.Scale(1.0/(1.0+epsilon));
287 double xi = 0.0;
double eta = 0.0;
double zeta = 0.0;
289 GRF_Generator->rng.seed(seeds[0]);
290 GRF_Generator->generator_one_gauss_point(w1_shino,*
Mesh,phase,xi,eta,zeta);
292 GRF_Generator->rng.seed(seeds[1]);
293 GRF_Generator->generator_one_gauss_point(w2_shino,*
Mesh,phase,xi,eta,zeta);
295 GRF_Generator->rng.seed(seeds[2]);
296 GRF_Generator->generator_one_gauss_point(w3_shino,*
Mesh,phase,xi,eta,zeta);
298 GRF_Generator->rng.seed(seeds[3]);
299 GRF_Generator->generator_one_gauss_point(w4_shino,*
Mesh,phase,xi,eta,zeta);
301 GRF_Generator->rng.seed(seeds[4]);
302 GRF_Generator->generator_one_gauss_point(w5_shino,*
Mesh,phase,xi,eta,zeta);
304 double alpha;
double beta = 1.0;
307 for (
unsigned int i=0;
i<w1_shino.Length(); ++
i){
308 alpha = 3.0/(2.0*_deltaN*
_deltaN); beta = 1.0;
310 m1(
i) = (_deltaN*_deltaN/3.0)*2.0*Psi1;
312 alpha = 3.0/(2.0*_deltaN*
_deltaN) - 1.0/2.0;
314 m2(
i) = (_deltaN*_deltaN/3.0)*( 2.0*Psi2 + w3_shino(
i)*w3_shino(
i) );
316 m3(
i) = (_deltaN*_deltaN/3.0)*std::sqrt(2.0*Psi1)*w3_shino(
i);
330 double epsilon = 1.0e-6;
331 Epetra_SerialDenseMatrix M(6,6);
332 double M1 =
m1(e_lid) + epsilon;
333 double M2 =
m2(e_lid) + epsilon;
334 double M3 =
m3(e_lid);
335 double M4 =
m4(e_lid) + epsilon;
336 double M5 =
m5(e_lid) + epsilon;
340 double c1 = 144.8969*1.0e3;
341 double c2 = 14.2500*1.0e3;
342 double c3 = 5.8442*1.0e3;
343 double c4 = 7.5462*1.0e3;
344 double c5 = 12.5580*1.0e3;
346 Epetra_SerialDenseMatrix sqrtmCmoy(6,6);
347 double constant = std::sqrt(c1*c1-2.0*c1*c2+c2*c2+4.0*c3*c3);
349 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);
350 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);
351 double d3 = std::sqrt(2.0)*c3*( std::sqrt(c1+c2+constant) - std::sqrt(c1+c2-constant) )/( 2.0*constant );
352 double d4 = std::sqrt(c4);
353 double d5 = std::sqrt(c5);
357 Epetra_SerialDenseMatrix AtimesB(6,6);
359 AtimesB.Multiply(
'N',
'N',1.0,M,sqrtmCmoy,0.0);
360 tangent_matrix.Multiply(
'N',
'N',1.0,sqrtmCmoy,AtimesB,0.0);
362 if(phase[e_gid] % 2){
363 tangent_matrix(0,5) = -tangent_matrix(0,5);
364 tangent_matrix(5,0) = -tangent_matrix(5,0);
365 tangent_matrix(1,5) = -tangent_matrix(1,5);
366 tangent_matrix(5,1) = -tangent_matrix(5,1);
367 tangent_matrix(2,5) = -tangent_matrix(2,5);
368 tangent_matrix(5,2) = -tangent_matrix(5,2);
369 tangent_matrix(3,4) = -tangent_matrix(3,4);
370 tangent_matrix(4,3) = -tangent_matrix(4,3);
372 tangent_matrix.Scale(1.0/(1.0+epsilon));
377 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;
378 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;
379 C(0,2) = (3.0*c2)/8.0 - (3.0*c4)/8.0 + (std::sqrt(2.0)*c3)/8.0;
382 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);
384 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;
385 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;
386 C(1,2) = c2/8.0 - c4/8.0 + (3.0*std::sqrt(2.0)*c3)/8.0;
389 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);
391 C(2,0) = (3.0*c2)/8.0 - (3.0*c4)/8.0 + std::sqrt(2.0)*c3/8.0;
392 C(2,1) = c2/8.0 - c4/8.0 + (3.0*std::sqrt(2.0)*c3)/8.0;
393 C(2,2) = c2/2.0 + c4/2.0;
396 C(2,5) = (std::sqrt(3.0)*(2.0*c3 - std::sqrt(2.0)*c2 + std::sqrt(2.0)*c4))/8.0;
401 C(3,3) = c4/4.0 + (3.0*c5)/4.0;
402 C(3,4) = -(std::sqrt(3.0)*(c4 - c5))/4.0;
408 C(4,3) = -(std::sqrt(3.0)*(c4 - c5))/4.0;
409 C(4,4) = (3.0*c4)/4.0 + c5/4.0;
412 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);
413 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);
414 C(5,2) = (std::sqrt(3.0)*(2.0*c3 - std::sqrt(2.0)*c2 + std::sqrt(2.0)*c4))/8.0;
417 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;
423 int NumTargetElements = 0;
424 if (
Comm->MyPID()==0){
427 Epetra_Map MapOnRoot(-1,NumTargetElements,0,*
Comm);
428 Epetra_Export ExportOnRoot(*
StandardMap,MapOnRoot);
429 Epetra_MultiVector lhs_root(MapOnRoot,
true);
430 lhs_root.Export(*solution,ExportOnRoot,Insert);
432 int error = EpetraExt::MultiVectorToMatrixMarketFile(fileName.c_str(),lhs_root,0,0,
false);
std::vector< int > local_nodes
Teuchos::ParameterList * Krylov
std::vector< double > nodes_coord
ceeSBVP(Epetra_Comm &comm, Teuchos::ParameterList &Parameters)
Epetra_SerialDenseVector m4
Teuchos::RCP< shinozuka_layeredcomp_2d > GRF_Generator
void solveOneRealization(double &bcDisp, int *seeds)
void recover_cauchy_stress(std::string &filename, int *seeds)
Epetra_SerialDenseVector m2
void apply_dirichlet_conditions(Epetra_FECrsMatrix &K, Epetra_FEVector &F, double &displacement)
Epetra_FECrsGraph * FEGraph
double icdf_gamma(double &w, double &alpha, double &beta)
int print_solution(std::string fileName)
void get_elasticity_tensor_for_recovery(unsigned int &e_lid, Epetra_SerialDenseMatrix &tangent_matrix)
std::vector< int > local_cells
clc clear all close all mesh
int n_local_nodes_without_ghosts
void compute_center_cauchy_stress(Epetra_Vector &x, std::string &filename, bool printCauchy, bool printVM)
void assemblePureDirichlet_homogeneousForcing(Epetra_FECrsMatrix &K)
Epetra_Import * ImportToOverlapMap
Epetra_SerialDenseVector m5
unsigned int n_gauss_cells
void transverse_isotropic_matrix(Epetra_SerialDenseMatrix &C, double &c1, double &c2, double &c3, double &c4, double &c5)
void get_elasticity_tensor(unsigned int &e_lid, unsigned int &gp, Epetra_SerialDenseMatrix &tangent_matrix)
void setup_dirichlet_conditions()
Epetra_SerialDenseVector get_forcing(double &x1, double &x2, double &x3, unsigned int &e_lid, unsigned int &gp)
Epetra_SerialDenseVector get_neumannBc(Epetra_SerialDenseMatrix &matrix_X, Epetra_SerialDenseMatrix &xg, unsigned int &gp)
Epetra_SerialDenseVector m1
Epetra_SerialDenseVector m3