1 #ifndef ELASTOPLASTIC_H
2 #define ELASTOPLASTIC_H
9 #include PROTEUS_LAPACK_H
10 #include PROTEUS_BLAS_H
21 #include "../mprans/ArgumentsDict.h"
22 #include "xtensor-python/pyarray.hpp"
23 #include "pybind11/pybind11.h"
25 namespace py = pybind11;
37 template<
class CompKernelType,
39 int nQuadraturePoints_element,
40 int nDOF_mesh_trial_element,
41 int nDOF_trial_element,
42 int nDOF_test_element,
43 int nQuadraturePoints_elementBoundary>
98 inline void elasticStress(
const double* C,
const double* strain,
double* stress)
100 stress[
sXX] = C[0]*strain[
sXX] + C[1]*(strain[
sYY] +strain[
sZZ]);
101 stress[
sYY] = C[0]*strain[
sYY] + C[1]*(strain[
sXX] +strain[
sZZ]);
102 stress[
sZZ] = C[0]*strain[
sZZ] + C[1]*(strain[
sXX] +strain[
sYY]);
108 inline void elasticStrain(
const double* Cinv,
const double* stress,
double* strain)
110 strain[
sXX] = Cinv[0]*stress[
sXX] + Cinv[1]*(stress[
sYY] +stress[
sZZ]);
111 strain[
sYY] = Cinv[0]*stress[
sYY] + Cinv[1]*(stress[
sXX] +stress[
sZZ]);
112 strain[
sZZ] = Cinv[0]*stress[
sZZ] + Cinv[1]*(stress[
sXX] +stress[
sYY]);
118 inline void elasticModuli(
const double& E,
const double& nu,
double* C,
double* Cinv)
161 if(fabs(1.0-I[i+j*
nSymTen]) > 1.0e-12)
162 std::cout<<
"I["<<i<<
"]["<<j<<
"]="<<I[i+j*
nSymTen]<<std::endl;
164 if(fabs(I[i+j*
nSymTen]) > 1.0e-12)
165 std::cout<<
"I["<<i<<
"]["<<j<<
"]="<<I[i+j*
nSymTen]<<std::endl;
171 double&
f,
double*
df,
double*
r,
double* dr,
double& stress_3)
231 mcdp(materialProperties[5],
232 materialProperties[7],
233 materialProperties[6],
243 inline void differenceJacobian(
const double* materialProperties,
const double* stress,
const double&
f,
double *
df,
const double*
r,
double* dr)
252 stress_plus_delta[i] = stress[i];
256 double Delta_stress = 1.0e-8*stress[j] + 1.0e-8;
257 stress_plus_delta[j] += Delta_stress;
259 df[j] = (f_delta -
f)/Delta_stress;
262 dr[k+
nSymTen*j] = (r_delta[k] -
r[k])/Delta_stress;
264 stress_plus_delta[j] = stress[j];
268 const double pore_pressure,
269 const double* materialProperties,
270 const double* strain0,
271 const double* strain_last,
272 const double* Delta_strain,
273 const double* plasticStrain_last,
274 double* plasticStrain,
278 int its=0, maxIts=25;
279 double E=materialProperties[0];
280 const double nu=materialProperties[1],
281 phi=materialProperties[5];
299 minusDelta_plasticStrain[
nSymTen],
313 stress_3_init,stress_3;
326 bool useSemiImplicit=
false;
327 bool useDifferenceJacobian=
false;
328 bool useFullPivoting=
false;
329 bool useDumbNewton=
false;
330 bool useContinuumTangentModulus=
false;
331 bool useLineSearch=
false;
332 bool useInnerPicard=
false;
333 bool useOuterPicard=bool(usePicard);
334 bool predictorPhase =
false;
335 int predictorPhaseIts=5;
336 std::vector<double> fhist,ahist;
341 const double n_e = 0.6,
342 P_a = materialProperties[12],
346 E =K_i*P_a*pow(fmax(stress_3_init,P_a)/P_a,n_e);
360 effectiveStrain[i] = strain_last[i] - plasticStrain_last[i];
374 Delta_stress[i] = 0.0;
375 minusDelta_plasticStrain[i] = 0.0;
376 plasticStrain[i] = plasticStrain_last[i];
377 effectiveStrain[i] = strain_last[i] + Delta_strain[i] - plasticStrain_last[i];
382 if (useDifferenceJacobian)
400 while ((
f >= f_atol || aNorm >= a_atol) && its < maxIts)
442 dgetc2_(&N,A,&N,IPIV,JPIV,&INFO);
443 dgesc2_(&N,A,&N,Aa,IPIV,JPIV,&SCALE);
444 dgesc2_(&N,A,&N,Ar,IPIV,JPIV,&SCALE);
448 dgetrf_(&N,&N,A,&N,IPIV,&INFO);
449 dgetrs_(&TRANS,&N,&NRHS,A,&N,IPIV,Aa,&N,&INFO);
450 dgetrs_(&TRANS,&N,&NRHS,A,&N,IPIV,Ar,&N,&INFO);
462 if (fabs(dfAr) < 1.0e-8)
463 dfAr = copysign(1.0e-8,dfAr);
464 Delta_lambda_incr = (
f-dfAa)/dfAr;
468 Delta_stress_incr[i] = - Aa[i] - Delta_lambda_incr*Ar[i];
473 dgetc2_(&NR,
B,&NR,IPIVR,JPIVR,&INFOR);
474 dgesc2_(&NR,
B,&NR,
R,IPIVR,JPIVR,&SCALER);
477 Delta_stress_incr[i] =
R[i];
482 Delta_lambda_old = Delta_lambda;
483 Delta_lambda += Delta_lambda_incr;
486 Delta_stress_old[i] = Delta_stress[i];
487 Delta_stress[i] += Delta_stress_incr[i];
488 stress_old[i] = stress[i];
489 stress[i] += Delta_stress_incr[i];
492 if (useDifferenceJacobian)
509 int linesearches=0,max_linesearches=100;
510 while(useLineSearch && (
f > 0.99*f_last) && (linesearches < max_linesearches))
513 double ds = pow(0.5,linesearches+1);
514 Delta_lambda = Delta_lambda_old + ds*Delta_lambda_incr;
517 Delta_stress[i] = Delta_stress_old[i] + ds*Delta_stress_incr[i];
518 stress[i] = stress_old[i] + ds*Delta_stress_incr[i];
521 if (useDifferenceJacobian)
526 if (useSemiImplicit || predictorPhase)
539 if (linesearches > 0)
543 std::cout<<
"f"<<std::endl;
547 std::cout<<
"s"<<std::endl;
557 a[i] = minusDelta_plasticStrain[i] + Delta_lambda*
r[i];
559 stressNorm+=stress[i]*stress[i];
562 stressNorm = sqrt(stressNorm);
649 plasticStrain[i] = plasticStrain_last[i] - minusDelta_plasticStrain[i];
662 std::cout<<
"Constiutive relation iteration failed "<<
f<<
'\t'<<stressNorm<<std::endl;
664 useContinuumTangentModulus=
true;
673 else if(useContinuumTangentModulus)
688 if (fabs(dfCr) < 1.0e-8)
689 dfCr = copysign(1.0e-8,dfCr);
710 dgetrf_(&N,&N,A,&N,IPIV,&INFO);
712 dgetrs_(&TRANS,&N,&NRHS,A,&N,IPIV,dfA,&N,&INFO);
714 dgetrs_(&TRANS,&N,&NRHS,A,&N,IPIV,Aa,&N,&INFO);
715 dgetrs_(&TRANS,&N,&NRHS,A,&N,IPIV,Ar,&N,&INFO);
721 dgetri_(&N,A,&N,IPIV,WORK,&LWORK,&INFO);
722 if (fabs(dfAr) < 1.0e-8)
723 dfAr = copysign(1.0e-8,dfAr);
738 for (
int i=0; i<nSpace; i++)
739 stress[i] -= pore_pressure;
743 const int& isDOFBoundary_u,
744 const int& isDOFBoundary_v,
745 const int& isDOFBoundary_w,
746 const int& isStressFluxBoundary_u,
747 const int& isStressFluxBoundary_v,
748 const int& isStressFluxBoundary_w,
749 const double& penalty,
756 const double& bc_stressFlux_u,
757 const double& bc_stressFlux_v,
758 const double& bc_stressFlux_w,
759 const double* stress,
760 const double* normal,
761 double& stressFlux_u,
762 double& stressFlux_v,
763 double& stressFlux_w)
766 if (isDOFBoundary_u == 1)
768 stressFlux_u = -(stress[
sXX]*normal[
X] + stress[
sXY]*normal[
Y] + stress[
sXZ]*normal[
Z] - penalty*(
u - bc_u));
770 else if(isStressFluxBoundary_u == 1)
772 stressFlux_u = -bc_stressFlux_u + normal[
X]*pore_pressure_ext;
779 if (isDOFBoundary_v == 1)
781 stressFlux_v = -(stress[
sYX]*normal[
X] + stress[
sYY]*normal[
Y] + stress[
sYZ]*normal[
Z] - penalty*(
v - bc_v));
783 else if(isStressFluxBoundary_v == 1)
785 stressFlux_v = -bc_stressFlux_v + normal[
Y]*pore_pressure_ext;
792 if (isDOFBoundary_w == 1)
794 stressFlux_w = -(stress[
sZX]*normal[
X] + stress[
sZY]*normal[
Y] + stress[
sZZ]*normal[
Z] - penalty*(
w - bc_w));
796 else if(isStressFluxBoundary_w == 1)
798 stressFlux_w = -bc_stressFlux_w + normal[
Z]*pore_pressure_ext;
807 const int& isDOFBoundary_v,
808 const int& isDOFBoundary_w,
809 const double* normal,
810 const double* dstress,
811 const double& penalty,
812 const double& disp_trial,
813 const double* disp_grad_trial,
814 double& dstressFlux_u_u,
815 double& dstressFlux_u_v,
816 double& dstressFlux_u_w,
817 double& dstressFlux_v_u,
818 double& dstressFlux_v_v,
819 double& dstressFlux_v_w,
820 double& dstressFlux_w_u,
821 double& dstressFlux_w_v,
822 double& dstressFlux_w_w)
825 if (isDOFBoundary_u == 1)
845 dstressFlux_u_u = 0.0;
846 dstressFlux_u_v = 0.0;
847 dstressFlux_u_w = 0.0;
850 if (isDOFBoundary_v == 1)
870 dstressFlux_v_u = 0.0;
871 dstressFlux_v_v = 0.0;
872 dstressFlux_v_w = 0.0;
875 if (isDOFBoundary_w == 1)
895 dstressFlux_w_u = 0.0;
896 dstressFlux_w_v = 0.0;
897 dstressFlux_w_w = 0.0;
903 xt::pyarray<double>& mesh_trial_ref = args.
array<
double>(
"mesh_trial_ref");
904 xt::pyarray<double>& mesh_grad_trial_ref = args.
array<
double>(
"mesh_grad_trial_ref");
905 xt::pyarray<double>& mesh_dof = args.
array<
double>(
"mesh_dof");
906 xt::pyarray<int>& mesh_l2g = args.
array<
int>(
"mesh_l2g");
907 xt::pyarray<double>& dV_ref = args.
array<
double>(
"dV_ref");
908 xt::pyarray<double>& disp_trial_ref = args.
array<
double>(
"disp_trial_ref");
909 xt::pyarray<double>& disp_grad_trial_ref = args.
array<
double>(
"disp_grad_trial_ref");
910 xt::pyarray<double>& disp_test_ref = args.
array<
double>(
"disp_test_ref");
911 xt::pyarray<double>& disp_grad_test_ref = args.
array<
double>(
"disp_grad_test_ref");
912 xt::pyarray<double>& mesh_trial_trace_ref = args.
array<
double>(
"mesh_trial_trace_ref");
913 xt::pyarray<double>& mesh_grad_trial_trace_ref = args.
array<
double>(
"mesh_grad_trial_trace_ref");
914 xt::pyarray<double>& dS_ref = args.
array<
double>(
"dS_ref");
915 xt::pyarray<double>& disp_trial_trace_ref = args.
array<
double>(
"disp_trial_trace_ref");
916 xt::pyarray<double>& disp_grad_trial_trace_ref = args.
array<
double>(
"disp_grad_trial_trace_ref");
917 xt::pyarray<double>& disp_test_trace_ref = args.
array<
double>(
"disp_test_trace_ref");
918 xt::pyarray<double>& disp_grad_test_trace_ref = args.
array<
double>(
"disp_grad_test_trace_ref");
919 xt::pyarray<double>& normal_ref = args.
array<
double>(
"normal_ref");
920 xt::pyarray<double>& boundaryJac_ref = args.
array<
double>(
"boundaryJac_ref");
921 xt::pyarray<double>& ebqe_penalty = args.
array<
double>(
"ebqe_penalty");
922 int gravityStep = args.
scalar<
int>(
"gravityStep");
923 int nElements_global = args.
scalar<
int>(
"nElements_global");
924 xt::pyarray<int>& materialTypes = args.
array<
int>(
"materialTypes");
925 int nMaterialProperties = args.
scalar<
int>(
"nMaterialProperties");
926 xt::pyarray<double>& materialProperties = args.
array<
double>(
"materialProperties");
927 double pore_fluid_unit_weight = args.
scalar<
double>(
"pore_fluid_unit_weight");
928 xt::pyarray<double>& pore_pressure_head_dof = args.
array<
double>(
"pore_pressure_head_dof");
929 xt::pyarray<double>& q_strain = args.
array<
double>(
"q_strain");
930 xt::pyarray<double>& q_strain0 = args.
array<
double>(
"q_strain0");
931 xt::pyarray<double>& q_strain_last = args.
array<
double>(
"q_strain_last");
932 xt::pyarray<double>& q_plasticStrain = args.
array<
double>(
"q_plasticStrain");
933 xt::pyarray<double>& q_plasticStrain_last = args.
array<
double>(
"q_plasticStrain_last");
934 xt::pyarray<double>& ebqe_strain = args.
array<
double>(
"ebqe_strain");
935 xt::pyarray<double>& ebqe_strain0 = args.
array<
double>(
"ebqe_strain0");
936 xt::pyarray<double>& ebqe_strain_last = args.
array<
double>(
"ebqe_strain_last");
937 xt::pyarray<double>& ebqe_plasticStrain = args.
array<
double>(
"ebqe_plasticStrain");
938 xt::pyarray<double>& ebqe_plasticStrain_last = args.
array<
double>(
"ebqe_plasticStrain_last");
939 xt::pyarray<int>& disp_l2g = args.
array<
int>(
"disp_l2g");
940 xt::pyarray<double>& u_dof = args.
array<
double>(
"u_dof");
941 xt::pyarray<double>& v_dof = args.
array<
double>(
"v_dof");
942 xt::pyarray<double>& w_dof = args.
array<
double>(
"w_dof");
943 xt::pyarray<double>& bodyForce = args.
array<
double>(
"bodyForce");
944 int offset_u = args.
scalar<
int>(
"offset_u");
945 int offset_v = args.
scalar<
int>(
"offset_v");
946 int offset_w = args.
scalar<
int>(
"offset_w");
947 int stride_u = args.
scalar<
int>(
"stride_u");
948 int stride_v = args.
scalar<
int>(
"stride_v");
949 int stride_w = args.
scalar<
int>(
"stride_w");
950 xt::pyarray<double>& globalResidual = args.
array<
double>(
"globalResidual");
951 int nExteriorElementBoundaries_global = args.
scalar<
int>(
"nExteriorElementBoundaries_global");
952 xt::pyarray<int>& exteriorElementBoundariesArray = args.
array<
int>(
"exteriorElementBoundariesArray");
953 xt::pyarray<int>& elementBoundaryElementsArray = args.
array<
int>(
"elementBoundaryElementsArray");
954 xt::pyarray<int>& elementBoundaryLocalElementBoundariesArray = args.
array<
int>(
"elementBoundaryLocalElementBoundariesArray");
955 xt::pyarray<int>& isDOFBoundary_u = args.
array<
int>(
"isDOFBoundary_u");
956 xt::pyarray<int>& isDOFBoundary_v = args.
array<
int>(
"isDOFBoundary_v");
957 xt::pyarray<int>& isDOFBoundary_w = args.
array<
int>(
"isDOFBoundary_w");
958 xt::pyarray<int>& isStressFluxBoundary_u = args.
array<
int>(
"isStressFluxBoundary_u");
959 xt::pyarray<int>& isStressFluxBoundary_v = args.
array<
int>(
"isStressFluxBoundary_v");
960 xt::pyarray<int>& isStressFluxBoundary_w = args.
array<
int>(
"isStressFluxBoundary_w");
961 xt::pyarray<double>& ebqe_bc_u_ext = args.
array<
double>(
"ebqe_bc_u_ext");
962 xt::pyarray<double>& ebqe_bc_v_ext = args.
array<
double>(
"ebqe_bc_v_ext");
963 xt::pyarray<double>& ebqe_bc_w_ext = args.
array<
double>(
"ebqe_bc_w_ext");
964 xt::pyarray<double>& ebqe_bc_stressFlux_u_ext = args.
array<
double>(
"ebqe_bc_stressFlux_u_ext");
965 xt::pyarray<double>& ebqe_bc_stressFlux_v_ext = args.
array<
double>(
"ebqe_bc_stressFlux_v_ext");
966 xt::pyarray<double>& ebqe_bc_stressFlux_w_ext = args.
array<
double>(
"ebqe_bc_stressFlux_w_ext");
972 const int usePicard = 0;
973 for(
int eN=0;eN<nElements_global;eN++)
977 elementResidual_u[nDOF_test_element],
978 elementResidual_v[nDOF_test_element],
979 elementResidual_w[nDOF_test_element];
980 for (
int i=0;i<nDOF_test_element;i++)
982 elementResidual_u[i]=0.0;
983 elementResidual_v[i]=0.0;
984 elementResidual_w[i]=0.0;
989 for(
int k=0;k<nQuadraturePoints_element;k++)
992 register int eN_k = eN*nQuadraturePoints_element+k,
993 eN_k_nSpace=eN_k*nSpace,
994 eN_nDOF_trial_element = eN*nDOF_trial_element,
995 eN_nDOF_mesh_trial_element = eN*nDOF_mesh_trial_element;
996 register double u=0.0,
v=0.0,
w=0.0,
1000 *grad_w(&
D[2*nSpace]),
1003 jacInv[nSpace*nSpace],
1004 disp_grad_trial[nDOF_trial_element*nSpace],
1005 disp_test_dV[nDOF_trial_element],
1006 disp_grad_test_dV[nDOF_test_element*nSpace],
1008 G[nSpace*nSpace],G_dd_G,tr_G,
1009 stress[
ck.nSymTen],strain[
ck.nSymTen],
1010 Delta_strain[
ck.nSymTen],dstress[
ck.nSymTen*
ck.nSymTen],pore_pressure=0.0;
1012 ck.calculateMapping_element(eN,
1016 mesh_trial_ref.data(),
1017 mesh_grad_trial_ref.data(),
1023 ck.mapping.valFromDOF(pore_pressure_head_dof.data(),&mesh_l2g.data()[eN_nDOF_mesh_trial_element],&mesh_trial_ref.data()[k*nDOF_mesh_trial_element],pore_pressure);
1025 pore_pressure *= pore_fluid_unit_weight;
1026 pore_pressure = fmax(pore_pressure,0.0);
1029 dV = fabs(jacDet)*dV_ref.data()[k];
1030 ck.calculateG(jacInv,G,G_dd_G,tr_G);
1032 ck.gradTrialFromRef(&disp_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,disp_grad_trial);
1034 ck.valFromDOF(u_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],&disp_trial_ref.data()[k*nDOF_trial_element],
u);
1035 ck.valFromDOF(v_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],&disp_trial_ref.data()[k*nDOF_trial_element],
v);
1036 ck.valFromDOF(w_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],&disp_trial_ref.data()[k*nDOF_trial_element],
w);
1038 ck.gradFromDOF(u_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],disp_grad_trial,grad_u);
1039 ck.gradFromDOF(v_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],disp_grad_trial,grad_v);
1040 ck.gradFromDOF(w_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],disp_grad_trial,grad_w);
1042 for (
int j=0;j<nDOF_trial_element;j++)
1044 disp_test_dV[j] = disp_test_ref.data()[k*nDOF_trial_element+j]*dV;
1045 for (
int I=0;I<nSpace;I++)
1047 disp_grad_test_dV[j*nSpace+I] = disp_grad_trial[j*nSpace+I]*dV;
1061 elasticModuli(materialProperties.data()[materialTypes.data()[eN]*nMaterialProperties],
1062 materialProperties.data()[materialTypes.data()[eN]*nMaterialProperties+1],
1064 if (gravityStep == 2)
1066 double f,
df[
nSymTen],
r[
nSymTen],dr[
nSymTen*
nSymTen],stress_3_init,E=materialProperties.data()[materialTypes.data()[eN]*nMaterialProperties],nu=materialProperties.data()[materialTypes.data()[eN]*nMaterialProperties+1];
1069 stress,
f,
df,
r,dr,stress_3_init);
1070 const double n_e = 0.6,
1071 P_a = materialProperties.data()[materialTypes.data()[eN]*nMaterialProperties+12],
1075 E =K_i*P_a*pow(fmax(stress_3_init,P_a)/P_a,n_e);
1081 strain[i] = Delta_strain[i] + q_strain_last.data()[eN_k*
nSymTen+i];
1086 for (
int i=0; i<nSpace; i++)
1087 stress[i] -= pore_pressure;
1092 &materialProperties.data()[materialTypes.data()[eN]*nMaterialProperties],
1093 &q_strain0.data()[eN_k*
nSymTen],
1094 &q_strain_last.data()[eN_k*
nSymTen],
1096 &q_plasticStrain_last.data()[eN_k*
nSymTen],
1097 &q_plasticStrain.data()[eN_k*
nSymTen],
1102 q_strain.data()[eN_k*
nSymTen+i] = q_strain_last.data()[eN_k*
nSymTen + i] + Delta_strain[i];
1111 for(
int i=0;i<nDOF_test_element;i++)
1113 register int i_nSpace=i*nSpace;
1114 elementResidual_u[i] +=
ck.Stress_u_weak(stress,&disp_grad_test_dV[i_nSpace]) +
1115 ck.Reaction_weak(-bodyForce.data()[eN_k_nSpace+0],disp_test_dV[i]);
1116 elementResidual_v[i] +=
ck.Stress_v_weak(stress,&disp_grad_test_dV[i_nSpace]) +
1117 ck.Reaction_weak(-bodyForce.data()[eN_k_nSpace+1],disp_test_dV[i]);
1118 elementResidual_w[i] +=
ck.Stress_w_weak(stress,&disp_grad_test_dV[i_nSpace]) +
1119 ck.Reaction_weak(-bodyForce.data()[eN_k_nSpace+2],disp_test_dV[i]);
1132 for(
int i=0;i<nDOF_test_element;i++)
1134 register int eN_i=eN*nDOF_test_element+i;
1136 globalResidual.data()[offset_u+stride_u*disp_l2g.data()[eN_i]] += elementResidual_u[i];
1137 globalResidual.data()[offset_v+stride_v*disp_l2g.data()[eN_i]] += elementResidual_v[i];
1138 globalResidual.data()[offset_w+stride_w*disp_l2g.data()[eN_i]] += elementResidual_w[i];
1147 for (
int ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
1149 register int ebN = exteriorElementBoundariesArray.data()[ebNE],
1150 eN = elementBoundaryElementsArray.data()[ebN*2+0],
1151 ebN_local = elementBoundaryLocalElementBoundariesArray.data()[ebN*2+0],
1152 eN_nDOF_trial_element = eN*nDOF_trial_element,
1153 eN_nDOF_mesh_trial_element = eN*nDOF_mesh_trial_element;
1154 register double elementResidual_u[nDOF_test_element],
1155 elementResidual_v[nDOF_test_element],
1156 elementResidual_w[nDOF_test_element];
1157 for (
int i=0;i<nDOF_test_element;i++)
1159 elementResidual_u[i]=0.0;
1160 elementResidual_v[i]=0.0;
1161 elementResidual_w[i]=0.0;
1163 for (
int kb=0;kb<nQuadraturePoints_elementBoundary;kb++)
1165 register int ebNE_kb = ebNE*nQuadraturePoints_elementBoundary+kb,
1166 ebN_local_kb = ebN_local*nQuadraturePoints_elementBoundary+kb,
1167 ebN_local_kb_nSpace = ebN_local_kb*nSpace;
1168 register double u_ext=0.0,
1173 *grad_v_ext(&
D[nSpace]),
1174 *grad_w_ext(&
D[2*nSpace]),
1178 jac_ext[nSpace*nSpace],
1180 jacInv_ext[nSpace*nSpace],
1181 boundaryJac[nSpace*(nSpace-1)],
1182 metricTensor[(nSpace-1)*(nSpace-1)],
1183 metricTensorDetSqrt,
1184 dS,disp_test_dS[nDOF_test_element],
1185 disp_grad_trial_trace[nDOF_trial_element*nSpace],
1186 normal[3],x_ext,y_ext,z_ext,
1187 G[nSpace*nSpace],G_dd_G,tr_G,h_penalty,
1188 Delta_strain[
ck.nSymTen],
1189 strain[
ck.nSymTen],stress[
ck.nSymTen],dstress[
ck.nSymTen*
ck.nSymTen],
1190 stressFlux_u,stressFlux_v,stressFlux_w,pore_pressure_ext;
1192 ck.calculateMapping_elementBoundary(eN,
1198 mesh_trial_trace_ref.data(),
1199 mesh_grad_trial_trace_ref.data(),
1200 boundaryJac_ref.data(),
1206 metricTensorDetSqrt,
1211 ck.mapping.valFromDOF(pore_pressure_head_dof.data(),&mesh_l2g.data()[eN_nDOF_mesh_trial_element],&mesh_trial_trace_ref.data()[ebN_local_kb*nDOF_mesh_trial_element],pore_pressure_ext);
1212 pore_pressure_ext *= pore_fluid_unit_weight;
1213 pore_pressure_ext = fmax(pore_pressure_ext,0.0);
1214 dS = metricTensorDetSqrt*dS_ref.data()[kb];
1217 ck.calculateG(jacInv_ext,G,G_dd_G,tr_G);
1220 ck.gradTrialFromRef(&disp_grad_trial_trace_ref.data()[ebN_local_kb_nSpace*nDOF_trial_element],jacInv_ext,disp_grad_trial_trace);
1222 ck.valFromDOF(u_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],&disp_trial_trace_ref.data()[ebN_local_kb*nDOF_test_element],u_ext);
1223 ck.valFromDOF(v_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],&disp_trial_trace_ref.data()[ebN_local_kb*nDOF_test_element],v_ext);
1224 ck.valFromDOF(w_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],&disp_trial_trace_ref.data()[ebN_local_kb*nDOF_test_element],w_ext);
1225 ck.gradFromDOF(u_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],disp_grad_trial_trace,grad_u_ext);
1226 ck.gradFromDOF(v_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],disp_grad_trial_trace,grad_v_ext);
1227 ck.gradFromDOF(w_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],disp_grad_trial_trace,grad_w_ext);
1229 for (
int j=0;j<nDOF_trial_element;j++)
1231 disp_test_dS[j] = disp_test_trace_ref.data()[ebN_local_kb*nDOF_test_element+j]*dS;
1236 bc_u_ext = isDOFBoundary_u.data()[ebNE_kb]*ebqe_bc_u_ext.data()[ebNE_kb]+(1-isDOFBoundary_u.data()[ebNE_kb])*u_ext;
1237 bc_v_ext = isDOFBoundary_v.data()[ebNE_kb]*ebqe_bc_v_ext.data()[ebNE_kb]+(1-isDOFBoundary_v.data()[ebNE_kb])*v_ext;
1238 bc_w_ext = isDOFBoundary_w.data()[ebNE_kb]*ebqe_bc_w_ext.data()[ebNE_kb]+(1-isDOFBoundary_w.data()[ebNE_kb])*w_ext;
1246 elasticModuli(materialProperties.data()[materialTypes.data()[eN]*nMaterialProperties],
1247 materialProperties.data()[materialTypes.data()[eN]*nMaterialProperties+1],
1249 if (gravityStep == 2)
1251 double f,
df[
nSymTen],
r[
nSymTen],dr[
nSymTen*
nSymTen],stress_3_init,E=materialProperties.data()[materialTypes.data()[eN]*nMaterialProperties],nu=materialProperties.data()[materialTypes.data()[eN]*nMaterialProperties+1];
1254 stress,
f,
df,
r,dr,stress_3_init);
1255 const double n_e = 0.6,
1256 P_a = materialProperties.data()[materialTypes.data()[eN]*nMaterialProperties+12],
1260 E =K_i*P_a*pow(fmax(stress_3_init,P_a)/P_a,n_e);
1266 strain[i] = Delta_strain[i] + ebqe_strain_last.data()[ebNE_kb*
nSymTen+i];
1271 for (
int i=0;i<nSpace;i++)
1272 stress[i] -= pore_pressure_ext;
1277 &materialProperties.data()[materialTypes.data()[eN]*nMaterialProperties],
1278 &ebqe_strain0.data()[ebNE_kb*
nSymTen],
1279 &ebqe_strain_last.data()[ebNE_kb*
nSymTen],
1281 &ebqe_plasticStrain_last.data()[ebNE_kb*
nSymTen],
1282 &ebqe_plasticStrain.data()[ebNE_kb*
nSymTen],
1287 ebqe_strain.data()[ebNE_kb*
nSymTen+i] = ebqe_strain_last.data()[ebNE_kb*
nSymTen+i] + Delta_strain[i];
1292 double E=materialProperties.data()[materialTypes.data()[eN]*nMaterialProperties],
1293 nu=materialProperties.data()[materialTypes.data()[eN]*nMaterialProperties+1];
1294 h_penalty=(E/(1.0+nu))*(1.0 + (nu/(1.0-2.0*nu)))*ebqe_penalty.data()[ebNE_kb];
1296 isDOFBoundary_u.data()[ebNE_kb],
1297 isDOFBoundary_v.data()[ebNE_kb],
1298 isDOFBoundary_w.data()[ebNE_kb],
1299 isStressFluxBoundary_u.data()[ebNE_kb],
1300 isStressFluxBoundary_v.data()[ebNE_kb],
1301 isStressFluxBoundary_w.data()[ebNE_kb],
1309 ebqe_bc_stressFlux_u_ext.data()[ebNE_kb],
1310 ebqe_bc_stressFlux_v_ext.data()[ebNE_kb],
1311 ebqe_bc_stressFlux_w_ext.data()[ebNE_kb],
1320 for (
int i=0;i<nDOF_test_element;i++)
1322 elementResidual_u[i] +=
ck.ExteriorElementBoundaryStressFlux(stressFlux_u,disp_test_dS[i]);
1323 elementResidual_v[i] +=
ck.ExteriorElementBoundaryStressFlux(stressFlux_v,disp_test_dS[i]);
1324 elementResidual_w[i] +=
ck.ExteriorElementBoundaryStressFlux(stressFlux_w,disp_test_dS[i]);
1330 for (
int i=0;i<nDOF_test_element;i++)
1332 int eN_i = eN*nDOF_test_element+i;
1334 globalResidual.data()[offset_u+stride_u*disp_l2g.data()[eN_i]]+=elementResidual_u[i];
1335 globalResidual.data()[offset_v+stride_v*disp_l2g.data()[eN_i]]+=elementResidual_v[i];
1336 globalResidual.data()[offset_w+stride_w*disp_l2g.data()[eN_i]]+=elementResidual_w[i];
1343 int usePicard = args.
scalar<
int>(
"usePicard");
1344 xt::pyarray<double>& mesh_trial_ref = args.
array<
double>(
"mesh_trial_ref");
1345 xt::pyarray<double>& mesh_grad_trial_ref = args.
array<
double>(
"mesh_grad_trial_ref");
1346 xt::pyarray<double>& mesh_dof = args.
array<
double>(
"mesh_dof");
1347 xt::pyarray<int>& mesh_l2g = args.
array<
int>(
"mesh_l2g");
1348 xt::pyarray<double>& dV_ref = args.
array<
double>(
"dV_ref");
1349 xt::pyarray<double>& disp_trial_ref = args.
array<
double>(
"disp_trial_ref");
1350 xt::pyarray<double>& disp_grad_trial_ref = args.
array<
double>(
"disp_grad_trial_ref");
1351 xt::pyarray<double>& disp_test_ref = args.
array<
double>(
"disp_test_ref");
1352 xt::pyarray<double>& disp_grad_test_ref = args.
array<
double>(
"disp_grad_test_ref");
1353 xt::pyarray<double>& mesh_trial_trace_ref = args.
array<
double>(
"mesh_trial_trace_ref");
1354 xt::pyarray<double>& mesh_grad_trial_trace_ref = args.
array<
double>(
"mesh_grad_trial_trace_ref");
1355 xt::pyarray<double>& dS_ref = args.
array<
double>(
"dS_ref");
1356 xt::pyarray<double>& disp_trial_trace_ref = args.
array<
double>(
"disp_trial_trace_ref");
1357 xt::pyarray<double>& disp_grad_trial_trace_ref = args.
array<
double>(
"disp_grad_trial_trace_ref");
1358 xt::pyarray<double>& disp_test_trace_ref = args.
array<
double>(
"disp_test_trace_ref");
1359 xt::pyarray<double>& disp_grad_test_trace_ref = args.
array<
double>(
"disp_grad_test_trace_ref");
1360 xt::pyarray<double>& normal_ref = args.
array<
double>(
"normal_ref");
1361 xt::pyarray<double>& boundaryJac_ref = args.
array<
double>(
"boundaryJac_ref");
1362 xt::pyarray<double>& ebqe_penalty = args.
array<
double>(
"ebqe_penalty");
1363 int gravityStep = args.
scalar<
int>(
"gravityStep");
1364 int nElements_global = args.
scalar<
int>(
"nElements_global");
1365 xt::pyarray<int>& materialTypes = args.
array<
int>(
"materialTypes");
1366 int nMaterialProperties = args.
scalar<
int>(
"nMaterialProperties");
1367 xt::pyarray<double>& materialProperties = args.
array<
double>(
"materialProperties");
1368 double pore_fluid_unit_weight = args.
scalar<
double>(
"pore_fluid_unit_weight");
1369 xt::pyarray<double>& pore_pressure_head_dof = args.
array<
double>(
"pore_pressure_head_dof");
1370 xt::pyarray<double>& q_strain = args.
array<
double>(
"q_strain");
1371 xt::pyarray<double>& q_strain0 = args.
array<
double>(
"q_strain0");
1372 xt::pyarray<double>& q_strain_last = args.
array<
double>(
"q_strain_last");
1373 xt::pyarray<double>& q_plasticStrain = args.
array<
double>(
"q_plasticStrain");
1374 xt::pyarray<double>& q_plasticStrain_last = args.
array<
double>(
"q_plasticStrain_last");
1375 xt::pyarray<double>& ebqe_strain = args.
array<
double>(
"ebqe_strain");
1376 xt::pyarray<double>& ebqe_strain0 = args.
array<
double>(
"ebqe_strain0");
1377 xt::pyarray<double>& ebqe_strain_last = args.
array<
double>(
"ebqe_strain_last");
1378 xt::pyarray<double>& ebqe_plasticStrain = args.
array<
double>(
"ebqe_plasticStrain");
1379 xt::pyarray<double>& ebqe_plasticStrain_last = args.
array<
double>(
"ebqe_plasticStrain_last");
1380 xt::pyarray<int>& disp_l2g = args.
array<
int>(
"disp_l2g");
1381 xt::pyarray<double>& u_dof = args.
array<
double>(
"u_dof");
1382 xt::pyarray<double>& v_dof = args.
array<
double>(
"v_dof");
1383 xt::pyarray<double>& w_dof = args.
array<
double>(
"w_dof");
1384 xt::pyarray<double>& bodyForce = args.
array<
double>(
"bodyForce");
1385 xt::pyarray<int>& csrRowIndeces_u_u = args.
array<
int>(
"csrRowIndeces_u_u");
1386 xt::pyarray<int>& csrColumnOffsets_u_u = args.
array<
int>(
"csrColumnOffsets_u_u");
1387 xt::pyarray<int>& csrRowIndeces_u_v = args.
array<
int>(
"csrRowIndeces_u_v");
1388 xt::pyarray<int>& csrColumnOffsets_u_v = args.
array<
int>(
"csrColumnOffsets_u_v");
1389 xt::pyarray<int>& csrRowIndeces_u_w = args.
array<
int>(
"csrRowIndeces_u_w");
1390 xt::pyarray<int>& csrColumnOffsets_u_w = args.
array<
int>(
"csrColumnOffsets_u_w");
1391 xt::pyarray<int>& csrRowIndeces_v_u = args.
array<
int>(
"csrRowIndeces_v_u");
1392 xt::pyarray<int>& csrColumnOffsets_v_u = args.
array<
int>(
"csrColumnOffsets_v_u");
1393 xt::pyarray<int>& csrRowIndeces_v_v = args.
array<
int>(
"csrRowIndeces_v_v");
1394 xt::pyarray<int>& csrColumnOffsets_v_v = args.
array<
int>(
"csrColumnOffsets_v_v");
1395 xt::pyarray<int>& csrRowIndeces_v_w = args.
array<
int>(
"csrRowIndeces_v_w");
1396 xt::pyarray<int>& csrColumnOffsets_v_w = args.
array<
int>(
"csrColumnOffsets_v_w");
1397 xt::pyarray<int>& csrRowIndeces_w_u = args.
array<
int>(
"csrRowIndeces_w_u");
1398 xt::pyarray<int>& csrColumnOffsets_w_u = args.
array<
int>(
"csrColumnOffsets_w_u");
1399 xt::pyarray<int>& csrRowIndeces_w_v = args.
array<
int>(
"csrRowIndeces_w_v");
1400 xt::pyarray<int>& csrColumnOffsets_w_v = args.
array<
int>(
"csrColumnOffsets_w_v");
1401 xt::pyarray<int>& csrRowIndeces_w_w = args.
array<
int>(
"csrRowIndeces_w_w");
1402 xt::pyarray<int>& csrColumnOffsets_w_w = args.
array<
int>(
"csrColumnOffsets_w_w");
1403 xt::pyarray<double>& globalJacobian = args.
array<
double>(
"globalJacobian");
1404 int nExteriorElementBoundaries_global = args.
scalar<
int>(
"nExteriorElementBoundaries_global");
1405 xt::pyarray<int>& exteriorElementBoundariesArray = args.
array<
int>(
"exteriorElementBoundariesArray");
1406 xt::pyarray<int>& elementBoundaryElementsArray = args.
array<
int>(
"elementBoundaryElementsArray");
1407 xt::pyarray<int>& elementBoundaryLocalElementBoundariesArray = args.
array<
int>(
"elementBoundaryLocalElementBoundariesArray");
1408 xt::pyarray<int>& isDOFBoundary_u = args.
array<
int>(
"isDOFBoundary_u");
1409 xt::pyarray<int>& isDOFBoundary_v = args.
array<
int>(
"isDOFBoundary_v");
1410 xt::pyarray<int>& isDOFBoundary_w = args.
array<
int>(
"isDOFBoundary_w");
1411 xt::pyarray<int>& isStressFluxBoundary_u = args.
array<
int>(
"isStressFluxBoundary_u");
1412 xt::pyarray<int>& isStressFluxBoundary_v = args.
array<
int>(
"isStressFluxBoundary_v");
1413 xt::pyarray<int>& isStressFluxBoundary_w = args.
array<
int>(
"isStressFluxBoundary_w");
1414 xt::pyarray<int>& csrColumnOffsets_eb_u_u = args.
array<
int>(
"csrColumnOffsets_eb_u_u");
1415 xt::pyarray<int>& csrColumnOffsets_eb_u_v = args.
array<
int>(
"csrColumnOffsets_eb_u_v");
1416 xt::pyarray<int>& csrColumnOffsets_eb_u_w = args.
array<
int>(
"csrColumnOffsets_eb_u_w");
1417 xt::pyarray<int>& csrColumnOffsets_eb_v_u = args.
array<
int>(
"csrColumnOffsets_eb_v_u");
1418 xt::pyarray<int>& csrColumnOffsets_eb_v_v = args.
array<
int>(
"csrColumnOffsets_eb_v_v");
1419 xt::pyarray<int>& csrColumnOffsets_eb_v_w = args.
array<
int>(
"csrColumnOffsets_eb_v_w");
1420 xt::pyarray<int>& csrColumnOffsets_eb_w_u = args.
array<
int>(
"csrColumnOffsets_eb_w_u");
1421 xt::pyarray<int>& csrColumnOffsets_eb_w_v = args.
array<
int>(
"csrColumnOffsets_eb_w_v");
1422 xt::pyarray<int>& csrColumnOffsets_eb_w_w = args.
array<
int>(
"csrColumnOffsets_eb_w_w");
1428 for(
int eN=0;eN<nElements_global;eN++)
1431 elementJacobian_u_u[nDOF_test_element][nDOF_trial_element],
1432 elementJacobian_u_v[nDOF_test_element][nDOF_trial_element],
1433 elementJacobian_u_w[nDOF_test_element][nDOF_trial_element],
1434 elementJacobian_v_u[nDOF_test_element][nDOF_trial_element],
1435 elementJacobian_v_v[nDOF_test_element][nDOF_trial_element],
1436 elementJacobian_v_w[nDOF_test_element][nDOF_trial_element],
1437 elementJacobian_w_u[nDOF_test_element][nDOF_trial_element],
1438 elementJacobian_w_v[nDOF_test_element][nDOF_trial_element],
1439 elementJacobian_w_w[nDOF_test_element][nDOF_trial_element];
1440 for (
int i=0;i<nDOF_test_element;i++)
1441 for (
int j=0;j<nDOF_trial_element;j++)
1443 elementJacobian_u_u[i][j]=0.0;
1444 elementJacobian_u_v[i][j]=0.0;
1445 elementJacobian_u_w[i][j]=0.0;
1446 elementJacobian_v_u[i][j]=0.0;
1447 elementJacobian_v_v[i][j]=0.0;
1448 elementJacobian_v_w[i][j]=0.0;
1449 elementJacobian_w_u[i][j]=0.0;
1450 elementJacobian_w_v[i][j]=0.0;
1451 elementJacobian_w_w[i][j]=0.0;
1453 for (
int k=0;k<nQuadraturePoints_element;k++)
1455 const int eN_k=eN*nQuadraturePoints_element+k,
1456 eN_nDOF_trial_element = eN*nDOF_trial_element,
1457 eN_nDOF_mesh_trial_element = eN*nDOF_mesh_trial_element;
1460 register double u=0.0,
v=0.0,
w=0.0,
1463 *grad_v(&
D[nSpace]),
1464 *grad_w(&
D[2*nSpace]),
1467 jacInv[nSpace*nSpace],
1468 disp_grad_trial[nDOF_trial_element*nSpace],
1470 disp_test_dV[nDOF_test_element],
1471 disp_grad_test_dV[nDOF_test_element*nSpace],
1473 G[nSpace*nSpace],G_dd_G,tr_G,
1475 stress[
nSymTen],dstress[nSpace*nSpace*nSpace*nSpace],pore_pressure=0.0;
1477 ck.calculateMapping_element(eN,
1481 mesh_trial_ref.data(),
1482 mesh_grad_trial_ref.data(),
1488 ck.mapping.valFromDOF(pore_pressure_head_dof.data(),&mesh_l2g.data()[eN_nDOF_mesh_trial_element],&mesh_trial_ref.data()[k*nDOF_mesh_trial_element],pore_pressure);
1489 pore_pressure *= pore_fluid_unit_weight;
1490 pore_pressure = fmax(pore_pressure,0.0);
1492 dV = fabs(jacDet)*dV_ref.data()[k];
1493 ck.calculateG(jacInv,G,G_dd_G,tr_G);
1495 ck.gradTrialFromRef(&disp_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,disp_grad_trial);
1497 ck.valFromDOF(u_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],&disp_trial_ref.data()[k*nDOF_trial_element],
u);
1498 ck.valFromDOF(v_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],&disp_trial_ref.data()[k*nDOF_trial_element],
v);
1499 ck.valFromDOF(w_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],&disp_trial_ref.data()[k*nDOF_trial_element],
w);
1501 ck.gradFromDOF(u_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],disp_grad_trial,grad_u);
1502 ck.gradFromDOF(v_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],disp_grad_trial,grad_v);
1503 ck.gradFromDOF(w_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],disp_grad_trial,grad_w);
1505 for (
int j=0;j<nDOF_trial_element;j++)
1507 disp_test_dV[j] = disp_test_ref.data()[k*nDOF_trial_element+j]*dV;
1508 for (
int I=0;I<nSpace;I++)
1510 disp_grad_test_dV[j*nSpace+I] = disp_grad_trial[j*nSpace+I]*dV;
1517 elasticModuli(materialProperties.data()[materialTypes.data()[eN]*nMaterialProperties],
1518 materialProperties.data()[materialTypes.data()[eN]*nMaterialProperties+1],
1520 if (gravityStep == 2)
1522 double f,
df[
nSymTen],
r[
nSymTen],dr[
nSymTen*
nSymTen],stress_3_init,E=materialProperties.data()[materialTypes.data()[eN]*nMaterialProperties],nu=materialProperties.data()[materialTypes.data()[eN]*nMaterialProperties+1];
1525 stress,
f,
df,
r,dr,stress_3_init);
1526 const double n_e = 0.6,
1527 P_a = materialProperties.data()[materialTypes.data()[eN]*nMaterialProperties+12],
1531 E =K_i*P_a*pow(fmax(stress_3_init,P_a)/P_a,n_e);
1537 strain[i] = Delta_strain[i] + q_strain_last.data()[eN_k*
nSymTen+i];
1542 for (
int i=0; i<nSpace; i++)
1543 stress[i] -= pore_pressure;
1548 &materialProperties.data()[materialTypes.data()[eN]*nMaterialProperties],
1549 &q_strain0.data()[eN_k*
nSymTen],
1550 &q_strain_last.data()[eN_k*
nSymTen],
1552 &q_plasticStrain_last.data()[eN_k*
nSymTen],
1553 &q_plasticStrain.data()[eN_k*
nSymTen],
1561 for(
int i=0;i<nDOF_test_element;i++)
1563 register int i_nSpace = i*nSpace;
1564 for(
int j=0;j<nDOF_trial_element;j++)
1566 register int j_nSpace = j*nSpace;
1568 elementJacobian_u_u[i][j] +=
ck.StressJacobian_u_u_weak(dstress,&disp_grad_trial[j_nSpace],&disp_grad_test_dV[i_nSpace]);
1569 elementJacobian_u_v[i][j] +=
ck.StressJacobian_u_v_weak(dstress,&disp_grad_trial[j_nSpace],&disp_grad_test_dV[i_nSpace]);
1570 elementJacobian_u_w[i][j] +=
ck.StressJacobian_u_w_weak(dstress,&disp_grad_trial[j_nSpace],&disp_grad_test_dV[i_nSpace]);
1572 elementJacobian_v_u[i][j] +=
ck.StressJacobian_v_u_weak(dstress,&disp_grad_trial[j_nSpace],&disp_grad_test_dV[i_nSpace]);
1573 elementJacobian_v_v[i][j] +=
ck.StressJacobian_v_v_weak(dstress,&disp_grad_trial[j_nSpace],&disp_grad_test_dV[i_nSpace]);
1574 elementJacobian_v_w[i][j] +=
ck.StressJacobian_v_w_weak(dstress,&disp_grad_trial[j_nSpace],&disp_grad_test_dV[i_nSpace]);
1576 elementJacobian_w_u[i][j] +=
ck.StressJacobian_w_u_weak(dstress,&disp_grad_trial[j_nSpace],&disp_grad_test_dV[i_nSpace]);
1577 elementJacobian_w_v[i][j] +=
ck.StressJacobian_w_v_weak(dstress,&disp_grad_trial[j_nSpace],&disp_grad_test_dV[i_nSpace]);
1578 elementJacobian_w_w[i][j] +=
ck.StressJacobian_w_w_weak(dstress,&disp_grad_trial[j_nSpace],&disp_grad_test_dV[i_nSpace]);
1585 for (
int i=0;i<nDOF_test_element;i++)
1587 register int eN_i = eN*nDOF_test_element+i;
1588 for (
int j=0;j<nDOF_trial_element;j++)
1590 register int eN_i_j = eN_i*nDOF_trial_element+j;
1602 globalJacobian.data()[csrRowIndeces_u_u[eN_i] + csrColumnOffsets_u_u[eN_i_j]] += elementJacobian_u_u[i][j];
1603 globalJacobian.data()[csrRowIndeces_u_v[eN_i] + csrColumnOffsets_u_v[eN_i_j]] += elementJacobian_u_v[i][j];
1604 globalJacobian.data()[csrRowIndeces_u_w[eN_i] + csrColumnOffsets_u_w[eN_i_j]] += elementJacobian_u_w[i][j];
1606 globalJacobian.data()[csrRowIndeces_v_u[eN_i] + csrColumnOffsets_v_u[eN_i_j]] += elementJacobian_v_u[i][j];
1607 globalJacobian.data()[csrRowIndeces_v_v[eN_i] + csrColumnOffsets_v_v[eN_i_j]] += elementJacobian_v_v[i][j];
1608 globalJacobian.data()[csrRowIndeces_v_w[eN_i] + csrColumnOffsets_v_w[eN_i_j]] += elementJacobian_v_w[i][j];
1610 globalJacobian.data()[csrRowIndeces_w_u[eN_i] + csrColumnOffsets_w_u[eN_i_j]] += elementJacobian_w_u[i][j];
1611 globalJacobian.data()[csrRowIndeces_w_v[eN_i] + csrColumnOffsets_w_v[eN_i_j]] += elementJacobian_w_v[i][j];
1612 globalJacobian.data()[csrRowIndeces_w_w[eN_i] + csrColumnOffsets_w_w[eN_i_j]] += elementJacobian_w_w[i][j];
1619 for (
int ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
1621 register int ebN = exteriorElementBoundariesArray.data()[ebNE],
1622 eN = elementBoundaryElementsArray.data()[ebN*2+0],
1623 eN_nDOF_trial_element = eN*nDOF_trial_element,
1624 eN_nDOF_mesh_trial_element = eN*nDOF_mesh_trial_element,
1625 ebN_local = elementBoundaryLocalElementBoundariesArray.data()[ebN*2+0];
1626 for (
int kb=0;kb<nQuadraturePoints_elementBoundary;kb++)
1628 register int ebNE_kb = ebNE*nQuadraturePoints_elementBoundary+kb,
1629 ebN_local_kb = ebN_local*nQuadraturePoints_elementBoundary+kb,
1630 ebN_local_kb_nSpace = ebN_local_kb*nSpace;
1636 D_ext[nSpace*nSpace],
1637 *grad_u_ext(&D_ext[0]),
1638 *grad_v_ext(&D_ext[nSpace]),
1639 *grad_w_ext(&D_ext[2*nSpace]),
1640 fluxJacobian_u_u[nDOF_trial_element],
1641 fluxJacobian_u_v[nDOF_trial_element],
1642 fluxJacobian_u_w[nDOF_trial_element],
1643 fluxJacobian_v_u[nDOF_trial_element],
1644 fluxJacobian_v_v[nDOF_trial_element],
1645 fluxJacobian_v_w[nDOF_trial_element],
1646 fluxJacobian_w_u[nDOF_trial_element],
1647 fluxJacobian_w_v[nDOF_trial_element],
1648 fluxJacobian_w_w[nDOF_trial_element],
1649 jac_ext[nSpace*nSpace],
1651 jacInv_ext[nSpace*nSpace],
1652 boundaryJac[nSpace*(nSpace-1)],
1653 metricTensor[(nSpace-1)*(nSpace-1)],
1654 metricTensorDetSqrt,
1655 disp_grad_trial_trace[nDOF_trial_element*nSpace],
1657 disp_test_dS[nDOF_test_element],
1660 G[nSpace*nSpace],G_dd_G,tr_G,h_penalty,
1665 ck.calculateMapping_elementBoundary(eN,
1671 mesh_trial_trace_ref.data(),
1672 mesh_grad_trial_trace_ref.data(),
1673 boundaryJac_ref.data(),
1679 metricTensorDetSqrt,
1684 ck.mapping.valFromDOF(pore_pressure_head_dof.data(),&mesh_l2g.data()[eN_nDOF_mesh_trial_element],&mesh_trial_trace_ref.data()[ebN_local_kb*nDOF_mesh_trial_element],pore_pressure_ext);
1685 pore_pressure_ext *= pore_fluid_unit_weight;
1686 pore_pressure_ext = fmax(pore_pressure_ext,0.0);
1687 dS = metricTensorDetSqrt*dS_ref.data()[kb];
1688 ck.calculateG(jacInv_ext,G,G_dd_G,tr_G);
1691 ck.gradTrialFromRef(&disp_grad_trial_trace_ref.data()[ebN_local_kb_nSpace*nDOF_trial_element],jacInv_ext,disp_grad_trial_trace);
1693 ck.valFromDOF(u_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],&disp_trial_trace_ref.data()[ebN_local_kb*nDOF_test_element],u_ext);
1694 ck.valFromDOF(v_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],&disp_trial_trace_ref.data()[ebN_local_kb*nDOF_test_element],v_ext);
1695 ck.valFromDOF(w_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],&disp_trial_trace_ref.data()[ebN_local_kb*nDOF_test_element],w_ext);
1696 ck.gradFromDOF(u_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],disp_grad_trial_trace,grad_u_ext);
1697 ck.gradFromDOF(v_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],disp_grad_trial_trace,grad_v_ext);
1698 ck.gradFromDOF(w_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],disp_grad_trial_trace,grad_w_ext);
1700 for (
int j=0;j<nDOF_trial_element;j++)
1702 disp_test_dS[j] = disp_test_trace_ref.data()[ebN_local_kb*nDOF_test_element+j]*dS;
1711 elasticModuli(materialProperties.data()[materialTypes.data()[eN]*nMaterialProperties],
1712 materialProperties.data()[materialTypes.data()[eN]*nMaterialProperties+1],
1714 if (gravityStep == 2)
1716 double f,
df[
nSymTen],
r[
nSymTen],dr[
nSymTen*
nSymTen],stress_3_init,E=materialProperties.data()[materialTypes.data()[eN]*nMaterialProperties],nu=materialProperties.data()[materialTypes.data()[eN]*nMaterialProperties+1];
1719 stress,
f,
df,
r,dr,stress_3_init);
1720 const double n_e = 0.6,
1721 P_a = materialProperties.data()[materialTypes.data()[eN]*nMaterialProperties+12],
1725 E =K_i*P_a*pow(fmax(stress_3_init,P_a)/P_a,n_e);
1731 strain[i] = Delta_strain[i] + ebqe_strain_last.data()[ebNE_kb*
nSymTen+i];
1736 for (
int i=0;i<nSpace;i++)
1737 stress[i] -= pore_pressure_ext;
1742 &materialProperties.data()[materialTypes.data()[eN]*nMaterialProperties],
1743 &ebqe_strain0.data()[ebNE_kb*
nSymTen],
1744 &ebqe_strain_last.data()[ebNE_kb*
nSymTen],
1746 &ebqe_plasticStrain_last.data()[ebNE_kb*
nSymTen],
1747 &ebqe_plasticStrain.data()[ebNE_kb*
nSymTen],
1753 double E=materialProperties.data()[materialTypes.data()[eN]*nMaterialProperties],
1754 nu=materialProperties.data()[materialTypes.data()[eN]*nMaterialProperties+1];
1755 h_penalty=(E/(1.0+nu))*(1.0 + (nu/(1.0-2.0*nu)))*ebqe_penalty.data()[ebNE_kb];
1756 for (
int j=0;j<nDOF_trial_element;j++)
1758 register int j_nSpace = j*nSpace;
1761 isDOFBoundary_v.data()[ebNE_kb],
1762 isDOFBoundary_w.data()[ebNE_kb],
1766 disp_trial_trace_ref.data()[ebN_local_kb*nDOF_trial_element+j],
1767 &disp_grad_trial_trace[j_nSpace],
1768 fluxJacobian_u_u[j],
1769 fluxJacobian_u_v[j],
1770 fluxJacobian_u_w[j],
1771 fluxJacobian_v_u[j],
1772 fluxJacobian_v_v[j],
1773 fluxJacobian_v_w[j],
1774 fluxJacobian_w_u[j],
1775 fluxJacobian_w_v[j],
1776 fluxJacobian_w_w[j]);
1781 for (
int i=0;i<nDOF_test_element;i++)
1783 register int eN_i = eN*nDOF_test_element+i;
1784 for (
int j=0;j<nDOF_trial_element;j++)
1788 globalJacobian.data()[csrRowIndeces_u_u[eN_i] + csrColumnOffsets_eb_u_u[ebN_i_j]] += fluxJacobian_u_u[j]*disp_test_dS[i];
1789 globalJacobian.data()[csrRowIndeces_u_v[eN_i] + csrColumnOffsets_eb_u_v[ebN_i_j]] += fluxJacobian_u_v[j]*disp_test_dS[i];
1790 globalJacobian.data()[csrRowIndeces_u_w[eN_i] + csrColumnOffsets_eb_u_w[ebN_i_j]] += fluxJacobian_u_w[j]*disp_test_dS[i];
1792 globalJacobian.data()[csrRowIndeces_v_u[eN_i] + csrColumnOffsets_eb_v_u[ebN_i_j]] += fluxJacobian_v_u[j]*disp_test_dS[i];
1793 globalJacobian.data()[csrRowIndeces_v_v[eN_i] + csrColumnOffsets_eb_v_v[ebN_i_j]] += fluxJacobian_v_v[j]*disp_test_dS[i];
1794 globalJacobian.data()[csrRowIndeces_v_w[eN_i] + csrColumnOffsets_eb_v_w[ebN_i_j]] += fluxJacobian_v_w[j]*disp_test_dS[i];
1796 globalJacobian.data()[csrRowIndeces_w_u[eN_i] + csrColumnOffsets_eb_w_u[ebN_i_j]] += fluxJacobian_w_u[j]*disp_test_dS[i];
1797 globalJacobian.data()[csrRowIndeces_w_v[eN_i] + csrColumnOffsets_eb_w_v[ebN_i_j]] += fluxJacobian_w_v[j]*disp_test_dS[i];
1798 globalJacobian.data()[csrRowIndeces_w_w[eN_i] + csrColumnOffsets_eb_w_w[ebN_i_j]] += fluxJacobian_w_w[j]*disp_test_dS[i];
1807 int nQuadraturePoints_elementIn,
1808 int nDOF_mesh_trial_elementIn,
1809 int nDOF_trial_elementIn,
1810 int nDOF_test_elementIn,
1811 int nQuadraturePoints_elementBoundaryIn,
1814 return proteus::chooseAndAllocateDiscretization<ElastoPlastic_base,ElastoPlastic,CompKernel>(nSpaceIn,
1815 nQuadraturePoints_elementIn,
1816 nDOF_mesh_trial_elementIn,
1817 nDOF_trial_elementIn,
1818 nDOF_test_elementIn,
1819 nQuadraturePoints_elementBoundaryIn,