Changeset 5640
- Timestamp:
- 09/01/10 07:59:46 (15 years ago)
- Location:
- issm/trunk/src/c
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/Container/Inputs.cpp
r5537 r5640 71 71 } 72 72 /*}}}*/ 73 /*FUNCTION Inputs::GetParameterValue(double* pvalue,GaussTria* gauss,int enum_type){{{1*/ 74 void Inputs::GetParameterValue(double* pvalue,GaussTria* gauss, int enum_type){ 75 76 vector<Object*>::iterator object; 77 Input* input=NULL; 78 bool found=false; 79 80 /*Go through inputs and check whether any input with the same name is already in: */ 81 for ( object=objects.begin() ; object < objects.end(); object++ ){ 82 83 input=(Input*)(*object); 84 if (input->EnumType()==enum_type){ 85 found=true; 86 break; 87 } 88 } 89 90 if (!found){ 91 /*we could not find an input with the correct enum type. No defaults values were provided, 92 * error out: */ 93 ISSMERROR("could not find input with enum type %i (%s)",enum_type,EnumToString(enum_type)); 94 } 95 96 /*Ok, we have an input if we made it here, request the input to return the values: */ 97 input->GetParameterValue(pvalue,gauss); 98 99 } 100 /*}}}*/ 73 101 /*FUNCTION Inputs::GetParameterValue(double* pvalue,double* gauss,int enum_type,double defaultvalue){{{1*/ 74 102 void Inputs::GetParameterValue(double* pvalue,double* gauss, int enum_type,double defaultvalue){ -
issm/trunk/src/c/Container/Inputs.h
r5537 r5640 16 16 class Input; 17 17 class Node; 18 class GaussTria; 18 19 19 20 class Inputs: public DataSet{ … … 43 44 void GetParameterValue(double* pvalue,int enum_type); 44 45 void GetParameterValue(double* pvalue,double* gauss,int enum_type); 46 void GetParameterValue(double* pvalue,GaussTria* gauss,int enum_type); 45 47 void GetParameterValue(double* pvalue,double* gauss,int enum_type,double defaultvalue); 46 48 void GetParameterValues(double* values,double* gauss_pointers, int numgauss,int enum_type); -
issm/trunk/src/c/objects/Elements/Penta.cpp
r5635 r5640 2158 2158 switch(analysis_type){ 2159 2159 2160 case DiagnosticHorizAnalysisEnum: case DiagnosticVertAnalysisEnum:2160 case DiagnosticHorizAnalysisEnum: 2161 2161 2162 2162 /*default vx,vy and vz: either observation or 0 */ 2163 2163 if(!iomodel->vx){ 2164 if ( false && iomodel->vx_obs) for(i=0;i<6;i++)nodeinputs[i]=iomodel->vx_obs[penta_vertex_ids[i]-1]/iomodel->yts; // false TO BE DELETED (for NR CM)2164 if (iomodel->vx_obs) for(i=0;i<6;i++)nodeinputs[i]=iomodel->vx_obs[penta_vertex_ids[i]-1]/iomodel->yts; 2165 2165 else for(i=0;i<6;i++)nodeinputs[i]=0; 2166 2166 this->inputs->AddInput(new PentaVertexInput(VxEnum,nodeinputs)); … … 2169 2169 } 2170 2170 if(!iomodel->vy){ 2171 if ( false && iomodel->vy_obs) for(i=0;i<6;i++)nodeinputs[i]=iomodel->vy_obs[penta_vertex_ids[i]-1]/iomodel->yts; // false TO BE DELETED (for NR CM)2171 if (iomodel->vy_obs) for(i=0;i<6;i++)nodeinputs[i]=iomodel->vy_obs[penta_vertex_ids[i]-1]/iomodel->yts; 2172 2172 else for(i=0;i<6;i++)nodeinputs[i]=0; 2173 2173 this->inputs->AddInput(new PentaVertexInput(VyEnum,nodeinputs)); … … 4579 4579 double L[numdof]; 4580 4580 double l1l2l3[3]; 4581 double alpha2_list[3];4582 double basalfriction_list[3]={0.0};4583 4581 double basalfriction; 4584 4582 double epsilon[6]; -
issm/trunk/src/c/objects/Elements/Tria.cpp
r5639 r5640 688 688 GetJacobianDeterminant2d(&Jdet, &xyz_list[0][0],gauss); 689 689 690 /*Add Tikhonov regularization term to misfit*/ 690 /*Add Tikhonov regularization term to misfit: 691 * 692 * WARNING: for now, the regularization is only taken into account by the gradient 693 * the misfit reflects the response only! 694 * 695 * */ 691 696 if (control_type==DragCoefficientEnum){ 692 if (!shelf) return 0; //only shelf?... TO BE CHECKED693 697 ISSMASSERT(drag_input); 694 698 drag_input->GetParameterDerivativeValue(&dk[0],&xyz_list[0][0],gauss); 695 Jelem+=cm_noisedmp*1/2*(pow(dk[0],2)+pow(dk[1],2))*Jdet*gauss->weight;699 //Jelem+=cm_noisedmp*1/2*(pow(dk[0],2)+pow(dk[1],2))*Jdet*gauss->weight; 696 700 } 697 701 else if (control_type==RheologyBbarEnum){ 698 702 ISSMASSERT(Bbar_input); 699 703 Bbar_input->GetParameterDerivativeValue(&dB[0], &xyz_list[0][0], gauss); 700 Jelem+=cm_noisedmp*1/2*(pow(dB[0],2)+pow(dB[1],2))*Jdet*gauss->weight;704 //Jelem+=cm_noisedmp*1/2*(pow(dB[0],2)+pow(dB[1],2))*Jdet*gauss->weight; 701 705 } 702 706 else if (control_type==DhDtEnum){ 703 707 ISSMASSERT(dhdt_input); 704 708 dhdt_input->GetParameterDerivativeValue(&dB[0], &xyz_list[0][0], gauss); 705 Jelem+=cm_noisedmp*1/2*(pow(dB[0],2)+pow(dB[1],2))*Jdet*gauss->weight;709 //Jelem+=cm_noisedmp*1/2*(pow(dB[0],2)+pow(dB[1],2))*Jdet*gauss->weight; 706 710 } 707 711 else{ … … 1029 1033 /*nodal functions: */ 1030 1034 double l1l2l3[3]; 1031 double alpha2complement_list[numvertices]; //TO BE DELETED1032 double gaussgrids[numvertices][numvertices] = {{1,0,0},{0,1,0},{0,0,1}}; //TO BE DELETED1033 1035 1034 1036 /* strain rate: */ … … 1068 1070 friction=new Friction("2d",inputs,matpar,analysis_type); 1069 1071 1070 /*COMPUT alpha2_list (TO BE DELETED)*/1071 for(i=0;i<numvertices;i++){1072 friction->GetAlphaComplement(&alpha2complement_list[i],&gaussgrids[i][0],VxEnum,VyEnum);1073 }1074 1075 1072 /*Retrieve all inputs we will be needing: */ 1076 1073 adjointx_input=inputs->GetInput(AdjointxEnum); … … 1087 1084 1088 1085 /*Build alpha_complement_list: */ 1089 //if (drag_type==2) friction->GetAlphaComplement(&alpha_complement, gauss,VxEnum,VyEnum); // TO BE UNCOMMENTED 1090 //else alpha_complement=0; 1091 TriaRef::GetParameterValue(&alpha_complement,&alpha2complement_list[0],gauss); // TO BE DELETED 1086 if (drag_type==2) friction->GetAlphaComplement(&alpha_complement, gauss,VxEnum,VyEnum); 1087 else alpha_complement=0; 1092 1088 1093 1089 /*Recover alpha_complement and k: */ … … 2594 2590 switch(analysis_type){ 2595 2591 2596 case DiagnosticHorizAnalysisEnum: case DiagnosticVertAnalysisEnum:2592 case DiagnosticHorizAnalysisEnum: 2597 2593 2598 2594 /*default vx,vy and vz: either observation or 0 */ 2599 2595 if(!iomodel->vx){ 2600 if ( false && iomodel->vx_obs) for(i=0;i<3;i++)nodeinputs[i]=iomodel->vx_obs[tria_vertex_ids[i]-1]/iomodel->yts; //false TO BE DELETED (for NR CM)2596 if (iomodel->vx_obs) for(i=0;i<3;i++)nodeinputs[i]=iomodel->vx_obs[tria_vertex_ids[i]-1]/iomodel->yts; 2601 2597 else for(i=0;i<3;i++)nodeinputs[i]=0; 2602 2598 this->inputs->AddInput(new TriaVertexInput(VxEnum,nodeinputs)); … … 2605 2601 } 2606 2602 if(!iomodel->vy){ 2607 if ( false && iomodel->vy_obs) for(i=0;i<3;i++)nodeinputs[i]=iomodel->vy_obs[tria_vertex_ids[i]-1]/iomodel->yts; //false TO BE DELETED (for NR CM)2603 if (iomodel->vy_obs) for(i=0;i<3;i++)nodeinputs[i]=iomodel->vy_obs[tria_vertex_ids[i]-1]/iomodel->yts; 2608 2604 else for(i=0;i<3;i++)nodeinputs[i]=0; 2609 2605 this->inputs->AddInput(new TriaVertexInput(VyEnum,nodeinputs)); … … 3256 3252 Friction *friction = NULL; 3257 3253 double alpha2; 3258 double alpha2_list[numvertices]; //TO BE DELETED3259 double gaussgrids[numvertices][numvertices] = {{1,0,0},{0,1,0},{0,0,1}}; //TO BE DELETED3260 3254 3261 3255 double MAXSLOPE=.06; // 6 % … … 3295 3289 friction=new Friction("2d",inputs,matpar,analysis_type); 3296 3290 3297 /*COMPUT alpha2_list (TO BE DELETED)*/3298 for(i=0;i<numvertices;i++){3299 friction->GetAlpha2(&alpha2_list[i],&gaussgrids[i][0],VxEnum,VyEnum,VzEnum);3300 }3301 3302 3291 /* Start looping on the number of gaussian points: */ 3303 3292 gauss=new GaussTria(2); … … 3307 3296 3308 3297 /*Friction: */ 3309 // friction->GetAlpha2(&alpha2, gauss,VxEnum,VyEnum,VzEnum); // TO UNCOMMENT 3310 TriaRef::GetParameterValue(&alpha2,&alpha2_list[0],gauss); // TO BE DELETED 3298 friction->GetAlpha2(&alpha2, gauss,VxEnum,VyEnum,VzEnum); 3311 3299 3312 3300 // If we have a slope > 6% for this element, it means we are on a mountain. In this particular case, … … 3388 3376 Friction *friction = NULL; 3389 3377 double alpha2; 3390 double alpha2_list[numvertices]; //TO BE DELETED3391 double gaussgrids[numvertices][numvertices] = {{1,0,0},{0,1,0},{0,0,1}}; //TO BE DELETED3392 3378 3393 3379 double MAXSLOPE=.06; // 6 % … … 3426 3412 friction=new Friction("2d",inputs,matpar,analysis_type); 3427 3413 3428 /*COMPUT alpha2_list (TO BE DELETED)*/3429 for(i=0;i<numvertices;i++){3430 friction->GetAlpha2(&alpha2_list[i],&gaussgrids[i][0],VxEnum,VyEnum,VzEnum);3431 }3432 3433 3414 /* Start looping on the number of gaussian points: */ 3434 3415 gauss=new GaussTria(2); … … 3438 3419 3439 3420 /*Friction: */ 3440 // friction->GetAlpha2(&alpha2, gauss,VxEnum,VyEnum,VzEnum); // TO UNCOMMENT 3441 TriaRef::GetParameterValue(&alpha2,&alpha2_list[0],gauss); // TO BE DELETED 3421 friction->GetAlpha2(&alpha2, gauss,VxEnum,VyEnum,VzEnum); 3442 3422 3443 3423 // If we have a slope > 6% for this element, it means we are on a mountain. In this particular case, … … 3517 3497 Friction *friction = NULL; 3518 3498 double alpha2; 3519 double alpha2_list[numvertices]; //TO BE DELETED3520 double gaussgrids[numvertices][numvertices] = {{1,0,0},{0,1,0},{0,0,1}}; //TO BE DELETED3521 3499 3522 3500 double MAXSLOPE=.06; // 6 % … … 3555 3533 friction=new Friction("2d",inputs,matpar,analysis_type); 3556 3534 3557 /*COMPUT alpha2_list (TO BE DELETED)*/3558 for(i=0;i<numvertices;i++){3559 friction->GetAlpha2(&alpha2_list[i],&gaussgrids[i][0],VxEnum,VyEnum,VzEnum);3560 }3561 3562 3535 /* Start looping on the number of gaussian points: */ 3563 3536 gauss=new GaussTria(2); … … 3567 3540 3568 3541 /*Friction: */ 3569 // friction->GetAlpha2(&alpha2, gauss,VxEnum,VyEnum,VzEnum); // TO UNCOMMENT 3570 TriaRef::GetParameterValue(&alpha2,&alpha2_list[0],gauss); // TO BE DELETED 3542 friction->GetAlpha2(&alpha2, gauss,VxEnum,VyEnum,VzEnum); // TO UNCOMMENT 3571 3543 3572 3544 // If we have a slope > 6% for this element, it means we are on a mountain. In this particular case, … … 5607 5579 double alpha2,vx,vy; 5608 5580 double geothermalflux_value; 5609 double alpha2_list[numvertices]; //TO BE DELETED5610 double gaussgrids[numvertices][numvertices] = {{1,0,0},{0,1,0},{0,0,1}}; //TO BE DELETED5611 double vx_list[numvertices]; //TO BE DELETED5612 double vy_list[numvertices]; //TO BE DELETED5613 double basalfriction_list[numvertices]; //TO BE DELETED5614 5581 5615 5582 /* gaussian points: */ … … 5629 5596 5630 5597 /*inputs: */ 5631 Input* vx_input=NULL; //TO BE DELETED5632 Input* vy_input=NULL; //TO BE DELETED5633 Input* vz_input=NULL; //TO BE DELETED5598 Input* vx_input=NULL; 5599 Input* vy_input=NULL; 5600 Input* vz_input=NULL; 5634 5601 Input* geothermalflux_input=NULL; 5635 5602 … … 5656 5623 geothermalflux_input=inputs->GetInput(GeothermalFluxEnum); 5657 5624 5658 /*COMPUT alpha2_list and basalfriction_list (TO BE DELETED)*/5659 for(i=0;i<numvertices;i++){5660 friction->GetAlpha2(&alpha2_list[i],&gaussgrids[i][0],VxEnum,VyEnum,VzEnum); //TO BE DELETED5661 }5662 vx_input->GetParameterValues(&vx_list[0],&gaussgrids[0][0],3); //TO BE DELETED5663 vy_input->GetParameterValues(&vy_list[0],&gaussgrids[0][0],3); //TO BE DELETED5664 for(i=0;i<numvertices;i++){5665 basalfriction_list[i]=alpha2_list[i]*(pow(vx_list[i],(double)2.0)+pow(vy_list[i],(double)2.0)); //TO BE DELETED5666 }5667 5668 5625 /* Ice/ocean heat exchange flux on ice shelf base */ 5669 5626 … … 5684 5641 5685 5642 /*Friction: */ 5686 //friction->GetAlpha2(&alpha2,&gauss_coord[0],VxEnum,VyEnum,VzEnum); 5687 TriaRef::GetParameterValue(&basalfriction,&basalfriction_list[0],gauss); // TO BE DELETED 5643 friction->GetAlpha2(&alpha2,gauss,VxEnum,VyEnum,VzEnum); 5688 5644 5689 5645 /*Calculate scalar parameter*/ -
issm/trunk/src/c/objects/Loads/Friction.cpp
r5103 r5640 116 116 } 117 117 /*}}}*/ 118 /*FUNCTION Friction::GetAlpha2{{{1*/ 119 void Friction::GetAlpha2(double* palpha2, GaussTria* gauss,int vxenum,int vyenum,int vzenum){ 120 121 /*This routine calculates the basal friction coefficient 122 alpha2= drag^2 * Neff ^r * vel ^s, with Neff=rho_ice*g*thickness+rho_ice*g*bed, r=q/p and s=1/p**/ 123 124 /*diverse: */ 125 double r,s; 126 double drag_p, drag_q; 127 double gravity,rho_ice,rho_water; 128 double Neff; 129 double thickness,bed; 130 double vx,vy,vz,vmag; 131 double drag_coefficient; 132 double alpha2; 133 134 135 /*Recover parameters: */ 136 inputs->GetParameterValue(&drag_p,DragPEnum); 137 inputs->GetParameterValue(&drag_q,DragQEnum); 138 inputs->GetParameterValue(&thickness, gauss,ThicknessEnum); 139 inputs->GetParameterValue(&bed, gauss,BedEnum); 140 inputs->GetParameterValue(&drag_coefficient, gauss,DragCoefficientEnum); 141 142 /*Get material parameters: */ 143 gravity=matpar->GetG(); 144 rho_ice=matpar->GetRhoIce(); 145 rho_water=matpar->GetRhoWater(); 146 147 //compute r and q coefficients: */ 148 r=drag_q/drag_p; 149 s=1./drag_p; 150 151 //From bed and thickness, compute effective pressure when drag is viscous: 152 Neff=gravity*(rho_ice*thickness+rho_water*bed); 153 154 /*If effective pressure becomes negative, sliding becomes unstable (Paterson 4th edition p 148). This is because 155 the water pressure is so high, the ice sheet elevates over its ice bumps and slides. But the limit behaviour 156 for friction should be an ice shelf sliding (no basal drag). Therefore, for any effective pressure Neff < 0, we should 157 replace it by Neff=0 (ie, equival it to an ice shelf)*/ 158 if (Neff<0)Neff=0; 159 160 if(strcmp(element_type,"2d")==0){ 161 inputs->GetParameterValue(&vx, gauss,vxenum); 162 inputs->GetParameterValue(&vy, gauss,vyenum); 163 vmag=sqrt(pow(vx,2)+pow(vy,2)); 164 } 165 else if (strcmp(element_type,"3d")==0){ 166 inputs->GetParameterValue(&vx, gauss,vxenum); 167 inputs->GetParameterValue(&vy, gauss,vyenum); 168 inputs->GetParameterValue(&vz, gauss,vzenum); 169 vmag=sqrt(pow(vx,2)+pow(vy,2)+pow(vz,2)); 170 } 171 else ISSMERROR("element_type %s not supported yet",element_type); 172 173 alpha2=pow(drag_coefficient,2)*pow(Neff,r)*pow(vmag,(s-1)); 174 175 /*Assign output pointers:*/ 176 *palpha2=alpha2; 177 } 178 /*}}}*/ 118 179 /*FUNCTION Friction::GetAlphaComplement {{{1*/ 119 180 void Friction::GetAlphaComplement(double* palpha_complement, double* gauss,int vxenum,int vyenum){ … … 174 235 } 175 236 /*}}}*/ 237 /*FUNCTION Friction::GetAlphaComplement {{{1*/ 238 void Friction::GetAlphaComplement(double* palpha_complement, GaussTria* gauss,int vxenum,int vyenum){ 239 240 /* FrictionGetAlpha2 computes alpha2= drag^2 * Neff ^r * vel ^s, with Neff=rho_ice*g*thickness+rho_ice*g*bed, r=q/p and s=1/p. 241 * FrictionGetAlphaComplement is used in control methods on drag, and it computes: 242 * alpha_complement= Neff ^r * vel ^s*/ 243 244 /*diverse: */ 245 int i; 246 double Neff; 247 double r,s; 248 double vx; 249 double vy; 250 double vmag; 251 double drag_p,drag_q; 252 double drag_coefficient; 253 double bed,thickness; 254 double gravity,rho_ice,rho_water; 255 double alpha_complement; 256 257 /*Recover parameters: */ 258 inputs->GetParameterValue(&drag_p,DragPEnum); 259 inputs->GetParameterValue(&drag_q,DragQEnum); 260 inputs->GetParameterValue(&thickness, gauss,ThicknessEnum); 261 inputs->GetParameterValue(&bed, gauss,BedEnum); 262 inputs->GetParameterValue(&drag_coefficient, gauss,DragCoefficientEnum); 263 264 /*Get material parameters: */ 265 gravity=matpar->GetG(); 266 rho_ice=matpar->GetRhoIce(); 267 rho_water=matpar->GetRhoWater(); 268 269 270 //compute r and q coefficients: */ 271 r=drag_q/drag_p; 272 s=1./drag_p; 273 274 //From bed and thickness, compute effective pressure when drag is viscous: 275 Neff=gravity*(rho_ice*thickness+rho_water*bed); 276 277 /*If effective pressure becomes negative, sliding becomes unstable (Paterson 4th edition p 148). This is because 278 the water pressure is so high, the ice sheet elevates over its ice bumps and slides. But the limit behaviour 279 for friction should be an ice shelf sliding (no basal drag). Therefore, for any effective pressure Neff < 0, we should 280 replace it by Neff=0 (ie, equival it to an ice shelf)*/ 281 if (Neff<0)Neff=0; 282 283 //We need the velocity magnitude to evaluate the basal stress: 284 inputs->GetParameterValue(&vx, gauss,vxenum); 285 inputs->GetParameterValue(&vy, gauss,vyenum); 286 vmag=sqrt(pow(vx,2)+pow(vy,2)); 287 288 alpha_complement=pow(Neff,r)*pow(vmag,(s-1)); 289 290 /*Assign output pointers:*/ 291 *palpha_complement=alpha_complement; 292 293 } 294 /*}}}*/ -
issm/trunk/src/c/objects/Loads/Friction.h
r4007 r5640 28 28 void Echo(void); 29 29 void GetAlpha2(double* palpha2, double* gauss,int vxenum,int vyenum,int vzenum); 30 void GetAlpha2(double* palpha2, GaussTria* gauss,int vxenum,int vyenum,int vzenum); 30 31 void GetAlphaComplement(double* alpha_complement, double* gauss,int vxenum,int vyenum); 32 void GetAlphaComplement(double* alpha_complement, GaussTria* gauss,int vxenum,int vyenum); 31 33 32 34 };
Note:
See TracChangeset
for help on using the changeset viewer.