Changeset 15517
- Timestamp:
- 07/18/13 15:55:23 (12 years ago)
- Location:
- issm/trunk-jpl/src/c/classes
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/Elements/Penta.cpp
r15497 r15517 6949 6949 6950 6950 /* Start looping on the number of gaussian points: */ 6951 gauss=new GaussPenta( 3,2);6951 gauss=new GaussPenta(5,5); 6952 6952 for(int ig=gauss->begin();ig<gauss->end();ig++){ 6953 6953 … … 7927 7927 7928 7928 /* Start looping on the number of gaussian points: */ 7929 gauss=new GaussPenta( 3,2);7929 gauss=new GaussPenta(5,5); 7930 7930 for(int ig=gauss->begin();ig<gauss->end();ig++){ 7931 7931 -
issm/trunk-jpl/src/c/classes/Elements/Tria.cpp
r15497 r15517 692 692 } 693 693 /*}}}*/ 694 /*FUNCTION Tria::GetAreaCoordinates{{{*/ 695 void Tria::GetAreaCoordinates(IssmDouble* area_coordinates,IssmDouble xyz_zero[3][3],IssmDouble xyz_list[3][3],int numpoints){ 696 /*Computeportion of the element that is grounded*/ 697 698 int i,j,k; 699 IssmDouble area_init,area_portion; 700 IssmDouble xyz_bis[3][3]; 701 702 GetJacobianDeterminant(&area_init, &xyz_list[0][0],NULL); 703 704 /*Initialize xyz_list with original xyz_list of triangle coordinates*/ 705 for(j=0;j<3;j++){ 706 for(k=0;k<3;j++){ 707 xyz_bis[j][k]=xyz_list[j][k]; 708 } 709 } 710 for(i=0;i<numpoints;i++){ 711 for(j=0;j<3;j++){ 712 for(k=0;k<3;j++){ 713 /*Change appropriate line*/ 714 xyz_bis[j][k]=xyz_zero[i][k]; 715 } 716 717 /*Compute area fraction*/ 718 GetJacobianDeterminant(&area_portion, &xyz_bis[0][0],NULL); 719 *(area_coordinates+3*i+j)=area_portion/area_init; 720 721 /*Reinitialize xyz_list*/ 722 for(k=0;k<3;j++){ 723 /*Reinitialize xyz_list with original coordinates*/ 724 xyz_bis[j][k]=xyz_list[j][k]; 725 } 726 } 727 } 728 } 729 /*}}}*/ 694 730 /*FUNCTION Tria::GetDofList {{{*/ 695 731 void Tria::GetDofList(int** pdoflist, int approximation_enum,int setenum){ … … 724 760 } 725 761 /*}}}*/ 762 /*FUNCTION Tria::GetGroundedPart{{{*/ 763 void Tria::GetGroundedPart(int* point1,IssmDouble* fraction1,IssmDouble* fraction2, bool* mainlyfloating){ 764 /*Computeportion of the element that is grounded*/ 765 766 bool floating=true; 767 int point; 768 const IssmPDouble epsilon= 1.e-15; 769 IssmDouble gl[3]; 770 IssmDouble f1,f2; 771 772 /*Recover parameters and values*/ 773 GetInputListOnVertices(&gl[0],GLlevelsetEnum); 774 775 /*Be sure that values are not zero*/ 776 if(gl[0]==0) gl[0]=gl[0]+epsilon; 777 if(gl[1]==0) gl[1]=gl[1]+epsilon; 778 if(gl[2]==0) gl[2]=gl[2]+epsilon; 779 780 /*Check that not all nodes are grounded or floating*/ 781 if(gl[0]>0 && gl[1]>0 && gl[2]>0){ // All grounded 782 point=0; 783 f1=1.; 784 f2=1.; 785 } 786 else if(gl[0]<0 && gl[1]<0 && gl[2]<0){ //All floating 787 point=0; 788 f1=0.; 789 f2=0.; 790 } 791 else{ 792 if(gl[0]*gl[1]*gl[2]<0) floating=false; 793 794 if(gl[0]*gl[1]>0){ //Nodes 0 and 1 are similar, so points must be found on segment 0-2 and 1-2 795 point=2; 796 f1=gl[2]/(gl[2]-gl[0]); 797 f2=gl[2]/(gl[2]-gl[1]); 798 } 799 else if(gl[1]*gl[2]>0){ //Nodes 1 and 2 are similar, so points must be found on segment 0-1 and 0-2 800 point=0; 801 f1=gl[0]/(gl[0]-gl[1]); 802 f2=gl[0]/(gl[0]-gl[2]); 803 } 804 else if(gl[0]*gl[2]>0){ //Nodes 0 and 2 are similar, so points must be found on segment 1-0 and 1-2 805 point=1; 806 f1=gl[1]/(gl[1]-gl[2]); 807 f2=gl[1]/(gl[1]-gl[0]); 808 } 809 } 810 *point1=point; 811 *fraction1=f1; 812 *fraction2=f2; 813 *mainlyfloating=floating; 814 } 815 /*}}}*/ 726 816 /*FUNCTION Tria::GetGroundedPortion{{{*/ 727 817 IssmDouble Tria::GetGroundedPortion(IssmDouble* xyz_list){ … … 826 916 } 827 917 /*}}}*/ 828 /*FUNCTION Tria::GetGroundedPart{{{*/ 829 void Tria::GetGroundedPart(int* point1,IssmDouble* fraction1,IssmDouble* fraction2, bool* mainlyfloating){ 918 /*FUNCTION Tria::GetSegmentNormal {{{*/ 919 void Tria:: GetSegmentNormal(IssmDouble* normal,IssmDouble xyz_list[2][3]){ 920 921 /*Build unit outward pointing vector*/ 922 IssmDouble vector[2]; 923 IssmDouble norm; 924 925 vector[0]=xyz_list[1][0] - xyz_list[0][0]; 926 vector[1]=xyz_list[1][1] - xyz_list[0][1]; 927 928 norm=sqrt(pow(vector[0],2.0)+pow(vector[1],2.0)); 929 930 normal[0]= + vector[1]/norm; 931 normal[1]= - vector[0]/norm; 932 } 933 /*}}}*/ 934 /*FUNCTION Tria::GetZeroLevelsetCoordinates{{{*/ 935 void Tria::GetZeroLevelsetCoordinates(IssmDouble* xyz_zero,IssmDouble xyz_list[3][3],int levelsetenum){ 830 936 /*Computeportion of the element that is grounded*/ 831 937 832 bool floating=true; 833 int point; 834 const IssmPDouble epsilon= 1.e-15; 835 IssmDouble gl[3]; 836 IssmDouble f1,f2; 938 int normal_orientation; 939 IssmDouble s1,s2; 940 IssmDouble levelset[3]; 837 941 838 942 /*Recover parameters and values*/ 839 GetInputListOnVertices(&gl[0],GLlevelsetEnum); 840 841 /*Be sure that values are not zero*/ 842 if(gl[0]==0) gl[0]=gl[0]+epsilon; 843 if(gl[1]==0) gl[1]=gl[1]+epsilon; 844 if(gl[2]==0) gl[2]=gl[2]+epsilon; 845 846 /*Check that not all nodes are grounded or floating*/ 847 if(gl[0]>0 && gl[1]>0 && gl[2]>0){ // All grounded 848 point=0; 849 f1=1.; 850 f2=1.; 851 } 852 else if(gl[0]<0 && gl[1]<0 && gl[2]<0){ //All floating 853 point=0; 854 f1=0.; 855 f2=0.; 856 } 857 else{ 858 if(gl[0]*gl[1]*gl[2]<0) floating=false; 859 860 if(gl[0]*gl[1]>0){ //Nodes 0 and 1 are similar, so points must be found on segment 0-2 and 1-2 861 point=2; 862 f1=gl[2]/(gl[2]-gl[0]); 863 f2=gl[2]/(gl[2]-gl[1]); 864 } 865 else if(gl[1]*gl[2]>0){ //Nodes 1 and 2 are similar, so points must be found on segment 0-1 and 0-2 866 point=0; 867 f1=gl[0]/(gl[0]-gl[1]); 868 f2=gl[0]/(gl[0]-gl[2]); 869 } 870 else if(gl[0]*gl[2]>0){ //Nodes 0 and 2 are similar, so points must be found on segment 1-0 and 1-2 871 point=1; 872 f1=gl[1]/(gl[1]-gl[2]); 873 f2=gl[1]/(gl[1]-gl[0]); 874 } 875 } 876 *point1=point; 877 *fraction1=f1; 878 *fraction2=f2; 879 *mainlyfloating=floating; 943 GetInputListOnVertices(&levelset[0],levelsetenum); 944 945 if(levelset[0]*levelset[1]>0){ //Nodes 0 and 1 are similar, so points must be found on segment 0-2 and 1-2 946 /*Portion of the segments*/ 947 s1=levelset[2]/(levelset[2]-levelset[1]); 948 s2=levelset[2]/(levelset[2]-levelset[0]); 949 950 if(levelset[2]>0) normal_orientation=0; 951 /*New point 1*/ 952 *(xyz_zero+3*normal_orientation+0)=xyz_list[2][0]+s1*(xyz_list[1][0]-xyz_list[2][0]); 953 *(xyz_zero+3*normal_orientation+1)=xyz_list[2][1]+s1*(xyz_list[1][1]-xyz_list[2][1]); 954 *(xyz_zero+3*normal_orientation+2)=xyz_list[2][2]+s1*(xyz_list[1][2]-xyz_list[2][2]); 955 956 /*New point 0*/ 957 *(xyz_zero+3*(1-normal_orientation)+0)=xyz_list[2][0]+s2*(xyz_list[0][0]-xyz_list[2][0]); 958 *(xyz_zero+3*(1-normal_orientation)+1)=xyz_list[2][1]+s2*(xyz_list[0][1]-xyz_list[2][1]); 959 *(xyz_zero+3*(1-normal_orientation)+2)=xyz_list[2][2]+s2*(xyz_list[0][2]-xyz_list[2][2]); 960 } 961 else if(levelset[1]*levelset[2]>0){ //Nodes 1 and 2 are similar, so points must be found on segment 0-1 and 0-2 962 /*Portion of the segments*/ 963 s1=levelset[0]/(levelset[0]-levelset[2]); 964 s2=levelset[0]/(levelset[0]-levelset[1]); 965 966 if(levelset[0]>0) normal_orientation=0; 967 /*New point 1*/ 968 *(xyz_zero+3*normal_orientation+0)=xyz_list[0][0]+s1*(xyz_list[2][0]-xyz_list[0][0]); 969 *(xyz_zero+3*normal_orientation+1)=xyz_list[0][1]+s1*(xyz_list[2][1]-xyz_list[0][1]); 970 *(xyz_zero+3*normal_orientation+2)=xyz_list[0][2]+s1*(xyz_list[2][2]-xyz_list[0][2]); 971 972 /*New point 2*/ 973 *(xyz_zero+3*(1-normal_orientation)+0)=xyz_list[0][0]+s2*(xyz_list[1][0]-xyz_list[0][0]); 974 *(xyz_zero+3*(1-normal_orientation)+1)=xyz_list[0][1]+s2*(xyz_list[1][1]-xyz_list[0][1]); 975 *(xyz_zero+3*(1-normal_orientation)+2)=xyz_list[0][2]+s2*(xyz_list[1][2]-xyz_list[0][2]); 976 } 977 else if(levelset[0]*levelset[2]>0){ //Nodes 0 and 2 are similar, so points must be found on segment 1-0 and 1-2 978 /*Portion of the segments*/ 979 s1=levelset[1]/(levelset[1]-levelset[0]); 980 s2=levelset[1]/(levelset[1]-levelset[2]); 981 982 if(levelset[1]>0) normal_orientation=0; 983 /*New point 0*/ 984 *(xyz_zero+3*normal_orientation+0)=xyz_list[1][0]+s1*(xyz_list[0][0]-xyz_list[1][0]); 985 *(xyz_zero+3*normal_orientation+1)=xyz_list[1][1]+s1*(xyz_list[0][1]-xyz_list[1][1]); 986 *(xyz_zero+3*normal_orientation+2)=xyz_list[1][2]+s1*(xyz_list[0][2]-xyz_list[1][2]); 987 988 /*New point 2*/ 989 *(xyz_zero+3*(1-normal_orientation)+0)=xyz_list[1][0]+s2*(xyz_list[2][0]-xyz_list[1][0]); 990 *(xyz_zero+3*(1-normal_orientation)+1)=xyz_list[1][1]+s2*(xyz_list[2][1]-xyz_list[1][1]); 991 *(xyz_zero+3*(1-normal_orientation)+2)=xyz_list[1][2]+s2*(xyz_list[2][2]-xyz_list[1][2]); 992 } 993 880 994 } 881 995 /*}}}*/ … … 3006 3120 3007 3121 /*Intermediaries */ 3008 int i,j; 3009 IssmDouble ls[3]; 3010 IssmDouble xyz_list[NUMVERTICES][3]; 3011 3012 /*Fetch number of nodes and dof for this finite element*/ 3013 int numnodes = this->NumberofNodes(); 3014 int numdof = numnodes*NDOF2; 3015 Icefront *icefront=NULL; 3122 IssmDouble ls[3]; 3123 IssmDouble xyz_list[NUMVERTICES][3]; 3124 bool isfront; 3016 3125 3017 3126 return NULL; 3127 3018 3128 /*Retrieve all inputs and parameters*/ 3019 GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES);3020 3129 GetInputListOnVertices(&ls[0],IcelevelsetEnum); 3021 ElementVector* pe=new ElementVector(nodes,NUMVERTICES,this->parameters,MacAyealApproximationEnum); 3022 GaussTria* gauss = new GaussTria(2); 3023 IssmDouble* basis = xNew<IssmDouble>(numnodes); 3024 3025 /*Create Ice Front if necessary*/ 3130 3131 /*If the level set is awlays <0, there is no ice front here*/ 3132 isfront = false; 3026 3133 if(ls[0]>0. || ls[1]>0. || ls[2]>0.){ 3027 3134 if(ls[0]*ls[1]<0. || ls[0]*ls[2]<0. || (ls[0]*ls[1]+ls[0]*ls[2]+ls[1]*ls[2]==0.)){ 3028 //icefront=new Icefront("2d",inputs,matpar,MacAyealApproximationEnum,analysis_type); 3135 isfront = true; 3136 } 3137 } 3138 3139 /*If no front, return NULL*/ 3140 if(!isfront) return NULL; 3141 3142 /*Fetch number of nodes and dof for this finite element*/ 3143 int numnodes = this->NumberofNodes(); 3144 int numdof = numnodes*NDOF2; 3145 IssmDouble rho_ice,rho_water,gravity; 3146 IssmDouble Jdet,thickness,bed,water_pressure,ice_pressure,air_pressure; 3147 IssmDouble surface_under_water,base_under_water,pressure; 3148 GaussTria* gauss; 3149 IssmDouble* basis = xNew<IssmDouble>(numnodes); 3150 IssmDouble xyz_list_front[2][3]; 3151 IssmDouble area_coordinates[2][3]; 3152 IssmDouble normal[2]; 3153 3154 GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 3155 ElementVector* pe=new ElementVector(nodes,NUMVERTICES,this->parameters,MacAyealApproximationEnum); 3156 Input* thickness_input=inputs->GetInput(ThicknessEnum); _assert_(thickness_input); 3157 Input* bed_input =inputs->GetInput(BedEnum); _assert_(bed_input); 3158 rho_water=matpar->GetRhoWater(); 3159 rho_ice =matpar->GetRhoIce(); 3160 gravity =matpar->GetG(); 3161 GetZeroLevelsetCoordinates(&xyz_list_front[0][0],xyz_list,IcelevelsetEnum); 3162 GetAreaCoordinates(&area_coordinates[0][0],xyz_list_front,xyz_list,2); 3163 GetSegmentNormal(&normal[0],xyz_list_front); 3164 3165 /*Start looping on Gaussian points*/ 3166 gauss=new GaussTria(area_coordinates,3); 3167 3168 for(int ig=gauss->begin();ig<gauss->end();ig++){ 3169 3170 gauss->GaussPoint(ig); 3171 thickness_input->GetInputValue(&thickness,gauss); 3172 bed_input->GetInputValue(&bed,gauss); 3173 3174 surface_under_water=min(0.,thickness+bed); // 0 if the top of the glacier is above water level 3175 base_under_water=min(0.,bed); // 0 if the bottom of the glacier is above water level 3176 water_pressure=1.0/2.0*gravity*rho_water*(pow(surface_under_water,2) - pow(base_under_water,2)); 3177 ice_pressure=1.0/2.0*gravity*rho_ice*pow(thickness,2); 3178 air_pressure=0; 3179 3180 pressure = ice_pressure + water_pressure + air_pressure; 3181 3182 GetSegmentJacobianDeterminant(&Jdet,&xyz_list_front[0][0],gauss); 3183 GetNodalFunctions(basis,gauss); 3184 3185 for (int i=0;i<numnodes;i++){ 3186 pe->values[2*i+0]+= pressure*Jdet*gauss->weight*normal[0]*basis[i]; 3187 pe->values[2*i+1]+= pressure*Jdet*gauss->weight*normal[1]*basis[i]; 3029 3188 } 3030 3189 } … … 3037 3196 delete gauss; 3038 3197 return pe; 3198 3039 3199 } 3040 3200 /*}}}*/ -
issm/trunk-jpl/src/c/classes/Elements/Tria.h
r15497 r15517 195 195 ElementVector* CreatePVectorSlope(void); 196 196 IssmDouble GetArea(void); 197 void GetAreaCoordinates(IssmDouble *area_coordinates,IssmDouble xyz_zero[3][3],IssmDouble xyz_list[3][3],int numpoints); 197 198 int GetElementType(void); 198 199 void GetDofList(int** pdoflist,int approximation_enum,int setenum); … … 202 203 IssmDouble GetGroundedPortion(IssmDouble* xyz_list); 203 204 void GetGroundedPart(int* point1,IssmDouble* fraction1, IssmDouble* fraction2,bool* mainlyfloating); 205 void GetSegmentNormal(IssmDouble* normal,IssmDouble xyz_list[2][3]); 206 void GetZeroLevelsetCoordinates(IssmDouble* xyz_zero,IssmDouble xyz_list[3][3],int levelsetenum); 204 207 void GetInputListOnVertices(IssmDouble* pvalue,int enumtype); 205 208 void GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue); -
issm/trunk-jpl/src/c/classes/gauss/GaussTria.cpp
r15429 r15517 87 87 coords2[i]=0.5*(b1+b2) + 0.5*seg_coords[i]*(b2-b1); 88 88 coords3[i]=0.5*(c1+c2) + 0.5*seg_coords[i]*(c2-c1); 89 weights[i]=seg_weights[i]; 90 } 91 92 /*Initialize static fields as undefined*/ 93 weight=UNDEF; 94 coord1=UNDEF; 95 coord2=UNDEF; 96 coord3=UNDEF; 97 98 /*clean up*/ 99 xDelete<double>(seg_coords); 100 xDelete<double>(seg_weights); 101 } 102 /*}}}*/ 103 /*FUNCTION GaussTria::GaussTria(IssmDouble area_coordinates,int order) {{{*/ 104 GaussTria::GaussTria(IssmDouble area_coordinates[2][3],int order){ 105 106 /*Intermediaties*/ 107 IssmPDouble *seg_coords = NULL; 108 IssmPDouble *seg_weights = NULL; 109 int i,index3; 110 111 /*Get Segment gauss points*/ 112 numgauss=order; 113 GaussLegendreLinear(&seg_coords,&seg_weights,numgauss); 114 115 /*Allocate GaussTria fields*/ 116 coords1=xNew<IssmDouble>(numgauss); 117 coords2=xNew<IssmDouble>(numgauss); 118 coords3=xNew<IssmDouble>(numgauss); 119 weights=xNew<IssmDouble>(numgauss); 120 121 /*Build Triangle Gauss point*/ 122 for(i=0;i<numgauss;i++){ 123 coords1[i]=0.5*(area_coordinates[0][0]+area_coordinates[1][0]) + 0.5*seg_coords[i]*(area_coordinates[1][0]-area_coordinates[0][0]); 124 coords2[i]=0.5*(area_coordinates[0][1]+area_coordinates[1][1]) + 0.5*seg_coords[i]*(area_coordinates[1][1]-area_coordinates[0][1]); 125 coords3[i]=0.5*(area_coordinates[0][2]+area_coordinates[1][2]) + 0.5*seg_coords[i]*(area_coordinates[1][2]-area_coordinates[0][2]); 89 126 weights[i]=seg_weights[i]; 90 127 } -
issm/trunk-jpl/src/c/classes/gauss/GaussTria.h
r15298 r15517 31 31 GaussTria(int index1,int index2,int order); 32 32 GaussTria(int index,IssmDouble r1, IssmDouble r2,bool maintlyfloating,int order); 33 GaussTria(IssmDouble area_coordinates[3][3],int order); 33 34 ~GaussTria(); 34 35
Note:
See TracChangeset
for help on using the changeset viewer.