Changeset 5872
- Timestamp:
- 09/17/10 16:27:59 (15 years ago)
- Location:
- issm/trunk/src/c/objects/Elements
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/objects/Elements/Penta.cpp
r5863 r5872 2004 2004 /*}}}*/ 2005 2005 /*FUNCTION Penta::CreateKMatrixCouplingMacAyealPattyn{{{1*/ 2006 void Penta::CreateKMatrixCouplingMacAyealPattyn( Mat Kgg){ 2007 2008 this->CreateKMatrixCouplingMacAyealPattynViscous(Kgg); 2009 this->CreateKMatrixCouplingMacAyealPattynFriction(Kgg); 2006 ElementMatrix* Penta::CreateKMatrixCouplingMacAyealPattyn(void){ 2007 2008 /*compute all stiffness matrices for this element*/ 2009 ElementMatrix* Ke1=CreateKMatrixCouplingMacAyealPattynViscous(); 2010 ElementMatrix* Ke2=CreateKMatrixCouplingMacAyealPattynFriction(); 2011 ElementMatrix* Ke =new ElementMatrix(Ke1,Ke2); 2012 2013 /*clean-up and return*/ 2014 delete Ke1; 2015 delete Ke2; 2016 return Ke; 2010 2017 } 2011 2018 /*}}}*/ 2012 2019 /*FUNCTION Penta::CreateKMatrixCouplingMacAyealPattynViscous{{{1*/ 2013 void Penta::CreateKMatrixCouplingMacAyealPattynViscous( Mat Kgg){ 2014 2015 /* local declarations */ 2016 int i,j; 2017 2018 /* node data: */ 2020 ElementMatrix* Penta::CreateKMatrixCouplingMacAyealPattynViscous(void){ 2021 2019 2022 const int NUMVERTICESm=3; //MacAyealNUMVERTICES 2020 2023 const int numdofm=2*NUMVERTICESm; 2021 2024 const int NUMVERTICESp=6; //Pattyn NUMVERTICES 2022 2025 const int numdofp=2*NUMVERTICESp; 2026 const int numdoftotal=2*NDOF2*NUMVERTICES; 2027 int i,j,ig; 2023 2028 double xyz_list[NUMVERTICESp][3]; 2024 int* doflistm=NULL;2025 int* doflistp=NULL;2026 2027 /* 3d gaussian points: */2028 int ig;2029 2029 GaussPenta *gauss=NULL; 2030 2030 GaussTria *gauss_tria=NULL; 2031 2032 /* material data: */2033 2031 double viscosity; //viscosity 2034 2032 double oldviscosity; //viscosity 2035 2033 double newviscosity; //viscosity 2036 2037 /* strain rate: */2038 2034 double epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/ 2039 2035 double oldepsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/ 2040 2041 /* matrices: */2042 2036 double B[3][numdofp]; 2043 2037 double Bprime[3][numdofm]; … … 2047 2041 double DL[2][2]={0.0}; //for basal drag 2048 2042 double DL_scalar; 2049 2050 /* local element matrices: */2051 2043 double Ke_gg[numdofp][numdofm]={0.0}; //local element stiffness matrix 2052 double Ke_gg_transp[numdofm][numdofp]={0.0}; //local element stiffness matrix2053 2044 double Ke_gg_gaussian[numdofp][numdofm]; //stiffness matrix evaluated at the gaussian point. 2054 2045 double Jdet; 2055 2056 /*friction: */2057 2046 double alpha2_list[3]; 2058 2047 double alpha2; 2059 2060 /*parameters: */2061 2048 double viscosity_overshoot; 2062 2049 2063 /*Collapsed formulation: */2064 Tria* tria =NULL;2065 Penta* pentabase=NULL;2066 2067 /*retrieve some parameters: */2068 this->parameters->FindParam(&viscosity_overshoot,ViscosityOvershootEnum);2069 2070 /*If on water, skip stiffness: */2071 if(IsOnWater())return;2072 2073 2050 /*Find penta on bed as pattyn must be coupled to the dofs on the bed: */ 2074 pentabase=GetBasalElement(); 2075 tria=pentabase->SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria. 2051 Penta* pentabase=GetBasalElement(); 2052 Tria* tria=pentabase->SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria. 2053 2054 /*Initialize Element matrix and return if necessary*/ 2055 if(IsOnWater()) return NULL; 2056 ElementMatrix* Ke1=pentabase->NewElementMatrix(MacAyealApproximationEnum); 2057 ElementMatrix* Ke2=this->NewElementMatrix(PattynApproximationEnum); 2058 ElementMatrix* Ke=new ElementMatrix(Ke1,Ke2); 2059 delete Ke1; delete Ke2; 2076 2060 2077 2061 /* Get node coordinates and dof list: */ 2078 2062 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICESp); 2079 tria->GetDofList(&doflistm,MacAyealApproximationEnum,GsetEnum); //Pattyn dof list 2080 GetDofList(&doflistp,PattynApproximationEnum,GsetEnum); //MacAyeal dof list 2081 2082 /*Retrieve all inputs we will be needing: */ 2063 this->parameters->FindParam(&viscosity_overshoot,ViscosityOvershootEnum); 2083 2064 Input* vx_input=inputs->GetInput(VxEnum); ISSMASSERT(vx_input); 2084 2065 Input* vy_input=inputs->GetInput(VyEnum); ISSMASSERT(vy_input); … … 2094 2075 gauss->SynchronizeGaussTria(gauss_tria); 2095 2076 2096 /*Get strain rate from velocity: */2097 2077 this->GetStrainRate3dPattyn(&epsilon[0],&xyz_list[0][0],gauss,vx_input,vy_input); 2098 2078 this->GetStrainRate3dPattyn(&oldepsilon[0],&xyz_list[0][0],gauss,vxold_input,vyold_input); 2099 2100 /*Get viscosity: */2101 2079 matice->GetViscosity3d(&viscosity, &epsilon[0]); 2102 2080 matice->GetViscosity3d(&oldviscosity, &oldepsilon[0]); 2103 2081 2104 /*Get B and Bprime matrices: */2105 2082 GetBMacAyealPattyn(&B[0][0], &xyz_list[0][0], gauss); 2106 2083 tria->GetBprimeMacAyeal(&Bprime[0][0], &xyz_list[0][0], gauss_tria); 2107 2084 2108 /* Get Jacobian determinant: */2109 2085 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss); 2110 2111 /*Build the D matrix: we plug the gaussian weight, the viscosity, and the jacobian determinant2112 onto this scalar matrix, so that we win some computational time: */2113 2114 2086 newviscosity=viscosity+viscosity_overshoot*(viscosity-oldviscosity); 2115 2087 D_scalar=2*newviscosity*gauss->weight*Jdet; 2116 2088 for (i=0;i<3;i++) D[i][i]=D_scalar; 2117 2089 2118 /* Do the triple product tB*D*Bprime: */2119 2090 TripleMultiply( &B[0][0],3,numdofp,1, 2120 2091 &D[0][0],3,3,0, … … 2122 2093 &Ke_gg_gaussian[0][0],0); 2123 2094 2124 /* Add the Ke_gg_gaussian, and optionally Ke_gg_gaussian onto Ke_gg: */2125 2095 for( i=0; i<numdofp; i++) for(j=0;j<numdofm; j++) Ke_gg[i][j]+=Ke_gg_gaussian[i][j]; 2126 2096 } 2127 2128 /*Add Ke_gg and its transpose to global matrix Kgg: */ 2129 MatrixTranspose(&Ke_gg_transp[0][0],&Ke_gg[0][0],12,6); 2130 MatSetValues(Kgg,numdofp,doflistp,numdofm,doflistm,(const double*)Ke_gg,ADD_VALUES); 2131 MatSetValues(Kgg,numdofm,doflistm,numdofp,doflistp,(const double*)Ke_gg_transp,ADD_VALUES); 2132 2133 xfree((void**)&doflistm); 2134 xfree((void**)&doflistp); 2097 for(i=0;i<numdofp;i++) for(j=0;j<numdofm;j++) Ke->values[(i+2*numdofm)*numdoftotal+j]+=Ke_gg[i][j]; 2098 for(i=0;i<numdofm;i++) for(j=0;j<numdofp;j++) Ke->values[i*numdoftotal+(j+2*numdofm)]+=Ke_gg[j][i]; 2099 2100 /*Clean-up and return*/ 2135 2101 delete tria->matice; delete tria; 2136 2102 delete gauss; 2137 2103 delete gauss_tria; 2104 return Ke; 2138 2105 } 2139 2106 /*}}}*/ 2140 2107 /*FUNCTION Penta::CreateKMatrixCouplingMacAyealPattynFriction{{{1*/ 2141 void Penta::CreateKMatrixCouplingMacAyealPattynFriction( Mat Kgg){2108 ElementMatrix* Penta::CreateKMatrixCouplingMacAyealPattynFriction(void){ 2142 2109 2143 2110 /*Initialize Element matrix and return if necessary*/ 2144 if(IsOnWater() || IsOnShelf() || !IsOnBed()) return ;2111 if(IsOnWater() || IsOnShelf() || !IsOnBed()) return NULL; 2145 2112 2146 2113 Tria* tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria. 2147 2114 ElementMatrix* Ke=tria->CreateKMatrixCouplingMacAyealPattynFriction(); 2148 if(Ke) Ke->AddToGlobal(Kgg,NULL,NULL);2149 delete Ke;2150 2115 delete tria->matice; delete tria; 2116 2117 return Ke; 2151 2118 } 2152 2119 /*}}}*/ 2153 2120 /*FUNCTION Penta::CreateKMatrixCouplingPattynStokes{{{1*/ 2154 void Penta::CreateKMatrixCouplingPattynStokes( Mat Kgg){2121 ElementMatrix* Penta::CreateKMatrixCouplingPattynStokes(void){ 2155 2122 2156 2123 int i,j; … … 2233 2200 if(Ke) Ke->AddToGlobal(Kgg,NULL,NULL); 2234 2201 delete Ke; 2235 CreateKMatrixCouplingMacAyealPattyn(Kgg); 2202 Ke=CreateKMatrixCouplingMacAyealPattyn(); 2203 if(Ke) Ke->AddToGlobal(Kgg,NULL,NULL); 2204 delete Ke; 2236 2205 break; 2237 2206 case PattynStokesApproximationEnum: … … 2242 2211 if(Ke) Ke->AddToGlobal(Kgg,NULL,NULL); 2243 2212 delete Ke; 2244 CreateKMatrixCouplingPattynStokes( Kgg); 2213 Ke=CreateKMatrixCouplingPattynStokes(); 2214 if(Ke) Ke->AddToGlobal(Kgg,NULL,NULL); 2215 delete Ke; 2245 2216 break; 2246 2217 default: -
issm/trunk/src/c/objects/Elements/Penta.h
r5863 r5872 123 123 ElementMatrix* CreateKMatrixBalancedthickness(void); 124 124 ElementMatrix* CreateKMatrixBalancedvelocities(void); 125 void CreateKMatrixCouplingMacAyealPattyn( Mat Kgg);126 void CreateKMatrixCouplingMacAyealPattynViscous( Mat Kgg);127 void CreateKMatrixCouplingMacAyealPattynFriction( Mat Kgg);128 void CreateKMatrixCouplingPattynStokes( Mat Kgg);125 ElementMatrix* CreateKMatrixCouplingMacAyealPattyn(void); 126 ElementMatrix* CreateKMatrixCouplingMacAyealPattynViscous(void); 127 ElementMatrix* CreateKMatrixCouplingMacAyealPattynFriction(void); 128 ElementMatrix* CreateKMatrixCouplingPattynStokes(void); 129 129 void CreateKMatrixDiagnosticHoriz( Mat Kgg); 130 130 ElementMatrix* CreateKMatrixDiagnosticHutter(void); -
issm/trunk/src/c/objects/Elements/Tria.cpp
r5865 r5872 2943 2943 } 2944 2944 2945 2946 2945 for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke->values[i*numdoftotal+(numdof+j)]+=Ke_gg[i][j]; 2947 2946 for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke->values[(i+numdof)*numdoftotal+j]+=Ke_gg[i][j];
Note:
See TracChangeset
for help on using the changeset viewer.