Changeset 5879
- Timestamp:
- 09/17/10 17:42:12 (15 years ago)
- Location:
- issm/trunk/src/c/objects/Elements
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/objects/Elements/Penta.cpp
r5877 r5879 700 700 case DiagnosticHorizAnalysisEnum: case AdjointHorizAnalysisEnum: 701 701 Ke=CreateKMatrixDiagnosticHoriz(); 702 if(Ke) Ke->AddToGlobal(Kgg,NULL,NULL);703 delete Ke;704 702 break; 705 703 case DiagnosticHutterAnalysisEnum: 706 704 Ke=CreateKMatrixDiagnosticHutter(); 707 if(Ke) Ke->AddToGlobal(Kgg,NULL,NULL);708 delete Ke;709 705 break; 710 706 case DiagnosticVertAnalysisEnum: 711 707 Ke=CreateKMatrixDiagnosticVert(); 712 if(Ke) Ke->AddToGlobal(Kgg,NULL,NULL);713 delete Ke;714 708 break; 715 709 case BedSlopeXAnalysisEnum: case SurfaceSlopeXAnalysisEnum: case BedSlopeYAnalysisEnum: case SurfaceSlopeYAnalysisEnum: 716 710 Ke=CreateKMatrixSlope(); 717 if(Ke) Ke->AddToGlobal(Kgg,NULL,NULL);718 delete Ke;719 711 break; 720 712 case PrognosticAnalysisEnum: 721 713 Ke=CreateKMatrixPrognostic(); 722 if(Ke) Ke->AddToGlobal(Kgg,NULL,NULL);723 delete Ke;724 714 break; 725 715 case BalancedthicknessAnalysisEnum: 726 716 Ke=CreateKMatrixBalancedthickness(); 727 if(Ke) Ke->AddToGlobal(Kgg,NULL,NULL);728 delete Ke;729 717 break; 730 718 case BalancedvelocitiesAnalysisEnum: 731 719 Ke=CreateKMatrixBalancedvelocities(); 732 if(Ke) Ke->AddToGlobal(Kgg,NULL,NULL);733 delete Ke;734 720 break; 735 721 case ThermalAnalysisEnum: 736 CreateKMatrixThermal( Kgg);722 Ke=CreateKMatrixThermal(); 737 723 break; 738 724 case MeltingAnalysisEnum: 739 725 Ke=CreateKMatrixMelting(); 740 if(Ke) Ke->AddToGlobal(Kgg,NULL,NULL);741 delete Ke;742 726 break; 743 727 default: 744 728 ISSMERROR("analysis %i (%s) not supported yet",analysis_type,EnumToString(analysis_type)); 729 } 730 731 /*Add to global matrix*/ 732 if(Ke){ 733 Ke->AddToGlobal(Kgg,Kff,Kfs); 734 delete Ke; 745 735 } 746 736 } … … 2840 2830 /*}}}*/ 2841 2831 /*FUNCTION Penta::CreateKMatrixThermal {{{1*/ 2842 void Penta::CreateKMatrixThermal(Mat Kgg){ 2843 2844 /* local declarations */ 2832 ElementMatrix* Penta::CreateKMatrixThermal(void){ 2833 2834 /*compute all stiffness matrices for this element*/ 2835 ElementMatrix* Ke1=CreateKMatrixThermalVolume(); 2836 ElementMatrix* Ke2=CreateKMatrixThermalShelf(); 2837 ElementMatrix* Ke =new ElementMatrix(Ke1,Ke2); 2838 printf("-------------- file: Penta.cpp line: %i\n",__LINE__); 2839 Ke->Echo(); 2840 2841 /*clean-up and return*/ 2842 delete Ke1; 2843 delete Ke2; 2844 return Ke; 2845 } 2846 /*}}}*/ 2847 /*FUNCTION Penta::CreateKMatrixThermalVolume {{{1*/ 2848 ElementMatrix* Penta::CreateKMatrixThermalVolume(void){ 2849 2845 2850 int i,j; 2851 int ig; 2846 2852 int found=0; 2847 2848 /* node data: */2849 2853 const int numdof=NDOF1*NUMVERTICES; 2850 2854 double xyz_list[NUMVERTICES][3]; 2851 2855 int* doflist=NULL; 2852 2853 /* gaussian points: */2854 int ig;2855 2856 GaussPenta *gauss=NULL; 2856 2857 2857 double K[2][2]={0.0}; 2858 2859 2858 double u,v,w; 2860 2861 /*matrices: */2862 double K_terms[numdof][numdof]={0.0};2863 2859 double Ke_gaussian_conduct[numdof][numdof]; 2864 2860 double Ke_gaussian_advec[numdof][numdof]; … … 2881 2877 double tBD_artdiff[3][numdof]; 2882 2878 double tLD[numdof]; 2883 2884 2879 double Jdet; 2885 2886 /*Material properties: */2887 2880 double gravity,rho_ice,rho_water; 2888 2881 double heatcapacity,thermalconductivity; 2889 2882 double mixed_layer_capacity,thermal_exchange_velocity; 2890 2891 /*parameters: */2892 2883 double dt,epsvel; 2893 2884 bool artdiff; 2894 2895 /*Collapsed formulation: */2896 2885 Tria* tria=NULL; 2897 2886 2898 /*If on water, skip: */ 2899 if(IsOnWater())return; 2900 2901 /* Get node coordinates and dof list: */ 2887 /*Initialize Element matrix and return if necessary*/ 2888 if(IsOnWater()) return NULL; 2889 ElementMatrix* Ke=this->NewElementMatrix(NoneApproximationEnum); 2890 2891 /*Retrieve all inputs and parameters*/ 2902 2892 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 2903 GetDofList(&doflist,NoneApproximationEnum,GsetEnum);2904 2905 // /*recovre material parameters: */2906 2893 rho_water=matpar->GetRhoWater(); 2907 2894 rho_ice=matpar->GetRhoIce(); … … 2909 2896 heatcapacity=matpar->GetHeatCapacity(); 2910 2897 thermalconductivity=matpar->GetThermalConductivity(); 2911 2912 /*retrieve some parameters: */2913 2898 this->parameters->FindParam(&dt,DtEnum); 2914 2899 this->parameters->FindParam(&artdiff,ArtDiffEnum); 2915 2900 this->parameters->FindParam(&epsvel,EpsVelEnum); 2916 2917 2901 Input* vx_input=inputs->GetInput(VxEnum); ISSMASSERT(vx_input); 2918 2902 Input* vy_input=inputs->GetInput(VyEnum); ISSMASSERT(vy_input); … … 2929 2913 /*Conduction: */ 2930 2914 2931 /*Get B_conduct matrix: */2932 2915 GetBConduct(&B_conduct[0][0],&xyz_list[0][0],gauss); 2933 2916 2934 /*Build D: */2935 2917 D_scalar=gauss->weight*Jdet*(thermalconductivity/(rho_ice*heatcapacity)); 2936 2937 2918 if(dt) D_scalar=D_scalar*dt; 2938 2919 … … 2941 2922 D[2][0]=0; D[2][1]=0; D[2][2]=D_scalar; 2942 2923 2943 /* Do the triple product B'*D*B: */2944 2924 MatrixMultiply(&B_conduct[0][0],3,numdof,1,&D[0][0],3,3,0,&tBD_conduct[0][0],0); 2945 2925 MatrixMultiply(&tBD_conduct[0][0],numdof,3,0,&B_conduct[0][0],3,numdof,0,&Ke_gaussian_conduct[0][0],0); … … 2947 2927 /*Advection: */ 2948 2928 2949 /*Get B_advec and Bprime_advec matrices: */2950 2929 GetBAdvec(&B_advec[0][0],&xyz_list[0][0],gauss); 2951 2930 GetBprimeAdvec(&Bprime_advec[0][0],&xyz_list[0][0],gauss); 2952 2931 2953 //Build the D matrix2954 2932 vx_input->GetParameterValue(&u, gauss); 2955 2933 vy_input->GetParameterValue(&v, gauss); … … 2957 2935 2958 2936 D_scalar=gauss->weight*Jdet; 2959 2960 2937 if(dt) D_scalar=D_scalar*dt; 2961 2938 … … 2964 2941 D[2][0]=0; D[2][1]=0; D[2][2]=D_scalar*w; 2965 2942 2966 /* Do the triple product B'*D*Bprime: */2967 2943 MatrixMultiply(&B_advec[0][0],3,numdof,1,&D[0][0],3,3,0,&tBD_advec[0][0],0); 2968 2944 MatrixMultiply(&tBD_advec[0][0],numdof,3,0,&Bprime_advec[0][0],3,numdof,0,&Ke_gaussian_advec[0][0],0); 2969 2945 2970 2946 /*Transient: */ 2947 2971 2948 if(dt){ 2972 2949 GetNodalFunctionsP1(&L[0], gauss); … … 2974 2951 D_scalar=D_scalar; 2975 2952 2976 /* Do the triple product L'*D*L: */2977 2953 MatrixMultiply(&L[0],numdof,1,0,&D_scalar,1,1,0,&tLD[0],0); 2978 2954 MatrixMultiply(&tLD[0],numdof,1,0,&L[0],1,numdof,0,&Ke_gaussian_transient[0][0],0); … … 2983 2959 2984 2960 /*Artifficial diffusivity*/ 2961 2985 2962 if(artdiff){ 2986 2963 /*Build K: */ … … 2990 2967 K[1][0]=D_scalar*fabs(u)*fabs(v);K[1][1]=D_scalar*pow(v,2); 2991 2968 2992 /*Get B_artdiff: */2993 2969 GetBArtdiff(&B_artdiff[0][0],&xyz_list[0][0],gauss); 2994 2970 2995 /* Do the triple product B'*K*B: */2996 2971 MatrixMultiply(&B_artdiff[0][0],2,numdof,1,&K[0][0],2,2,0,&tBD_artdiff[0][0],0); 2997 2972 MatrixMultiply(&tBD_artdiff[0][0],numdof,2,0,&B_artdiff[0][0],2,numdof,0,&Ke_gaussian_artdiff[0][0],0); … … 3001 2976 } 3002 2977 3003 /*Add Ke_gaussian to pKe: */ 3004 for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) K_terms[i][j]+=Ke_gaussian_conduct[i][j]+Ke_gaussian_advec[i][j]+Ke_gaussian_transient[i][j]+Ke_gaussian_artdiff[i][j]; 3005 } 3006 3007 /*Add Ke_gg to global matrix Kgg: */ 3008 MatSetValues(Kgg,numdof,doflist,numdof,doflist,(const double*)K_terms,ADD_VALUES); 3009 3010 //Ice/ocean heat exchange flux on ice shelf base 3011 if(IsOnBed() && IsOnShelf()){ 3012 3013 tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria. 3014 tria->CreateKMatrixThermal(Kgg); 3015 delete tria->matice; delete tria; 3016 } 3017 3018 /*Free ressources:*/ 2978 for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke->values[i*numdof+j]+=Ke_gaussian_conduct[i][j]+Ke_gaussian_advec[i][j]+Ke_gaussian_transient[i][j]+Ke_gaussian_artdiff[i][j]; 2979 } 2980 2981 /*Clean up and return*/ 3019 2982 delete gauss; 3020 xfree((void**)&doflist); 3021 2983 return Ke; 2984 } 2985 /*}}}*/ 2986 /*FUNCTION Penta::CreateKMatrixThermalShelf {{{1*/ 2987 ElementMatrix* Penta::CreateKMatrixThermalShelf(void){ 2988 2989 if (!IsOnBed() || !IsOnShelf() || IsOnWater()) return NULL; 2990 2991 /*Call Tria function*/ 2992 Tria* tria=(Tria*)SpawnTria(0,1,2); 2993 ElementMatrix* Ke=tria->CreateKMatrixThermal(); 2994 delete tria->matice; delete tria; 2995 2996 return Ke; 3022 2997 } 3023 2998 /*}}}*/ -
issm/trunk/src/c/objects/Elements/Penta.h
r5877 r5879 147 147 ElementMatrix* CreateKMatrixPrognostic(void); 148 148 ElementMatrix* CreateKMatrixSlope(void); 149 void CreateKMatrixThermal(Mat Kggg); 149 ElementMatrix* CreateKMatrixThermal(void); 150 ElementMatrix* CreateKMatrixThermalVolume(void); 151 ElementMatrix* CreateKMatrixThermalShelf(void); 150 152 void CreatePVectorBalancedthickness( Vec pg); 151 153 void CreatePVectorBalancedvelocities( Vec pg); -
issm/trunk/src/c/objects/Elements/Tria.cpp
r5878 r5879 3408 3408 /*}}}*/ 3409 3409 /*FUNCTION Tria::CreateKMatrixThermal {{{1*/ 3410 void Tria::CreateKMatrixThermal(Mat Kgg){ 3411 3410 ElementMatrix* Tria::CreateKMatrixThermal(void){ 3411 3412 const int numdof=NDOF1*NUMVERTICES; 3412 3413 int i,j; 3413 3414 /* node data: */ 3415 const int numdof=NDOF1*NUMVERTICES; 3414 int ig; 3416 3415 double xyz_list[NUMVERTICES][3]; 3417 int* doflist=NULL;3418 3419 3416 double mixed_layer_capacity; 3420 3417 double thermal_exchange_velocity; … … 3422 3419 double rho_ice; 3423 3420 double heatcapacity; 3424 3425 int ig;3426 3421 GaussTria *gauss=NULL; 3427 3428 /*matrices: */3429 3422 double Jdet; 3430 3423 double K_terms[numdof][numdof]={0.0}; … … 3433 3426 double tl1l2l3D[3]; 3434 3427 double D_scalar; 3435 3436 /*parameters: */3437 3428 double dt; 3438 3429 3439 /*retrieve some parameters: */ 3430 /*Initialize Element matrix and return if necessary*/ 3431 if(IsOnWater() || !IsOnShelf()) return NULL; 3432 ElementMatrix* Ke=this->NewElementMatrix(NoneApproximationEnum); 3433 3434 /*Retrieve all inputs and parameters*/ 3435 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 3440 3436 this->parameters->FindParam(&dt,DtEnum); 3441 3442 /* Get node coordinates and dof list: */3443 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);3444 GetDofList(&doflist,NoneApproximationEnum,GsetEnum);3445 3446 //recover material parameters3447 3437 mixed_layer_capacity=matpar->GetMixedLayerCapacity(); 3448 3438 thermal_exchange_velocity=matpar->GetThermalExchangeVelocity(); … … 3457 3447 gauss->GaussPoint(ig); 3458 3448 3459 //Get the Jacobian determinant3460 GetJacobianDeterminant3d(&Jdet, &xyz_list[0][0], gauss);3461 3462 /*Get nodal functions values: */3463 3449 GetNodalFunctions(&l1l2l3[0], gauss); 3464 3450 3465 /*Calculate DL on gauss point */3451 GetJacobianDeterminant3d(&Jdet, &xyz_list[0][0], gauss); 3466 3452 D_scalar=gauss->weight*Jdet*rho_water*mixed_layer_capacity*thermal_exchange_velocity/(heatcapacity*rho_ice); 3467 if(dt){ 3468 D_scalar=dt*D_scalar; 3469 } 3470 3471 /* Do the triple product tL*D*L: */ 3453 if(dt) D_scalar=dt*D_scalar; 3454 3472 3455 MatrixMultiply(&l1l2l3[0],numdof,1,0,&D_scalar,1,1,0,&tl1l2l3D[0],0); 3473 3456 MatrixMultiply(&tl1l2l3D[0],numdof,1,0,&l1l2l3[0],1,numdof,0,&Ke_gaussian[0][0],0); 3474 3457 3475 for(i=0;i<3;i++){ 3476 for(j=0;j<3;j++){ 3477 K_terms[i][j]+=Ke_gaussian[i][j]; 3478 } 3479 } 3458 for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke->values[i*numdof+j]+=Ke_gaussian[i][j]; 3480 3459 } 3481 3460 3482 /*Add Ke_gg to global matrix Kgg: */3483 MatSetValues(Kgg,numdof,doflist,numdof,doflist,(const double*)K_terms,ADD_VALUES);3484 3485 3486 3461 /*Clean up and return*/ 3487 3462 delete gauss; 3488 xfree((void**)&doflist);3463 return Ke; 3489 3464 } 3490 3465 /*}}}*/ -
issm/trunk/src/c/objects/Elements/Tria.h
r5877 r5879 138 138 ElementMatrix* CreateKMatrixPrognostic_DG(void); 139 139 ElementMatrix* CreateKMatrixSlope(void); 140 void CreateKMatrixThermal(Mat Kgg);140 ElementMatrix* CreateKMatrixThermal(void); 141 141 void CreatePVectorBalancedthickness_DG(Vec pg); 142 142 void CreatePVectorBalancedthickness_CG(Vec pg);
Note:
See TracChangeset
for help on using the changeset viewer.