Changeset 15870
- Timestamp:
- 08/22/13 08:20:35 (12 years ago)
- Location:
- issm/trunk-jpl/src/c/classes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/Elements/Penta.cpp
r15869 r15870 5058 5058 /*FUNCTION Penta::ComputeBasalMeltrate{{{*/ 5059 5059 void Penta::ComputeBasalMeltrate(void){ 5060 /*Calculate the basal melt rates of the enthalpy model after Aschwanden 2012*/ 5061 5062 /*Parameters*/ 5063 int dim; 5064 parameters->FindParam(&dim, MeshDimensionEnum); 5065 5066 /* Intermediaries */ 5067 bool isenthalpy; 5068 int i, analysis_type; 5069 IssmDouble xyz_list[NUMVERTICES][3]; 5070 IssmDouble heatflux, geothermalflux_value; 5071 IssmDouble vec_heatflux[dim]; 5072 IssmDouble normal_base[dim], d1enthalpy[dim]; 5073 IssmDouble kappa; 5074 IssmDouble enthalpy, enthalpyup; 5075 IssmDouble pressure, pressureup; 5076 IssmDouble meltrate, watercolumn; 5077 IssmDouble temperature, waterfraction; 5078 IssmDouble latentheat; 5079 IssmDouble basalfriction, alpha2; 5080 IssmDouble vx,vy,vz; 5081 IssmDouble dt; 5082 Friction* friction=NULL; 5083 GaussPenta* gauss=NULL; 5084 GaussPenta* gaussup=NULL; 5085 5086 /*check that dimension is 3*/ 5087 if(dim!=3) return; 5088 /* Only compute melt rates at the base of grounded ice*/ 5089 if(!IsOnBed() || IsFloating()) return; 5090 /*Check wether enthalpy is activated*/ 5091 parameters->FindParam(&isenthalpy,ThermalIsenthalpyEnum); 5092 if(!isenthalpy) return; 5093 5094 /*Fetch parameters: */ 5095 latentheat=matpar->GetLatentHeat(); 5096 5097 Input* watercolumn_input=inputs->GetInput(WatercolumnEnum); _assert_(watercolumn_input); 5098 Input* enthalpy_input=inputs->GetInput(EnthalpyEnum); _assert_(enthalpy_input); 5099 Input* pressure_input=inputs->GetInput(PressureEnum); _assert_(pressure_input); 5100 Input* vx_input=inputs->GetInput(VxEnum); _assert_(vx_input); 5101 Input* vy_input=inputs->GetInput(VyEnum); _assert_(vy_input); 5102 Input* vz_input=inputs->GetInput(VzEnum); _assert_(vz_input); 5103 Input* geothermalflux_input=inputs->GetInput(BasalforcingsGeothermalfluxEnum); _assert_(geothermalflux_input); 5104 5105 /*Build friction element, needed later: */ 5106 parameters->FindParam(&analysis_type,AnalysisTypeEnum); 5107 friction=new Friction("3d",inputs,matpar,analysis_type); 5108 5109 /* Start looping on the number of gaussian points: */ 5110 gauss=new GaussPenta(0,1,2,2); 5111 gaussup=new GaussPenta(3,4,5,2); 5112 for(int ig=gauss->begin();ig<gauss->end();ig++){ 5113 gauss->GaussPoint(ig); 5114 gaussup->GaussPoint(ig); 5115 5116 watercolumn_input->GetInputValue(&watercolumn, gauss); 5117 enthalpy_input->GetInputValue(&enthalpy, gauss); 5118 pressure_input->GetInputValue(&pressure, gauss); 5119 5120 /*Calculate basal meltrate*/ 5121 if((watercolumn>0) && (enthalpy<matpar->PureIceEnthalpy(pressure))) 5122 enthalpy=matpar->PureIceEnthalpy(pressure); 5123 else if(enthalpy<matpar->PureIceEnthalpy(pressure)){ 5124 meltrate=0.; //TODO: set zero meltrate and watercolumn in model 5125 watercolumn=0.; 5126 return; 5127 } 5128 5129 /*ok, from here on all basal ice is temperate. Check for positive thickness of layer of temperate ice) */ 5130 enthalpy_input->GetInputValue(&enthalpyup, gaussup); 5131 pressure_input->GetInputValue(&pressureup, gaussup); 5132 if(enthalpyup>=matpar->PureIceEnthalpy(pressureup)) 5133 for(i=0;i<dim;i++) 5134 vec_heatflux[i]=0.; 5135 else{ 5136 enthalpy_input->GetInputDerivativeValue(&d1enthalpy[0],&xyz_list[0][0],gauss); 5137 kappa=matpar->GetEnthalpyDiffusionParameter(enthalpy,pressure); 5138 for(i=0;i<dim;i++) 5139 vec_heatflux[i]=-1.*kappa*d1enthalpy[i]; 5140 } 5141 /*Get normal at base*/ 5142 normal_base[0]=0.; normal_base[1]=0.; normal_base[2]=1.; // TODO: get normal from model geometry 5143 5144 heatflux=0.; 5145 for(i=0;i<dim;i++) 5146 heatflux+=(vec_heatflux[i])*normal_base[i]; 5147 geothermalflux_input->GetInputValue(&geothermalflux_value,gauss); 5148 5149 matpar->EnthalpyToThermal(&temperature, &waterfraction, enthalpy,pressure); 5150 5151 friction->GetAlpha2(&alpha2,gauss,VxEnum,VyEnum,VzEnum); 5152 vx_input->GetInputValue(&vx,gauss); 5153 vy_input->GetInputValue(&vy,gauss); 5154 vz_input->GetInputValue(&vz,gauss); 5155 basalfriction=alpha2*(pow(vx,2.0)+pow(vy,2.0)+pow(vz,2.0)); 5156 meltrate=(basalfriction-(heatflux-geothermalflux_value))/(1-waterfraction)/latentheat; 5157 5158 /*Update water column*/ 5159 this->parameters->FindParam(&dt,TimesteppingTimeStepEnum); 5160 if(reCast<bool,IssmDouble>(dt)) 5161 watercolumn+=dt*meltrate; 5162 else 5163 watercolumn=meltrate; 5164 // TODO: feed meltrate & watercolumn back to model 5165 } 5060 /*Calculate the basal melt rates of the enthalpy model after Aschwanden 2012*/ 5061 5062 /* Intermediaries */ 5063 bool isenthalpy; 5064 int i,j,analysis_type; 5065 IssmDouble xyz_list[NUMVERTICES][3]; 5066 IssmDouble xyz_list_tria[NUMVERTICES2D][3]; 5067 IssmDouble heatflux, geothermalflux_value; 5068 IssmDouble vec_heatflux[3]; 5069 IssmDouble normal_base[3], d1enthalpy[3]; 5070 IssmDouble kappa; 5071 IssmDouble enthalpy, enthalpyup; 5072 IssmDouble pressure, pressureup; 5073 IssmDouble meltrate, watercolumn; 5074 IssmDouble temperature, waterfraction; 5075 IssmDouble latentheat; 5076 IssmDouble basalfriction, alpha2; 5077 IssmDouble vx,vy,vz; 5078 IssmDouble dt; 5079 Friction *friction = NULL; 5080 GaussPenta *gauss = NULL; 5081 GaussPenta *gaussup = NULL; 5082 5083 /* Only compute melt rates at the base of grounded ice*/ 5084 if(!IsOnBed() || IsFloating()) return; 5085 5086 /*Check wether enthalpy is activated*/ 5087 parameters->FindParam(&isenthalpy,ThermalIsenthalpyEnum); 5088 if(!isenthalpy) return; 5089 5090 /*Fetch parameters and inputs */ 5091 latentheat=matpar->GetLatentHeat(); 5092 Input* watercolumn_input=inputs->GetInput(WatercolumnEnum); _assert_(watercolumn_input); 5093 Input* enthalpy_input=inputs->GetInput(EnthalpyEnum); _assert_(enthalpy_input); 5094 Input* pressure_input=inputs->GetInput(PressureEnum); _assert_(pressure_input); 5095 Input* vx_input=inputs->GetInput(VxEnum); _assert_(vx_input); 5096 Input* vy_input=inputs->GetInput(VyEnum); _assert_(vy_input); 5097 Input* vz_input=inputs->GetInput(VzEnum); _assert_(vz_input); 5098 Input* geothermalflux_input=inputs->GetInput(BasalforcingsGeothermalfluxEnum); _assert_(geothermalflux_input); 5099 5100 for(i=0;i<NUMVERTICES2D;i++) for(j=0;j<3;j++) xyz_list_tria[i][j]=xyz_list[i][j]; 5101 5102 /*Build friction element, needed later: */ 5103 parameters->FindParam(&analysis_type,AnalysisTypeEnum); 5104 friction=new Friction("3d",inputs,matpar,analysis_type); 5105 5106 /* Start looping on the number of gaussian points: */ 5107 gauss=new GaussPenta(0,1,2,2); 5108 gaussup=new GaussPenta(3,4,5,2); 5109 for(int ig=gauss->begin();ig<gauss->end();ig++){ 5110 gauss->GaussPoint(ig); 5111 gaussup->GaussPoint(ig); 5112 5113 watercolumn_input->GetInputValue(&watercolumn, gauss); 5114 enthalpy_input->GetInputValue(&enthalpy, gauss); 5115 pressure_input->GetInputValue(&pressure, gauss); 5116 5117 /*Calculate basal meltrate*/ 5118 if((watercolumn>0.) && (enthalpy<matpar->PureIceEnthalpy(pressure))){ 5119 enthalpy=matpar->PureIceEnthalpy(pressure); 5120 } 5121 else if(enthalpy<matpar->PureIceEnthalpy(pressure)){ 5122 meltrate=0.; //TODO: set zero meltrate and watercolumn in model 5123 watercolumn=0.; 5124 return; 5125 } 5126 5127 /*ok, from here on all basal ice is temperate. Check for positive thickness of layer of temperate ice) */ 5128 enthalpy_input->GetInputValue(&enthalpyup, gaussup); 5129 pressure_input->GetInputValue(&pressureup, gaussup); 5130 if(enthalpyup>=matpar->PureIceEnthalpy(pressureup)){ 5131 for(i=0;i<3;i++) vec_heatflux[i]=0.; 5132 } 5133 else{ 5134 enthalpy_input->GetInputDerivativeValue(&d1enthalpy[0],&xyz_list[0][0],gauss); 5135 kappa=matpar->GetEnthalpyDiffusionParameter(enthalpy,pressure); 5136 for(i=0;i<3;i++) vec_heatflux[i]=-kappa*d1enthalpy[i]; 5137 } 5138 5139 /*Get normal vector to the bed */ 5140 BedNormal(&normal_base[0],xyz_list_tria); 5141 5142 heatflux=0.; 5143 for(i=0;i<3;i++) heatflux+=(vec_heatflux[i])*normal_base[i]; 5144 geothermalflux_input->GetInputValue(&geothermalflux_value,gauss); 5145 5146 matpar->EnthalpyToThermal(&temperature, &waterfraction, enthalpy,pressure); 5147 5148 friction->GetAlpha2(&alpha2,gauss,VxEnum,VyEnum,VzEnum); 5149 vx_input->GetInputValue(&vx,gauss); 5150 vy_input->GetInputValue(&vy,gauss); 5151 vz_input->GetInputValue(&vz,gauss); 5152 basalfriction=alpha2*(pow(vx,2.0)+pow(vy,2.0)+pow(vz,2.0)); 5153 meltrate=(basalfriction-(heatflux-geothermalflux_value))/(1-waterfraction)/latentheat; 5154 5155 /*Update water column*/ 5156 this->parameters->FindParam(&dt,TimesteppingTimeStepEnum); 5157 if(reCast<bool,IssmDouble>(dt)) 5158 watercolumn+=dt*meltrate; 5159 else 5160 watercolumn=meltrate; 5161 // TODO: feed meltrate & watercolumn back to model 5162 } 5166 5163 } 5167 5164 /*}}}*/ -
issm/trunk-jpl/src/c/classes/Materials/Matpar.cpp
r15863 r15870 398 398 IssmDouble Matpar::GetEnthalpyDiffusionParameter(IssmDouble enthalpy,IssmDouble pressure){ 399 399 if(enthalpy<PureIceEnthalpy(pressure)){ 400 400 return thermalconductivity/(rho_ice*heatcapacity); 401 401 } 402 402 else{ 403 return 1.045*pow(10,-4.)/rho_ice; // K0=1.045*1e-4 from Aschwanden 2012. TODO: fetch K0 from model403 return 1.045*1.e-4/rho_ice; // K0=1.045*1e-4 from Aschwanden 2012. TODO: fetch K0 from model 404 404 } 405 405 }
Note:
See TracChangeset
for help on using the changeset viewer.