Changeset 5946
- Timestamp:
- 09/22/10 10:40:57 (14 years ago)
- Location:
- issm/trunk/src/c/objects/Elements
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/objects/Elements/Penta.cpp
r5943 r5946 1979 1979 ElementMatrix* Penta::CreateKMatrixCouplingMacAyealPattynViscous(void){ 1980 1980 1981 const int NUMVERTICESm=3; //MacAyealNUMVERTICES 1982 const int numdofm=2*NUMVERTICESm; 1983 const int NUMVERTICESp=6; //Pattyn NUMVERTICES 1984 const int numdofp=2*NUMVERTICESp; 1981 /*Constants*/ 1982 const int numdofm=NDOF2*NUMVERTICES2D; 1983 const int numdofp=NDOF2*NUMVERTICES; 1985 1984 const int numdoftotal=2*NDOF2*NUMVERTICES; 1986 int i,j,ig; 1987 double xyz_list[NUMVERTICESp][3]; 1985 1986 /*Intermediaries */ 1987 int i,j,ig; 1988 double Jdet; 1989 double viscosity,oldviscosity,newviscosity,viscosity_overshoot; //viscosity 1990 double epsilon[5],oldepsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/ 1991 double xyz_list[NUMVERTICES][3]; 1992 double B[3][numdofp]; 1993 double Bprime[3][numdofm]; 1994 double D[3][3]={0.0}; // material matrix, simple scalar matrix. 1995 double D_scalar; 1996 double Ke_gg[numdofp][numdofm]={0.0}; //local element stiffness matrix 1997 double Ke_gg_gaussian[numdofp][numdofm]; //stiffness matrix evaluated at the gaussian point. 1988 1998 GaussPenta *gauss=NULL; 1989 1999 GaussTria *gauss_tria=NULL; 1990 double viscosity; //viscosity1991 double oldviscosity; //viscosity1992 double newviscosity; //viscosity1993 double epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/1994 double oldepsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/1995 double B[3][numdofp];1996 double Bprime[3][numdofm];1997 double L[2][numdofp];1998 double D[3][3]={0.0}; // material matrix, simple scalar matrix.1999 double D_scalar;2000 double DL[2][2]={0.0}; //for basal drag2001 double DL_scalar;2002 double Ke_gg[numdofp][numdofm]={0.0}; //local element stiffness matrix2003 double Ke_gg_gaussian[numdofp][numdofm]; //stiffness matrix evaluated at the gaussian point.2004 double Jdet;2005 double alpha2_list[3];2006 double alpha2;2007 double viscosity_overshoot;2008 2000 2009 2001 /*Find penta on bed as pattyn must be coupled to the dofs on the bed: */ … … 2019 2011 2020 2012 /* Get node coordinates and dof list: */ 2021 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES p);2013 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 2022 2014 this->parameters->FindParam(&viscosity_overshoot,ViscosityOvershootEnum); 2023 2015 Input* vx_input=inputs->GetInput(VxEnum); ISSMASSERT(vx_input); … … 2034 2026 gauss->SynchronizeGaussTria(gauss_tria); 2035 2027 2028 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss); 2029 GetBMacAyealPattyn(&B[0][0], &xyz_list[0][0], gauss); 2030 tria->GetBprimeMacAyeal(&Bprime[0][0], &xyz_list[0][0], gauss_tria); 2031 2036 2032 this->GetStrainRate3dPattyn(&epsilon[0],&xyz_list[0][0],gauss,vx_input,vy_input); 2037 2033 this->GetStrainRate3dPattyn(&oldepsilon[0],&xyz_list[0][0],gauss,vxold_input,vyold_input); … … 2039 2035 matice->GetViscosity3d(&oldviscosity, &oldepsilon[0]); 2040 2036 2041 GetBMacAyealPattyn(&B[0][0], &xyz_list[0][0], gauss);2042 tria->GetBprimeMacAyeal(&Bprime[0][0], &xyz_list[0][0], gauss_tria);2043 2044 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss);2045 2037 newviscosity=viscosity+viscosity_overshoot*(viscosity-oldviscosity); 2046 2038 D_scalar=2*newviscosity*gauss->weight*Jdet; … … 2139 2131 ElementMatrix* Penta::CreateKMatrixDiagnosticHutter(void){ 2140 2132 2133 /*Constants*/ 2134 const int numdof=NDOF2*NUMVERTICES; 2135 2141 2136 /*Intermediaries*/ 2142 const int numdof=NDOF2*NUMVERTICES;2143 2137 int connectivity[2]; 2138 int i,i0,i1,j0,j1; 2144 2139 double one0,one1; 2145 int i,i0,i1,j0,j1;2146 2140 2147 2141 /*Initialize Element matrix and return if necessary*/ … … 2238 2232 ElementMatrix* Penta::CreateKMatrixDiagnosticMacAyeal3dViscous(void){ 2239 2233 2234 /*Constants*/ 2240 2235 const int numdof2d=2*NUMVERTICES2D; 2241 int i,j,ig; 2242 double xyz_list[NUMVERTICES][3]; 2236 2237 /*Intermediaries */ 2238 int i,j,ig; 2239 double Jdet; 2240 double viscosity, oldviscosity, newviscosity, viscosity_overshoot; 2241 double epsilon[5],oldepsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/ 2242 double xyz_list[NUMVERTICES][3]; 2243 double B[3][numdof2d]; 2244 double Bprime[3][numdof2d]; 2245 double D[3][3]={0.0}; // material matrix, simple scalar matrix. 2246 double D_scalar; 2247 double Ke_gg_gaussian[numdof2d][numdof2d]; //stiffness matrix evaluated at the gaussian point. 2248 Tria* tria=NULL; 2249 Penta* pentabase=NULL; 2243 2250 GaussPenta *gauss=NULL; 2244 2251 GaussTria *gauss_tria=NULL; 2245 double viscosity, oldviscosity, newviscosity, viscosity_overshoot;2246 double epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/2247 double oldepsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/2248 double B[3][numdof2d];2249 double Bprime[3][numdof2d];2250 double L[2][numdof2d];2251 double D[3][3]={0.0}; // material matrix, simple scalar matrix.2252 double D_scalar;2253 double DL[2][2]={0.0}; //for basal drag2254 double DL_scalar;2255 double Ke_gg_gaussian[numdof2d][numdof2d]; //stiffness matrix evaluated at the gaussian point.2256 double Jdet;2257 double slope[2]={0.0};2258 double slope_magnitude;2259 double alpha2_list[3];2260 double alpha2;2261 double MAXSLOPE=.06; // 6 %2262 double MOUNTAINKEXPONENT=10;2263 Tria* tria=NULL;2264 Penta* pentabase=NULL;2265 2252 2266 2253 /*Find penta on bed as this is a macayeal elements: */ … … 2288 2275 gauss->SynchronizeGaussTria(gauss_tria); 2289 2276 2277 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss); 2290 2278 tria->GetBMacAyeal(&B[0][0], &xyz_list[0][0], gauss_tria); 2291 2279 tria->GetBprimeMacAyeal(&Bprime[0][0], &xyz_list[0][0], gauss_tria); 2292 2293 2280 2294 2281 this->GetStrainRate3dPattyn(&epsilon[0],&xyz_list[0][0],gauss,vx_input,vy_input); … … 2296 2283 matice->GetViscosity3d(&viscosity, &epsilon[0]); 2297 2284 matice->GetViscosity3d(&oldviscosity, &oldepsilon[0]); 2285 2298 2286 newviscosity=viscosity+viscosity_overshoot*(viscosity-oldviscosity); 2299 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss);2300 2287 D_scalar=2*newviscosity*gauss->weight*Jdet; 2301 2288 for (i=0;i<3;i++) D[i][i]=D_scalar; … … 2555 2542 double LprimeStokes[14][numdof2d]; 2556 2543 double DLStokes[14][14]={0.0}; 2557 double Ke_temp[27][27]={0.0}; //for the six nodes and the bubble2558 2544 double Ke_drag_gaussian[numdof2d][numdof2d]; 2559 2545 Friction* friction=NULL; … … 2613 2599 &Ke_drag_gaussian[0][0],0); 2614 2600 2615 for(i=0;i<numdof2d;i++) for(j=0;j<numdof2d;j++) Ke_temp[i][j]+=Ke_drag_gaussian[i][j]; 2616 } 2617 2618 for(i=0;i<numdof2d;i++) for(j=0;j<numdof2d;j++) Ke->values[i*numdof+j]+=Ke_temp[i][j]; 2601 for(i=0;i<numdof2d;i++) for(j=0;j<numdof2d;j++) Ke->values[i*numdof+j]+=Ke_drag_gaussian[i][j]; 2602 } 2619 2603 2620 2604 /*Clean up and return*/ … … 2641 2625 ElementMatrix* Penta::CreateKMatrixDiagnosticVertVolume(void){ 2642 2626 2643 /* local declarations*/2627 /*Constants*/ 2644 2628 const int numdof=NDOF1*NUMVERTICES; 2645 int i,j,ig; 2646 double xyz_list[NUMVERTICES][3]; 2647 GaussPenta *gauss=NULL; 2648 double Ke_gg[numdof][numdof]={0.0}; 2649 double Jdet; 2650 double B[NDOF1][NUMVERTICES]; 2651 double Bprime[NDOF1][NUMVERTICES]; 2652 double DL_scalar; 2629 2630 /*Intermediaries */ 2631 int i,j,ig; 2632 double Jdet; 2633 double xyz_list[NUMVERTICES][3]; 2634 double B[NDOF1][NUMVERTICES]; 2635 double Bprime[NDOF1][NUMVERTICES]; 2636 double DL_scalar; 2637 double Ke_gg[numdof][numdof]={0.0}; 2638 GaussPenta *gauss=NULL; 2653 2639 2654 2640 /*Initialize Element matrix and return if necessary*/ … … 2665 2651 gauss->GaussPoint(ig); 2666 2652 2653 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss); 2667 2654 GetBVert(&B[0][0], &xyz_list[0][0], gauss); 2668 2655 GetBprimeVert(&Bprime[0][0], &xyz_list[0][0], gauss); 2669 2656 2670 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss);2671 2657 DL_scalar=gauss->weight*Jdet; 2672 2658 … … 2761 2747 ElementMatrix* Penta::CreateKMatrixThermalVolume(void){ 2762 2748 2763 int i,j; 2764 int ig; 2765 int found=0; 2749 /*Constants*/ 2766 2750 const int numdof=NDOF1*NUMVERTICES; 2767 double xyz_list[NUMVERTICES][3]; 2768 int* doflist=NULL; 2769 GaussPenta *gauss=NULL; 2770 double K[2][2]={0.0}; 2771 double u,v,w; 2772 double Ke_gaussian_conduct[numdof][numdof]; 2773 double Ke_gaussian_advec[numdof][numdof]; 2774 double Ke_gaussian_artdiff[numdof][numdof]; 2775 double Ke_gaussian_transient[numdof][numdof]; 2751 2752 /*Intermediaries */ 2753 bool artdiff; 2754 int i,j,ig,found=0; 2755 double Jdet,u,v,w,epsvel; 2756 double gravity,rho_ice,rho_water; 2757 double heatcapacity,thermalconductivity,dt; 2758 double xyz_list[NUMVERTICES][3]; 2776 2759 double B[3][numdof]; 2777 2760 double Bprime[3][numdof]; … … 2783 2766 double D_scalar; 2784 2767 double D[3][3]; 2785 double l1l2l3[3]; 2786 double tl1l2l3D[3]; 2768 double K[2][2]={0.0}; 2787 2769 double tBD[3][numdof]; 2788 2770 double tBD_conduct[3][numdof]; … … 2790 2772 double tBD_artdiff[3][numdof]; 2791 2773 double tLD[numdof]; 2792 double Jdet; 2793 double gravity,rho_ice,rho_water; 2794 double heatcapacity,thermalconductivity; 2795 double mixed_layer_capacity,thermal_exchange_velocity; 2796 double dt,epsvel; 2797 bool artdiff; 2798 Tria* tria=NULL; 2774 double Ke_gaussian_conduct[numdof][numdof]; 2775 double Ke_gaussian_advec[numdof][numdof]; 2776 double Ke_gaussian_artdiff[numdof][numdof]; 2777 double Ke_gaussian_transient[numdof][numdof]; 2778 Tria* tria=NULL; 2779 GaussPenta *gauss=NULL; 2799 2780 2800 2781 /*Initialize Element matrix and return if necessary*/ … … 3019 3000 ElementVector* Penta::CreatePVectorCouplingPattynStokesViscous(void){ 3020 3001 3021 const int numdof=NUMVERTICES*NDOF4; 3022 int i,j; 3023 int ig; 3024 double xyz_list_tria[NUMVERTICES2D][3]; 3025 double xyz_list[NUMVERTICES][3]; 3026 double bed_normal[3]; 3002 /*Constants*/ 3003 const int numdof=NUMVERTICES*NDOF4; 3004 3005 /*Intermediaries */ 3006 int i,j,ig; 3007 int approximation; 3008 double viscosity,Jdet; 3009 double stokesreconditioning; 3010 double epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/ 3011 double dw[3]; 3012 double xyz_list[NUMVERTICES][3]; 3013 double l1l6[6]; //for the six nodes of the penta 3014 double dh1dh6[3][6]; //for the six nodes of the penta 3027 3015 GaussPenta *gauss=NULL; 3028 double epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/3029 double viscosity, w, alpha2_gauss;3030 double dw[3];3031 double Pe_gaussian[24]={0.0}; //for the six nodes3032 double l1l6[6]; //for the six nodes of the penta3033 double dh1dh6[3][6]; //for the six nodes of the penta3034 double Jdet;3035 double Jdet2d;3036 Tria* tria=NULL;3037 Friction* friction=NULL;3038 double stokesreconditioning;3039 int approximation;3040 int analysis_type;3041 3016 3042 3017 /*Initialize Element vector and return if necessary*/ 3043 3018 if(IsOnWater()) return NULL; 3019 inputs->GetParameterValue(&approximation,ApproximationEnum); 3020 if(approximation!=PattynStokesApproximationEnum) return NULL; 3021 ElementVector* pe=NewElementVector(nodes,NUMVERTICES,this->parameters,StokesApproximationEnum); 3022 3023 /*Retrieve all inputs and parameters*/ 3024 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 3025 this->parameters->FindParam(&stokesreconditioning,StokesReconditioningEnum); 3026 Input* vx_input=inputs->GetInput(VxEnum); ISSMASSERT(vx_input); 3027 Input* vy_input=inputs->GetInput(VyEnum); ISSMASSERT(vy_input); 3028 Input* vz_input=inputs->GetInput(VzEnum); ISSMASSERT(vz_input); 3029 Input* vzpattyn_input=inputs->GetInput(VzPattynEnum); ISSMASSERT(vzpattyn_input); 3030 3031 /* Start looping on the number of gaussian points: */ 3032 gauss=new GaussPenta(5,5); 3033 for (ig=gauss->begin();ig<gauss->end();ig++){ 3034 3035 gauss->GaussPoint(ig); 3036 3037 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss); 3038 GetNodalFunctionsP1(&l1l6[0], gauss); 3039 GetNodalFunctionsP1Derivatives(&dh1dh6[0][0],&xyz_list[0][0], gauss); 3040 3041 vzpattyn_input->GetParameterDerivativeValue(&dw[0],&xyz_list[0][0],gauss); 3042 3043 this->GetStrainRate3d(&epsilon[0],&xyz_list[0][0],gauss,vx_input,vy_input,vz_input); 3044 matice->GetViscosity3dStokes(&viscosity,&epsilon[0]); 3045 3046 for(i=0;i<NUMVERTICES;i++){ 3047 pe->values[i*NDOF4+0]+=-Jdet*gauss->weight*viscosity*dw[0]*dh1dh6[2][i]/2; 3048 pe->values[i*NDOF4+1]+=-Jdet*gauss->weight*viscosity*dw[1]*dh1dh6[2][i]/2; 3049 pe->values[i*NDOF4+2]+=-Jdet*gauss->weight*viscosity*(dw[0]*dh1dh6[0][i]+dw[1]*dh1dh6[1][i]+dw[2]*dh1dh6[2][i])/2; 3050 pe->values[i*NDOF4+3]+=Jdet*gauss->weight*stokesreconditioning*dw[2]*l1l6[i]; 3051 } 3052 } 3053 3054 /*Clean up and return*/ 3055 delete gauss; 3056 return pe; 3057 } 3058 /*}}}*/ 3059 /*FUNCTION Penta::CreatePVectorCouplingPattynStokesFriction{{{1*/ 3060 ElementVector* Penta::CreatePVectorCouplingPattynStokesFriction(void){ 3061 3062 /*Constants*/ 3063 const int numdof=NUMVERTICES*NDOF4; 3064 3065 /*Intermediaries*/ 3066 int i,j,ig; 3067 int approximation,analysis_type; 3068 double Jdet,Jdet2d; 3069 double stokesreconditioning; 3070 double bed_normal[3]; 3071 double epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/ 3072 double viscosity, w, alpha2_gauss; 3073 double dw[3]; 3074 double xyz_list_tria[NUMVERTICES2D][3]; 3075 double xyz_list[NUMVERTICES][3]; 3076 double l1l6[6]; //for the six nodes of the penta 3077 Tria* tria=NULL; 3078 Friction* friction=NULL; 3079 GaussPenta *gauss=NULL; 3080 3081 /*Initialize Element vector and return if necessary*/ 3082 if(IsOnWater() || !IsOnBed() || IsOnShelf()) return NULL; 3044 3083 inputs->GetParameterValue(&approximation,ApproximationEnum); 3045 3084 if(approximation!=PattynStokesApproximationEnum) return NULL; … … 3055 3094 Input* vzpattyn_input=inputs->GetInput(VzPattynEnum); ISSMASSERT(vzpattyn_input); 3056 3095 3057 /* Start looping on the number of gaussian points: */ 3058 gauss=new GaussPenta(5,5); 3059 for (ig=gauss->begin();ig<gauss->end();ig++){ 3060 3061 gauss->GaussPoint(ig); 3062 3063 this->GetStrainRate3d(&epsilon[0],&xyz_list[0][0],gauss,vx_input,vy_input,vz_input); 3064 matice->GetViscosity3dStokes(&viscosity,&epsilon[0]); 3065 3066 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss); 3067 3068 GetNodalFunctionsP1(&l1l6[0], gauss); 3069 GetNodalFunctionsP1Derivatives(&dh1dh6[0][0],&xyz_list[0][0], gauss); 3070 3071 vzpattyn_input->GetParameterDerivativeValue(&dw[0],&xyz_list[0][0],gauss); 3072 3073 for(i=0;i<NUMVERTICES;i++){ 3074 pe->values[i*NDOF4+0]+=-Jdet*gauss->weight*viscosity*dw[0]*dh1dh6[2][i]/2; 3075 pe->values[i*NDOF4+1]+=-Jdet*gauss->weight*viscosity*dw[1]*dh1dh6[2][i]/2; 3076 pe->values[i*NDOF4+2]+=-Jdet*gauss->weight*viscosity*(dw[0]*dh1dh6[0][i]+dw[1]*dh1dh6[1][i]+dw[2]*dh1dh6[2][i])/2; 3077 pe->values[i*NDOF4+3]+=Jdet*gauss->weight*stokesreconditioning*dw[2]*l1l6[i]; 3078 } 3079 } 3080 3081 /*Clean up and return*/ 3082 delete gauss; 3083 return pe; 3084 } 3085 /*}}}*/ 3086 /*FUNCTION Penta::CreatePVectorCouplingPattynStokesFriction{{{1*/ 3087 ElementVector* Penta::CreatePVectorCouplingPattynStokesFriction(void){ 3088 3089 const int numdof=NUMVERTICES*NDOF4; 3090 int i,j; 3091 int ig; 3092 double xyz_list_tria[NUMVERTICES2D][3]; 3093 double xyz_list[NUMVERTICES][3]; 3094 double bed_normal[3]; 3095 GaussPenta *gauss=NULL; 3096 double epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/ 3097 double viscosity, w, alpha2_gauss; 3098 double dw[3]; 3099 double Pe_gaussian[24]={0.0}; //for the six nodes 3100 double l1l6[6]; //for the six nodes of the penta 3101 double dh1dh6[3][6]; //for the six nodes of the penta 3102 double Jdet; 3103 double Jdet2d; 3104 Tria* tria=NULL; 3105 Friction* friction=NULL; 3106 double stokesreconditioning; 3107 int approximation; 3108 int analysis_type; 3109 3110 /*Initialize Element vector and return if necessary*/ 3111 if(IsOnWater() || !IsOnBed() || IsOnShelf()) return NULL; 3112 inputs->GetParameterValue(&approximation,ApproximationEnum); 3113 if(approximation!=PattynStokesApproximationEnum) return NULL; 3114 ElementVector* pe=NewElementVector(nodes,NUMVERTICES,this->parameters,StokesApproximationEnum); 3115 3116 /*Retrieve all inputs and parameters*/ 3117 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 3118 parameters->FindParam(&analysis_type,AnalysisTypeEnum); 3119 this->parameters->FindParam(&stokesreconditioning,StokesReconditioningEnum); 3120 Input* vx_input=inputs->GetInput(VxEnum); ISSMASSERT(vx_input); 3121 Input* vy_input=inputs->GetInput(VyEnum); ISSMASSERT(vy_input); 3122 Input* vz_input=inputs->GetInput(VzEnum); ISSMASSERT(vz_input); 3123 Input* vzpattyn_input=inputs->GetInput(VzPattynEnum); ISSMASSERT(vzpattyn_input); 3124 3125 3126 for(i=0;i<NUMVERTICES2D;i++){ 3127 for(j=0;j<3;j++){ 3128 xyz_list_tria[i][j]=xyz_list[i][j]; 3129 } 3130 } 3096 for(i=0;i<NUMVERTICES2D;i++) for(j=0;j<3;j++) xyz_list_tria[i][j]=xyz_list[i][j]; 3131 3097 3132 3098 /*build friction object, used later on: */ … … 3139 3105 gauss->GaussPoint(ig); 3140 3106 3141 /*Get the Jacobian determinant */3142 3107 GetTriaJacobianDeterminant(&Jdet2d, &xyz_list_tria[0][0], gauss); 3143 3144 /*Get L matrix : */3145 3108 GetNodalFunctionsP1(l1l6, gauss); 3146 3109 3147 /*Get normal vecyor to the bed */ 3110 vzpattyn_input->GetParameterValue(&w, gauss); 3111 vzpattyn_input->GetParameterDerivativeValue(&dw[0],&xyz_list[0][0],gauss); 3112 3148 3113 BedNormal(&bed_normal[0],xyz_list_tria); 3149 3150 /*Get Viscosity*/3151 3114 this->GetStrainRate3d(&epsilon[0],&xyz_list[0][0],gauss,vx_input,vy_input,vz_input); 3152 3115 matice->GetViscosity3dStokes(&viscosity,&epsilon[0]); 3153 3154 /*Get friction*/3155 3116 friction->GetAlpha2(&alpha2_gauss, gauss,VxEnum,VyEnum,VzEnum); 3156 3157 /*Get w and its derivatives*/3158 vzpattyn_input->GetParameterValue(&w, gauss);3159 vzpattyn_input->GetParameterDerivativeValue(&dw[0],&xyz_list[0][0],gauss);3160 3117 3161 3118 for(i=0;i<NUMVERTICES2D;i++){ … … 3230 3187 ElementVector* Penta::CreatePVectorDiagnosticHutter(void){ 3231 3188 3232 int i,j,k; 3233 int ig; 3189 /*Constants*/ 3234 3190 const int numdofs=NDOF2*NUMVERTICES; 3235 double xyz_list[NUMVERTICES][3]; 3236 double xyz_list_segment[2][3];3237 double z_list[NUMVERTICES];3238 double z_segment[2];3239 double slope2,constant_part;3240 int node0,node1;3241 GaussPenta* gauss=NULL;3242 double slope[2];3243 double z_g;3244 double rho_ice,gravity,n,B;3245 double Jdet;3246 double ub,vb;3247 double surface,thickness;3248 int connectivity[2];3191 3192 /*Intermediaries*/ 3193 int i,j,k,ig; 3194 int node0,node1; 3195 int connectivity[2]; 3196 double Jdet; 3197 double xyz_list[NUMVERTICES][3]; 3198 double xyz_list_segment[2][3]; 3199 double z_list[NUMVERTICES]; 3200 double z_segment[2],slope[2]; 3201 double slope2,constant_part; 3202 double rho_ice,gravity,n,B; 3203 double ub,vb,z_g,surface,thickness; 3204 GaussPenta* gauss=NULL; 3249 3205 3250 3206 /*Initialize Element vector and return if necessary*/ … … 3266 3222 /*Loop on the three segments*/ 3267 3223 for(i=0;i<3;i++){ 3268 3269 3224 node0=i; 3270 3225 node1=i+3; … … 3335 3290 ElementVector* Penta::CreatePVectorDiagnosticPattyn(void){ 3336 3291 3337 /* node data:*/3292 /*Constants*/ 3338 3293 const int numdof=NDOF2*NUMVERTICES; 3339 int i,j; 3340 int ig; 3341 double xyz_list[NUMVERTICES][3]; 3342 double slope[3]; //do not put 2! this goes into GetParameterDerivativeValue, which addresses slope[3] also! 3343 double driving_stress_baseline; 3344 double thickness; 3345 GaussPenta *gauss=NULL; 3346 double Jdet; 3347 double l1l6[6]; 3348 double pe_g_gaussian[numdof]; 3294 3295 /*Intermediaries*/ 3296 int i,j,ig; 3297 double Jdet; 3298 double slope[3]; //do not put 2! this goes into GetParameterDerivativeValue, which addresses slope[3] also! 3299 double driving_stress_baseline,thickness; 3300 double xyz_list[NUMVERTICES][3]; 3301 double l1l6[6]; 3302 GaussPenta *gauss=NULL; 3349 3303 3350 3304 /*Initialize Element vector and return if necessary*/ … … 3363 3317 gauss->GaussPoint(ig); 3364 3318 3319 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss); 3320 GetNodalFunctionsP1(l1l6, gauss); 3321 3365 3322 thickness_input->GetParameterValue(&thickness, gauss); 3366 3323 surface_input->GetParameterDerivativeValue(&slope[0],&xyz_list[0][0],gauss); 3367 3368 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss);3369 GetNodalFunctionsP1(l1l6, gauss);3370 3324 3371 3325 driving_stress_baseline=matpar->GetRhoIce()*matpar->GetG(); … … 3396 3350 ElementVector* Penta::CreatePVectorDiagnosticStokesViscous(void){ 3397 3351 3398 int i,j; 3399 int ig; 3400 const int numdof=NUMVERTICES*NDOF4; 3401 int numdof2d=NUMVERTICES2D*NDOF4; 3402 double gravity,rho_ice,rho_water; 3403 double xyz_list_tria[NUMVERTICES2D][3]; 3404 double xyz_list[NUMVERTICES][3]; 3405 double bed_normal[3]; 3406 double bed; 3407 GaussPenta *gauss=NULL; 3408 double epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/ 3409 double viscosity; 3410 double water_pressure; 3411 double Pe_temp[27]={0.0}; //for the six nodes and the bubble 3412 double Pe_gaussian[27]={0.0}; //for the six nodes and the bubble 3413 double Ke_temp[27][3]={0.0}; //for the six nodes and the bubble 3414 double Pe_reduced[numdof]; //for the six nodes only 3415 double Ke_gaussian[27][3]; 3416 double l1l6[6]; //for the six nodes of the penta 3352 /*Constants*/ 3353 const int numdofbubble=NDOF4*NUMVERTICES+NDOF3*1; 3354 3355 /*Intermediaries*/ 3356 int i,j,ig; 3357 int approximation; 3358 double Jdet,viscosity; 3359 double gravity,rho_ice,stokesreconditioning; 3360 double xyz_list[NUMVERTICES][3]; 3361 double epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/ 3417 3362 double l1l7[7]; //for the six nodes and the bubble 3418 double B[8][ 27];3419 double B_prime[8][ 27];3363 double B[8][numdofbubble]; 3364 double B_prime[8][numdofbubble]; 3420 3365 double B_prime_bubble[8][3]; 3421 double Jdet;3422 double Jdet2d;3423 3366 double D[8][8]={0.0}; 3424 3367 double D_scalar; 3425 double tBD[27][8]; 3426 Tria* tria=NULL; 3427 double stokesreconditioning; 3428 int approximation; 3368 double tBD[numdofbubble][8]; 3369 double Pe_gaussian[numdofbubble]={0.0}; //for the six nodes and the bubble 3370 double Ke_temp[numdofbubble][3]={0.0}; //for the six nodes and the bubble 3371 double Ke_gaussian[numdofbubble][3]; 3372 GaussPenta *gauss=NULL; 3429 3373 3430 3374 /*Initialize Element vector and return if necessary*/ … … 3436 3380 /*Retrieve all inputs and parameters*/ 3437 3381 this->parameters->FindParam(&stokesreconditioning,StokesReconditioningEnum); 3438 rho_water=matpar->GetRhoWater();3439 3382 rho_ice=matpar->GetRhoIce(); 3440 3383 gravity=matpar->GetG(); … … 3443 3386 Input* vy_input=inputs->GetInput(VyEnum); ISSMASSERT(vy_input); 3444 3387 Input* vz_input=inputs->GetInput(VzEnum); ISSMASSERT(vz_input); 3445 Input* bed_input=inputs->GetInput(BedEnum); ISSMASSERT(bed_input);3446 3388 3447 3389 /* Start looping on the number of gaussian points: */ … … 3451 3393 gauss->GaussPoint(ig); 3452 3394 3395 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss); 3396 GetBStokes(&B[0][0],&xyz_list[0][0],gauss); 3397 GetBprimeStokes(&B_prime[0][0],&xyz_list[0][0], gauss); 3398 GetNodalFunctionsMINI(&l1l7[0], gauss); 3399 3453 3400 this->GetStrainRate3d(&epsilon[0],&xyz_list[0][0],gauss,vx_input,vy_input,vz_input); 3454 3401 matice->GetViscosity3dStokes(&viscosity,&epsilon[0]); 3455 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss); 3456 GetNodalFunctionsMINI(&l1l7[0], gauss); 3457 3458 /* Build gaussian vector */ 3402 3459 3403 for(i=0;i<NUMVERTICES+1;i++){ 3460 Pe_gaussian[i*NDOF4+2]=-rho_ice*gravity*Jdet*gauss->weight*l1l7[i]; 3461 } 3462 3463 /*Add Pe_gaussian to terms in Pe_temp. Watch out for column orientation from matlab: */ 3464 for(i=0;i<27;i++) Pe_temp[i]+=Pe_gaussian[i]; 3465 3466 /*Get B and Bprime matrices: */ 3467 GetBStokes(&B[0][0],&xyz_list[0][0],gauss); 3468 GetBprimeStokes(&B_prime[0][0],&xyz_list[0][0], gauss); 3404 Pe_gaussian[i*NDOF4+2]+=-rho_ice*gravity*Jdet*gauss->weight*l1l7[i]; 3405 } 3469 3406 3470 3407 /*Get bubble part of Bprime */ 3471 3408 for(i=0;i<8;i++) for(j=0;j<3;j++) B_prime_bubble[i][j]=B_prime[i][j+24]; 3472 3409 3473 /* Build the D matrix: we plug the gaussian weight, the thickness, the viscosity, and the jacobian determinant3474 * onto this scalar matrix, so that we win some computational time: */3475 3410 D_scalar=gauss->weight*Jdet; 3476 3411 for (i=0;i<6;i++) D[i][i]=D_scalar*2*viscosity; 3477 3412 for (i=6;i<8;i++) D[i][i]=-D_scalar*stokesreconditioning; 3478 3413 3479 /* Do the triple product tB*D*Bprime: */ 3480 MatrixMultiply(&B[0][0],8,27,1,&D[0][0],8,8,0,&tBD[0][0],0); 3481 MatrixMultiply(&tBD[0][0],27,8,0,&B_prime_bubble[0][0],8,3,0,&Ke_gaussian[0][0],0); 3482 3483 /*Add Ke_gaussian and Ke_gaussian to terms in pKe. Watch out for column orientation from matlab: */ 3484 for(i=0;i<27;i++) for(j=0;j<3;j++) Ke_temp[i][j]+=Ke_gaussian[i][j]; 3414 MatrixMultiply(&B[0][0],8,numdofbubble,1,&D[0][0],8,8,0,&tBD[0][0],0); 3415 MatrixMultiply(&tBD[0][0],numdofbubble,8,0,&B_prime_bubble[0][0],8,3,0,&Ke_gaussian[0][0],0); 3416 3417 for(i=0;i<numdofbubble;i++) for(j=0;j<NDOF3;j++) Ke_temp[i][j]+=Ke_gaussian[i][j]; 3485 3418 } 3486 3419 3487 3420 /*Condensation*/ 3488 ReduceVectorStokes(pe->values, &Ke_temp[0][0], &Pe_ temp[0]);3421 ReduceVectorStokes(pe->values, &Ke_temp[0][0], &Pe_gaussian[0]); 3489 3422 3490 3423 /*Clean up and return*/ … … 3496 3429 ElementVector* Penta::CreatePVectorDiagnosticStokesShelf(void){ 3497 3430 3498 int i,j; 3499 int ig; 3500 const int numdof=NUMVERTICES*NDOF4; 3501 int numdof2d=NUMVERTICES2D*NDOF4; 3502 double gravity,rho_ice,rho_water; 3503 double xyz_list_tria[NUMVERTICES2D][3]; 3504 double xyz_list[NUMVERTICES][3]; 3505 double bed_normal[3]; 3506 double bed; 3507 GaussPenta *gauss=NULL; 3508 double epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/ 3509 double viscosity; 3510 double water_pressure; 3511 double Pe_temp[27]={0.0}; //for the six nodes and the bubble 3512 double Pe_gaussian[27]={0.0}; //for the six nodes and the bubble 3513 double Ke_temp[27][3]={0.0}; //for the six nodes and the bubble 3514 double Pe_reduced[numdof]; //for the six nodes only 3515 double Ke_gaussian[27][3]; 3516 double l1l6[6]; //for the six nodes of the penta 3517 double l1l7[7]; //for the six nodes and the bubble 3518 double B[8][27]; 3519 double B_prime[8][27]; 3520 double B_prime_bubble[8][3]; 3521 double Jdet; 3522 double Jdet2d; 3523 double D[8][8]={0.0}; 3524 double D_scalar; 3525 double tBD[27][8]; 3526 Tria* tria=NULL; 3527 double stokesreconditioning; 3528 int approximation; 3431 /*Intermediaries*/ 3432 int i,j,ig; 3433 int approximation; 3434 double gravity,rho_water,bed,water_pressure; 3435 double xyz_list_tria[NUMVERTICES2D][3]; 3436 double xyz_list[NUMVERTICES][3]; 3437 double bed_normal[3]; 3438 double l1l6[6]; //for the six nodes of the penta 3439 double Jdet2d; 3440 Tria* tria=NULL; 3441 GaussPenta *gauss=NULL; 3529 3442 3530 3443 /*Initialize Element vector and return if necessary*/ … … 3535 3448 3536 3449 /*Retrieve all inputs and parameters*/ 3537 this->parameters->FindParam(&stokesreconditioning,StokesReconditioningEnum);3538 3450 rho_water=matpar->GetRhoWater(); 3539 rho_ice=matpar->GetRhoIce();3540 3451 gravity=matpar->GetG(); 3541 3452 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 3542 Input* vx_input=inputs->GetInput(VxEnum); ISSMASSERT(vx_input);3543 Input* vy_input=inputs->GetInput(VyEnum); ISSMASSERT(vy_input);3544 Input* vz_input=inputs->GetInput(VzEnum); ISSMASSERT(vz_input);3545 3453 Input* bed_input=inputs->GetInput(BedEnum); ISSMASSERT(bed_input); 3546 3454 3547 3548 for(i=0;i<NUMVERTICES2D;i++){ 3549 for(j=0;j<3;j++){ 3550 xyz_list_tria[i][j]=xyz_list[i][j]; 3551 } 3552 } 3455 for(i=0;i<NUMVERTICES2D;i++) for(j=0;j<3;j++) xyz_list_tria[i][j]=xyz_list[i][j]; 3553 3456 3554 3457 /* Start looping on the number of gauss 2d (nodes on the bedrock) */ … … 3559 3462 3560 3463 GetTriaJacobianDeterminant(&Jdet2d, &xyz_list_tria[0][0], gauss); 3464 GetNodalFunctionsP1(l1l6, gauss); 3465 3561 3466 bed_input->GetParameterValue(&bed, gauss); 3562 GetNodalFunctionsP1(l1l6, gauss); 3563 3467 BedNormal(&bed_normal[0],xyz_list_tria); 3564 3468 water_pressure=gravity*rho_water*bed; 3565 3566 BedNormal(&bed_normal[0],xyz_list_tria);3567 3469 3568 3470 for(i=0;i<NUMVERTICES2D;i++) for(j=0;j<3;j++) pe->values[i*NDOF4+j]+=water_pressure*gauss->weight*Jdet2d*l1l6[i]*bed_normal[j]; … … 3605 3507 ElementVector* Penta::CreatePVectorDiagnosticVertVolume(void){ 3606 3508 3607 const int numdof=NDOF1*NUMVERTICES; 3608 double xyz_list[NUMVERTICES][3]; 3609 int* doflist=NULL; 3610 int i; 3611 int ig; 3509 /*Constants*/ 3510 const int numdof=NDOF1*NUMVERTICES; 3511 3512 /*Intermediaries*/ 3513 int i,ig; 3514 int approximation; 3515 double Jdet; 3516 double xyz_list[NUMVERTICES][3]; 3517 double dudx,dvdy,dwdz; 3518 double du[3],dv[3],dw[3]; 3519 double l1l6[6]; 3612 3520 GaussPenta *gauss=NULL; 3613 double Jdet;3614 double l1l6[6];3615 Tria* tria=NULL;3616 double du[3];3617 double dv[3];3618 double dw[3];3619 double dudx,dvdy,dwdz;3620 int approximation;3621 3521 3622 3522 /*Initialize Element vector and return if necessary*/ … … 3640 3540 gauss->GaussPoint(ig); 3641 3541 3542 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss); 3543 GetNodalFunctionsP1(l1l6, gauss); 3544 3642 3545 vx_input->GetParameterDerivativeValue(&du[0],&xyz_list[0][0],gauss); 3643 3546 vy_input->GetParameterDerivativeValue(&dv[0],&xyz_list[0][0],gauss); … … 3650 3553 dvdy=dv[1]; 3651 3554 3652 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss);3653 GetNodalFunctionsP1(l1l6, gauss);3654 3655 3555 for (i=0;i<numdof;i++) pe->values[i] += (dudx+dvdy+dwdz)*Jdet*gauss->weight*l1l6[i]; 3656 3556 } … … 3735 3635 ElementVector* Penta::CreatePVectorThermalVolume(void){ 3736 3636 3637 /*Constants*/ 3737 3638 const int numdof=NUMVERTICES*NDOF1; 3738 int i,j; 3739 int ig; 3740 int found=0; 3741 double xyz_list[NUMVERTICES][3]; 3639 3640 /*Intermediaries*/ 3641 int i,j,ig,found=0; 3642 int friction_type; 3643 double Jdet,phi,dt; 3644 double rho_ice,heatcapacity; 3645 double viscosity,temperature; 3646 double scalar_def,scalar_transient; 3647 double temperature_list[NUMVERTICES]; 3648 double xyz_list[NUMVERTICES][3]; 3649 double L[numdof]; 3650 double epsilon[6]; 3742 3651 GaussPenta *gauss=NULL; 3743 double temperature_list[NUMVERTICES];3744 double temperature;3745 double gravity,rho_ice,rho_water;3746 double mixed_layer_capacity,heatcapacity;3747 double beta,meltingpoint,thermal_exchange_velocity;3748 int friction_type;3749 double P_terms[numdof]={0.0};3750 double L[numdof];3751 double l1l2l3[3];3752 double basalfriction;3753 double epsilon[6];3754 double epsilon_sqr[3][3];3755 double epsilon_matrix[3][3];3756 double Jdet;3757 double viscosity;3758 double epsilon_eff;3759 double phi;3760 double t_pmp;3761 double scalar;3762 double scalar_def;3763 double scalar_ocean;3764 double scalar_transient;3765 Tria* tria=NULL;3766 double dt;3767 3652 3768 3653 /*Initialize Element vector and return if necessary*/ … … 3773 3658 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 3774 3659 this->parameters->FindParam(&dt,DtEnum); 3775 rho_water=matpar->GetRhoWater();3776 3660 rho_ice=matpar->GetRhoIce(); 3777 gravity=matpar->GetG();3778 3661 heatcapacity=matpar->GetHeatCapacity(); 3779 beta=matpar->GetBeta();3780 meltingpoint=matpar->GetMeltingPoint();3781 3662 Input* vx_input=inputs->GetInput(VxEnum); ISSMASSERT(vx_input); 3782 3663 Input* vy_input=inputs->GetInput(VyEnum); ISSMASSERT(vy_input); 3783 3664 Input* vz_input=inputs->GetInput(VzEnum); ISSMASSERT(vz_input); 3784 3665 Input* temperature_input=NULL; 3785 if (dt){ 3786 temperature_input=inputs->GetInput(TemperatureEnum); ISSMASSERT(inputs); 3787 } 3666 if (dt) temperature_input=inputs->GetInput(TemperatureEnum); ISSMASSERT(inputs); 3788 3667 3789 3668 /* Start looping on the number of gaussian points: */ … … 3793 3672 gauss->GaussPoint(ig); 3794 3673 3674 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss); 3675 GetNodalFunctionsP1(&L[0], gauss); 3676 3795 3677 this->GetStrainRate3d(&epsilon[0],&xyz_list[0][0],gauss,vx_input,vy_input,vz_input); 3796 3678 matice->GetViscosity3dStokes(&viscosity,&epsilon[0]); 3797 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss);3798 GetNodalFunctionsP1(&L[0], gauss);3799 3679 GetPhi(&phi, &epsilon[0], viscosity); 3800 3680 -
issm/trunk/src/c/objects/Elements/Tria.cpp
r5934 r5946 3038 3038 /*Intermediaries */ 3039 3039 int i,j,ig; 3040 int* doflist=NULL;3041 3040 double xyz_list[NUMVERTICES][3]; 3042 3041 double surface_normal[3]; … … 3274 3273 /*Intermediaries */ 3275 3274 int i,j,ig,dim; 3276 int* doflist=NULL;3277 3275 double xyz_list[NUMVERTICES][3]; 3278 3276 double Jdettria,dt,vx,vy; … … 3468 3466 /*Intermediaries */ 3469 3467 int i,j,ig; 3470 int* doflist=NULL;3471 3468 double xyz_list[NUMVERTICES][3]; 3472 3469 double dhdt_g,melting_g,accumulation_g,Jdettria; … … 3513 3510 /*Intermediaries */ 3514 3511 int i,j,ig; 3515 int* doflist=NULL;3516 3512 double xyz_list[NUMVERTICES][3]; 3517 3513 double melting_g,accumulation_g,dhdt_g,Jdettria; … … 3558 3554 /*Intermediaries */ 3559 3555 int i,j,ig; 3560 int* doflist=NULL;3561 3556 double xyz_list[NUMVERTICES][3]; 3562 3557 double Jdettria,accumulation_g,melting_g; … … 3703 3698 for (i=0;i<NUMVERTICES;i++){ 3704 3699 for (j=0;j<NDOF2;j++){ 3705 pe _g_gaussian[i*NDOF2+j]=(-driving_stress_baseline*slope[j]-plastic_stress)*Jdet*gauss->weight*l1l2l3[i];3700 pe->values[i*NDOF2+j]+=(-driving_stress_baseline*slope[j]-plastic_stress)*Jdet*gauss->weight*l1l2l3[i]; 3706 3701 } 3707 3702 } … … 3710 3705 for (i=0;i<NUMVERTICES;i++){ 3711 3706 for (j=0;j<NDOF2;j++){ 3712 pe _g_gaussian[i*NDOF2+j]=-driving_stress_baseline*slope[j]*Jdet*gauss->weight*l1l2l3[i];3707 pe->values[i*NDOF2+j]+=-driving_stress_baseline*slope[j]*Jdet*gauss->weight*l1l2l3[i]; 3713 3708 } 3714 3709 } 3715 3710 } 3716 for(i=0;i<numdof;i++) pe->values[i]+=pe_g_gaussian[i];3717 3711 } 3718 3712 … … 3730 3724 /*Intermediaries */ 3731 3725 int i,ig; 3732 int* doflist=NULL;3733 3726 double Jdet; 3734 3727 double thickness,thicknessobs,weight; 3735 3728 double xyz_list[NUMVERTICES][3]; 3736 3729 double l1l2l3[3]; 3737 double pe_g_gaussian[numdof]; 3738 GaussTria* gauss=NULL; 3730 GaussTria* gauss=NULL; 3739 3731 3740 3732 /*Initialize Element vector and return if necessary*/ … … 3774 3766 /*Constants*/ 3775 3767 const int numdof=NDOF2*NUMVERTICES; 3776 double xyz_list[NUMVERTICES][3]; 3777 double vx_list[NUMVERTICES]; 3778 double vy_list[NUMVERTICES]; 3779 double obs_vx_list[NUMVERTICES]; 3780 double obs_vy_list[NUMVERTICES]; 3781 double dux_list[NUMVERTICES]; 3782 double duy_list[NUMVERTICES]; 3783 double weights_list[NUMVERTICES]; 3784 int i; 3785 int ig; 3768 3769 /*Intermediaries */ 3770 int i,ig,response; 3771 double Jdet; 3772 double obs_velocity_mag,velocity_mag; 3773 double dux,duy,meanvel,epsvel; 3774 double scalex=0,scaley=0,scale=0,S=0; 3775 double xyz_list[NUMVERTICES][3]; 3776 double vx_list[NUMVERTICES]; 3777 double vy_list[NUMVERTICES]; 3778 double obs_vx_list[NUMVERTICES]; 3779 double obs_vy_list[NUMVERTICES]; 3780 double dux_list[NUMVERTICES]; 3781 double duy_list[NUMVERTICES]; 3782 double weights_list[NUMVERTICES]; 3783 double l1l2l3[3]; 3786 3784 GaussTria* gauss=NULL; 3787 double obs_velocity_mag,velocity_mag;3788 double dux,duy;3789 double meanvel, epsvel;3790 double pe_g_gaussian[numdof];3791 double Jdet;3792 double l1l2l3[3];3793 double scalex=0;3794 double scaley=0;3795 double scale=0;3796 double S=0;3797 int response;3798 3785 3799 3786 /*Initialize Element vector and return if necessary*/ … … 3946 3933 3947 3934 for (i=0;i<NUMVERTICES;i++){ 3948 pe _g_gaussian[i*NDOF2+0]=dux*Jdet*gauss->weight*l1l2l3[i];3949 pe _g_gaussian[i*NDOF2+1]=duy*Jdet*gauss->weight*l1l2l3[i];3935 pe->values[i*NDOF2+0]+=dux*Jdet*gauss->weight*l1l2l3[i]; 3936 pe->values[i*NDOF2+1]+=duy*Jdet*gauss->weight*l1l2l3[i]; 3950 3937 } 3951 3952 for(i=0;i<numdof;i++) pe->values[i]+=pe_g_gaussian[i];3953 3938 } 3954 3939 … … 3961 3946 ElementVector* Tria::CreatePVectorAdjointStokes(void){ 3962 3947 3963 const int numdof=NDOF4*NUMVERTICES; 3964 int i; 3965 int ig; 3966 double xyz_list[NUMVERTICES][3]; 3967 double vx_list[NUMVERTICES]; 3968 double vy_list[NUMVERTICES]; 3969 double obs_vx_list[NUMVERTICES]; 3970 double obs_vy_list[NUMVERTICES]; 3971 double dux_list[NUMVERTICES]; 3972 double duy_list[NUMVERTICES]; 3973 double weights_list[NUMVERTICES]; 3948 /*Intermediaries */ 3949 int i,ig; 3950 int fit=-1; 3951 int response; 3952 double Jdet; 3953 double obs_velocity_mag,velocity_mag; 3954 double dux,duy,meanvel,epsvel; 3955 double scalex=0,scaley=0,scale=0,S=0; 3956 double xyz_list[NUMVERTICES][3]; 3957 double vx_list[NUMVERTICES]; 3958 double vy_list[NUMVERTICES]; 3959 double obs_vx_list[NUMVERTICES]; 3960 double obs_vy_list[NUMVERTICES]; 3961 double dux_list[NUMVERTICES]; 3962 double duy_list[NUMVERTICES]; 3963 double weights_list[NUMVERTICES]; 3964 double l1l2l3[3]; 3974 3965 GaussTria* gauss=NULL; 3975 double obs_velocity_mag,velocity_mag;3976 double dux,duy;3977 double meanvel, epsvel;3978 double pe_g[numdof]={0.0};3979 double Jdet;3980 double l1l2l3[3];3981 double scalex=0;3982 double scaley=0;3983 double scale=0;3984 double S=0;3985 int fit=-1;3986 int response;3987 3966 3988 3967 /*Initialize Element vector and return if necessary*/ … … 4148 4127 ElementVector* Tria::CreatePVectorDiagnosticHutter(void){ 4149 4128 4150 /*Collapsed formulation: */ 4151 int i; 4152 const int numdofs=NDOF2*NUMVERTICES; 4153 int* doflist=NULL; 4154 double constant_part,ub,vb; 4155 double rho_ice,gravity,n,B; 4156 double slope[2]; 4157 double thickness; 4158 double slope2; 4159 int connectivity; 4129 /*Intermediaries */ 4130 int i,connectivity; 4131 double constant_part,ub,vb; 4132 double rho_ice,gravity,n,B; 4133 double slope2,thickness; 4134 double slope[2]; 4160 4135 GaussTria* gauss=NULL; 4161 4136 … … 4216 4191 ElementVector* Tria::CreatePVectorPrognostic_CG(void){ 4217 4192 4218 /* local declarations */ 4219 int i,j; 4220 4221 /* node data: */ 4193 /*Constants*/ 4222 4194 const int numdof=NDOF1*NUMVERTICES; 4223 double xyz_list[NUMVERTICES][3]; 4224 int* doflist=NULL; 4225 int numberofdofspernode=1; 4226 int ig; 4195 4196 /*Intermediaries */ 4197 int i,j,ig; 4198 double Jdettria,dt; 4199 double accumulation_g,melting_g,thickness_g; 4200 double xyz_list[NUMVERTICES][3]; 4201 double L[NUMVERTICES]; 4227 4202 GaussTria* gauss=NULL; 4228 double L[NUMVERTICES];4229 double Jdettria;4230 double accumulation_g;4231 double melting_g;4232 double thickness_g;4233 double dt;4234 4203 4235 4204 /*Initialize Element vector and return if necessary*/ … … 4251 4220 4252 4221 GetJacobianDeterminant2d(&Jdettria, &xyz_list[0][0],gauss); 4253 GetL(&L[0], &xyz_list[0][0], gauss, numberofdofspernode);4222 GetL(&L[0], &xyz_list[0][0], gauss,NDOF1); 4254 4223 4255 4224 accumulation_input->GetParameterValue(&accumulation_g,gauss); … … 4268 4237 ElementVector* Tria::CreatePVectorPrognostic_DG(void){ 4269 4238 4270 /* local declarations*/4239 /*Constants*/ 4271 4240 const int numdof=NDOF1*NUMVERTICES; 4272 int i,j; 4273 int ig; 4274 double xyz_list[NUMVERTICES][3]; 4275 int* doflist=NULL; 4276 int numberofdofspernode=1; 4241 4242 /*Intermediaries */ 4243 int i,j,ig; 4244 double Jdettria,dt; 4245 double accumulation_g,melting_g,thickness_g; 4246 double xyz_list[NUMVERTICES][3]; 4247 double L[NUMVERTICES]; 4277 4248 GaussTria* gauss=NULL; 4278 double L[NUMVERTICES];4279 double Jdettria;4280 double accumulation_g;4281 double melting_g;4282 double thickness_g;4283 double dt;4284 4249 4285 4250 /*Initialize Element vector and return if necessary*/ … … 4301 4266 4302 4267 GetJacobianDeterminant2d(&Jdettria, &xyz_list[0][0],gauss); 4303 GetL(&L[0], &xyz_list[0][0], gauss, numberofdofspernode);4268 GetL(&L[0], &xyz_list[0][0], gauss,NDOF1); 4304 4269 4305 4270 accumulation_input->GetParameterValue(&accumulation_g,gauss); … … 4318 4283 ElementVector* Tria::CreatePVectorSlope(void){ 4319 4284 4320 /* node data:*/4285 /*Constants*/ 4321 4286 const int numdof=NDOF1*NUMVERTICES; 4322 int i,j; 4323 int ig; 4324 double xyz_list[NUMVERTICES][3]; 4325 int* doflist=NULL; 4287 4288 /*Intermediaries */ 4289 int i,j,ig; 4290 int analysis_type; 4291 double Jdet; 4292 double xyz_list[NUMVERTICES][3]; 4293 double slope[2]; 4294 double l1l2l3[3]; 4326 4295 GaussTria* gauss=NULL; 4327 double Jdet;4328 double l1l2l3[3];4329 double pe_g_gaussian[numdof];4330 double slope[2];4331 int analysis_type;4332 4296 4333 4297 /*Initialize Element vector and return if necessary*/ … … 4352 4316 gauss->GaussPoint(ig); 4353 4317 4318 GetJacobianDeterminant2d(&Jdet, &xyz_list[0][0],gauss); 4319 GetNodalFunctions(l1l2l3, gauss); 4320 4354 4321 slope_input->GetParameterDerivativeValue(&slope[0],&xyz_list[0][0],gauss); 4355 4322 4356 /* Get Jacobian determinant: */4357 GetJacobianDeterminant2d(&Jdet, &xyz_list[0][0],gauss);4358 4359 /*Get nodal functions: */4360 GetNodalFunctions(l1l2l3, gauss);4361 4362 /*Build pe_g_gaussian vector: */4363 4323 if ( (analysis_type==SurfaceSlopeXAnalysisEnum) || (analysis_type==BedSlopeXAnalysisEnum)){ 4364 for(i=0;i<numdof;i++) pe _g_gaussian[i]=Jdet*gauss->weight*slope[0]*l1l2l3[i];4324 for(i=0;i<numdof;i++) pe->values[i]+=Jdet*gauss->weight*slope[0]*l1l2l3[i]; 4365 4325 } 4366 4326 if ( (analysis_type==SurfaceSlopeYAnalysisEnum) || (analysis_type==BedSlopeYAnalysisEnum)){ 4367 for(i=0;i<numdof;i++) pe _g_gaussian[i]=Jdet*gauss->weight*slope[1]*l1l2l3[i];4327 for(i=0;i<numdof;i++) pe->values[i]+=Jdet*gauss->weight*slope[1]*l1l2l3[i]; 4368 4328 } 4369 4370 /*Add pe_g_gaussian vector to pe_g: */4371 for(i=0;i<numdof;i++) pe->values[i]+=pe_g_gaussian[i];4372 4373 4329 } 4374 4330 … … 4381 4337 ElementVector* Tria::CreatePVectorThermalShelf(void){ 4382 4338 4339 /*Constants*/ 4383 4340 const int numdof=NUMVERTICES*NDOF1; 4384 int i; 4385 double xyz_list[NUMVERTICES][3]; 4386 double mixed_layer_capacity; 4387 double thermal_exchange_velocity; 4388 double rho_water; 4389 double rho_ice; 4390 double heatcapacity; 4391 double beta; 4392 double meltingpoint; 4393 double dt; 4394 double pressure; 4395 int ig; 4341 4342 /*Intermediaries */ 4343 int i,ig; 4344 double Jdet; 4345 double mixed_layer_capacity,thermal_exchange_velocity; 4346 double rho_ice,rho_water,pressure,dt,scalar_ocean; 4347 double meltingpoint,beta,heatcapacity,t_pmp; 4348 double xyz_list[NUMVERTICES][3]; 4349 double l1l2l3[NUMVERTICES]; 4396 4350 GaussTria* gauss=NULL; 4397 double Jdet;4398 double l1l2l3[NUMVERTICES];4399 double t_pmp;4400 double scalar_ocean;4401 4351 4402 4352 /*Initialize Element vector and return if necessary*/ … … 4429 4379 4430 4380 scalar_ocean=gauss->weight*Jdet*rho_water*mixed_layer_capacity*thermal_exchange_velocity*(t_pmp)/(heatcapacity*rho_ice); 4431 if(dt){ 4432 scalar_ocean=dt*scalar_ocean; 4433 } 4381 if(dt) scalar_ocean=dt*scalar_ocean; 4434 4382 4435 4383 for(i=0;i<numdof;i++) pe->values[i]+=scalar_ocean*l1l2l3[i]; … … 4444 4392 ElementVector* Tria::CreatePVectorThermalSheet(void){ 4445 4393 4394 /*Constants*/ 4446 4395 const int numdof=NUMVERTICES*NDOF1; 4447 int i; 4448 int ig; 4396 4397 /*Intermediaries */ 4398 int i,ig; 4399 int analysis_type,drag_type; 4449 4400 double xyz_list[NUMVERTICES][3]; 4450 double rho_ice; 4451 double heatcapacity; 4452 double dt; 4453 double pressure_list[3]; 4454 double pressure; 4455 int drag_type; 4456 double basalfriction; 4457 Friction* friction=NULL; 4458 double alpha2,vx,vy; 4459 double geothermalflux_value; 4401 double Jdet,dt; 4402 double rho_ice,heatcapacity,geothermalflux_value; 4403 double basalfriction,alpha2,vx,vy,pressure; 4404 double pressure_list[3]; 4405 double scalar; 4406 double l1l2l3[NUMVERTICES]; 4407 Friction* friction=NULL; 4460 4408 GaussTria* gauss=NULL; 4461 double Jdet;4462 double P_terms[numdof]={0.0};4463 double l1l2l3[NUMVERTICES];4464 double scalar;4465 int analysis_type;4466 4409 4467 4410 /*Initialize Element vector and return if necessary*/ … … 4498 4441 4499 4442 scalar=gauss->weight*Jdet*(basalfriction+geothermalflux_value)/(heatcapacity*rho_ice); 4500 if(dt){ 4501 scalar=dt*scalar; 4502 } 4443 if(dt) scalar=dt*scalar; 4503 4444 4504 4445 for(i=0;i<numdof;i++) pe->values[i]+=scalar*l1l2l3[i];
Note:
See TracChangeset
for help on using the changeset viewer.