Changeset 10141
- Timestamp:
- 10/07/11 15:34:54 (14 years ago)
- Location:
- issm/trunk/src
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/objects/Elements/Penta.cpp
r10135 r10141 1745 1745 const int numdof2d = NDOF1*NUMVERTICES2D; 1746 1746 1747 int i, dummy,hydroadjustment;1747 int i,hydroadjustment; 1748 1748 int* doflist = NULL; 1749 double values[numdof];1750 1749 double rho_ice,rho_water; 1751 double bed[numdof]; 1752 double surface[numdof]; 1753 double *bed_ptr = NULL; 1754 double *thickness_ptr = NULL; 1755 double *surface_ptr = NULL; 1750 double newthickness[numdof]; 1751 double newbed[numdof]; 1752 double newsurface[numdof]; 1753 double oldbed[NUMVERTICES]; 1754 double oldsurface[NUMVERTICES]; 1755 double oldthickness[NUMVERTICES]; 1756 1756 Penta *penta = NULL; 1757 1757 … … 1764 1764 /*Use the dof list to index into the solution vector and extrude it */ 1765 1765 for(i=0;i<numdof2d;i++){ 1766 values[i]=solution[doflist[i]];1767 if(isnan( values[i])) _error_("NaN found in solution vector");1766 newthickness[i]=solution[doflist[i]]; 1767 if(isnan(newthickness[i])) _error_("NaN found in solution vector"); 1768 1768 /*Constrain thickness to be at least 1m*/ 1769 if( values[i]<1) values[i]=1;1770 values[i+numdof2d]=values[i];1769 if(newthickness[i]<1) newthickness[i]=1; 1770 newthickness[i+numdof2d]=newthickness[i]; 1771 1771 } 1772 1772 1773 1773 /*Get previous bed, thickness and surface*/ 1774 Input* bed_input=inputs->GetInput(BedEnum); _assert_(bed_input); 1775 Input* thickness_input=inputs->GetInput(ThicknessEnum); _assert_(thickness_input); 1776 Input* surface_input=inputs->GetInput(SurfaceEnum); _assert_(surface_input); 1777 bed_input->GetValuesPtr(&bed_ptr,&dummy); 1778 thickness_input->GetValuesPtr(&thickness_ptr,&dummy); 1779 surface_input->GetValuesPtr(&surface_ptr,&dummy); 1774 GetInputListOnVertices(&oldbed[0],BedEnum); 1775 GetInputListOnVertices(&oldsurface[0],SurfaceEnum); 1776 GetInputListOnVertices(&oldthickness[0],ThicknessEnum); 1780 1777 1781 1778 /*Fing PrognosticHydrostaticAdjustment to figure out how to update the geometry:*/ … … 1789 1786 /*If shelf: hydrostatic equilibrium*/ 1790 1787 if (this->nodes[i]->IsOnSheet()){ 1791 surface[i]=bed_ptr[i]+values[i]; //surface=oldbed+newthickness1792 bed[i]=bed_ptr[i]; //bed does not change1788 newsurface[i]=oldbed[i]+newthickness[i]; //surface = oldbed + newthickness 1789 newbed[i]=oldbed[i]; //same bed: do nothing 1793 1790 } 1794 1791 else{ //so it is an ice shelf 1795 1792 if(hydroadjustment==AbsoluteEnum){ 1796 surface[i]=values[i]*(1-rho_ice/rho_water);1797 bed[i]=values[i]*(-rho_ice/rho_water);1793 newsurface[i]=newthickness[i]*(1-rho_ice/rho_water); 1794 newbed[i]=newthickness[i]*(-rho_ice/rho_water); 1798 1795 } 1799 1796 else if(hydroadjustment==IncrementalEnum){ 1800 surface[i]=surface_ptr[i]+(1.0-rho_ice/rho_water)*(values[i]-thickness_ptr[i]); //surface = oldsurface + (1-di) * dH1801 bed[i]=bed_ptr[i]-rho_ice/rho_water*(values[i]-thickness_ptr[i]); //bed = oldbed + di * dH1797 newsurface[i]=oldsurface[i]+(1.0-rho_ice/rho_water)*(newthickness[i]-oldthickness[i]); //surface = oldsurface + (1-di) * dH 1798 newbed[i]=oldbed[i]-rho_ice/rho_water*(newthickness[i]-oldthickness[i]); //bed = oldbed + di * dH 1802 1799 } 1803 1800 else _error_("Hydrostatic adjustment %i (%s) not supported yet",hydroadjustment,EnumToStringx(hydroadjustment)); … … 1809 1806 for(;;){ 1810 1807 /*Add input to the element: */ 1811 penta->inputs->AddInput(new PentaVertexInput(ThicknessEnum, values));1812 penta->inputs->AddInput(new PentaVertexInput(SurfaceEnum, surface));1813 penta->inputs->AddInput(new PentaVertexInput(BedEnum, bed));1808 penta->inputs->AddInput(new PentaVertexInput(ThicknessEnum,newthickness)); 1809 penta->inputs->AddInput(new PentaVertexInput(SurfaceEnum,newsurface)); 1810 penta->inputs->AddInput(new PentaVertexInput(BedEnum,newbed)); 1814 1811 1815 1812 /*Stop if we have reached the surface*/ … … 7097 7094 const int numdof=NDOF2*NUMVERTICES; 7098 7095 7099 int i ,dummy;7096 int i; 7100 7097 double rho_ice,g; 7101 7098 double values[numdof]; … … 7108 7105 double xyz_list[NUMVERTICES][3]; 7109 7106 int *doflist = NULL; 7110 double *vz_ptr = NULL;7111 7107 Penta *penta = NULL; 7112 7108 … … 7141 7137 7142 7138 /*Now Compute vel*/ 7143 Input* vz_input=inputs->GetInput(VzEnum); 7144 if (vz_input){ 7145 if (vz_input->ObjectEnum()!=PentaVertexInputEnum) _error_("Cannot compute Vel as Vz is of type %s",EnumToStringx(vz_input->ObjectEnum())); 7146 vz_input->GetValuesPtr(&vz_ptr,&dummy); 7147 for(i=0;i<NUMVERTICES;i++) vz[i]=vz_ptr[i]; 7148 } 7149 else{for(i=0;i<NUMVERTICES;i++) vz[i]=0.0;} 7139 GetInputListOnVertices(&vz[0],VzEnum,0.0); //default is 0 7150 7140 for(i=0;i<NUMVERTICES;i++) vel[i]=pow( pow(vx[i],2.0) + pow(vy[i],2.0) + pow(vz[i],2.0) , 0.5); 7151 7141 … … 7183 7173 const int numdof2d=NDOF2*NUMVERTICES2D; 7184 7174 7185 int i ,dummy;7175 int i; 7186 7176 double rho_ice,g; 7187 7177 double macayeal_values[numdof]; … … 7196 7186 int* doflistp = NULL; 7197 7187 int* doflistm = NULL; 7198 double *vz_ptr = NULL;7199 7188 Penta *penta = NULL; 7200 7189 … … 7230 7219 } 7231 7220 7232 /*Get Vz*/7233 Input* vz_input=inputs->GetInput(VzEnum);7234 if (vz_input){7235 if (vz_input->ObjectEnum()!=PentaVertexInputEnum){7236 _error_("Cannot compute Vel as Vz is of type %s",EnumToStringx(vz_input->ObjectEnum()));7237 }7238 vz_input->GetValuesPtr(&vz_ptr,&dummy);7239 for(i=0;i<NUMVERTICES;i++) vz[i]=vz_ptr[i];7240 }7241 else{7242 for(i=0;i<NUMVERTICES;i++) vz[i]=0.0;7243 }7244 7245 7221 /*Now Compute vel*/ 7222 GetInputListOnVertices(&vz[0],VzEnum,0.0); //default is 0 7246 7223 for(i=0;i<NUMVERTICES;i++) vel[i]=pow( pow(vx[i],2.0) + pow(vy[i],2.0) + pow(vz[i],2.0) , 0.5); 7247 7224 … … 7277 7254 const int numdof2d=NDOF2*NUMVERTICES2D; 7278 7255 7279 int i ,dummy;7256 int i; 7280 7257 double stokesreconditioning; 7281 7258 double macayeal_values[numdofm]; … … 7291 7268 int* doflistm = NULL; 7292 7269 int* doflists = NULL; 7293 double *vzmacayeal_ptr = NULL;7294 7270 Penta *penta = NULL; 7295 7271 … … 7335 7311 _error_("Cannot compute Vel as VzMacAyeal is of type %s",EnumToStringx(vzmacayeal_input->ObjectEnum())); 7336 7312 } 7337 vzmacayeal_input->GetValuesPtr(&vzmacayeal_ptr,&dummy); 7338 for(i=0;i<NUMVERTICES;i++) vzmacayeal[i]=vzmacayeal_ptr[i]; 7313 GetInputListOnVertices(&vzmacayeal[0],VzMacAyealEnum); 7339 7314 } 7340 7315 else{ … … 7373 7348 const int numdof=NDOF2*NUMVERTICES; 7374 7349 7375 int i ,dummy;7350 int i; 7376 7351 double rho_ice,g; 7377 7352 double values[numdof]; … … 7445 7420 const int numdofs=NDOF4*NUMVERTICES; 7446 7421 7447 int i ,dummy;7422 int i; 7448 7423 double pattyn_values[numdofp]; 7449 7424 double stokes_values[numdofs]; … … 7459 7434 int* doflistp = NULL; 7460 7435 int* doflists = NULL; 7461 double *vzpattyn_ptr = NULL;7462 7436 Penta *penta = NULL; 7463 7437 … … 7498 7472 _error_("Cannot compute Vel as VzPattyn is of type %s",EnumToStringx(vzpattyn_input->ObjectEnum())); 7499 7473 } 7500 vzpattyn_input->GetValuesPtr(&vzpattyn_ptr,&dummy); 7501 for(i=0;i<NUMVERTICES;i++) vzpattyn[i]=vzpattyn_ptr[i]; 7474 GetInputListOnVertices(&vzpattyn[0],VzPattynEnum); 7502 7475 } 7503 7476 else{ … … 7536 7509 const int numdof=NDOF2*NUMVERTICES; 7537 7510 7538 int i ,dummy;7511 int i; 7539 7512 double rho_ice,g; 7540 7513 double values[numdof]; … … 7547 7520 double xyz_list[NUMVERTICES][3]; 7548 7521 int* doflist = NULL; 7549 double* vz_ptr = NULL;7550 7522 7551 7523 /*Get dof list: */ … … 7568 7540 } 7569 7541 7570 /*Get Vz*/7571 Input* vz_input=inputs->GetInput(VzEnum);7572 if (vz_input){7573 if (vz_input->ObjectEnum()!=PentaVertexInputEnum){7574 _error_("Cannot compute Vel as Vz is of type %s",EnumToStringx(vz_input->ObjectEnum()));7575 }7576 vz_input->GetValuesPtr(&vz_ptr,&dummy);7577 for(i=0;i<NUMVERTICES;i++) vz[i]=vz_ptr[i];7578 }7579 else{7580 for(i=0;i<NUMVERTICES;i++) vz[i]=0.0;7581 }7582 7583 7542 /*Now Compute vel*/ 7543 GetInputListOnVertices(&vz[0],VzEnum,0.0); //default is 0 7584 7544 for(i=0;i<NUMVERTICES;i++) vel[i]=pow( pow(vx[i],2.0) + pow(vy[i],2.0) + pow(vz[i],2.0) , 0.5); 7585 7545 … … 7600 7560 this->inputs->AddInput(new PentaVertexInput(VxEnum,vx)); 7601 7561 this->inputs->AddInput(new PentaVertexInput(VyEnum,vy)); 7602 this->inputs->AddInput(new TriaVertexInput(VelEnum,vel));7562 this->inputs->AddInput(new PentaVertexInput(VelEnum,vel)); 7603 7563 this->inputs->AddInput(new PentaVertexInput(PressureEnum,pressure)); 7604 7564 … … 7612 7572 const int numdof=NDOF1*NUMVERTICES; 7613 7573 7614 int i ,dummy;7574 int i; 7615 7575 int approximation; 7616 7576 double rho_ice,g; … … 7627 7587 double xyz_list[NUMVERTICES][3]; 7628 7588 int* doflist = NULL; 7629 double* vx_ptr = NULL;7630 double* vy_ptr = NULL;7631 double* vzstokes_ptr = NULL;7632 7589 7633 7590 … … 7652 7609 7653 7610 /*Get Vx and Vy*/ 7654 Input* vx_input=inputs->GetInput(VxEnum); 7655 if (vx_input){ 7656 if (vx_input->ObjectEnum()!=PentaVertexInputEnum) _error_("Cannot compute Vel as Vx is of type %s",EnumToStringx(vx_input->ObjectEnum())); 7657 vx_input->GetValuesPtr(&vx_ptr,&dummy); 7658 for(i=0;i<NUMVERTICES;i++) vx[i]=vx_ptr[i]; 7659 } 7660 else for(i=0;i<NUMVERTICES;i++) vx[i]=0.0; 7661 7662 Input* vy_input=inputs->GetInput(VyEnum); 7663 if (vy_input){ 7664 if (vy_input->ObjectEnum()!=PentaVertexInputEnum) _error_("Cannot compute Vel as Vy is of type %s",EnumToStringx(vy_input->ObjectEnum())); 7665 vy_input->GetValuesPtr(&vy_ptr,&dummy); 7666 for(i=0;i<NUMVERTICES;i++) vy[i]=vy_ptr[i]; 7667 } 7668 else for(i=0;i<NUMVERTICES;i++) vy[i]=0.0; 7611 GetInputListOnVertices(&vx[0],VxEnum,0.0); //default is 0 7612 GetInputListOnVertices(&vy[0],VyEnum,0.0); //default is 0 7669 7613 7670 7614 /*Do some modifications if we actually have a PattynStokes or MacAyealStokes element*/ … … 7672 7616 Input* vzstokes_input=inputs->GetInput(VzStokesEnum); 7673 7617 if (vzstokes_input){ 7674 if (vzstokes_input->ObjectEnum()!=PentaVertexInputEnum) _error_("Cannot compute Vel as VzStokes is of type %s",EnumToStringx(vy_input->ObjectEnum())); 7675 vzstokes_input->GetValuesPtr(&vzstokes_ptr,&dummy); 7676 for(i=0;i<NUMVERTICES;i++) vzstokes[i]=vzstokes_ptr[i]; 7618 if (vzstokes_input->ObjectEnum()!=PentaVertexInputEnum) _error_("Cannot compute Vel as VzStokes is of type %s",EnumToStringx(vzstokes_input->ObjectEnum())); 7619 GetInputListOnVertices(&vzstokes[0],VzStokesEnum); 7677 7620 } 7678 7621 else _error_("Cannot compute Vz as VzStokes in not present in PattynStokes element"); … … 7685 7628 Input* vzstokes_input=inputs->GetInput(VzStokesEnum); 7686 7629 if (vzstokes_input){ 7687 if (vzstokes_input->ObjectEnum()!=PentaVertexInputEnum) _error_("Cannot compute Vel as VzStokes is of type %s",EnumToStringx(vy_input->ObjectEnum())); 7688 vzstokes_input->GetValuesPtr(&vzstokes_ptr,&dummy); 7689 for(i=0;i<NUMVERTICES;i++) vzstokes[i]=vzstokes_ptr[i]; 7630 if (vzstokes_input->ObjectEnum()!=PentaVertexInputEnum) _error_("Cannot compute Vel as VzStokes is of type %s",EnumToStringx(vzstokes_input->ObjectEnum())); 7631 GetInputListOnVertices(&vzstokes[0],VzStokesEnum); 7690 7632 } 7691 7633 else _error_("Cannot compute Vz as VzStokes in not present in MacAyealStokes element"); … … 7722 7664 this->inputs->AddInput(new PentaVertexInput(VzMacAyealEnum,vzmacayeal)); 7723 7665 } 7724 7725 7666 this->inputs->AddInput(new PentaVertexInput(VzEnum,vz)); 7726 7667 this->inputs->AddInput(new PentaVertexInput(VelEnum,vel)); -
issm/trunk/src/c/objects/Elements/Tria.cpp
r10135 r10141 333 333 334 334 /*Surface and bed are updated. Update inputs:*/ 335 surface_input->GetValuesPtr(&values,NULL); for(i=0;i<3;i++)values[i]=s[i]; 336 bed_input->GetValuesPtr(&values,NULL); for(i=0;i<3;i++)values[i]=b[i]; 337 335 this->inputs->AddInput(new TriaVertexInput(SurfaceEnum,&s[0])); 336 this->inputs->AddInput(new TriaVertexInput(BedEnum,&b[0])); 338 337 } 339 338 /*}}}*/ … … 1651 1650 const int numdof = NDOF1*NUMVERTICES; 1652 1651 1653 int i, dummy,hydroadjustment;1652 int i,hydroadjustment; 1654 1653 int* doflist=NULL; 1655 1654 double rho_ice,rho_water; 1656 double values[numdof];1657 double bed[numdof];1658 double surface[numdof];1659 double *bed_ptr = NULL;1660 double *thickness_ptr = NULL;1661 double *surface_ptr = NULL;1655 double newthickness[numdof]; 1656 double newbed[numdof]; 1657 double newsurface[numdof]; 1658 double oldbed[NUMVERTICES]; 1659 double oldsurface[NUMVERTICES]; 1660 double oldthickness[NUMVERTICES]; 1662 1661 1663 1662 /*Get dof list: */ … … 1666 1665 /*Use the dof list to index into the solution vector: */ 1667 1666 for(i=0;i<numdof;i++){ 1668 values[i]=solution[doflist[i]];1669 if(isnan( values[i])) _error_("NaN found in solution vector");1667 newthickness[i]=solution[doflist[i]]; 1668 if(isnan(newthickness[i])) _error_("NaN found in solution vector"); 1670 1669 /*Constrain thickness to be at least 1m*/ 1671 if( values[i]<1) values[i]=1;1670 if(newthickness[i]<1) newthickness[i]=1; 1672 1671 } 1673 1672 1674 1673 /*Get previous bed, thickness and surface*/ 1675 Input* bed_input=inputs->GetInput(BedEnum); _assert_(bed_input); 1676 Input* thickness_input=inputs->GetInput(ThicknessEnum); _assert_(thickness_input); 1677 Input* surface_input=inputs->GetInput(SurfaceEnum); _assert_(surface_input); 1678 bed_input->GetValuesPtr(&bed_ptr,&dummy); 1679 thickness_input->GetValuesPtr(&thickness_ptr,&dummy); 1680 surface_input->GetValuesPtr(&surface_ptr,&dummy); 1674 GetInputListOnVertices(&oldbed[0],BedEnum); 1675 GetInputListOnVertices(&oldsurface[0],SurfaceEnum); 1676 GetInputListOnVertices(&oldthickness[0],ThicknessEnum); 1681 1677 1682 1678 /*Fing PrognosticHydrostaticAdjustment to figure out how to update the geometry:*/ 1683 1679 this->parameters->FindParam(&hydroadjustment,PrognosticHydrostaticAdjustmentEnum); 1684 1685 /*recover material parameters: */1686 1680 rho_ice=matpar->GetRhoIce(); 1687 1681 rho_water=matpar->GetRhoWater(); … … 1690 1684 /*If shelf: hydrostatic equilibrium*/ 1691 1685 if (this->nodes[i]->IsOnSheet()){ 1692 surface[i]=bed_ptr[i]+values[i]; //surface=oldbed+newthickness1693 bed[i]=bed_ptr[i]; //do nothing1686 newsurface[i]=oldbed[i]+newthickness[i]; //surface = oldbed + newthickness 1687 newbed[i]=oldbed[i]; //same bed: do nothing 1694 1688 } 1695 1689 else{ //this is an ice shelf 1696 1690 1697 1691 if(hydroadjustment==AbsoluteEnum){ 1698 surface[i]=values[i]*(1-rho_ice/rho_water);1699 bed[i]=values[i]*(-rho_ice/rho_water);1692 newsurface[i]=newthickness[i]*(1-rho_ice/rho_water); 1693 newbed[i]=newthickness[i]*(-rho_ice/rho_water); 1700 1694 } 1701 1695 else if(hydroadjustment==IncrementalEnum){ 1702 surface[i]=surface_ptr[i]+(1.0-rho_ice/rho_water)*(values[i]-thickness_ptr[i]); //surface = oldsurface + (1-di) * dH1703 bed[i]=bed_ptr[i]-rho_ice/rho_water*(values[i]-thickness_ptr[i]); //bed = oldbed + di * dH1696 newsurface[i]=oldsurface[i]+(1.0-rho_ice/rho_water)*(newthickness[i]-oldthickness[i]); //surface = oldsurface + (1-di) * dH 1697 newbed[i]=oldbed[i]-rho_ice/rho_water*(newthickness[i]-oldthickness[i]); //bed = oldbed + di * dH 1704 1698 } 1705 1699 else _error_("Hydrostatic adjustment %i (%s) not supported yet",hydroadjustment,EnumToStringx(hydroadjustment)); … … 1708 1702 1709 1703 /*Add input to the element: */ 1710 this->inputs->AddInput(new TriaVertexInput(ThicknessEnum, values));1711 this->inputs->AddInput(new TriaVertexInput(SurfaceEnum, surface));1712 this->inputs->AddInput(new TriaVertexInput(BedEnum, bed));1704 this->inputs->AddInput(new TriaVertexInput(ThicknessEnum,newthickness)); 1705 this->inputs->AddInput(new TriaVertexInput(SurfaceEnum,newsurface)); 1706 this->inputs->AddInput(new TriaVertexInput(BedEnum,newbed)); 1713 1707 1714 1708 /*Free ressources:*/ … … 1983 1977 void Tria::MigrateGroundingLine(void){ 1984 1978 1985 1986 1979 double *values = NULL; 1987 1980 double h[3],s[3],b[3],ba[3]; … … 1992 1985 bool elementonshelf = false; 1993 1986 1994 1995 1987 /*Recover info at the vertices: */ 1996 Input* surface_input =inputs->GetInput(SurfaceEnum); _assert_(surface_input);1997 Input* bed_input =inputs->GetInput(BedEnum); _assert_(bed_input);1998 if((surface_input->ObjectEnum()!=TriaVertexInputEnum) | (bed_input->ObjectEnum()!=TriaVertexInputEnum))_error_(" not supported yet for bed and surface interpolations not P1!");1999 2000 1988 GetInputListOnVertices(&h[0],ThicknessEnum); 2001 1989 GetInputListOnVertices(&s[0],SurfaceEnum); … … 2020 2008 b[i]=ba[i]; 2021 2009 s[i]=b[i]+h[i]; 2022 if((nodes[i]->Sid()+1)==36)printf("MigrateGroundingLine: El %i Node %i grounding %g %g %g\n",this->Id(),nodes[i]->Sid()+1,b[i],ba[i],s[i]);2023 2010 } 2024 2011 else{ 2025 2012 /*do nothing, we are still floating.*/ 2026 if((nodes[i]->Sid()+1)==36)printf("MigrateGroundingLine: El %i Node %i still floating %g %g %g\n",this->Id(),nodes[i]->Sid()+1,b[i],ba[i],s[i]);2027 2013 } 2028 2014 } … … 2035 2021 s[i]=(1-density)*h[i]; 2036 2022 b[i]=-density*h[i]; 2037 printf("%i\n",nodes[i]->Sid()+1);2038 if((nodes[i]->Sid()+1)==36)printf("MigrateGroundingLine: El %i Node %i floating %g %g %g\n",this->Id(),nodes[i]->Sid()+1,b[i],ba[i],s[i]);2039 2023 } 2040 2024 else{ 2041 2025 /*do nothing, we are still grounded.*/ 2042 if((nodes[i]->Sid()+1)==36)printf("MigrateGroundingLine: El %i Node %i still grounded %g %g %g\n",this->Id(),nodes[i]->Sid()+1,b[i],ba[i],s[i]);2043 2026 } 2044 2027 } … … 2046 2029 2047 2030 /*Surface and bed are updated. Update inputs:*/ 2048 surface_input->GetValuesPtr(&values,NULL); for(i=0;i<3;i++)values[i]=s[i];2049 bed_input->GetValuesPtr(&values,NULL); for(i=0;i<3;i++)values[i]=b[i];2031 this->inputs->AddInput(new TriaVertexInput(SurfaceEnum,&s[0])); 2032 this->inputs->AddInput(new TriaVertexInput(BedEnum,&b[0])); 2050 2033 2051 for(i=0;i<3;i++){ 2052 isonshelf[i]=nodes[i]->IsOnShelf(); 2053 if((nodes[i]->Sid()+1)==36)printf("MigrateGroundingLine: El %i Node %i second shelf status %i\n",this->Id(),nodes[i]->Sid()+1,isonshelf[i]); 2054 } 2034 for(i=0;i<3;i++) isonshelf[i]=nodes[i]->IsOnShelf(); 2055 2035 } 2056 2036 /*}}}*/ … … 2207 2187 void Tria::ShelfSync(void){ 2208 2188 2189 double melting[NUMVERTICES]; 2190 double h[NUMVERTICES],s[NUMVERTICES],b[NUMVERTICES],ba[NUMVERTICES]; 2191 double bed_hydro; 2192 double rho_water,rho_ice,density; 2193 int i; 2194 bool elementonshelf = false; 2195 2196 /*melting rate at the grounding line: */ 2197 double yts; 2198 int swap; 2199 double gl_melting_rate; 2200 2201 /*recover parameters: */ 2202 parameters->FindParam(&yts,ConstantsYtsEnum); 2203 parameters->FindParam(&gl_melting_rate,GroundinglineMeltingRateEnum); 2204 2205 /*Recover info at the vertices: */ 2206 GetInputListOnVertices(&h[0],ThicknessEnum); 2207 GetInputListOnVertices(&s[0],SurfaceEnum); 2208 GetInputListOnVertices(&b[0],BedEnum); 2209 GetInputListOnVertices(&ba[0],BathymetryEnum); 2210 2211 /*material parameters: */ 2212 rho_water=matpar->GetRhoWater(); 2213 rho_ice=matpar->GetRhoIce(); 2214 density=rho_ice/rho_water; 2215 2216 /*go through vertices, and update inputs, considering them to be TriaVertex type: */ 2217 for(i=0;i<NUMVERTICES;i++){ 2218 if(b[i]==ba[i]){ 2219 nodes[i]->inputs->AddInput(new BoolInput(MaskVertexonfloatingiceEnum,false)); 2220 nodes[i]->inputs->AddInput(new BoolInput(MaskVertexongroundediceEnum,true)); 2221 } 2222 else{ 2223 nodes[i]->inputs->AddInput(new BoolInput(MaskVertexonfloatingiceEnum,true)); 2224 nodes[i]->inputs->AddInput(new BoolInput(MaskVertexongroundediceEnum,false)); 2225 } 2226 } 2227 2228 /*Now, update shelf status of element. An element can only be on shelf if all its nodes are on shelf: */ 2229 swap=0; 2230 elementonshelf=false; 2231 for(i=0;i<NUMVERTICES;i++){ 2232 if(nodes[i]->IsOnShelf()){ 2233 elementonshelf=true; 2234 break; 2235 } 2236 } 2237 if(!this->IsOnShelf() && elementonshelf==true)swap=1; 2238 this->inputs->AddInput(new BoolInput(MaskElementonfloatingiceEnum,elementonshelf)); 2239 2240 /*If this element just became ungrounded, set its basal melting rate at 50 m/yr:*/ 2241 if(swap){ 2242 for(i=0;i<NUMVERTICES;i++)melting[i]=gl_melting_rate/yts; 2243 this->inputs->AddInput(new TriaVertexInput(BasalforcingsMeltingRateEnum,&melting[0])); 2244 } 2245 } 2246 /*}}}*/ 2247 /*FUNCTION Tria::SoftMigration{{{1*/ 2248 void Tria::SoftMigration(double* sheet_ungrounding){ 2209 2249 2210 2250 double *values = NULL; … … 2215 2255 bool elementonshelf = false; 2216 2256 2217 /*melting rate at the grounding line: */2218 double yts;2219 int swap;2220 double gl_melting_rate;2221 2222 /*recover parameters: */2223 parameters->FindParam(&yts,ConstantsYtsEnum);2224 parameters->FindParam(&gl_melting_rate,GroundinglineMeltingRateEnum);2225 2226 2257 /*Recover info at the vertices: */ 2227 Input* surface_input =inputs->GetInput(SurfaceEnum); _assert_(surface_input);2228 Input* bed_input =inputs->GetInput(BedEnum); _assert_(bed_input);2229 if((surface_input->ObjectEnum()!=TriaVertexInputEnum) | (bed_input->ObjectEnum()!=TriaVertexInputEnum))_error_(" not supported yet for bed and surface interpolations not P1!");2230 2231 GetInputListOnVertices(&h[0],ThicknessEnum);2232 GetInputListOnVertices(&s[0],SurfaceEnum);2233 GetInputListOnVertices(&b[0],BedEnum);2234 GetInputListOnVertices(&ba[0],BathymetryEnum);2235 2236 /*material parameters: */2237 rho_water=matpar->GetRhoWater();2238 rho_ice=matpar->GetRhoIce();2239 density=rho_ice/rho_water;2240 2241 /*go through vertices, and update inputs, considering them to be TriaVertex type: */2242 for(i=0;i<3;i++){2243 if(b[i]==ba[i]){2244 2245 nodes[i]->inputs->AddInput(new BoolInput(MaskVertexonfloatingiceEnum,false));2246 nodes[i]->inputs->AddInput(new BoolInput(MaskVertexongroundediceEnum,true));2247 }2248 else{2249 nodes[i]->inputs->AddInput(new BoolInput(MaskVertexonfloatingiceEnum,true));2250 nodes[i]->inputs->AddInput(new BoolInput(MaskVertexongroundediceEnum,false));2251 2252 }2253 }2254 2255 /*Now, update shelf status of element. An element can only be on shelf if all its nodes are on shelf: */2256 swap=0;2257 elementonshelf=false;2258 for(i=0;i<3;i++){2259 if(nodes[i]->IsOnShelf()){2260 elementonshelf=true;2261 break;2262 }2263 }2264 if(!this->IsOnShelf() && elementonshelf==true)swap=1;2265 this->inputs->AddInput(new BoolInput(MaskElementonfloatingiceEnum,elementonshelf));2266 2267 /*If this element just became ungrounded, set its basal melting rate at 50 m/yr:*/2268 if(swap){2269 Input* basal_melting_rate_input =inputs->GetInput(BasalforcingsMeltingRateEnum); _assert_(basal_melting_rate_input);2270 basal_melting_rate_input->GetValuesPtr(&values,NULL); for(i=0;i<3;i++)values[i]=gl_melting_rate/yts;2271 }2272 2273 2274 }2275 /*}}}*/2276 /*FUNCTION Tria::SoftMigration{{{1*/2277 void Tria::SoftMigration(double* sheet_ungrounding){2278 2279 2280 double *values = NULL;2281 double h[3],s[3],b[3],ba[3];2282 double bed_hydro;2283 double rho_water,rho_ice,density;2284 int i;2285 bool elementonshelf = false;2286 2287 /*Recover info at the vertices: */2288 Input* surface_input =inputs->GetInput(SurfaceEnum); _assert_(surface_input);2289 Input* bed_input =inputs->GetInput(BedEnum); _assert_(bed_input);2290 if((surface_input->ObjectEnum()!=TriaVertexInputEnum) | (bed_input->ObjectEnum()!=TriaVertexInputEnum))_error_(" not supported yet for bed and surface interpolations not P1!");2291 2292 2258 GetInputListOnVertices(&h[0],ThicknessEnum); 2293 2259 GetInputListOnVertices(&s[0],SurfaceEnum); … … 2333 2299 2334 2300 /*Surface and bed are updated. Update inputs:*/ 2335 surface_input->GetValuesPtr(&values,NULL); for(i=0;i<3;i++)values[i]=s[i]; 2336 bed_input->GetValuesPtr(&values,NULL); for(i=0;i<3;i++)values[i]=b[i]; 2337 2338 } 2301 this->inputs->AddInput(new TriaVertexInput(SurfaceEnum,&s[0])); 2302 this->inputs->AddInput(new TriaVertexInput(BedEnum,&b[0])); 2303 } 2339 2304 /*}}}*/ 2340 2305 /*FUNCTION Tria::SurfaceArea {{{1*/ … … 3244 3209 const int numdof=NDOF2*NUMVERTICES; 3245 3210 3246 int i,dummy;3247 int* doflist=NULL;3248 double vx,vy;3249 double values[numdof];3250 GaussTria * gauss=NULL;3211 int i; 3212 double vx,vy; 3213 double values[numdof]; 3214 int *doflist = NULL; 3215 GaussTria *gauss = NULL; 3251 3216 3252 3217 /*Get dof list: */ … … 3284 3249 3285 3250 int i; 3286 int dummy;3287 3251 int* doflist=NULL; 3288 3252 double rho_ice,g; … … 3345 3309 3346 3310 int i; 3347 int dummy;3348 3311 int* doflist=NULL; 3349 3312 double rho_ice,g; … … 3355 3318 double pressure[NUMVERTICES]; 3356 3319 double thickness[NUMVERTICES]; 3357 double* vz_ptr=NULL;3358 Input* vz_input=NULL;3359 3320 3360 3321 /*Get dof list: */ … … 3374 3335 } 3375 3336 3376 /*Get Vz*/3377 vz_input=inputs->GetInput(VzEnum);3378 if (vz_input){3379 if (vz_input->ObjectEnum()!=TriaVertexInputEnum){3380 _error_("Cannot compute Vel as Vz is of type %s",EnumToStringx(vz_input->ObjectEnum()));3381 }3382 vz_input->GetValuesPtr(&vz_ptr,&dummy);3383 for(i=0;i<NUMVERTICES;i++) vz[i]=vz_ptr[i];3384 }3385 else{3386 for(i=0;i<NUMVERTICES;i++) vz[i]=0.0;3387 }3388 3389 3337 /*Now Compute vel*/ 3338 GetInputListOnVertices(&vz[0],VzEnum,0.0); //default is 0 3390 3339 for(i=0;i<NUMVERTICES;i++) vel[i]=pow( pow(vx[i],2.0) + pow(vy[i],2.0) + pow(vz[i],2.0) , 0.5); 3391 3340 … … 3413 3362 } 3414 3363 /*}}}*/ 3415 3416 3364 #endif 3417 3365 … … 5103 5051 const int numdof=NDOF1*NUMVERTICES; 5104 5052 5105 int i ,dummy;5053 int i; 5106 5054 int* doflist=NULL; 5107 5055 double watercolumn; … … 5564 5512 /*}}}*/ 5565 5513 #endif 5566
Note:
See TracChangeset
for help on using the changeset viewer.