5 #ifndef DIRICHLETSTRIPELONGATION_STOCHASTICPOLYCONVEXHGO_HPP 6 #define DIRICHLETSTRIPELONGATION_STOCHASTICPOLYCONVEXHGO_HPP 12 #include <boost/random/mersenne_twister.hpp> 13 #include <boost/random/uniform_real_distribution.hpp> 14 #include <boost/math/special_functions/erf.hpp> 15 #include <boost/random/normal_distribution.hpp> 16 #include <boost/math/special_functions/gamma.hpp> 17 #include <boost/math/special_functions/beta.hpp> 41 Epetra_SerialDenseVector
a,
b;
46 std::string mesh_file = Teuchos::getParameter<std::string>(Parameters.sublist(
"Mesh"),
"mesh_file");
48 unsigned int number_physical_groups = Teuchos::getParameter<unsigned int>(Parameters.sublist(
"Mesh"),
"nb_phys_groups");
49 std::string select_model = Teuchos::getParameter<std::string>(Parameters.sublist(
"Mesh"),
"model");
51 mean_mu1 = Teuchos::getParameter<double>(Parameters.sublist(select_model),
"mu1");
52 mean_mu2 = Teuchos::getParameter<double>(Parameters.sublist(select_model),
"mu2");
53 mean_mu3 = Teuchos::getParameter<double>(Parameters.sublist(select_model),
"mu3");
54 mean_mu4 = Teuchos::getParameter<double>(Parameters.sublist(select_model),
"mu4");
55 beta3 = Teuchos::getParameter<double>(Parameters.sublist(select_model),
"beta3");
56 beta4 = Teuchos::getParameter<double>(Parameters.sublist(select_model),
"beta4");
57 theta = Teuchos::getParameter<double>(Parameters.sublist(select_model),
"theta");
58 deltaC1 = Teuchos::getParameter<double>(Parameters.sublist(select_model),
"deltaC1");
59 deltaC2 = Teuchos::getParameter<double>(Parameters.sublist(select_model),
"deltaC2");
60 deltaU1 = Teuchos::getParameter<double>(Parameters.sublist(select_model),
"deltaU1");
61 deltaG4 = Teuchos::getParameter<double>(Parameters.sublist(select_model),
"deltaG4");
63 mean_c1 = 2.0*mean_mu3*beta3*
beta3;
64 mean_c2 = 2.0*mean_mu1 + std::sqrt(3.0)*3.0*
mean_mu2;
67 double gamma = 2.0*mean_mu1/(std::sqrt(3.0)*3.0*
mean_mu2);
68 tau2 = (1.0 - deltaU1*
deltaU1)/(deltaU1*deltaU1*gamma*(gamma+1.0));
69 tau1 = (2.0*mean_mu1/(std::sqrt(3.0)*3.0*
mean_mu2))*
tau2;
72 alpha2 = mean_c1*deltaC1*
deltaC1;
74 alpha4 = mean_c2*deltaC2*
deltaC2;
76 alpha6 = mean_mu4*deltaG4*
deltaG4;
78 Mesh =
new mesh(comm, mesh_file, 1000.0);
87 a.Resize(3); b.Resize(3);
88 E1.Resize(3); E2.Resize(3); E3.Resize(3);
89 E1(0) = 1.0;
E1(1) = 0.0;
E1(2) = 0.0;
90 E2(0) = 0.0;
E2(1) = 1.0;
E2(2) = 0.0;
91 E3(0) = 0.0;
E3(1) = 0.0;
E3(2) = 1.0;
92 for (
int i=0;
i<3; ++
i){
93 a(
i) = std::cos(theta)*
E1(
i) + std::sin(theta)*
E2(
i);
94 b(
i) = std::cos(theta)*
E1(
i) - std::sin(theta)*
E2(
i);
103 void get_media(
unsigned int & n_cells,
unsigned int & n_nodes, std::string & path){
105 std::ifstream connectivity_file_med;
106 connectivity_file_med.open(path);
108 w1_gmrf.Resize(n_nodes);
109 w2_gmrf.Resize(n_nodes);
110 w3_gmrf.Resize(n_nodes);
111 w4_gmrf.Resize(n_nodes);
112 if (connectivity_file_med.is_open()){
113 cells_nodes_p1_med.Resize(4*n_cells);
114 for (
unsigned int e=0;
e<4*n_cells; ++
e){
115 connectivity_file_med >> cells_nodes_p1_med[
e];
116 cells_nodes_p1_med[
e] = cells_nodes_p1_med[
e]-1;
118 connectivity_file_med.close();
121 std::cout <<
"Couldn't open the connectivity file for the media.\n";
141 if(coord==10.0/1000.0){
157 if (coord==10.0/1000.0){
176 if (coord==10.0/1000.0){
183 F.Update(-1.0,rhs_dir,1.0);
193 if (coord==10.0/1000.0){
208 Epetra_SerialDenseVector N(4);
211 w1 = 0.0; w2 = 0.0; w3 = 0.0; w4 = 0.0;
212 for (
unsigned int j=0;
j<4; ++
j){
225 mu1 = ( epsilon*mean_mu1 + (1.0/2.0)*c2*
u1 )/( 1.0+epsilon );
226 mu2 = ( epsilon*mean_mu2 + (1.0/(std::sqrt(3.0)*3.0))*c2*(1.0-u1) )/( 1.0+epsilon );
227 mu3 = ( epsilon*mean_mu3 + c1/(2.0*beta3*
beta3) )/( 1.0+
epsilon );
228 mu4 = ( epsilon*mean_mu4 +
mu4 )/( 1.0+epsilon );
233 double erfx = boost::math::erf<double>(w/std::sqrt(2.0));
234 double y = (1.0/2.0)*(1.0 + erfx);
235 double yinv = boost::math::gamma_p_inv<double,double>(alpha,y);
236 double z = yinv*
beta;
240 double icdf_beta(
double & w,
double & tau1,
double & tau2){
241 double erfx = boost::math::erf<double>(w/std::sqrt(2.0));
242 double y = (1.0/2.0)*(1.0 + erfx);
243 double z = boost::math::ibeta_inv<double,double,double>(
tau1,
tau2,y);
247 void get_constitutive_tensors_static_condensation(Epetra_SerialDenseMatrix & deformation_gradient,
double & det, Epetra_SerialDenseVector & inverse_cauchy, Epetra_SerialDenseVector & piola_isc, Epetra_SerialDenseVector & piola_vol, Epetra_SerialDenseMatrix & tangent_piola_isc, Epetra_SerialDenseMatrix & tangent_piola_vol){
248 model_C(deformation_gradient, det, inverse_cauchy, piola_isc, piola_vol, tangent_piola_isc, tangent_piola_vol);
252 double ptheta = std::pow(theta,beta3);
253 pressure = beta3*( (ptheta/
theta) - (1.0/(ptheta*theta)) );
254 dpressure = beta3*( (beta3-1.0)*(ptheta/(theta*
theta)) + (beta3+1.0)/(ptheta*theta*
theta) );
260 double xi = 1.0/3.0;
double eta = 1.0/3.0;
double zeta = 1.0/3.0;
261 Epetra_SerialDenseVector N(4);
264 w1 = 0.0; w2 = 0.0; w3 = 0.0; w4 = 0.0;
265 for (
unsigned int j=0;
j<4; ++
j){
278 mu1 = ( epsilon*mean_mu1 + (1.0/2.0)*c2*
u1 )/( 1.0+epsilon );
279 mu2 = ( epsilon*mean_mu2 + (1.0/(std::sqrt(3.0)*3.0))*c2*(1.0-u1) )/( 1.0+epsilon );
280 mu3 = ( epsilon*mean_mu3 + c1/(2.0*beta3*
beta3) )/( 1.0+
epsilon );
281 mu4 = ( epsilon*mean_mu4 +
mu4 )/( 1.0+epsilon );
285 void get_stress_for_recover(Epetra_SerialDenseMatrix & deformation_gradient,
double & det, Epetra_SerialDenseMatrix & piola_stress){
287 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);
289 double alpha = std::pow(det,-2.0/3.0);
290 double beta = 1.0/(det*det);
291 Epetra_SerialDenseMatrix eye(3,3);
292 Epetra_SerialDenseMatrix M1(3,3), M2(3,3);
293 Epetra_SerialDenseMatrix C(3,3),
L(3,3);
294 Epetra_SerialDenseMatrix piola_ani1(3,3), piola_ani2(3,3);
296 eye(0,0) = 1.0; eye(0,1) = 0.0; eye(0,2) = 0.0;
297 eye(1,0) = 0.0; eye(1,1) = 1.0; eye(1,2) = 0.0;
298 eye(2,0) = 0.0; eye(2,1) = 0.0; eye(2,2) = 1.0;
300 M1.Multiply(
'N',
'T',1.0,a,a,0.0);
301 M2.Multiply(
'N',
'T',1.0,b,b,0.0);
303 C.Multiply(
'T',
'N',1.0,deformation_gradient,deformation_gradient,0.0);
305 L(0,0) = (1.0/(det*det))*(C(1,1)*C(2,2)-C(1,2)*C(2,1));
306 L(1,1) = (1.0/(det*det))*(C(0,0)*C(2,2)-C(0,2)*C(2,0));
307 L(2,2) = (1.0/(det*det))*(C(0,0)*C(1,1)-C(0,1)*C(1,0));
308 L(1,2) = (1.0/(det*det))*(C(0,2)*C(1,0)-C(0,0)*C(1,2));
309 L(0,2) = (1.0/(det*det))*(C(0,1)*C(1,2)-C(0,2)*C(1,1));
310 L(0,1) = (1.0/(det*det))*(C(0,2)*C(2,1)-C(0,1)*C(2,2));
311 L(2,1) =
L(1,2);
L(2,0) =
L(0,2);
L(1,0) =
L(0,1);
313 double I1 = C(0,0) + C(1,1) + C(2,2);
314 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);
315 double I2 = (1.0/2.0)*(I1*I1-II1);
316 double I4_1 = C(0,0)*M1(0,0) + C(1,1)*M1(1,1) + C(2,2)*M1(2,2) + 2.0*C(0,1)*M1(0,1) + 2.0*C(0,2)*M1(0,2) + 2.0*C(1,2)*M1(1,2);
317 double I4_2 = C(0,0)*M2(0,0) + C(1,1)*M2(1,1) + C(2,2)*M2(2,2) + 2.0*C(0,1)*M2(0,1) + 2.0*C(0,2)*M2(0,2) + 2.0*C(1,2)*M2(1,2);
318 double pI2 = std::sqrt(I2);
320 double S4_1 = (I4_1-1.0)*(I4_1-1.0);
321 double S4_2 = (I4_2-1.0)*(I4_2-1.0);
323 double ptheta = std::pow(det,beta3);
324 double pressure = mu3*beta3*( (ptheta/det) - (1.0/(ptheta*det)) );
326 for (
unsigned int i=0;
i<3; ++
i){
327 for (
unsigned int j=0;
j<3; ++
j){
328 piola_stress(
i,
j) = 2.0*mu1*alpha*(eye(
i,
j)-(1.0/3.0)*
L(
i,
j))
329 + mu2*beta*( 3.0*pI2*(I1*eye(
i,
j)-C(
i,
j)) - 2.0*I2*pI2*
L(
i,
j) )
330 + det*pressure*
L(
i,
j);
331 piola_ani1(
i,
j) = 4.0*mu4*(I4_1-1.0)*exp(beta4*S4_1)*M1(
i,
j);
332 piola_ani2(
i,
j) = 4.0*mu4*(I4_2-1.0)*exp(beta4*S4_2)*M2(
i,
j);
337 piola_stress += piola_ani1;
340 piola_stress += piola_ani2;
345 void model_C(Epetra_SerialDenseMatrix & deformation_gradient,
double & det, Epetra_SerialDenseVector &
L, Epetra_SerialDenseVector & piola_isc, Epetra_SerialDenseVector & piola_vol, Epetra_SerialDenseMatrix & tangent_piola_isc, Epetra_SerialDenseMatrix & tangent_piola_vol){
347 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);
349 double alpha = std::pow(det,-2.0/3.0);
351 Epetra_SerialDenseVector eye(6);
352 Epetra_SerialDenseMatrix rightCauchy(3,3);
353 Epetra_SerialDenseVector M1(6), M2(6);
354 Epetra_SerialDenseVector C(6), D(6);
355 Epetra_SerialDenseVector piola_nh(6), piola_ani1(6), piola_ani2(6);
357 M1(0) =
a(0)*
a(0); M2(0) =
b(0)*
b(0);
358 M1(1) =
a(1)*
a(1); M2(1) =
b(1)*
b(1);
359 M1(2) =
a(2)*
a(2); M2(2) =
b(2)*
b(2);
360 M1(3) =
a(1)*
a(2); M2(3) =
b(1)*
b(2);
361 M1(4) =
a(0)*
a(2); M2(4) =
b(0)*
b(2);
362 M1(5) =
a(0)*
a(1); M2(5) =
b(0)*
b(1);
364 rightCauchy.Multiply(
'T',
'N',1.0,deformation_gradient,deformation_gradient,0.0);
366 eye(0) = 1.0; eye(1) = 1.0; eye(2) = 1.0; eye(3) = 0.0; eye(4) = 0.0; eye(5) = 0.0;
368 C(0) = rightCauchy(0,0); C(1) = rightCauchy(1,1); C(2) = rightCauchy(2,2);
369 C(3) = rightCauchy(1,2); C(4) = rightCauchy(0,2); C(5) = rightCauchy(0,1);
371 L(0) = (1.0/(det*det))*(rightCauchy(1,1)*rightCauchy(2,2)-rightCauchy(1,2)*rightCauchy(2,1));
372 L(1) = (1.0/(det*det))*(rightCauchy(0,0)*rightCauchy(2,2)-rightCauchy(0,2)*rightCauchy(2,0));
373 L(2) = (1.0/(det*det))*(rightCauchy(0,0)*rightCauchy(1,1)-rightCauchy(0,1)*rightCauchy(1,0));
374 L(3) = (1.0/(det*det))*(rightCauchy(0,2)*rightCauchy(1,0)-rightCauchy(0,0)*rightCauchy(1,2));
375 L(4) = (1.0/(det*det))*(rightCauchy(0,1)*rightCauchy(1,2)-rightCauchy(0,2)*rightCauchy(1,1));
376 L(5) = (1.0/(det*det))*(rightCauchy(0,2)*rightCauchy(2,1)-rightCauchy(0,1)*rightCauchy(2,2));
378 double I1 = C(0) + C(1) + C(2);
379 double II1 = C(0)*C(0) + C(1)*C(1) + C(2)*C(2) + 2.0*C(3)*C(3) + 2.0*C(4)*C(4) + 2.0*C(5)*C(5);
380 double I2 = (1.0/2.0)*(I1*I1-II1);
381 double I4_1 = C(0)*M1(0) + C(1)*M1(1) + C(2)*M1(2) + 2.0*C(5)*M1(5) + 2.0*C(4)*M1(4) + 2.0*C(3)*M1(3);
382 double I4_2 = C(0)*M2(0) + C(1)*M2(1) + C(2)*M2(2) + 2.0*C(5)*M2(5) + 2.0*C(4)*M2(4) + 2.0*C(3)*M2(3);
383 double pI2 = std::sqrt(I2);
385 double S4_1 = (I4_1-1.0)*(I4_1-1.0);
386 double S4_2 = (I4_2-1.0)*(I4_2-1.0);
388 for (
unsigned int i=0;
i<6; ++
i){
389 D(
i) = I1*eye(
i) - C(
i);
390 piola_nh(
i) = 2.0*alpha*mu1*(eye(
i)-(1.0/3.0)*I1*
L(
i));
391 piola_isc(
i) = piola_nh(
i) + (mu2/(det*det))*( 3.0*pI2*D(
i) - 2.0*pI2*I2*
L(
i) );
393 piola_ani1(
i) = 4.0*mu4*(I4_1-1.0)*exp(beta4*S4_1)*M1(
i);
394 piola_ani2(
i) = 4.0*mu4*(I4_2-1.0)*exp(beta4*S4_2)*M2(
i);
396 piola_vol(
i) = mu3*det*
L(
i);
403 scalarAB = -2.0*mu3*det;
410 scalarAB = -6.0*mu2*pI2/(det*det);
414 scalarAB = (-4.0/9.0)*mu1*alpha*I1 + 4.0*mu2*pI2*I2/(det*det);
417 scalarAB = (4.0/3.0)*mu1*alpha*I1 + 4.0*mu2*pI2*I2/(det*det);
420 scalarAB = 3.0*mu2/(det*det*pI2);
423 scalarAB = 6.0*mu2*pI2/(det*det);
426 scalarAB = -scalarAB;
430 piola_isc += piola_ani1;
431 scalarAB = (8.0*mu4 + 16.0*mu4*beta4*S4_1)*exp(beta4*S4_1);
435 piola_isc += piola_ani2;
436 scalarAB = (8.0*mu4 + 16.0*mu4*beta4*S4_2)*exp(beta4*S4_2);
void get_internal_pressure(double &theta, double &pressure, double &dpressure)
void apply_dirichlet_conditions(Epetra_FECrsMatrix &K, Epetra_FEVector &F, double &displacement)
Epetra_SerialDenseVector E1
void get_material_parameters_for_recover(unsigned int &e_lid)
std::vector< int > local_nodes
void tensor_product(double scalarAB, Epetra_SerialDenseVector &A, Epetra_SerialDenseVector &B, Epetra_SerialDenseMatrix &AoB, double scalarThis)
double icdf_gamma(double &w, double &alpha, double &beta)
std::vector< double > nodes_coord
std::vector< int > local_dof
void setup_dirichlet_conditions()
Epetra_SerialDenseVector E2
~dirichletStripElongation_StochasticPolyconvexHGO()
double icdf_beta(double &w, double &tau1, double &tau2)
Epetra_SerialDenseVector eta_cells
void get_media(unsigned int &n_cells, unsigned int &n_nodes, std::string &path)
Epetra_SerialDenseVector w2_gmrf
Epetra_SerialDenseVector xi_cells
void get_stress_for_recover(Epetra_SerialDenseMatrix &deformation_gradient, double &det, Epetra_SerialDenseMatrix &piola_stress)
Epetra_SerialDenseVector w4_gmrf
void get_material_parameters(unsigned int &e_lid, unsigned int &gp)
Epetra_SerialDenseVector E3
std::vector< int > local_cells
clc clear all close all mesh
int n_local_nodes_without_ghosts
void shape_functions(Epetra_SerialDenseVector &N, double &xi, double &eta, double &zeta)
Epetra_Import * ImportToOverlapMap
void get_constitutive_tensors_static_condensation(Epetra_SerialDenseMatrix &deformation_gradient, double &det, Epetra_SerialDenseVector &inverse_cauchy, Epetra_SerialDenseVector &piola_isc, Epetra_SerialDenseVector &piola_vol, Epetra_SerialDenseMatrix &tangent_piola_isc, Epetra_SerialDenseMatrix &tangent_piola_vol)
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)
std::vector< int > local_dof_without_ghosts
Epetra_SerialDenseVector a
void assemblePureDirichlet_homogeneousForcing(Epetra_Vector &x, Epetra_FECrsMatrix &K, Epetra_FEVector &F)
Epetra_SerialDenseVector zeta_cells
Epetra_IntSerialDenseVector cells_nodes_p1_med
dirichletStripElongation_StochasticPolyconvexHGO(Epetra_Comm &comm, Teuchos::ParameterList &Parameters)
Epetra_SerialDenseVector w1_gmrf
void model_C(Epetra_SerialDenseMatrix &deformation_gradient, double &det, Epetra_SerialDenseVector &L, Epetra_SerialDenseVector &piola_isc, Epetra_SerialDenseVector &piola_vol, Epetra_SerialDenseMatrix &tangent_piola_isc, Epetra_SerialDenseMatrix &tangent_piola_vol)
Epetra_SerialDenseVector w3_gmrf
Epetra_SerialDenseVector b