33 #include "../generic/elements.h" 44 if(M.
nrow() != M.
ncol()) {
return false;}
72 "Undeformed metric tensor not square",
73 OOMPH_CURRENT_FUNCTION,
74 OOMPH_EXCEPTION_LOCATION);
82 "Deformed metric tensor does \n";
84 "not have same dimensions as the undeformed metric tensor\n";
87 OOMPH_CURRENT_FUNCTION,
88 OOMPH_EXCEPTION_LOCATION);
96 "Strain tensor passed to calculate_green_strain() does \n";
98 "not have same dimensions as the undeformed metric tensor\n";
101 OOMPH_CURRENT_FUNCTION,
102 OOMPH_EXCEPTION_LOCATION);
120 "Matrices passed to calculate_contravariant() are not of equal dimension",
121 OOMPH_CURRENT_FUNCTION,
122 OOMPH_EXCEPTION_LOCATION);
127 unsigned dim = Gdown.
ncol();
134 "Matrix passed to calculate_contravariant() is not square\n";
136 "non-square matrix inversion not implemented yet!\n";
139 OOMPH_CURRENT_FUNCTION,
140 OOMPH_EXCEPTION_LOCATION);
153 "Zero dimensional matrix",
154 OOMPH_CURRENT_FUNCTION,
155 OOMPH_EXCEPTION_LOCATION);
163 Gup(0,0) = 1.0/Gdown(0,0);
170 det = Gdown(0,0)*Gdown(1,1) - Gdown(0,1)*Gdown(1,0);
172 Gup(0,0) = Gdown(1,1)/det;
173 Gup(0,1) = -Gdown(0,1)/det;
174 Gup(1,0) = -Gdown(1,0)/det;
175 Gup(1,1) = Gdown(0,0)/det;
181 det = Gdown(0,0)*Gdown(1,1)*Gdown(2,2)
182 + Gdown(0,1)*Gdown(1,2)*Gdown(2,0)
183 + Gdown(0,2)*Gdown(1,0)*Gdown(2,1)
184 - Gdown(0,0)*Gdown(1,2)*Gdown(2,1)
185 - Gdown(0,1)*Gdown(1,0)*Gdown(2,2)
186 - Gdown(0,2)*Gdown(1,1)*Gdown(2,0);
189 Gup(0,0) = (Gdown(1,1)*Gdown(2,2) - Gdown(1,2)*Gdown(2,1))/det;
190 Gup(0,1) = -(Gdown(0,1)*Gdown(2,2) - Gdown(0,2)*Gdown(2,1))/det;
191 Gup(0,2) = (Gdown(0,1)*Gdown(1,2) - Gdown(0,2)*Gdown(1,1))/det;
192 Gup(1,0) = -(Gdown(1,0)*Gdown(2,2) - Gdown(1,2)*Gdown(2,0))/det;
193 Gup(1,1) = (Gdown(0,0)*Gdown(2,2) - Gdown(0,2)*Gdown(2,0))/det;
194 Gup(1,2) = -(Gdown(0,0)*Gdown(1,2) - Gdown(0,2)*Gdown(1,0))/det;
195 Gup(2,0) = (Gdown(1,0)*Gdown(2,1) - Gdown(1,1)*Gdown(2,0))/det;
196 Gup(2,1) = -(Gdown(0,0)*Gdown(2,1) - Gdown(0,1)*Gdown(2,0))/det;
197 Gup(2,2) = (Gdown(0,0)*Gdown(1,1) - Gdown(0,1)*Gdown(1,0))/det;
201 throw OomphLibError(
"Dimension of matrix must be 0, 1, 2 or 3\n",
202 OOMPH_CURRENT_FUNCTION,
203 OOMPH_EXCEPTION_LOCATION);
223 const unsigned dim = Gdown.
ncol();
230 "Matrix passed to calculate_contravariant() is not square\n";
232 "non-square matrix inversion not implemented yet!\n";
235 OOMPH_CURRENT_FUNCTION,
236 OOMPH_EXCEPTION_LOCATION);
249 "Zero dimensional matrix",
250 OOMPH_CURRENT_FUNCTION,
251 OOMPH_EXCEPTION_LOCATION);
257 d_detG_dG(0,0) = 1.0;
258 d_Gup_dG(0,0,0,0) = -1.0/(Gdown(0,0)*Gdown(0,0));
265 det = Gdown(0,0)*Gdown(1,1) - Gdown(0,1)*Gdown(1,0);
268 d_detG_dG(0,0) = Gdown(1,1);
270 d_detG_dG(0,1) = d_detG_dG(1,0) = -2.0*Gdown(0,1);
271 d_detG_dG(1,1) = Gdown(0,0);
275 const double det2 = det*det;
276 d_Gup_dG(0,0,0,0) = -Gdown(1,1)*d_detG_dG(0,0)/det2;
277 d_Gup_dG(0,0,0,1) = -Gdown(1,1)*d_detG_dG(0,1)/det2;
278 d_Gup_dG(0,0,1,1) = 1.0/det - Gdown(1,1)*d_detG_dG(1,1)/det2;
280 d_Gup_dG(0,1,0,0) = Gdown(0,1)*d_detG_dG(0,0)/det2;
281 d_Gup_dG(0,1,0,1) = -1.0/det + Gdown(0,1)*d_detG_dG(0,1)/det2;
282 d_Gup_dG(0,1,1,1) = Gdown(0,1)*d_detG_dG(1,1)/det2;
284 d_Gup_dG(1,1,0,0) = 1.0/det - Gdown(0,0)*d_detG_dG(0,0)/det2;
285 d_Gup_dG(1,1,0,1) = -Gdown(0,0)*d_detG_dG(0,1)/det2;
286 d_Gup_dG(1,1,1,1) = -Gdown(0,0)*d_detG_dG(1,1)/det2;
300 "Analytic derivatives of metric tensors not yet implemented in 3D\n",
301 OOMPH_CURRENT_FUNCTION,
302 OOMPH_EXCEPTION_LOCATION);
305 det = Gdown(0,0)*Gdown(1,1)*Gdown(2,2)
306 + Gdown(0,1)*Gdown(1,2)*Gdown(2,0)
307 + Gdown(0,2)*Gdown(1,0)*Gdown(2,1)
308 - Gdown(0,0)*Gdown(1,2)*Gdown(2,1)
309 - Gdown(0,1)*Gdown(1,0)*Gdown(2,2)
310 - Gdown(0,2)*Gdown(1,1)*Gdown(2,0);
325 throw OomphLibError(
"Dimension of matrix must be 0, 1, 2 or 3\n",
326 OOMPH_CURRENT_FUNCTION,
327 OOMPH_EXCEPTION_LOCATION);
348 const bool &symmetrize_tensor)
356 "Matrices passed are not of equal dimension",
357 OOMPH_CURRENT_FUNCTION,
358 OOMPH_EXCEPTION_LOCATION);
363 const unsigned dim = G.
ncol();
374 for(
unsigned i=0;
i<dim;
i++)
376 for(
unsigned j=0;j<dim;j++)
388 for(
unsigned i=0;
i<dim;
i++)
390 for(
unsigned j=
i;j<dim;j++)
392 G_pls(
i,j) += eps_fd;
393 G_pls(j,
i) = G_pls(
i,j);
398 for(
unsigned ii=0;ii<dim;ii++)
400 for(
unsigned jj=ii;jj<dim;jj++)
402 d_sigma_dG(ii,jj,
i,j)=(sigma_pls(ii,jj)-sigma(ii,jj))/eps_fd;
413 if(symmetrize_tensor)
415 for(
unsigned i=0;
i<dim;
i++)
417 for(
unsigned j=0;j<
i;j++)
419 for(
unsigned ii=0;ii<dim;ii++)
421 for(
unsigned jj=0;jj<ii;jj++)
423 d_sigma_dG(ii,jj,i,j)= d_sigma_dG(jj,ii,j,i);
448 const double &interpolated_solid_p,
451 const bool &symmetrize_tensor)
459 "Matrices passed are not of equal dimension",
460 OOMPH_CURRENT_FUNCTION,
461 OOMPH_EXCEPTION_LOCATION);
466 const unsigned dim = G.
ncol();
478 for (
unsigned i=0;
i<dim;
i++)
480 for (
unsigned j=0;j<dim;j++)
492 for(
unsigned i=0;
i<dim;
i++)
494 for (
unsigned j=
i;j<dim;j++)
496 G_pls(
i,j) += eps_fd;
497 G_pls(j,
i) = G_pls(
i,j);
501 g,G_pls,sigma_dev_pls,Gup_pls,detG_pls);
505 d_detG_dG(
i,j)=(detG_pls-detG)/eps_fd;
509 for (
unsigned ii=0;ii<dim;ii++)
511 for (
unsigned jj=ii;jj<dim;jj++)
513 d_sigma_dG(ii,jj,
i,j)=(
514 sigma_dev_pls(ii,jj)-interpolated_solid_p*Gup_pls(ii,jj)-
515 sigma(ii,jj))/eps_fd;
526 if(symmetrize_tensor)
528 for(
unsigned i=0;
i<dim;
i++)
530 for(
unsigned j=0;j<
i;j++)
532 d_detG_dG(i,j) = d_detG_dG(j,i);
534 for(
unsigned ii=0;ii<dim;ii++)
536 for(
unsigned jj=0;jj<ii;jj++)
538 d_sigma_dG(ii,jj,i,j)= d_sigma_dG(jj,ii,j,i);
559 const double &gen_dil,
560 const double &inv_kappa,
561 const double &interpolated_solid_p,
564 const bool &symmetrize_tensor)
572 "Matrices passed are not of equal dimension",
573 OOMPH_CURRENT_FUNCTION,
574 OOMPH_EXCEPTION_LOCATION);
579 const unsigned dim = G.
ncol();
589 double inv_kappa_pls;
592 for (
unsigned i=0;
i<dim;
i++)
594 for (
unsigned j=0;j<dim;j++)
606 for(
unsigned i=0;
i<dim;
i++)
608 for (
unsigned j=
i;j<dim;j++)
610 G_pls(
i,j) += eps_fd;
611 G_pls(j,
i) = G_pls(
i,j);
615 g,G_pls,sigma_dev_pls,Gup_pls,gen_dil_pls,inv_kappa_pls);
618 d_gen_dil_dG(
i,j)=(gen_dil_pls-gen_dil)/eps_fd;
622 for (
unsigned ii=0;ii<dim;ii++)
624 for (
unsigned jj=ii;jj<dim;jj++)
626 d_sigma_dG(ii,jj,
i,j)=(
627 sigma_dev_pls(ii,jj)-interpolated_solid_p*Gup_pls(ii,jj)-
628 sigma(ii,jj))/eps_fd;
639 if(symmetrize_tensor)
641 for(
unsigned i=0;
i<dim;
i++)
643 for(
unsigned j=0;j<
i;j++)
645 d_gen_dil_dG(i,j) = d_gen_dil_dG(j,i);
647 for(
unsigned ii=0;ii<dim;ii++)
649 for(
unsigned jj=0;jj<ii;jj++)
651 d_sigma_dG(ii,jj,i,j)= d_sigma_dG(jj,ii,j,i);
683 unsigned dim = G.
nrow();
691 double C1 = (*E_pt)/(2.0*(1.0+(*Nu_pt)));
692 double C2 = 2.0*(*Nu_pt)/(1.0-2.0*(*Nu_pt));
698 for (
unsigned i=0;
i<dim;
i++)
700 for (
unsigned j=
i;j<dim;j++)
702 strain(
i,j)=0.5*(G(
i,j) - g(
i,j));
707 for (
unsigned i=0;
i<dim;
i++)
709 for (
unsigned j=0;j<
i;j++)
711 strain(i,j)=strain(j,i);
716 for(
unsigned i=0;
i<dim;
i++)
718 for(
unsigned j=
i;j<dim;j++)
722 for(
unsigned k=0;k<dim;k++)
724 for(
unsigned l=0;l<dim;l++)
726 sigma(
i,j) += C1*(Gup(
i,k)*Gup(j,l)+Gup(
i,l)*Gup(j,k)+
727 C2*Gup(
i,j)*Gup(k,l))*strain(k,l);
734 for (
unsigned i=0;
i<dim;
i++)
736 for (
unsigned j=0;j<
i;j++)
738 sigma(i,j)=sigma(j,i);
763 unsigned dim = G.
nrow();
773 inv_kappa = (1.0 - 2.0*(*Nu_pt))*(1.0 + (*Nu_pt))/((*E_pt)*(*Nu_pt));
778 for(
unsigned i=0;
i<dim;
i++)
780 for(
unsigned j=0;j<dim;j++)
782 gen_dil += Gup(
i,j)*0.5*(G(
i,j) - g(
i,j));
813 unsigned dim = G.
nrow();
819 double C1 = (*E_pt)/(2.0*(1.0+(*Nu_pt)));
825 for (
unsigned i=0;
i<dim;
i++)
827 for (
unsigned j=
i;j<dim;j++)
829 strain(
i,j)=0.5*(G(
i,j) - g(
i,j));
834 for (
unsigned i=0;
i<dim;
i++)
836 for (
unsigned j=0;j<
i;j++)
838 strain(i,j)=strain(j,i);
843 for(
unsigned i=0;
i<dim;
i++)
845 for(
unsigned j=
i;j<dim;j++)
848 sigma_dev(
i,j) = 0.0;
849 for(
unsigned k=0;k<dim;k++)
851 for(
unsigned l=0;l<dim;l++)
854 C1*(Gup(
i,k)*Gup(j,l)+Gup(
i,l)*Gup(j,k))*strain(k,l);
861 for (
unsigned i=0;
i<dim;
i++)
863 for (
unsigned j=0;j<
i;j++)
865 sigma_dev(i,j)=sigma_dev(j,i);
899 unsigned dim = g.
nrow();
905 "IsotropicStrainEnergyFunctionConstitutiveLaw::";
906 function_name +=
"calculate_second_piola_kirchhoff_stress()";
909 "Check constitutive equations carefully when dim=1",
910 OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
925 for(
unsigned i=0;
i<dim;
i++)
927 for(
unsigned j=0;j<dim;j++)
929 I[0] += gup(
i,j)*G(
i,j);
930 I[1] += g(
i,j)*Gup(
i,j);
951 Strain_energy_function_pt->derivatives(I,dWdI);
957 if(std::fabs(dWdI[1]) > 0.0)
959 for(
unsigned i=0;
i<dim;
i++)
961 for(
unsigned j=0;j<dim;j++)
963 Bup(
i,j) = I[0]*gup(
i,j);
964 for(
unsigned r=0;r<dim;r++)
966 for(
unsigned s=0;
s<dim;
s++)
968 Bup(
i,j) -= gup(
i,r)*gup(j,
s)*G(r,
s);
979 double phi = 2.0*dWdI[0];
980 double psi = 2.0*dWdI[1];
981 double p = 2.0*dWdI[2]*I[2];
984 for(
unsigned i=0;
i<dim;
i++)
986 for(
unsigned j=0;j<dim;j++)
988 sigma(
i,j) = phi*gup(
i,j) + psi*Bup(
i,j) + p*Gup(
i,j);
1014 unsigned dim = g.
nrow();
1021 "IsotropicStrainEnergyFunctionConstitutiveLaw::";
1022 function_name +=
"calculate_second_piola_kirchhoff_stress()";
1025 "Check constitutive equations carefully when dim=1",
1026 OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
1042 for(
unsigned i=0;
i<dim;
i++)
1044 for(
unsigned j=0;j<dim;j++)
1046 I[0] += gup(
i,j)*G(
i,j);
1047 I[1] += g(
i,j)*Gup(
i,j);
1065 Strain_energy_function_pt->derivatives(I,dWdI);
1070 if(std::fabs(dWdI[1]) > 0.0)
1072 for(
unsigned i=0;
i<dim;
i++)
1074 for(
unsigned j=0;j<dim;j++)
1076 Bup(
i,j) = I[0]*gup(
i,j);
1077 for(
unsigned r=0;r<dim;r++)
1079 for(
unsigned s=0;
s<dim;
s++)
1081 Bup(
i,j) -= gup(
i,r)*gup(j,
s)*G(r,
s);
1089 double phi = 2.0*dWdI[0];
1090 double psi = 2.0*dWdI[1];
1098 K = 0.5*((I[0]-1.0)*phi +
1099 psi*(Bup(0,0)*G(0,0) + Bup(1,1)*G(1,1) + 2.0*Bup(0,1)*G(0,1)));
1104 K = (I[0]*phi + 2.0*I[1]*psi)/3.0;
1110 for(
unsigned i=0;
i<dim;
i++)
1112 for(
unsigned j=0;j<dim;j++)
1114 sigma_dev(
i,j) = phi*gup(
i,j) + psi*Bup(
i,j) - K*Gup(
i,j);
1132 double &gen_dil,
double &inv_kappa)
1141 unsigned dim = g.
nrow();
1147 "IsotropicStrainEnergyFunctionConstitutiveLaw::";
1148 function_name +=
"calculate_second_piola_kirchhoff_stress()";
1151 "Check constitutive equations carefully when dim=1",
1152 OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
1167 for(
unsigned i=0;
i<dim;
i++)
1169 for(
unsigned j=0;j<dim;j++)
1171 I[0] += gup(
i,j)*G(
i,j);
1172 I[1] += g(
i,j)*Gup(
i,j);
1193 Strain_energy_function_pt->derivatives(I,dWdI);
1198 if(std::fabs(dWdI[1]) > 0.0)
1200 for(
unsigned i=0;
i<dim;
i++)
1202 for(
unsigned j=0;j<dim;j++)
1204 Bup(
i,j) = I[0]*gup(
i,j);
1205 for(
unsigned r=0;r<dim;r++)
1207 for(
unsigned s=0;
s<dim;
s++)
1209 Bup(
i,j) -= gup(
i,r)*gup(j,
s)*G(r,
s);
1218 double phi = 2.0*dWdI[0];
1219 double psi = 2.0*dWdI[1];
1228 K = 0.5*((I[0]-1.0)*phi +
1229 psi*(Bup(0,0)*G(0,0) + Bup(1,1)*G(1,1) + 2.0*Bup(0,1)*G(0,1)));
1234 K = (I[0]*phi + 2.0*I[1]*psi)/3.0;
1244 gen_dil = 2.0*dWdI[2]*I[2] + K;
1248 for(
unsigned i=0;
i<dim;
i++)
1250 for(
unsigned j=0;j<dim;j++)
1252 sigma_dev(
i,j) = phi*gup(
i,j) + psi*Bup(
i,j) - K*Gup(
i,j);
unsigned long nrow() const
Return the number of rows of the matrix.
bool are_matrices_of_equal_dimensions(const DenseMatrix< double > &M1, const DenseMatrix< double > &M2)
Test whether two matrices are of equal dimensions.
virtual void calculate_d_second_piola_kirchhoff_stress_dG(const DenseMatrix< double > &g, const DenseMatrix< double > &G, const DenseMatrix< double > &sigma, RankFourTensor< double > &d_sigma_dG, const bool &symmetrize_tensor=true)
Calculate the derivatives of the contravariant 2nd Piola Kirchhoff stress tensor with respect to the ...
unsigned long ncol() const
Return the number of columns of the matrix.
void error_checking_in_input(const DenseMatrix< double > &g, const DenseMatrix< double > &G, DenseMatrix< double > &sigma)
Check for errors in the input, i.e. check that the dimensions of the arrays are all consistent...
void calculate_second_piola_kirchhoff_stress(const DenseMatrix< double > &g, const DenseMatrix< double > &G, DenseMatrix< double > &sigma)
Calculate the contravariant 2nd Piola Kirchhoff stress tensor. Arguments are the covariant undeformed...
virtual void calculate_second_piola_kirchhoff_stress(const DenseMatrix< double > &g, const DenseMatrix< double > &G, DenseMatrix< double > &sigma)=0
Calculate the contravariant 2nd Piola Kirchhoff stress tensor. Arguments are the covariant undeformed...
const std::complex< double > I(0.0, 1.0)
The imaginary unit.
void calculate_second_piola_kirchhoff_stress(const DenseMatrix< double > &g, const DenseMatrix< double > &G, DenseMatrix< double > &sigma)
Calculate the contravariant 2nd Piola Kirchhoff stress tensor. Arguments are the covariant undeformed...
double calculate_contravariant(const DenseMatrix< double > &Gcov, DenseMatrix< double > &Gcontra)
Calculate a contravariant tensor from a covariant tensor, and return the determinant of the covariant...
std::string string(const unsigned &i)
Return the i-th string or "" if the relevant string hasn't been defined.
void calculate_d_contravariant_dG(const DenseMatrix< double > &Gcov, RankFourTensor< double > &dGcontra_dG, DenseMatrix< double > &d_detG_dG)
Calculate the derivatives of the contravariant tensor and the derivatives of the determinant of the c...
bool is_matrix_square(const DenseMatrix< double > &M)
Test whether a matrix is square.
static double Default_fd_jacobian_step
Double used for the default finite difference step in elemental jacobian calculations.