Changeset 18957
- Timestamp:
- 12/11/14 01:32:48 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/Elements/Tria.cpp
r18956 r18957 1504 1504 IssmDouble Tria::IceVolume(void){/*{{{*/ 1505 1505 1506 /*The volume of a troncated prism is base * 1/3 sum(length of edges)*/ 1507 IssmDouble base,surface,bed; 1508 IssmDouble xyz_list[NUMVERTICES][3]; 1509 1510 if(!IsIceInElement())return 0; 1511 1512 /*First get back the area of the base*/ 1513 base=this->GetArea(); 1514 1515 /*Now get the average height*/ 1516 Input* surface_input = inputs->GetInput(SurfaceEnum); _assert_(surface_input); 1517 Input* base_input = inputs->GetInput(BaseEnum); _assert_(base_input); 1518 surface_input->GetInputAverage(&surface); 1519 base_input->GetInputAverage(&bed); 1520 1521 /*Return: */ 1506 /*The volume of a truncated prism is area_base * 1/numedges sum(length of edges)*/ 1507 1508 /*Intermediaries*/ 1509 int i, numiceverts; 1510 IssmDouble area_base,surface,base,Haverage; 1511 IssmDouble Haux[NUMVERTICES], surfaces[NUMVERTICES], bases[NUMVERTICES]; 1512 IssmDouble s[2]; // s:fraction of intersected triangle edges, that lies inside ice 1513 int* indices=NULL; 1514 IssmDouble* H=NULL; 1515 1516 if(!IsIceInElement())return 0.; 1517 1522 1518 int domaintype; 1523 1519 parameters->FindParam(&domaintype,DomainTypeEnum); 1520 1521 if(IsIcefront()){ 1522 area_base=this->GetAreaIce(); 1523 //Assumption: linear ice thickness profile on element. 1524 //Hence ice thickness at intersection of levelset function with triangle edge is linear interpolation of ice thickness at vertices. 1525 this->GetLevelsetIntersection(&indices, &numiceverts, s, MaskIceLevelsetEnum, 0.); 1526 GetInputListOnVertices(&surfaces[0],SurfaceEnum); 1527 GetInputListOnVertices(&bases[0],BaseEnum); 1528 for(i=0;i<NUMVERTICES;i++) Haux[i]= surfaces[indices[i]]-bases[indices[i]]; //sort thicknesses in ice/noice 1529 int numthk=numiceverts+2; 1530 H=xNew<IssmDouble>(numthk); 1531 switch(numiceverts){ 1532 case 1: // average over triangle 1533 H[0]=Haux[0]; 1534 H[1]=Haux[0]+s[0]*(Haux[1]-Haux[0]); 1535 H[2]=Haux[0]+s[1]*(Haux[2]-Haux[0]); 1536 break; 1537 case 2: // average over quadrangle 1538 H[0]=Haux[0]; 1539 H[1]=Haux[1]; 1540 H[2]=Haux[0]+s[0]*(Haux[2]-Haux[0]); 1541 H[3]=Haux[1]+s[1]*(Haux[2]-Haux[1]); 1542 break; 1543 default: 1544 _error_("Number of ice covered vertices wrong in Tria::IceVolume()"); 1545 break; 1546 } 1547 Haverage=0.; 1548 for(i=0;i<numthk;i++) Haverage+=H[i]; 1549 Haverage/=IssmDouble(numthk); 1550 } 1551 else{ 1552 /*First get back the area of the base*/ 1553 area_base=this->GetArea(); 1554 1555 /*Now get the average height*/ 1556 Input* surface_input = inputs->GetInput(SurfaceEnum); _assert_(surface_input); 1557 Input* base_input = inputs->GetInput(BaseEnum); _assert_(base_input); 1558 surface_input->GetInputAverage(&surface); 1559 base_input->GetInputAverage(&base); 1560 Haverage=surface-base; 1561 } 1562 1563 /*Cleanup & return: */ 1564 xDelete<int>(indices); 1565 xDelete<IssmDouble>(H); 1566 1524 1567 if(domaintype==Domain2DverticalEnum){ 1525 return base;1568 return area_base; 1526 1569 } 1527 1570 else{ 1528 return base*(surface-bed);1571 return area_base*Haverage; 1529 1572 } 1530 1573 }
Note:
See TracChangeset
for help on using the changeset viewer.