source:
issm/oecreview/Archive/25834-26739/ISSM-26652-26653.diff
Last change on this file was 26740, checked in by , 3 years ago | |
---|---|
File size: 9.4 KB |
-
../trunk-jpl/src/c/classes/Elements/Penta.cpp
1295 1295 else phi = f1*f2; 1296 1296 1297 1297 /*Compute weights*/ 1298 gauss = this->NewGauss(point,f1,f2, trapezeisnegative,2);1298 gauss = this->NewGauss(point,f1,f2,1-trapezeisnegative,2); 1299 1299 1300 1300 total_weight = 0.0; 1301 1301 for(int i=0;i<NUMVERTICES2D;i++)weights[i] = 0; … … 1305 1305 total_weight += gauss->weight; 1306 1306 } 1307 1307 1308 /*Normalize to phi*/ 1309 if(total_weight>0.){ 1310 for(int i=0;i<NUMVERTICES2D;i++) weights[i] = weights[i]*phi/total_weight; 1311 } 1308 /*Normalizing to phi such that weights provide coefficients for integration over subelement (for averaging:phi*weights)*/ 1309 if(total_weight>0.) for(int i=0;i<NUMVERTICES;i++) weights[i] = weights[i]*phi/total_weight; 1312 1310 else for(int i=0;i<NUMVERTICES2D;i++) weights[i] = 0.0; 1313 1311 1314 1312 /*Cleanup*/ … … 2206 2204 2207 2205 IssmDouble basetot; 2208 2206 height = 0.0; 2209 for(int i=0;i<NUMVERTICES2D;i++) height += weights[i] *heights[i];2207 for(int i=0;i<NUMVERTICES2D;i++) height += weights[i]/phi*heights[i]; 2210 2208 basetot = 1./2.*fabs((xyz_list[0][0]-xyz_list[2][0])*(xyz_list[1][1]-xyz_list[0][1]) - (xyz_list[0][0]-xyz_list[1][0])*(xyz_list[2][1]-xyz_list[0][1])); 2211 2209 base = basetot*phi; 2212 2210 … … 2216 2214 Element::GetInputListOnVertices(&scalefactor_vertices[0],MeshScaleFactorEnum); 2217 2215 /*Compute loop only over lower vertices: i<NUMVERTICES2D*/ 2218 2216 scalefactor = 0.0; 2219 for(int i=0;i<NUMVERTICES2D;i++) scalefactor += weights[i] *scalefactor_vertices[i];2217 for(int i=0;i<NUMVERTICES2D;i++) scalefactor += weights[i]/phi*scalefactor_vertices[i]; 2220 2218 base = base*scalefactor; 2221 2219 xDelete<IssmDouble>(scalefactor_vertices); 2222 2220 } … … 4388 4386 /*The smb[Gt yr-1] of one element is area[m2] * smb [ m ice yr^-1] * rho_ice [kg m-3] / 1e+10^12 */ 4389 4387 IssmDouble base,smb,rho_ice,scalefactor; 4390 4388 IssmDouble Total_Smb=0; 4389 IssmDouble lsf[NUMVERTICES]; 4391 4390 IssmDouble xyz_list[NUMVERTICES][3]; 4392 4391 4393 4392 /*Get material parameters :*/ … … 4403 4402 base = 1./2. * fabs((xyz_list[0][0]-xyz_list[2][0])*(xyz_list[1][1]-xyz_list[0][1]) - (xyz_list[0][0]-xyz_list[1][0])*(xyz_list[2][1]-xyz_list[0][1])); 4404 4403 4405 4404 /*Now get the average SMB over the element*/ 4406 Input* smb_input = this->GetInput(SmbMassBalanceEnum); _assert_(smb_input); 4405 Element::GetInputListOnVertices(&lsf[0],MaskIceLevelsetEnum); 4406 if(false && (lsf[0]*lsf[1]<=0 || lsf[0]*lsf[2]<=0 || lsf[1]*lsf[2]<=0)){ 4407 /*Partially ice-covered element*/ 4408 bool mainlyice; 4409 int point; 4410 IssmDouble* smb_vertices = xNew<IssmDouble>(NUMVERTICES); 4411 IssmDouble weights[NUMVERTICES2D]; 4412 IssmDouble lsf2d[NUMVERTICES2D]; 4413 IssmDouble f1,f2,phi; 4414 Element::GetInputListOnVertices(&smb_vertices[0],SmbMassBalanceEnum); 4415 for(int i=0;i<NUMVERTICES2D;i++) lsf2d[i] = lsf[i]; 4416 GetFractionGeometry2D(weights,&phi,&point,&f1,&f2,&mainlyice,lsf2d); 4417 smb = 0.0; 4418 for(int i=0;i<NUMVERTICES2D;i++) smb += weights[i]*smb_vertices[i]; 4407 4419 4408 smb_input->GetInputAverage(&smb); 4409 if(scaled==true){ 4410 Input* scalefactor_input = this->GetInput(MeshScaleFactorEnum); _assert_(scalefactor_input); 4411 scalefactor_input->GetInputAverage(&scalefactor);// average scalefactor on element 4420 if(scaled==true){ 4421 IssmDouble* scalefactor_vertices = xNew<IssmDouble>(NUMVERTICES); 4422 Element::GetInputListOnVertices(&scalefactor_vertices[0],MeshScaleFactorEnum); 4423 /*Compute loop only over lower vertices: i<NUMVERTICES2D*/ 4424 scalefactor = 0.0; 4425 for(int i=0;i<NUMVERTICES2D;i++) scalefactor += weights[i]/phi*scalefactor_vertices[i]; 4426 xDelete<IssmDouble>(scalefactor_vertices); 4427 } 4428 else scalefactor = 1.0; 4429 4430 /*Cleanup*/ 4431 xDelete<IssmDouble>(smb_vertices); 4412 4432 } 4433 4413 4434 else{ 4414 scalefactor=1.; 4435 /*Fully ice-covered element*/ 4436 Input* smb_input = this->GetInput(SmbMassBalanceEnum); _assert_(smb_input); 4437 smb_input->GetInputAverage(&smb); 4438 4439 if(scaled==true){ 4440 Input* scalefactor_input = this->GetInput(MeshScaleFactorEnum); _assert_(scalefactor_input); 4441 scalefactor_input->GetInputAverage(&scalefactor);// average scalefactor on element 4442 } 4443 else scalefactor=1.0; 4415 4444 } 4445 4416 4446 Total_Smb=rho_ice*base*smb*scalefactor;// smb on element in kg s-1 4417 4447 4418 4448 /*Return: */ -
../trunk-jpl/src/c/classes/Elements/Tria.cpp
1816 1816 else phi=f1*f2; 1817 1817 1818 1818 /*Compute weights:*/ 1819 gauss = this->NewGauss(point,f1,f2, trapezeisnegative,2);1819 gauss = this->NewGauss(point,f1,f2,1-trapezeisnegative,2); //VV correction (16Nov2021) 1820 1820 1821 1821 total_weight=0; 1822 1822 for(int i=0;i<NUMVERTICES;i++)weights[i]=0; … … 1825 1825 for(int i=0;i<NUMVERTICES;i++)weights[i]+=loadweights_g[i]*gauss->weight; 1826 1826 total_weight+=gauss->weight; 1827 1827 } 1828 / /normalize to phi.1828 /*Normalizing to phi such that weights provide coefficients for integration over subelement (for averaging:phi*weights)*/ 1829 1829 if(total_weight>0.) for(int i=0;i<NUMVERTICES;i++)weights[i]/=total_weight/phi; 1830 1830 else for(int i=0;i<NUMVERTICES;i++)weights[i]=0; 1831 1831 … … 3545 3545 Haverage/=IssmDouble(numthk); 3546 3546 }*/ 3547 3547 3548 IssmDouble * lsf = xNew<IssmDouble>(NUMVERTICES);3549 3548 IssmDouble lsf[NUMVERTICES]; 3549 Element::GetInputListOnVertices(&lsf[0],MaskIceLevelsetEnum); 3550 3550 /*Deal with partially ice-covered elements*/ 3551 3551 if(false && (lsf[0]*lsf[1]<=0 || lsf[0]*lsf[2]<=0 || lsf[1]*lsf[2]<=0)){ 3552 3552 bool istrapneg; … … 3562 3562 GetFractionGeometry(weights,&phi,&point,&f1,&f2,&istrapneg,lsf); 3563 3563 for(int i=0;i<NUMVERTICES;i++) Hice[i] = surfaces[i]-bases[i]; 3564 3564 Haverage = 0.0; 3565 for(int i=0;i<NUMVERTICES;i++) Haverage += weights[i]*Hice[i]; 3565 /*Use weights[i]/phi to get average thickness over subelement*/ 3566 for(int i=0;i<NUMVERTICES;i++) Haverage += weights[i]/phi*Hice[i]; 3566 3567 /*Get back area of ice-covered base*/ 3567 3568 area_basetot = this->GetArea(); 3568 3569 area_base = phi*area_basetot; … … 3572 3573 IssmDouble* scalefactor_vertices = xNew<IssmDouble>(NUMVERTICES); 3573 3574 Element::GetInputListOnVertices(&scalefactor_vertices[0],MeshScaleFactorEnum); 3574 3575 scalefactor = 0.0; 3575 for(int i=0;i<NUMVERTICES;i++) scalefactor += weights[i] *scalefactor_vertices[i];3576 for(int i=0;i<NUMVERTICES;i++) scalefactor += weights[i]/phi*scalefactor_vertices[i]; 3576 3577 area_base = area_base*scalefactor; 3577 3578 xDelete<IssmDouble>(scalefactor_vertices); 3578 3579 } … … 3605 3606 xDelete<int>(indices); 3606 3607 xDelete<IssmDouble>(H); 3607 3608 xDelete<IssmDouble>(SF); 3608 xDelete<IssmDouble>(lsf);3609 3609 3610 3610 if(domaintype==Domain2DverticalEnum){ 3611 3611 return area_base; … … 5478 5478 /*The smb[kg yr-1] of one element is area[m2] * smb [kg m^-2 yr^-1]*/ 5479 5479 IssmDouble base,smb,rho_ice,scalefactor; 5480 5480 IssmDouble Total_Smb=0; 5481 IssmDouble lsf[NUMVERTICES]; 5481 5482 IssmDouble xyz_list[NUMVERTICES][3]; 5482 5483 5483 5484 /*Get material parameters :*/ … … 5491 5492 * http://en.wikipedia.org/wiki/Triangle 5492 5493 * base = 1/2 abs((xA-xC)(yB-yA)-(xA-xB)(yC-yA))*/ 5493 5494 base = 1./2. * fabs((xyz_list[0][0]-xyz_list[2][0])*(xyz_list[1][1]-xyz_list[0][1]) - (xyz_list[0][0]-xyz_list[1][0])*(xyz_list[2][1]-xyz_list[0][1])); // area of element in m2 5495 5496 /*Now get the average SMB over the element*/ 5497 Element::GetInputListOnVertices(&lsf[0],MaskIceLevelsetEnum); 5498 if(false && (lsf[0]*lsf[1]<=0 || lsf[0]*lsf[2]<=0 || lsf[1]*lsf[2]<=0)){ 5499 /*Partially ice-covered element*/ 5500 bool mainlyice; 5501 int point; 5502 IssmDouble* weights = xNew<IssmDouble>(NUMVERTICES); 5503 IssmDouble* smb_vertices = xNew<IssmDouble>(NUMVERTICES); 5504 IssmDouble f1,f2,phi; 5505 5506 Element::GetInputListOnVertices(&smb_vertices[0],SmbMassBalanceEnum); 5507 GetFractionGeometry(weights,&phi,&point,&f1,&f2,&mainlyice,lsf); 5508 smb = 0.0; 5509 for(int i=0;i<NUMVERTICES;i++) smb += weights[i]*smb_vertices[i]; 5510 5511 if(scaled==true){ 5512 IssmDouble* scalefactor_vertices = xNew<IssmDouble>(NUMVERTICES); 5513 Element::GetInputListOnVertices(&scalefactor_vertices[0],MeshScaleFactorEnum); 5514 scalefactor = 0.0; 5515 for(int i=0;i<NUMVERTICES;i++) scalefactor += weights[i]/phi*scalefactor_vertices[i]; 5516 xDelete<IssmDouble>(scalefactor_vertices); 5517 } 5518 else scalefactor = 1.0; 5494 5519 5495 /*Now get the average SMB over the element*/ 5496 Input* smb_input = this->GetInput(SmbMassBalanceEnum); _assert_(smb_input); 5497 smb_input->GetInputAverage(&smb); // average smb on element in m ice s-1 5498 if(scaled==true){ 5499 Input* scalefactor_input = this->GetInput(MeshScaleFactorEnum); _assert_(scalefactor_input); 5500 scalefactor_input->GetInputAverage(&scalefactor);// average scalefactor on element 5520 /*Cleanup*/ 5521 xDelete<IssmDouble>(weights); 5522 xDelete<IssmDouble>(smb_vertices); 5501 5523 } 5502 5524 else{ 5503 scalefactor=1.; 5525 /*Fully ice-covered element*/ 5526 Input* smb_input = this->GetInput(SmbMassBalanceEnum); _assert_(smb_input); 5527 smb_input->GetInputAverage(&smb); // average smb on element in m ice s-1 5528 5529 if(scaled==true){ 5530 Input* scalefactor_input = this->GetInput(MeshScaleFactorEnum); _assert_(scalefactor_input); 5531 scalefactor_input->GetInputAverage(&scalefactor);// average scalefactor on element 5532 } 5533 else scalefactor=1.0; 5504 5534 } 5535 5505 5536 Total_Smb=rho_ice*base*smb*scalefactor; // smb on element in kg s-1 5506 5537 5507 5538 /*Return: */
Note:
See TracBrowser
for help on using the repository browser.