Changeset 24013
- Timestamp:
- 06/12/19 14:40:27 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/Elements/Element.cpp
r24010 r24013 66 66 67 67 /*Allocate arrays*/ 68 int numvertices = this->GetNumberOfVertices(); 69 IssmDouble* lambdas = xNew<IssmDouble>(numvertices); 68 const int NUM_VERTICES = this->GetNumberOfVertices(); 69 70 IssmDouble* lambdas = xNew<IssmDouble>(NUM_VERTICES); 70 71 71 72 /* Start looping on the number of vertices: */ 72 73 Gauss* gauss=this->NewGauss(); 73 for (int iv=0;iv< numvertices;iv++){74 for (int iv=0;iv<NUM_VERTICES;iv++){ 74 75 gauss->GaussVertex(iv); 75 76 … … 245 246 246 247 /*Allocate arrays*/ 247 int numvertices = this->GetNumberOfVertices(); 248 IssmDouble* eps_xx = xNew<IssmDouble>(numvertices); 249 IssmDouble* eps_yy = xNew<IssmDouble>(numvertices); 250 IssmDouble* eps_zz = xNew<IssmDouble>(numvertices); 251 IssmDouble* eps_xy = xNew<IssmDouble>(numvertices); 252 IssmDouble* eps_xz = xNew<IssmDouble>(numvertices); 253 IssmDouble* eps_yz = xNew<IssmDouble>(numvertices); 254 IssmDouble* eps_ef = xNew<IssmDouble>(numvertices); 248 const int NUM_VERTICES = this->GetNumberOfVertices(); 249 250 IssmDouble* eps_xx = xNew<IssmDouble>(NUM_VERTICES); 251 IssmDouble* eps_yy = xNew<IssmDouble>(NUM_VERTICES); 252 IssmDouble* eps_zz = xNew<IssmDouble>(NUM_VERTICES); 253 IssmDouble* eps_xy = xNew<IssmDouble>(NUM_VERTICES); 254 IssmDouble* eps_xz = xNew<IssmDouble>(NUM_VERTICES); 255 IssmDouble* eps_yz = xNew<IssmDouble>(NUM_VERTICES); 256 IssmDouble* eps_ef = xNew<IssmDouble>(NUM_VERTICES); 255 257 256 258 /* Start looping on the number of vertices: */ 257 259 Gauss* gauss=this->NewGauss(); 258 for (int iv=0;iv< numvertices;iv++){260 for (int iv=0;iv<NUM_VERTICES;iv++){ 259 261 gauss->GaussVertex(iv); 260 262 … … 388 390 _printf_(" sid: "<<this->sid<<"\n"); 389 391 if(vertices){ 390 int numvertices= this->GetNumberOfVertices();391 for(int i=0;i< numvertices;i++) vertices[i]->Echo();392 const int NUM_VERTICES = this->GetNumberOfVertices(); 393 for(int i=0;i<NUM_VERTICES;i++) vertices[i]->Echo(); 392 394 } 393 395 else _printf_("vertices = NULL\n"); … … 427 429 if(!IsOnBase()) return; 428 430 429 int numvertices = this->GetNumberOfVertices(); 431 const int NUM_VERTICES = this->GetNumberOfVertices(); 432 const int NUM_VERTICES_MONTHS_PER_YEAR = NUM_VERTICES * 12; 430 433 431 434 int i; 432 IssmDouble* monthlytemperatures=xNew<IssmDouble>( 12*numvertices);433 IssmDouble* monthlyprec=xNew<IssmDouble>( 12*numvertices);434 IssmDouble* TemperaturesPresentday=xNew<IssmDouble>( 12*numvertices);435 IssmDouble* TemperaturesLgm=xNew<IssmDouble>( 12*numvertices);436 IssmDouble* PrecipitationsPresentday=xNew<IssmDouble>( 12*numvertices);437 IssmDouble* tmp=xNew<IssmDouble>( numvertices);435 IssmDouble* monthlytemperatures=xNew<IssmDouble>(NUM_VERTICES_MONTHS_PER_YEAR); 436 IssmDouble* monthlyprec=xNew<IssmDouble>(NUM_VERTICES_MONTHS_PER_YEAR); 437 IssmDouble* TemperaturesPresentday=xNew<IssmDouble>(NUM_VERTICES_MONTHS_PER_YEAR); 438 IssmDouble* TemperaturesLgm=xNew<IssmDouble>(NUM_VERTICES_MONTHS_PER_YEAR); 439 IssmDouble* PrecipitationsPresentday=xNew<IssmDouble>(NUM_VERTICES_MONTHS_PER_YEAR); 440 IssmDouble* tmp=xNew<IssmDouble>(NUM_VERTICES); 438 441 IssmDouble Delta18oPresent,Delta18oLgm,Delta18oTime; 439 442 IssmDouble Delta18oSurfacePresent,Delta18oSurfaceLgm,Delta18oSurfaceTime; … … 453 456 Gauss* gauss=this->NewGauss(); 454 457 for(int month=0;month<12;month++){ 455 for(int iv=0;iv< numvertices;iv++){458 for(int iv=0;iv<NUM_VERTICES;iv++){ 456 459 gauss->GaussVertex(iv); 457 460 input->GetInputValue(&TemperaturesPresentday[iv*12+month],gauss,month/12.*yts); … … 472 475 473 476 /*Compute the temperature and precipitation*/ 474 for(int iv=0;iv< numvertices;iv++){477 for(int iv=0;iv<NUM_VERTICES;iv++){ 475 478 ComputeDelta18oTemperaturePrecipitation(Delta18oSurfacePresent, Delta18oSurfaceLgm, Delta18oSurfaceTime, 476 479 Delta18oPresent, Delta18oLgm, Delta18oTime, … … 484 487 TransientInput* NewPrecipitationInput = new TransientInput(SmbPrecipitationEnum); 485 488 for (int imonth=0;imonth<12;imonth++) { 486 for(i=0;i< numvertices;i++) tmp[i]=monthlytemperatures[i*12+imonth];489 for(i=0;i<NUM_VERTICES;i++) tmp[i]=monthlytemperatures[i*12+imonth]; 487 490 switch(this->ObjectEnum()){ 488 491 case TriaEnum: NewTemperatureInput->AddTimeInput(new TriaInput(SmbMonthlytemperaturesEnum,&tmp[0],P1Enum),time_yr+imonth/12.*yts); break; … … 491 494 default: _error_("Not implemented yet"); 492 495 } 493 for(i=0;i< numvertices;i++) tmp[i]=monthlyprec[i*12+imonth]/yts;496 for(i=0;i<NUM_VERTICES;i++) tmp[i]=monthlyprec[i*12+imonth]/yts; 494 497 switch(this->ObjectEnum()){ 495 498 case TriaEnum: NewPrecipitationInput->AddTimeInput(new TriaInput(SmbPrecipitationEnum,&tmp[0],P1Enum),time_yr+imonth/12.*yts); break; … … 530 533 if(!IsOnBase()) return; 531 534 532 int numvertices = this->GetNumberOfVertices(); 533 534 int i; 535 IssmDouble* monthlytemperatures=xNew<IssmDouble>(12*numvertices); 536 IssmDouble* monthlyprec=xNew<IssmDouble>(12*numvertices); 537 IssmDouble* TemperaturesPresentday=xNew<IssmDouble>(12*numvertices); 538 IssmDouble* PrecipitationsPresentday=xNew<IssmDouble>(12*numvertices); 539 IssmDouble* TemperaturesReconstructed=xNew<IssmDouble>(12*numvertices); 540 IssmDouble* PrecipitationsReconstructed=xNew<IssmDouble>(12*numvertices); 541 IssmDouble* tmp=xNew<IssmDouble>(numvertices); 535 const int NUM_VERTICES = this->GetNumberOfVertices(); 536 const int NUM_VERTICES_MONTHS_PER_YEAR = NUM_VERTICES * 12; 537 538 int i; 539 IssmDouble* monthlytemperatures=xNew<IssmDouble>(NUM_VERTICES_MONTHS_PER_YEAR); 540 IssmDouble* monthlyprec=xNew<IssmDouble>(NUM_VERTICES_MONTHS_PER_YEAR); 541 IssmDouble* TemperaturesPresentday=xNew<IssmDouble>(NUM_VERTICES_MONTHS_PER_YEAR); 542 IssmDouble* PrecipitationsPresentday=xNew<IssmDouble>(NUM_VERTICES_MONTHS_PER_YEAR); 543 IssmDouble* TemperaturesReconstructed=xNew<IssmDouble>(NUM_VERTICES_MONTHS_PER_YEAR); 544 IssmDouble* PrecipitationsReconstructed=xNew<IssmDouble>(NUM_VERTICES_MONTHS_PER_YEAR); 545 IssmDouble* tmp=xNew<IssmDouble>(NUM_VERTICES); 542 546 IssmDouble Delta18oTime; 543 547 IssmDouble dpermil,f; … … 583 587 Gauss* gauss=this->NewGauss(); 584 588 for(int month=0;month<12;month++) { 585 for(int iv=0;iv< numvertices;iv++) {589 for(int iv=0;iv<NUM_VERTICES;iv++) { 586 590 gauss->GaussVertex(iv); 587 591 input->GetInputValue(&TemperaturesPresentday[iv*12+month],gauss,time_clim+month/12.*yts); … … 604 608 605 609 /*Compute the temperature and precipitation*/ 606 for(int iv=0;iv< numvertices;iv++){610 for(int iv=0;iv<NUM_VERTICES;iv++){ 607 611 ComputeD18OTemperaturePrecipitationFromPD(Delta18oTime,dpermil,isTemperatureScaled,isPrecipScaled, 608 612 f,&PrecipitationsPresentday[iv*12], &TemperaturesPresentday[iv*12], … … 615 619 TransientInput* NewPrecipitationInput = new TransientInput(SmbPrecipitationEnum); 616 620 for (int imonth=0;imonth<12;imonth++) { 617 for(i=0;i< numvertices;i++) tmp[i]=monthlytemperatures[i*12+imonth];621 for(i=0;i<NUM_VERTICES;i++) tmp[i]=monthlytemperatures[i*12+imonth]; 618 622 switch(this->ObjectEnum()){ 619 623 case TriaEnum: NewTemperatureInput->AddTimeInput(new TriaInput(SmbMonthlytemperaturesEnum,&tmp[0],P1Enum),time_yr+imonth/12.*yts); break; … … 622 626 default: _error_("Not implemented yet"); 623 627 } 624 for(i=0;i< numvertices;i++) tmp[i]=monthlyprec[i*12+imonth]/yts;628 for(i=0;i<NUM_VERTICES;i++) tmp[i]=monthlyprec[i*12+imonth]/yts; 625 629 switch(this->ObjectEnum()){ 626 630 case TriaEnum: NewPrecipitationInput->AddTimeInput(new TriaInput(SmbPrecipitationEnum,&tmp[0],P1Enum),time_yr+imonth/12.*yts); break; … … 662 666 /*Are we on the base? If not, return*/ 663 667 if(!IsOnBase()) return; 664 int numvertices= this->GetNumberOfVertices();668 const int NUM_VERTICES = this->GetNumberOfVertices(); 665 669 666 670 int i; … … 671 675 IssmDouble time; 672 676 673 IssmDouble* smb = xNew<IssmDouble>(numvertices);674 IssmDouble* surf = xNew<IssmDouble>(numvertices);675 IssmDouble* accu = xNew<IssmDouble>(numvertices);676 IssmDouble* runoff = xNew<IssmDouble>(numvertices);677 IssmDouble* smb = xNew<IssmDouble>(NUM_VERTICES); 678 IssmDouble* surf = xNew<IssmDouble>(NUM_VERTICES); 679 IssmDouble* accu = xNew<IssmDouble>(NUM_VERTICES); 680 IssmDouble* runoff = xNew<IssmDouble>(NUM_VERTICES); 677 681 678 682 /*Get material parameters :*/ … … 695 699 696 700 /*Compute the temperature and precipitation*/ 697 for(int iv=0;iv< numvertices;iv++){701 for(int iv=0;iv<NUM_VERTICES;iv++){ 698 702 accu[iv]=max(0.,(accuref+(surf[iv]-accualti)*accugrad)); 699 703 runoff[iv]=max(0.,(runoffref+(surf[iv]-runoffalti)*runoffgrad)); … … 914 918 _printf_(" sid: "<<this->sid<<"\n"); 915 919 if(vertices){ 916 int numvertices= this->GetNumberOfVertices();917 for(int i=0;i< numvertices;i++) vertices[i]->Echo();920 const int NUM_VERTICES = this->GetNumberOfVertices(); 921 for(int i=0;i<NUM_VERTICES;i++) vertices[i]->Echo(); 918 922 } 919 923 else _printf_("vertices = NULL\n"); … … 1173 1177 1174 1178 /*Fetch number vertices for this element*/ 1175 int numvertices= this->GetNumberOfVertices();1179 const int NUM_VERTICES = this->GetNumberOfVertices(); 1176 1180 1177 1181 /*Checks in debugging mode*/ … … 1180 1184 /* Start looping on the number of vertices: */ 1181 1185 Gauss*gauss=this->NewGauss(); 1182 for(int iv=0;iv< numvertices;iv++){1186 for(int iv=0;iv<NUM_VERTICES;iv++){ 1183 1187 gauss->GaussVertex(iv); 1184 1188 input->GetInputValue(&pvalue[iv],gauss); … … 1196 1200 1197 1201 /*Fetch number vertices for this element*/ 1198 int numvertices= this->GetNumberOfVertices();1202 const int NUM_VERTICES = this->GetNumberOfVertices(); 1199 1203 1200 1204 /*Checks in debugging mode*/ … … 1203 1207 /* Start looping on the number of vertices: */ 1204 1208 Gauss*gauss=this->NewGauss(); 1205 for(int iv=0;iv< numvertices;iv++){1209 for(int iv=0;iv<NUM_VERTICES;iv++){ 1206 1210 gauss->GaussVertex(iv); 1207 1211 input->GetInputValue(&pvalue[iv],gauss,time); … … 1221 1225 1222 1226 /*Fetch number vertices for this element*/ 1223 int numvertices= this->GetNumberOfVertices();1227 const int NUM_VERTICES = this->GetNumberOfVertices(); 1224 1228 1225 1229 /* Start looping on the number of vertices: */ 1226 1230 if (input){ 1227 1231 Gauss* gauss=this->NewGauss(); 1228 for (int iv=0;iv< numvertices;iv++){1232 for (int iv=0;iv<NUM_VERTICES;iv++){ 1229 1233 gauss->GaussVertex(iv); 1230 1234 input->GetInputValue(&pvalue[iv],gauss); … … 1233 1237 } 1234 1238 else{ 1235 for(int iv=0;iv< numvertices;iv++) pvalue[iv]=defaultvalue;1239 for(int iv=0;iv<NUM_VERTICES;iv++) pvalue[iv]=defaultvalue; 1236 1240 } 1237 1241 } … … 1406 1410 1407 1411 /* /\*Fetch number vertices for this element and allocate arrays*\/ */ 1408 /* int numvertices= this->GetNumberOfVertices(); */1409 /* int* vertexpidlist = xNew<int>( numvertices); */1410 /* IssmDouble* values = xNew<IssmDouble>( numvertices); */1412 /* const int NUM_VERTICES = this->GetNumberOfVertices(); */ 1413 /* int* vertexpidlist = xNew<int>(NUM_VERTICES); */ 1414 /* IssmDouble* values = xNew<IssmDouble>(NUM_VERTICES); */ 1411 1415 1412 1416 /* /\*Fill in values*\/ */ 1413 1417 /* this->GetVerticesPidList(vertexpidlist); */ 1414 1418 /* this->GetInputListOnVertices(values,input_enum); */ 1415 /* vector->SetValues( numvertices,vertexpidlist,values,INS_VAL); */1419 /* vector->SetValues(NUM_VERTICES,vertexpidlist,values,INS_VAL); */ 1416 1420 1417 1421 /* /\*Clean up*\/ */ … … 1424 1428 1425 1429 /*Fetch number vertices for this element and allocate arrays*/ 1426 int numvertices = this->GetNumberOfVertices(); 1430 const int NUM_VERTICES = this->GetNumberOfVertices(); 1431 1427 1432 int numnodes = this->GetNumberOfNodes(); 1428 1433 int* doflist = NULL; … … 1438 1443 break; 1439 1444 case VertexPIdEnum: 1440 doflist = xNew<int>( numvertices);1441 values = xNew<IssmDouble>( numvertices);1445 doflist = xNew<int>(NUM_VERTICES); 1446 values = xNew<IssmDouble>(NUM_VERTICES); 1442 1447 /*Fill in values*/ 1443 1448 this->GetVerticesPidList(doflist); 1444 1449 this->GetInputListOnVertices(values,input_enum); 1445 vector->SetValues( numvertices,doflist,values,INS_VAL);1450 vector->SetValues(NUM_VERTICES,doflist,values,INS_VAL); 1446 1451 break; 1447 1452 case VertexSIdEnum: 1448 doflist = xNew<int>( numvertices);1449 values = xNew<IssmDouble>( numvertices);1453 doflist = xNew<int>(NUM_VERTICES); 1454 values = xNew<IssmDouble>(NUM_VERTICES); 1450 1455 /*Fill in values*/ 1451 1456 this->GetVerticesSidList(doflist); 1452 1457 this->GetInputListOnVertices(values,input_enum); 1453 vector->SetValues( numvertices,doflist,values,INS_VAL);1458 vector->SetValues(NUM_VERTICES,doflist,values,INS_VAL); 1454 1459 break; 1455 1460 case NodesEnum: … … 1482 1487 1483 1488 /*Fetch number vertices for this element and allocate arrays*/ 1484 int numvertices = this->GetNumberOfVertices(); 1489 const int NUM_VERTICES = this->GetNumberOfVertices(); 1490 1485 1491 int numnodes = this->GetNumberOfNodes(); 1486 1492 int* doflist = NULL; … … 1489 1495 switch(type){ 1490 1496 case VertexPIdEnum: 1491 doflist = xNew<int>( numvertices);1492 values = xNew<IssmDouble>( numvertices);1497 doflist = xNew<int>(NUM_VERTICES); 1498 values = xNew<IssmDouble>(NUM_VERTICES); 1493 1499 /*Fill in values*/ 1494 1500 this->GetVerticesPidList(doflist); 1495 1501 this->GetInputListOnVerticesAtTime(values,input_enum,time); 1496 vector->SetValues( numvertices,doflist,values,INS_VAL);1502 vector->SetValues(NUM_VERTICES,doflist,values,INS_VAL); 1497 1503 break; 1498 1504 case VertexSIdEnum: 1499 doflist = xNew<int>( numvertices);1500 values = xNew<IssmDouble>( numvertices);1505 doflist = xNew<int>(NUM_VERTICES); 1506 values = xNew<IssmDouble>(NUM_VERTICES); 1501 1507 /*Fill in values*/ 1502 1508 this->GetVerticesSidList(doflist); 1503 1509 this->GetInputListOnVerticesAtTime(values,input_enum,time); 1504 vector->SetValues( numvertices,doflist,values,INS_VAL);1510 vector->SetValues(NUM_VERTICES,doflist,values,INS_VAL); 1505 1511 break; 1506 1512 default: … … 1516 1522 void Element::GetVerticesLidList(int* lidlist){/*{{{*/ 1517 1523 1518 int numvertices= this->GetNumberOfVertices();1519 for(int i=0;i< numvertices;i++) lidlist[i]=vertices[i]->Lid();1524 const int NUM_VERTICES = this->GetNumberOfVertices(); 1525 for(int i=0;i<NUM_VERTICES;i++) lidlist[i]=vertices[i]->Lid(); 1520 1526 1521 1527 } … … 1523 1529 void Element::GetVerticesPidList(int* pidlist){/*{{{*/ 1524 1530 1525 int numvertices= this->GetNumberOfVertices();1526 for(int i=0;i< numvertices;i++) pidlist[i]=vertices[i]->Pid();1531 const int NUM_VERTICES = this->GetNumberOfVertices(); 1532 for(int i=0;i<NUM_VERTICES;i++) pidlist[i]=vertices[i]->Pid(); 1527 1533 1528 1534 } … … 1530 1536 void Element::GetVerticesConnectivityList(int* connectivity){/*{{{*/ 1531 1537 1532 int numvertices= this->GetNumberOfVertices();1533 for(int i=0;i< numvertices;i++) connectivity[i]=this->vertices[i]->Connectivity();1538 const int NUM_VERTICES = this->GetNumberOfVertices(); 1539 for(int i=0;i<NUM_VERTICES;i++) connectivity[i]=this->vertices[i]->Connectivity(); 1534 1540 } 1535 1541 /*}}}*/ 1536 1542 void Element::GetVerticesCoordinates(IssmDouble** pxyz_list){/*{{{*/ 1537 1543 1538 int numvertices = this->GetNumberOfVertices(); 1539 IssmDouble* xyz_list = xNew<IssmDouble>(numvertices*3); 1540 ::GetVerticesCoordinates(xyz_list,this->vertices,numvertices); 1544 const int NUM_VERTICES = this->GetNumberOfVertices(); 1545 1546 IssmDouble* xyz_list = xNew<IssmDouble>(NUM_VERTICES*3); 1547 ::GetVerticesCoordinates(xyz_list,this->vertices,NUM_VERTICES); 1541 1548 1542 1549 *pxyz_list = xyz_list; … … 1545 1552 void Element::GetVerticesSidList(int* sidlist){/*{{{*/ 1546 1553 1547 int numvertices= this->GetNumberOfVertices();1548 for(int i=0;i< numvertices;i++) sidlist[i]=this->vertices[i]->Sid();1554 const int NUM_VERTICES = this->GetNumberOfVertices(); 1555 for(int i=0;i<NUM_VERTICES;i++) sidlist[i]=this->vertices[i]->Sid(); 1549 1556 } 1550 1557 /*}}}*/ … … 1555 1562 1556 1563 /*Create list of x*/ 1557 int numvertices = this->GetNumberOfVertices(); 1558 IssmDouble* x_list = xNew<IssmDouble>(numvertices); 1559 1560 for(int i=0;i<numvertices;i++) x_list[i]=xyz_list[i*3+0]; 1564 const int NUM_VERTICES = this->GetNumberOfVertices(); 1565 1566 IssmDouble* x_list = xNew<IssmDouble>(NUM_VERTICES); 1567 1568 for(int i=0;i<NUM_VERTICES;i++) x_list[i]=xyz_list[i*3+0]; 1561 1569 ValueP1OnGauss(&x,x_list,gauss); 1562 1570 … … 1570 1578 1571 1579 /*Create list of y*/ 1572 int numvertices = this->GetNumberOfVertices(); 1573 IssmDouble* y_list = xNew<IssmDouble>(numvertices); 1574 1575 for(int i=0;i<numvertices;i++) y_list[i]=xyz_list[i*3+1]; 1580 const int NUM_VERTICES = this->GetNumberOfVertices(); 1581 1582 IssmDouble* y_list = xNew<IssmDouble>(NUM_VERTICES); 1583 1584 for(int i=0;i<NUM_VERTICES;i++) y_list[i]=xyz_list[i*3+1]; 1576 1585 ValueP1OnGauss(&y,y_list,gauss); 1577 1586 … … 1585 1594 1586 1595 /*Create list of z*/ 1587 int numvertices = this->GetNumberOfVertices(); 1588 IssmDouble* z_list = xNew<IssmDouble>(numvertices); 1589 1590 for(int i=0;i<numvertices;i++) z_list[i]=xyz_list[i*3+2]; 1596 const int NUM_VERTICES = this->GetNumberOfVertices(); 1597 1598 IssmDouble* z_list = xNew<IssmDouble>(NUM_VERTICES); 1599 1600 for(int i=0;i<NUM_VERTICES;i++) z_list[i]=xyz_list[i*3+2]; 1591 1601 ValueP1OnGauss(&z,z_list,gauss); 1592 1602 … … 1603 1613 1604 1614 /*Get number of vertices*/ 1605 int numvertices= this->GetNumberOfVertices();1615 const int NUM_VERTICES = this->GetNumberOfVertices(); 1606 1616 if(isautodiff){ 1607 1617 int* N=NULL; … … 1617 1627 1618 1628 for(int n=0;n<N[control_index];n++){ 1619 for(int i=0;i< numvertices;i++){1620 indexing[i+n* numvertices]=this->vertices[i]->Sid() + start + n*M[control_index];1629 for(int i=0;i<NUM_VERTICES;i++){ 1630 indexing[i+n*NUM_VERTICES]=this->vertices[i]->Sid() + start + n*M[control_index]; 1621 1631 } 1622 1632 } … … 1626 1636 parameters->FindParam(&M,ControlInputSizeMEnum); 1627 1637 /*get gradient indices*/ 1628 for(int i=0;i< numvertices;i++){1638 for(int i=0;i<NUM_VERTICES;i++){ 1629 1639 indexing[i]=this->vertices[i]->Sid() + (control_index)*M; 1630 1640 } … … 1720 1730 if(vector_type==1){ //nodal vector 1721 1731 1722 int numvertices = this->GetNumberOfVertices(); 1723 int *vertexids = xNew<int>(numvertices); 1724 IssmDouble *values = xNew<IssmDouble>(numvertices); 1732 const int NUM_VERTICES = this->GetNumberOfVertices(); 1733 1734 int *vertexids = xNew<int>(NUM_VERTICES); 1735 IssmDouble *values = xNew<IssmDouble>(NUM_VERTICES); 1725 1736 1726 1737 /*Recover vertices ids needed to initialize inputs*/ 1727 1738 _assert_(iomodel->elements); 1728 for(i=0;i< numvertices;i++){1729 vertexids[i]=reCast<int>(iomodel->elements[ numvertices*this->Sid()+i]); //ids for vertices are in the elements array from Matlab1739 for(i=0;i<NUM_VERTICES;i++){ 1740 vertexids[i]=reCast<int>(iomodel->elements[NUM_VERTICES*this->Sid()+i]); //ids for vertices are in the elements array from Matlab 1730 1741 } 1731 1742 … … 1736 1747 } 1737 1748 else if(M==iomodel->numberofvertices){ 1738 for(i=0;i< numvertices;i++) values[i]=vector[vertexids[i]-1];1749 for(i=0;i<NUM_VERTICES;i++) values[i]=vector[vertexids[i]-1]; 1739 1750 this->AddInput(vector_enum,values,P1Enum); 1740 1751 } … … 1745 1756 TransientInput* transientinput=new TransientInput(vector_enum,times,N); 1746 1757 for(t=0;t<N;t++){ 1747 for(i=0;i< numvertices;i++) values[i]=vector[N*(vertexids[i]-1)+t];1758 for(i=0;i<NUM_VERTICES;i++) values[i]=vector[N*(vertexids[i]-1)+t]; 1748 1759 switch(this->ObjectEnum()){ 1749 1760 case TriaEnum: transientinput->AddTimeInput(new TriaInput( vector_enum,values,P1Enum)); break; … … 1833 1844 1834 1845 /*Intermediaries*/ 1835 int numvertices = this->GetNumberOfVertices(); 1836 int *vertexids = xNew<int>(numvertices); 1837 IssmDouble *values = xNew<IssmDouble>(numvertices); 1838 IssmDouble *values_min = xNew<IssmDouble>(numvertices); 1839 IssmDouble *values_max = xNew<IssmDouble>(numvertices); 1846 const int NUM_VERTICES = this->GetNumberOfVertices(); 1847 1848 int *vertexids = xNew<int>(NUM_VERTICES); 1849 IssmDouble *values = xNew<IssmDouble>(NUM_VERTICES); 1850 IssmDouble *values_min = xNew<IssmDouble>(NUM_VERTICES); 1851 IssmDouble *values_max = xNew<IssmDouble>(NUM_VERTICES); 1840 1852 1841 1853 /*Some sanity checks*/ … … 1850 1862 /*Recover vertices ids needed to initialize inputs*/ 1851 1863 _assert_(iomodel->elements); 1852 for(int i=0;i< numvertices;i++){1853 vertexids[i]=reCast<int>(iomodel->elements[ numvertices*this->Sid()+i]); //ids for vertices are in the elements array from Matlab1864 for(int i=0;i<NUM_VERTICES;i++){ 1865 vertexids[i]=reCast<int>(iomodel->elements[NUM_VERTICES*this->Sid()+i]); //ids for vertices are in the elements array from Matlab 1854 1866 } 1855 1867 1856 1868 /*Are we in transient or static? */ 1857 1869 if(M==iomodel->numberofvertices){ 1858 for(int i=0;i< numvertices;i++){1870 for(int i=0;i<NUM_VERTICES;i++){ 1859 1871 values[i]=vector[vertexids[i]-1]; 1860 1872 values_min[i] = min_vector[vertexids[i]-1]; … … 1874 1886 TransientInput* grad_input = new TransientInput(ControlInputGradEnum); 1875 1887 for(int t=0;t<N;t++){ 1876 for(int i=0;i< numvertices;i++){1888 for(int i=0;i<NUM_VERTICES;i++){ 1877 1889 values[i]=vector[N*(vertexids[i]-1)+t]; 1878 1890 values_min[i] = min_vector[N*(vertexids[i]-1)+t]; … … 1935 1947 if(vector_type==1){ //nodal vector 1936 1948 1937 int numvertices = this->GetNumberOfVertices(); 1938 int *vertexids = xNew<int>(numvertices); 1939 IssmDouble *values = xNew<IssmDouble>(numvertices); 1949 const int NUM_VERTICES = this->GetNumberOfVertices(); 1950 1951 int *vertexids = xNew<int>(NUM_VERTICES); 1952 IssmDouble *values = xNew<IssmDouble>(NUM_VERTICES); 1940 1953 1941 1954 /*Recover vertices ids needed to initialize inputs*/ 1942 1955 _assert_(iomodel->elements); 1943 for(i=0;i< numvertices;i++){1944 vertexids[i]=reCast<int>(iomodel->elements[ numvertices*this->Sid()+i]); //ids for vertices are in the elements array from Matlab1956 for(i=0;i<NUM_VERTICES;i++){ 1957 vertexids[i]=reCast<int>(iomodel->elements[NUM_VERTICES*this->Sid()+i]); //ids for vertices are in the elements array from Matlab 1945 1958 } 1946 1959 … … 1956 1969 } 1957 1970 else if(M==iomodel->numberofvertices){ 1958 for(i=0;i< numvertices;i++) values[i]=vector[vertexids[i]-1];1971 for(i=0;i<NUM_VERTICES;i++) values[i]=vector[vertexids[i]-1]; 1959 1972 switch(this->ObjectEnum()){ 1960 1973 case TriaEnum: datasetinput->AddInput(new TriaInput(input_enum,values,P1Enum),input_id); break; … … 1969 1982 TransientInput* transientinput=new TransientInput(input_enum,times,N); 1970 1983 for(t=0;t<N;t++){ 1971 for(i=0;i< numvertices;i++) values[i]=vector[N*(vertexids[i]-1)+t];1984 for(i=0;i<NUM_VERTICES;i++) values[i]=vector[N*(vertexids[i]-1)+t]; 1972 1985 switch(this->ObjectEnum()){ 1973 1986 case TriaEnum: transientinput->AddTimeInput(new TriaInput( input_enum,values,P1Enum)); break; … … 2161 2174 if(!this->IsIceInElement() || !this->IsFloating()) return; 2162 2175 2163 int numvertices = this->GetNumberOfVertices(); 2176 const int NUM_VERTICES = this->GetNumberOfVertices(); 2177 2164 2178 int basinid,num_basins,M,N; 2165 2179 IssmDouble tf,gamma0,base,delta_t_basin,mean_tf_basin,absval; 2166 IssmDouble basalmeltrate[ numvertices];2180 IssmDouble basalmeltrate[NUM_VERTICES]; 2167 2181 bool islocal; 2168 2182 IssmDouble* delta_t = NULL; … … 2194 2208 /*Compute melt rate for Local and Nonlocal parameterizations*/ 2195 2209 Gauss* gauss=this->NewGauss(); 2196 for(int i=0;i< numvertices;i++){2210 for(int i=0;i<NUM_VERTICES;i++){ 2197 2211 gauss->GaussVertex(i); 2198 2212 tf_input->GetInputValue(&tf,gauss); … … 2220 2234 void Element::LinearFloatingiceMeltingRate(){/*{{{*/ 2221 2235 2222 int numvertices = this->GetNumberOfVertices(); 2236 const int NUM_VERTICES = this->GetNumberOfVertices(); 2237 2223 2238 IssmDouble deepwaterel,upperwaterel,deepwatermelt,upperwatermelt; 2224 IssmDouble* base = xNew<IssmDouble>(numvertices);2225 IssmDouble* values = xNew<IssmDouble>(numvertices);2226 IssmDouble time;2239 IssmDouble* base = xNew<IssmDouble>(NUM_VERTICES); 2240 IssmDouble* values = xNew<IssmDouble>(NUM_VERTICES); 2241 IssmDouble time; 2227 2242 2228 2243 parameters->FindParam(&time,TimeEnum); … … 2231 2246 parameters->FindParam(&upperwaterel,BasalforcingsUpperwaterElevationEnum,time); 2232 2247 parameters->FindParam(&upperwatermelt,BasalforcingsUpperwaterMeltingRateEnum,time); 2233 _assert_(upperwaterel>deepwaterel); 2248 _assert_(upperwaterel>deepwaterel); 2234 2249 2235 2250 this->GetInputListOnVertices(base,BaseEnum); 2236 for(int i=0;i< numvertices;i++){2251 for(int i=0;i<NUM_VERTICES;i++){ 2237 2252 if(base[i]>=upperwaterel){ 2238 2253 values[i]=upperwatermelt; … … 2253 2268 void Element::SpatialLinearFloatingiceMeltingRate(){/*{{{*/ 2254 2269 2255 int numvertices = this->GetNumberOfVertices(); 2256 IssmDouble* deepwatermelt = xNew<IssmDouble>(numvertices); 2257 IssmDouble* deepwaterel = xNew<IssmDouble>(numvertices); 2258 IssmDouble* upperwaterel = xNew<IssmDouble>(numvertices); 2259 IssmDouble* base = xNew<IssmDouble>(numvertices); 2260 IssmDouble* values = xNew<IssmDouble>(numvertices); 2270 const int NUM_VERTICES = this->GetNumberOfVertices(); 2271 2272 IssmDouble* deepwatermelt = xNew<IssmDouble>(NUM_VERTICES); 2273 IssmDouble* deepwaterel = xNew<IssmDouble>(NUM_VERTICES); 2274 IssmDouble* upperwaterel = xNew<IssmDouble>(NUM_VERTICES); 2275 IssmDouble* base = xNew<IssmDouble>(NUM_VERTICES); 2276 IssmDouble* values = xNew<IssmDouble>(NUM_VERTICES); 2261 2277 2262 2278 this->GetInputListOnVertices(base,BaseEnum); … … 2265 2281 this->GetInputListOnVertices(upperwaterel,BasalforcingsUpperwaterElevationEnum); 2266 2282 2267 for(int i=0;i< numvertices;i++){2283 for(int i=0;i<NUM_VERTICES;i++){ 2268 2284 if(base[i]>upperwaterel[i]) values[i]=0; 2269 2285 else if (base[i]<deepwaterel[i]) values[i]=deepwatermelt[i]; … … 2281 2297 void Element::MantlePlumeGeothermalFlux(){/*{{{*/ 2282 2298 2283 int numvertices= this->GetNumberOfVertices();2299 const int NUM_VERTICES = this->GetNumberOfVertices(); 2284 2300 IssmDouble mantleconductivity,nusselt,dtbg,plumeradius,topplumedepth,bottomplumedepth,plumex,plumey; 2285 2301 IssmDouble crustthickness,uppercrustthickness,uppercrustheat,lowercrustheat; 2286 2302 IssmDouble crustheat,plumeheat,dt,middleplumedepth,a,e,eprime,A0,lambda,Alambda,dAlambda; 2287 2303 IssmDouble x,y,z,c; 2288 IssmDouble* values = xNew<IssmDouble>( numvertices);2304 IssmDouble* values = xNew<IssmDouble>(NUM_VERTICES); 2289 2305 IssmDouble *xyz_list = NULL; 2290 2306 … … 2307 2323 e=pow(a*a-c*c,1./2.)/a; 2308 2324 A0=(1-pow(e,2.))/pow(e,3.)*(1./2.*log((1+e)/(1-e))-e); 2309 for(int i=0;i< numvertices;i++){2325 for(int i=0;i<NUM_VERTICES;i++){ 2310 2326 y=xyz_list[i*3+0]-plumex; 2311 2327 z=xyz_list[i*3+1]-plumey; … … 2346 2362 void Element::MigrateGroundingLine(IssmDouble* phi_ungrounding){/*{{{*/ 2347 2363 2348 int numvertices= this->GetNumberOfVertices();2364 const int NUM_VERTICES = this->GetNumberOfVertices(); 2349 2365 int i,migration_style; 2350 2366 IssmDouble bed_hydro,yts; 2351 2367 IssmDouble rho_water,rho_ice,density; 2352 IssmDouble* melting = xNew<IssmDouble>( numvertices);2353 IssmDouble* phi = xNew<IssmDouble>( numvertices);2354 IssmDouble* h = xNew<IssmDouble>( numvertices);2355 IssmDouble* s = xNew<IssmDouble>( numvertices);2356 IssmDouble* b = xNew<IssmDouble>( numvertices);2357 IssmDouble* r = xNew<IssmDouble>( numvertices);2358 IssmDouble* sl = xNew<IssmDouble>( numvertices);2368 IssmDouble* melting = xNew<IssmDouble>(NUM_VERTICES); 2369 IssmDouble* phi = xNew<IssmDouble>(NUM_VERTICES); 2370 IssmDouble* h = xNew<IssmDouble>(NUM_VERTICES); 2371 IssmDouble* s = xNew<IssmDouble>(NUM_VERTICES); 2372 IssmDouble* b = xNew<IssmDouble>(NUM_VERTICES); 2373 IssmDouble* r = xNew<IssmDouble>(NUM_VERTICES); 2374 IssmDouble* sl = xNew<IssmDouble>(NUM_VERTICES); 2359 2375 2360 2376 /*Recover info at the vertices: */ … … 2372 2388 2373 2389 /*go through vertices, and update inputs, considering them to be TriaVertex type: */ 2374 for(i=0;i< numvertices;i++){2390 for(i=0;i<NUM_VERTICES;i++){ 2375 2391 /* Contact FS*/ 2376 2392 if(migration_style == ContactEnum){ … … 2408 2424 2409 2425 /*Recalculate phi*/ 2410 for(i=0;i< numvertices;i++){2426 for(i=0;i<NUM_VERTICES;i++){ 2411 2427 if(migration_style==SoftMigrationEnum){ 2412 2428 bed_hydro=-density*h[i]+sl[i]; … … 2438 2454 /*}}}*/ 2439 2455 void Element::MismipFloatingiceMeltingRate(){/*{{{*/ 2440 2441 int numvertices = this->GetNumberOfVertices(); 2456 const int NUM_VERTICES = this->GetNumberOfVertices(); 2457 2442 2458 IssmDouble meltratefactor,thresholdthickness,upperdepthmelt; 2443 IssmDouble* base = xNew<IssmDouble>( numvertices);2444 IssmDouble* bed = xNew<IssmDouble>( numvertices);2445 IssmDouble* values = xNew<IssmDouble>( numvertices);2459 IssmDouble* base = xNew<IssmDouble>(NUM_VERTICES); 2460 IssmDouble* bed = xNew<IssmDouble>(NUM_VERTICES); 2461 IssmDouble* values = xNew<IssmDouble>(NUM_VERTICES); 2446 2462 2447 2463 parameters->FindParam(&meltratefactor,BasalforcingsMeltrateFactorEnum); … … 2451 2467 this->GetInputListOnVertices(base,BaseEnum); 2452 2468 this->GetInputListOnVertices(bed,BedEnum); 2453 for(int i=0;i< numvertices;i++){2469 for(int i=0;i<NUM_VERTICES;i++){ 2454 2470 if(base[i]>upperdepthmelt){ 2455 2471 values[i]=0; … … 2470 2486 if(!IsOnBase()) return; 2471 2487 2472 int numvertices = this->GetNumberOfVertices(); 2473 2474 int i; 2475 IssmDouble* monthlytemperatures=xNew<IssmDouble>(12*numvertices); 2476 IssmDouble* monthlyprec=xNew<IssmDouble>(12*numvertices); 2477 IssmDouble* TemperaturesPresentday=xNew<IssmDouble>(12*numvertices); 2478 IssmDouble* TemperaturesLgm=xNew<IssmDouble>(12*numvertices); 2479 IssmDouble* PrecipitationsPresentday=xNew<IssmDouble>(12*numvertices); 2480 IssmDouble* PrecipitationsLgm=xNew<IssmDouble>(12*numvertices); 2481 IssmDouble* tmp=xNew<IssmDouble>(numvertices); 2488 const int NUM_VERTICES = this->GetNumberOfVertices(); 2489 const int NUM_VERTICES_MONTHS_PER_YEAR = NUM_VERTICES * 12; 2490 2491 int i; 2492 IssmDouble* monthlytemperatures=xNew<IssmDouble>(NUM_VERTICES_MONTHS_PER_YEAR); 2493 IssmDouble* monthlyprec=xNew<IssmDouble>(NUM_VERTICES_MONTHS_PER_YEAR); 2494 IssmDouble* TemperaturesPresentday=xNew<IssmDouble>(NUM_VERTICES_MONTHS_PER_YEAR); 2495 IssmDouble* TemperaturesLgm=xNew<IssmDouble>(NUM_VERTICES_MONTHS_PER_YEAR); 2496 IssmDouble* PrecipitationsPresentday=xNew<IssmDouble>(NUM_VERTICES_MONTHS_PER_YEAR); 2497 IssmDouble* PrecipitationsLgm=xNew<IssmDouble>(NUM_VERTICES_MONTHS_PER_YEAR); 2498 IssmDouble* tmp=xNew<IssmDouble>(NUM_VERTICES); 2482 2499 IssmDouble TdiffTime,PfacTime; 2483 2500 IssmDouble time,yts,time_yr; … … 2494 2511 Gauss* gauss=this->NewGauss(); 2495 2512 for(int month=0;month<12;month++) { 2496 for(int iv=0;iv< numvertices;iv++) {2513 for(int iv=0;iv<NUM_VERTICES;iv++) { 2497 2514 gauss->GaussVertex(iv); 2498 2515 input->GetInputValue(&TemperaturesPresentday[iv*12+month],gauss,month/12.*yts); … … 2511 2528 2512 2529 /*Compute the temperature and precipitation*/ 2513 for(int iv=0;iv< numvertices;iv++){2530 for(int iv=0;iv<NUM_VERTICES;iv++){ 2514 2531 ComputeMungsmTemperaturePrecipitation(TdiffTime,PfacTime, 2515 2532 &PrecipitationsLgm[iv*12],&PrecipitationsPresentday[iv*12], … … 2522 2539 TransientInput* NewPrecipitationInput = new TransientInput(SmbPrecipitationEnum); 2523 2540 for (int imonth=0;imonth<12;imonth++) { 2524 for(i=0;i< numvertices;i++) tmp[i]=monthlytemperatures[i*12+imonth];2541 for(i=0;i<NUM_VERTICES;i++) tmp[i]=monthlytemperatures[i*12+imonth]; 2525 2542 switch(this->ObjectEnum()){ 2526 2543 case TriaEnum: NewTemperatureInput->AddTimeInput(new TriaInput(SmbMonthlytemperaturesEnum,&tmp[0],P1Enum),time_yr+imonth/12.*yts); break; … … 2529 2546 default: _error_("Not implemented yet"); 2530 2547 } 2531 for(i=0;i< numvertices;i++) tmp[i]=monthlyprec[i*12+imonth]/yts;2548 for(i=0;i<NUM_VERTICES;i++) tmp[i]=monthlyprec[i*12+imonth]/yts; 2532 2549 switch(this->ObjectEnum()){ 2533 2550 case TriaEnum: NewPrecipitationInput->AddTimeInput(new TriaInput(SmbPrecipitationEnum,&tmp[0],P1Enum),time_yr+imonth/12.*yts); break; … … 2616 2633 2617 2634 this->inputs->AddInput(new IntInput(BasalforcingsPicoBoxIdEnum, boxid)); 2618 2635 2619 2636 }/*}}}*/ 2620 2637 void Element::PicoUpdateBox(int loopboxid){/*{{{*/ … … 2626 2643 if(loopboxid!=boxid) return; 2627 2644 2628 int NUMVERTICES = this->GetNumberOfVertices(); 2645 const int NUM_VERTICES = this->GetNumberOfVertices(); 2646 2629 2647 int basinid, maxbox, num_basins, numnodes, M; 2630 2648 IssmDouble gamma_T, overturning_coeff, thickness; … … 2664 2682 IssmDouble g1 = area_boxi*gamma_T; 2665 2683 2666 IssmDouble basalmeltrates_shelf[NUM VERTICES];2667 IssmDouble potential_pressure_melting_point[NUM VERTICES];2668 IssmDouble Tocs[NUM VERTICES];2669 IssmDouble Socs[NUM VERTICES];2684 IssmDouble basalmeltrates_shelf[NUM_VERTICES]; 2685 IssmDouble potential_pressure_melting_point[NUM_VERTICES]; 2686 IssmDouble Tocs[NUM_VERTICES]; 2687 IssmDouble Socs[NUM_VERTICES]; 2670 2688 2671 2689 /* First box calculations */ … … 2677 2695 this->parameters->FindParam(&soc_farocean, basinid, time, BasalforcingsPicoFarOceansalinityEnum); 2678 2696 IssmDouble s1 = soc_farocean/(nu*lambda); 2679 IssmDouble overturnings[NUM VERTICES];2697 IssmDouble overturnings[NUM_VERTICES]; 2680 2698 2681 2699 /* Start looping on the number of verticies and calculate ocean vars */ 2682 2700 Gauss* gauss=this->NewGauss(); 2683 for(int i=0;i<NUM VERTICES;i++){2701 for(int i=0;i<NUM_VERTICES;i++){ 2684 2702 gauss->GaussVertex(i); 2685 2703 thickness_input->GetInputValue(&thickness,gauss); … … 2724 2742 /* Start looping on the number of verticies and calculate ocean vars */ 2725 2743 Gauss* gauss=this->NewGauss(); 2726 for(int i=0;i<NUM VERTICES;i++){2744 for(int i=0;i<NUM_VERTICES;i++){ 2727 2745 gauss->GaussVertex(i); 2728 2746 thickness_input->GetInputValue(&thickness,gauss); … … 2748 2766 /*Cleanup and return*/ 2749 2767 xDelete<IssmDouble>(boxareas); 2750 2768 2751 2769 }/*}}}*/ 2752 2770 void Element::PicoComputeBasalMelt(){/*{{{*/ … … 2754 2772 if(!this->IsIceInElement() || !this->IsFloating()) return; 2755 2773 2756 int NUMVERTICES = this->GetNumberOfVertices(); 2774 const int NUM_VERTICES = this->GetNumberOfVertices(); 2775 2757 2776 IssmDouble E0, Cd, CdT, YT, lam1, lam2, lam3, M0, CdTS0, y1, y2, x0; 2758 2777 IssmDouble Tf_gl, YTS, CdTS, G1, G2, G3, g_alpha, M, l, X_hat, M_hat; … … 2774 2793 2775 2794 /*Define arrays*/ 2776 IssmDouble basalmeltrates_shelf[NUM VERTICES]; //Basal melt-rate2795 IssmDouble basalmeltrates_shelf[NUM_VERTICES]; //Basal melt-rate 2777 2796 2778 2797 /*Polynomial coefficients*/ … … 2802 2821 /*Loop over the number of vertices in this element*/ 2803 2822 Gauss* gauss=this->NewGauss(); 2804 for(int i=0;i<NUM VERTICES;i++){2823 for(int i=0;i<NUM_VERTICES;i++){ 2805 2824 gauss->GaussVertex(i); 2806 2825 … … 2851 2870 /*Cleanup and return*/ 2852 2871 delete gauss; 2853 2872 2854 2873 }/*}}}*/ 2855 2874 void Element::PositiveDegreeDay(IssmDouble* pdds,IssmDouble* pds,IssmDouble signorm,bool ismungsm,bool issetpddfac){/*{{{*/ 2856 2875 2857 int numvertices = this->GetNumberOfVertices(); 2858 2859 int i; 2860 IssmDouble* agd=xNew<IssmDouble>(numvertices); // surface mass balance 2861 IssmDouble* melt=xNew<IssmDouble>(numvertices); // surface mass balance 2862 IssmDouble* accu=xNew<IssmDouble>(numvertices); // surface mass balance 2863 IssmDouble* monthlytemperatures=xNew<IssmDouble>(12*numvertices); 2864 IssmDouble* monthlyprec=xNew<IssmDouble>(12*numvertices); 2865 IssmDouble* yearlytemperatures=xNew<IssmDouble>(numvertices); memset(yearlytemperatures, 0., numvertices*sizeof(IssmDouble)); 2866 IssmDouble* tmp=xNew<IssmDouble>(numvertices); 2867 IssmDouble* h=xNew<IssmDouble>(numvertices); 2868 IssmDouble* s=xNew<IssmDouble>(numvertices); 2869 IssmDouble* s0p=xNew<IssmDouble>(numvertices); 2870 IssmDouble* s0t=xNew<IssmDouble>(numvertices); 2876 const int NUM_VERTICES = this->GetNumberOfVertices(); 2877 const int NUM_VERTICES_MONTHS_PER_YEAR = NUM_VERTICES * 12; 2878 2879 int i; 2880 IssmDouble* agd=xNew<IssmDouble>(NUM_VERTICES); // surface mass balance 2881 IssmDouble* melt=xNew<IssmDouble>(NUM_VERTICES); // surface mass balance 2882 IssmDouble* accu=xNew<IssmDouble>(NUM_VERTICES); // surface mass balance 2883 IssmDouble* monthlytemperatures=xNew<IssmDouble>(NUM_VERTICES_MONTHS_PER_YEAR); 2884 IssmDouble* monthlyprec=xNew<IssmDouble>(NUM_VERTICES_MONTHS_PER_YEAR); 2885 IssmDouble* yearlytemperatures=xNew<IssmDouble>(NUM_VERTICES); memset(yearlytemperatures, 0., NUM_VERTICES*sizeof(IssmDouble)); 2886 IssmDouble* tmp=xNew<IssmDouble>(NUM_VERTICES); 2887 IssmDouble* h=xNew<IssmDouble>(NUM_VERTICES); 2888 IssmDouble* s=xNew<IssmDouble>(NUM_VERTICES); 2889 IssmDouble* s0p=xNew<IssmDouble>(NUM_VERTICES); 2890 IssmDouble* s0t=xNew<IssmDouble>(NUM_VERTICES); 2871 2891 IssmDouble pddsnowfac = -1.; 2872 2892 IssmDouble pddicefac = -1.; … … 2895 2915 Gauss* gauss=this->NewGauss(); 2896 2916 for(int month=0;month<12;month++) { 2897 for(int iv=0;iv< numvertices;iv++) {2917 for(int iv=0;iv<NUM_VERTICES;iv++) { 2898 2918 gauss->GaussVertex(iv); 2899 2919 input->GetInputValue(&monthlytemperatures[iv*12+month],gauss,time_yr+month/12.*yts); … … 2932 2952 2933 2953 /*measure the surface mass balance*/ 2934 for (int iv = 0; iv< numvertices; iv++){2954 for (int iv = 0; iv<NUM_VERTICES; iv++){ 2935 2955 gauss->GaussVertex(iv); 2936 2956 pddsnowfac=-1.; … … 2952 2972 // TransientInput* NewPrecipitationInput = new TransientInput(SmbPrecipitationEnum); 2953 2973 // for (int imonth=0;imonth<12;imonth++) { 2954 // for(i=0;i< numvertices;i++) tmp[i]=monthlytemperatures[i*12+imonth];2974 // for(i=0;i<NUM_VERTICES;i++) tmp[i]=monthlytemperatures[i*12+imonth]; 2955 2975 // TriaInput* newmonthinput1 = new TriaInput(SmbMonthlytemperaturesEnum,&tmp[0],P1Enum); 2956 2976 // NewTemperatureInput->AddTimeInput(newmonthinput1,time+imonth/12.*yts); 2957 2977 // 2958 // for(i=0;i< numvertices;i++) tmp[i]=monthlyprec[i*12+imonth]/yts;2978 // for(i=0;i<NUM_VERTICES;i++) tmp[i]=monthlyprec[i*12+imonth]/yts; 2959 2979 // TriaInput* newmonthinput2 = new TriaInput(SmbPrecipitationEnum,&tmp[0],P1Enum); 2960 2980 // NewPrecipitationInput->AddTimeInput(newmonthinput2,time+imonth/12.*yts); … … 3042 3062 /* General FIXMEs: get Tmelting point, pddicefactor, pddsnowfactor, sigma from parameters/user input */ 3043 3063 3044 int numvertices = this->GetNumberOfVertices(); 3045 3046 int i; 3047 IssmDouble* smb=xNew<IssmDouble>(numvertices); // surface mass balance 3048 IssmDouble* melt=xNew<IssmDouble>(numvertices); // melting comp. of surface mass balance 3049 IssmDouble* accu=xNew<IssmDouble>(numvertices); // accuumulation comp. of surface mass balance 3050 IssmDouble* melt_star=xNew<IssmDouble>(numvertices); 3051 IssmDouble* monthlytemperatures=xNew<IssmDouble>(12*numvertices); 3052 IssmDouble* monthlyprec=xNew<IssmDouble>(12*numvertices); 3053 IssmDouble* yearlytemperatures=xNew<IssmDouble>(numvertices); memset(yearlytemperatures, 0., numvertices*sizeof(IssmDouble)); 3054 IssmDouble* s=xNew<IssmDouble>(numvertices); // actual surface height 3055 IssmDouble* s0p=xNew<IssmDouble>(numvertices); // reference elevation for precip. 3056 IssmDouble* s0t=xNew<IssmDouble>(numvertices); // reference elevation for temperature 3057 IssmDouble* smbcorr=xNew<IssmDouble>(numvertices); // surface mass balance correction; will be added after pdd call 3058 IssmDouble* p_ampl=xNew<IssmDouble>(numvertices); // precip anomaly 3059 IssmDouble* t_ampl=xNew<IssmDouble>(numvertices); // remperature anomaly 3064 const int NUM_VERTICES = this->GetNumberOfVertices(); 3065 const int NUM_VERTICES_MONTHS_PER_YEAR = NUM_VERTICES * 12; 3066 3067 int i; 3068 IssmDouble* smb=xNew<IssmDouble>(NUM_VERTICES); // surface mass balance 3069 IssmDouble* melt=xNew<IssmDouble>(NUM_VERTICES); // melting comp. of surface mass balance 3070 IssmDouble* accu=xNew<IssmDouble>(NUM_VERTICES); // accuumulation comp. of surface mass balance 3071 IssmDouble* melt_star=xNew<IssmDouble>(NUM_VERTICES); 3072 IssmDouble* monthlytemperatures=xNew<IssmDouble>(NUM_VERTICES_MONTHS_PER_YEAR); 3073 IssmDouble* monthlyprec=xNew<IssmDouble>(NUM_VERTICES_MONTHS_PER_YEAR); 3074 IssmDouble* yearlytemperatures=xNew<IssmDouble>(NUM_VERTICES); memset(yearlytemperatures, 0., NUM_VERTICES*sizeof(IssmDouble)); 3075 IssmDouble* s=xNew<IssmDouble>(NUM_VERTICES); // actual surface height 3076 IssmDouble* s0p=xNew<IssmDouble>(NUM_VERTICES); // reference elevation for precip. 3077 IssmDouble* s0t=xNew<IssmDouble>(NUM_VERTICES); // reference elevation for temperature 3078 IssmDouble* smbcorr=xNew<IssmDouble>(NUM_VERTICES); // surface mass balance correction; will be added after pdd call 3079 IssmDouble* p_ampl=xNew<IssmDouble>(NUM_VERTICES); // precip anomaly 3080 IssmDouble* t_ampl=xNew<IssmDouble>(NUM_VERTICES); // remperature anomaly 3060 3081 IssmDouble rho_water,rho_ice,desfac,rlaps; 3061 3082 IssmDouble inv_twelve=1./12.; //factor for monthly average … … 3088 3109 Gauss* gauss=this->NewGauss(); 3089 3110 for(int month=0;month<12;month++){ 3090 for(int iv=0;iv< numvertices;iv++){3111 for(int iv=0;iv<NUM_VERTICES;iv++){ 3091 3112 gauss->GaussVertex(iv); 3092 3113 input->GetInputValue(&monthlytemperatures[iv*12+month],gauss,(month+1)/12.*yts); … … 3106 3127 3107 3128 /*measure the surface mass balance*/ 3108 for (int iv = 0; iv< numvertices; iv++){3129 for (int iv = 0; iv<NUM_VERTICES; iv++){ 3109 3130 smb[iv]=PddSurfaceMassBalanceSicopolis(&monthlytemperatures[iv*12], &monthlyprec[iv*12], 3110 3131 &melt[iv], &accu[iv], &melt_star[iv], &t_ampl[iv], &p_ampl[iv], yts, s[iv], … … 3324 3345 } 3325 3346 case P1Enum:{ 3326 int numvertices = this->GetNumberOfVertices(); 3327 IssmDouble *values = xNew<IssmDouble>(numvertices); 3328 int *connectivity= xNew<int>(numvertices); 3329 int *sidlist = xNew<int>(numvertices); 3347 const int NUM_VERTICES = this->GetNumberOfVertices(); 3348 3349 IssmDouble *values = xNew<IssmDouble>(NUM_VERTICES); 3350 int *connectivity= xNew<int>(NUM_VERTICES); 3351 int *sidlist = xNew<int>(NUM_VERTICES); 3330 3352 3331 3353 this->GetVerticesSidList(sidlist); 3332 3354 this->GetVerticesConnectivityList(connectivity); 3333 3355 this->GetInputListOnVertices(values,output_enum); 3334 for(int i=0;i< numvertices;i++) values[i] = values[i]/reCast<IssmDouble>(connectivity[i]);3335 3336 vector->SetValues( numvertices,sidlist,values,ADD_VAL);3356 for(int i=0;i<NUM_VERTICES;i++) values[i] = values[i]/reCast<IssmDouble>(connectivity[i]); 3357 3358 vector->SetValues(NUM_VERTICES,sidlist,values,ADD_VAL); 3337 3359 3338 3360 xDelete<IssmDouble>(values); … … 3421 3443 if (!IsOnSurface()) return; 3422 3444 3423 int numvertices = this->GetNumberOfVertices(); 3424 3425 IssmDouble* s=xNew<IssmDouble>(numvertices); 3426 IssmDouble* s0gcm=xNew<IssmDouble>(numvertices); 3427 IssmDouble* st=xNew<IssmDouble>(numvertices); 3445 const int NUM_VERTICES = this->GetNumberOfVertices(); 3446 const int NUM_VERTICES_DAYS_PER_YEAR = NUM_VERTICES * 365; 3447 3448 IssmDouble* s=xNew<IssmDouble>(NUM_VERTICES); 3449 IssmDouble* s0gcm=xNew<IssmDouble>(NUM_VERTICES); 3450 IssmDouble* st=xNew<IssmDouble>(NUM_VERTICES); 3428 3451 3429 3452 // daily forcing inputs 3430 IssmDouble* dailyrainfall=xNew<IssmDouble>( 365*numvertices);3431 IssmDouble* dailysnowfall=xNew<IssmDouble>( 365*numvertices);3432 IssmDouble* dailydlradiation=xNew<IssmDouble>( 365*numvertices);3433 IssmDouble* dailydsradiation=xNew<IssmDouble>( 365*numvertices);3434 IssmDouble* dailywindspeed=xNew<IssmDouble>( 365*numvertices);3435 IssmDouble* dailypressure=xNew<IssmDouble>( 365*numvertices);3436 IssmDouble* dailyairdensity=xNew<IssmDouble>( 365*numvertices);3437 IssmDouble* dailyairhumidity=xNew<IssmDouble>( 365*numvertices);3438 IssmDouble* dailytemperature=xNew<IssmDouble>( 365*numvertices);3453 IssmDouble* dailyrainfall=xNew<IssmDouble>(NUM_VERTICES_DAYS_PER_YEAR); 3454 IssmDouble* dailysnowfall=xNew<IssmDouble>(NUM_VERTICES_DAYS_PER_YEAR); 3455 IssmDouble* dailydlradiation=xNew<IssmDouble>(NUM_VERTICES_DAYS_PER_YEAR); 3456 IssmDouble* dailydsradiation=xNew<IssmDouble>(NUM_VERTICES_DAYS_PER_YEAR); 3457 IssmDouble* dailywindspeed=xNew<IssmDouble>(NUM_VERTICES_DAYS_PER_YEAR); 3458 IssmDouble* dailypressure=xNew<IssmDouble>(NUM_VERTICES_DAYS_PER_YEAR); 3459 IssmDouble* dailyairdensity=xNew<IssmDouble>(NUM_VERTICES_DAYS_PER_YEAR); 3460 IssmDouble* dailyairhumidity=xNew<IssmDouble>(NUM_VERTICES_DAYS_PER_YEAR); 3461 IssmDouble* dailytemperature=xNew<IssmDouble>(NUM_VERTICES_DAYS_PER_YEAR); 3439 3462 // daily outputs 3440 IssmDouble* tsurf_out=xNew<IssmDouble>( numvertices); memset(tsurf_out, 0., numvertices*sizeof(IssmDouble));3441 IssmDouble* smb_out=xNew<IssmDouble>( numvertices); memset(smb_out, 0., numvertices*sizeof(IssmDouble));3442 IssmDouble* saccu_out=xNew<IssmDouble>( numvertices); memset(saccu_out, 0., numvertices*sizeof(IssmDouble));3443 IssmDouble* smelt_out=xNew<IssmDouble>( numvertices); memset(smelt_out, 0., numvertices*sizeof(IssmDouble));3463 IssmDouble* tsurf_out=xNew<IssmDouble>(NUM_VERTICES); memset(tsurf_out, 0., NUM_VERTICES*sizeof(IssmDouble)); 3464 IssmDouble* smb_out=xNew<IssmDouble>(NUM_VERTICES); memset(smb_out, 0., NUM_VERTICES*sizeof(IssmDouble)); 3465 IssmDouble* saccu_out=xNew<IssmDouble>(NUM_VERTICES); memset(saccu_out, 0., NUM_VERTICES*sizeof(IssmDouble)); 3466 IssmDouble* smelt_out=xNew<IssmDouble>(NUM_VERTICES); memset(smelt_out, 0., NUM_VERTICES*sizeof(IssmDouble)); 3444 3467 3445 3468 IssmDouble rho_water,rho_ice,desfac,rlaps,rdl; … … 3476 3499 Gauss* gauss=this->NewGauss(); 3477 3500 for (int iday = 0; iday < 365; iday++){ 3478 for(int iv=0;iv< numvertices;iv++) {3501 for(int iv=0;iv<NUM_VERTICES;iv++) { 3479 3502 gauss->GaussVertex(iv); 3480 3503 /* get forcing */ … … 3508 3531 } 3509 3532 3510 for (int iv = 0; iv< numvertices; iv++){3533 for (int iv = 0; iv<NUM_VERTICES; iv++){ 3511 3534 /* call semic */ 3512 run_semic_(&dailysnowfall[iv*365], &dailyrainfall[iv*365], &dailydsradiation[iv*365], &dailydlradiation[iv*365], 3535 run_semic_(&dailysnowfall[iv*365], &dailyrainfall[iv*365], &dailydsradiation[iv*365], &dailydlradiation[iv*365], 3513 3536 &dailywindspeed[iv*365], &dailypressure[iv*365], &dailyairdensity[iv*365], &dailyairhumidity[iv*365], &dailytemperature[iv*365], 3514 3537 &tsurf_out[iv], &smb_out[iv], &saccu_out[iv], &smelt_out[iv]); … … 3516 3539 3517 3540 switch(this->ObjectEnum()){ 3518 case TriaEnum: 3541 case TriaEnum: 3519 3542 this->inputs->AddInput(new TriaInput(TemperatureSEMICEnum,&tsurf_out[0],P1Enum)); // TODO add TemperatureSEMICEnum to EnumDefinitions 3520 3543 this->inputs->AddInput(new TriaInput(SmbMassBalanceEnum,&smb_out[0],P1Enum)); … … 3525 3548 // TODO 3526 3549 break; 3527 case TetraEnum: 3550 case TetraEnum: 3528 3551 // TODO 3529 3552 break; … … 3540 3563 xDelete<IssmDouble>(dailypressure); 3541 3564 xDelete<IssmDouble>(dailyairdensity); 3542 xDelete<IssmDouble>(dailyairhumidity); 3565 xDelete<IssmDouble>(dailyairhumidity); 3543 3566 xDelete<IssmDouble>(dailypressure); 3544 3567 xDelete<IssmDouble>(dailytemperature); … … 3548 3571 xDelete<IssmDouble>(tsurf_out); 3549 3572 xDelete<IssmDouble>(s); 3550 xDelete<IssmDouble>(st); 3573 xDelete<IssmDouble>(st); 3551 3574 xDelete<IssmDouble>(s0gcm); 3552 3575 } … … 4161 4184 4162 4185 /*Fetch number vertices and allocate memory*/ 4163 int numvertices = this->GetNumberOfVertices(); 4164 IssmDouble* maxprincipal = xNew<IssmDouble>(numvertices); 4186 const int NUM_VERTICES = this->GetNumberOfVertices(); 4187 4188 IssmDouble* maxprincipal = xNew<IssmDouble>(NUM_VERTICES); 4165 4189 4166 4190 /*Retrieve all inputs and parameters*/ … … 4180 4204 /*loop over vertices: */ 4181 4205 Gauss* gauss=this->NewGauss(); 4182 for (int iv=0;iv< numvertices;iv++){4206 for (int iv=0;iv<NUM_VERTICES;iv++){ 4183 4207 gauss->GaussVertex(iv); 4184 4208 … … 4503 4527 4504 4528 /*Fetch number vertices and allocate memory*/ 4505 int numvertices = this->GetNumberOfVertices(); 4506 IssmDouble* viscousheating = xNew<IssmDouble>(numvertices); 4529 const int NUM_VERTICES = this->GetNumberOfVertices(); 4530 4531 IssmDouble* viscousheating = xNew<IssmDouble>(NUM_VERTICES); 4507 4532 4508 4533 /*Retrieve all inputs and parameters*/ … … 4514 4539 /*loop over vertices: */ 4515 4540 Gauss* gauss=this->NewGauss(); 4516 for (int iv=0;iv< numvertices;iv++){4541 for (int iv=0;iv<NUM_VERTICES;iv++){ 4517 4542 gauss->GaussVertex(iv); 4518 4543
Note:
See TracChangeset
for help on using the changeset viewer.