[16534] | 1 | #include "./EnthalpyAnalysis.h"
|
---|
| 2 | #include "../toolkits/toolkits.h"
|
---|
| 3 | #include "../classes/classes.h"
|
---|
| 4 | #include "../shared/shared.h"
|
---|
| 5 | #include "../modules/modules.h"
|
---|
[18591] | 6 | #include "../solutionsequences/solutionsequences.h"
|
---|
[21721] | 7 | #include "../cores/cores.h"
|
---|
[16534] | 8 |
|
---|
| 9 | /*Model processing*/
|
---|
[18930] | 10 | void EnthalpyAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/
|
---|
[16604] | 11 |
|
---|
[18930] | 12 | /*Intermediary*/
|
---|
| 13 | int count;
|
---|
| 14 | int M,N;
|
---|
| 15 | bool spcpresent = false;
|
---|
[21546] | 16 | int finiteelement;
|
---|
[18930] | 17 | IssmDouble heatcapacity;
|
---|
| 18 | IssmDouble referencetemperature;
|
---|
[16604] | 19 |
|
---|
[18930] | 20 | /*Output*/
|
---|
| 21 | IssmDouble *spcvector = NULL;
|
---|
| 22 | IssmDouble* times=NULL;
|
---|
| 23 | IssmDouble* values=NULL;
|
---|
[16604] | 24 |
|
---|
[18930] | 25 | /*Fetch parameters: */
|
---|
[20690] | 26 | iomodel->FindConstant(&heatcapacity,"md.materials.heatcapacity");
|
---|
| 27 | iomodel->FindConstant(&referencetemperature,"md.constants.referencetemperature");
|
---|
[21546] | 28 | iomodel->FindConstant(&finiteelement,"md.thermal.fe");
|
---|
[18732] | 29 |
|
---|
[18930] | 30 | /*return if 2d mesh*/
|
---|
| 31 | if(iomodel->domaintype==Domain2DhorizontalEnum) return;
|
---|
| 32 |
|
---|
| 33 | /*Fetch data: */
|
---|
[20690] | 34 | iomodel->FetchData(&spcvector,&M,&N,"md.thermal.spctemperature");
|
---|
[18930] | 35 |
|
---|
[21546] | 36 | /*Convert spcs from temperatures to enthalpy*/
|
---|
| 37 | _assert_(N>0); _assert_(M>=iomodel->numberofvertices);
|
---|
| 38 | for(int i=0;i<iomodel->numberofvertices;i++){
|
---|
[21549] | 39 | for(int j=0;j<N;j++){
|
---|
| 40 | spcvector[i*N+j] = heatcapacity*(spcvector[i*N+j]-referencetemperature);
|
---|
[18930] | 41 | }
|
---|
| 42 | }
|
---|
| 43 |
|
---|
[21548] | 44 | /*Specific case for PDD, we want the constaints to be updated by the PDD scheme itself*/
|
---|
| 45 | bool isdynamic = false;
|
---|
| 46 | if (iomodel->solution_enum==TransientSolutionEnum){
|
---|
| 47 | int smb_model;
|
---|
| 48 | iomodel->FindConstant(&smb_model,"md.smb.model");
|
---|
| 49 | if(smb_model==SMBpddEnum) isdynamic=true;
|
---|
| 50 | if(smb_model==SMBd18opddEnum) isdynamic=true;
|
---|
| 51 | }
|
---|
| 52 |
|
---|
| 53 | if(isdynamic){
|
---|
[21560] | 54 | IoModelToDynamicConstraintsx(constraints,iomodel,spcvector,M,N,EnthalpyAnalysisEnum,finiteelement);
|
---|
[21548] | 55 | }
|
---|
| 56 | else{
|
---|
| 57 | IoModelToConstraintsx(constraints,iomodel,spcvector,M,N,EnthalpyAnalysisEnum,finiteelement);
|
---|
| 58 | }
|
---|
| 59 |
|
---|
[18930] | 60 | /*Free ressources:*/
|
---|
[20690] | 61 | iomodel->DeleteData(spcvector,"md.thermal.spctemperature");
|
---|
[18930] | 62 | xDelete<IssmDouble>(times);
|
---|
| 63 | xDelete<IssmDouble>(values);
|
---|
[16539] | 64 | }/*}}}*/
|
---|
[18930] | 65 | void EnthalpyAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/
|
---|
| 66 |
|
---|
| 67 | /*No loads */
|
---|
| 68 | }/*}}}*/
|
---|
| 69 | void EnthalpyAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/
|
---|
| 70 |
|
---|
[21542] | 71 | int finiteelement;
|
---|
| 72 | iomodel->FindConstant(&finiteelement,"md.thermal.fe");
|
---|
| 73 |
|
---|
[20690] | 74 | if(iomodel->domaintype==Domain3DEnum) iomodel->FetchData(2,"md.mesh.vertexonbase","md.mesh.vertexonsurface");
|
---|
[21542] | 75 | ::CreateNodes(nodes,iomodel,EnthalpyAnalysisEnum,finiteelement);
|
---|
[20690] | 76 | iomodel->DeleteData(2,"md.mesh.vertexonbase","md.mesh.vertexonsurface");
|
---|
[18930] | 77 | }/*}}}*/
|
---|
| 78 | int EnthalpyAnalysis::DofsPerNode(int** doflist,int domaintype,int approximation){/*{{{*/
|
---|
| 79 | return 1;
|
---|
| 80 | }/*}}}*/
|
---|
[16539] | 81 | void EnthalpyAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/
|
---|
| 82 |
|
---|
[20459] | 83 | bool dakota_analysis,ismovingfront,isenthalpy;
|
---|
[21382] | 84 | int frictionlaw,basalforcing_model,materialstype;
|
---|
[19161] | 85 | int FrictionCoupling;
|
---|
| 86 |
|
---|
[16539] | 87 | /*Now, is the model 3d? otherwise, do nothing: */
|
---|
[17700] | 88 | if(iomodel->domaintype==Domain2DhorizontalEnum)return;
|
---|
[16539] | 89 |
|
---|
| 90 | /*Is enthalpy requested?*/
|
---|
[20690] | 91 | iomodel->FindConstant(&isenthalpy,"md.thermal.isenthalpy");
|
---|
[16539] | 92 | if(!isenthalpy) return;
|
---|
| 93 |
|
---|
| 94 | /*Fetch data needed: */
|
---|
[20690] | 95 | iomodel->FetchData(3,"md.initialization.temperature","md.initialization.waterfraction","md.initialization.pressure");
|
---|
[16539] | 96 |
|
---|
[21542] | 97 | /*Finite element type*/
|
---|
| 98 | int finiteelement;
|
---|
| 99 | iomodel->FindConstant(&finiteelement,"md.thermal.fe");
|
---|
| 100 |
|
---|
[16539] | 101 | /*Update elements: */
|
---|
| 102 | int counter=0;
|
---|
| 103 | for(int i=0;i<iomodel->numberofelements;i++){
|
---|
| 104 | if(iomodel->my_elements[i]){
|
---|
| 105 | Element* element=(Element*)elements->GetObjectByOffset(counter);
|
---|
[21542] | 106 | element->Update(i,iomodel,analysis_counter,analysis_type,finiteelement);
|
---|
[16539] | 107 | counter++;
|
---|
| 108 | }
|
---|
| 109 | }
|
---|
| 110 |
|
---|
[20690] | 111 | iomodel->FindConstant(&dakota_analysis,"md.qmu.isdakota");
|
---|
| 112 | iomodel->FindConstant(&ismovingfront,"md.transient.ismovingfront");
|
---|
| 113 | iomodel->FindConstant(&frictionlaw,"md.friction.law");
|
---|
[21382] | 114 | iomodel->FindConstant(&materialstype,"md.materials.type");
|
---|
[16539] | 115 |
|
---|
[20690] | 116 | iomodel->FetchDataToInput(elements,"md.geometry.thickness",ThicknessEnum);
|
---|
| 117 | iomodel->FetchDataToInput(elements,"md.geometry.surface",SurfaceEnum);
|
---|
| 118 | iomodel->FetchDataToInput(elements,"md.slr.sealevel",SealevelEnum,0);
|
---|
| 119 | iomodel->FetchDataToInput(elements,"md.geometry.base",BaseEnum);
|
---|
| 120 | iomodel->FetchDataToInput(elements,"md.mask.ice_levelset",MaskIceLevelsetEnum);
|
---|
| 121 | iomodel->FetchDataToInput(elements,"md.mask.groundedice_levelset",MaskGroundediceLevelsetEnum);
|
---|
[17886] | 122 | if(iomodel->domaintype!=Domain2DhorizontalEnum){
|
---|
[20690] | 123 | iomodel->FetchDataToInput(elements,"md.mesh.vertexonbase",MeshVertexonbaseEnum);
|
---|
| 124 | iomodel->FetchDataToInput(elements,"md.mesh.vertexonsurface",MeshVertexonsurfaceEnum);
|
---|
[17886] | 125 | }
|
---|
[20690] | 126 | iomodel->FetchDataToInput(elements,"md.initialization.pressure",PressureEnum);
|
---|
| 127 | iomodel->FetchDataToInput(elements,"md.initialization.temperature",TemperatureEnum);
|
---|
| 128 | iomodel->FetchDataToInput(elements,"md.initialization.waterfraction",WaterfractionEnum);
|
---|
| 129 | iomodel->FetchDataToInput(elements,"md.initialization.enthalpy",EnthalpyEnum);
|
---|
| 130 | iomodel->FetchDataToInput(elements,"md.initialization.watercolumn",WatercolumnEnum);
|
---|
| 131 | iomodel->FetchDataToInput(elements,"md.basalforcings.groundedice_melting_rate",BasalforcingsGroundediceMeltingRateEnum);
|
---|
| 132 | iomodel->FetchDataToInput(elements,"md.initialization.vx",VxEnum);
|
---|
| 133 | iomodel->FetchDataToInput(elements,"md.initialization.vy",VyEnum);
|
---|
| 134 | iomodel->FetchDataToInput(elements,"md.initialization.vz",VzEnum);
|
---|
[16539] | 135 | InputUpdateFromConstantx(elements,0.,VxMeshEnum);
|
---|
| 136 | InputUpdateFromConstantx(elements,0.,VyMeshEnum);
|
---|
| 137 | InputUpdateFromConstantx(elements,0.,VzMeshEnum);
|
---|
[20459] | 138 | if(ismovingfront){
|
---|
[20690] | 139 | iomodel->FetchDataToInput(elements,"md.mesh.vertexonbase",MeshVertexonbaseEnum); // required for updating active nodes
|
---|
[17434] | 140 | }
|
---|
[20020] | 141 |
|
---|
| 142 | /*Basal forcings variables*/
|
---|
[20690] | 143 | iomodel->FindConstant(&basalforcing_model,"md.basalforcings.model");
|
---|
[20020] | 144 | switch(basalforcing_model){
|
---|
| 145 | case MantlePlumeGeothermalFluxEnum:
|
---|
| 146 | break;
|
---|
| 147 | default:
|
---|
[20690] | 148 | iomodel->FetchDataToInput(elements,"md.basalforcings.geothermalflux",BasalforcingsGeothermalfluxEnum);
|
---|
[20020] | 149 | break;
|
---|
| 150 | }
|
---|
[21382] | 151 |
|
---|
| 152 | /*Rheology type*/
|
---|
| 153 | iomodel->FetchDataToInput(elements,"md.materials.rheology_B",MaterialsRheologyBEnum);
|
---|
| 154 | switch(materialstype){
|
---|
[21389] | 155 | case MatenhancediceEnum:
|
---|
| 156 | iomodel->FetchDataToInput(elements,"md.materials.rheology_n",MaterialsRheologyNEnum);
|
---|
| 157 | iomodel->FetchDataToInput(elements,"md.materials.rheology_E",MaterialsRheologyEEnum);
|
---|
| 158 | break;
|
---|
[21382] | 159 | case MatdamageiceEnum:
|
---|
| 160 | iomodel->FetchDataToInput(elements,"md.materials.rheology_n",MaterialsRheologyNEnum);
|
---|
| 161 | break;
|
---|
| 162 | case MatestarEnum:
|
---|
| 163 | iomodel->FetchDataToInput(elements,"md.materials.rheology_Ec",MaterialsRheologyEcEnum);
|
---|
| 164 | iomodel->FetchDataToInput(elements,"md.materials.rheology_Es",MaterialsRheologyEsEnum);
|
---|
| 165 | break;
|
---|
| 166 | case MaticeEnum:
|
---|
| 167 | iomodel->FetchDataToInput(elements,"md.materials.rheology_n",MaterialsRheologyNEnum);
|
---|
| 168 | break;
|
---|
| 169 | default:
|
---|
| 170 | _error_("not supported");
|
---|
| 171 | }
|
---|
[17952] | 172 |
|
---|
| 173 | /*Friction law variables*/
|
---|
| 174 | switch(frictionlaw){
|
---|
| 175 | case 1:
|
---|
[21740] | 176 | iomodel->FindConstant(&FrictionCoupling,"md.friction.coupling");
|
---|
[20690] | 177 | iomodel->FetchDataToInput(elements,"md.friction.coefficient",FrictionCoefficientEnum);
|
---|
| 178 | iomodel->FetchDataToInput(elements,"md.friction.p",FrictionPEnum);
|
---|
| 179 | iomodel->FetchDataToInput(elements,"md.friction.q",FrictionQEnum);
|
---|
[21740] | 180 | if (FrictionCoupling==1){
|
---|
| 181 | iomodel->FetchDataToInput(elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum);
|
---|
| 182 | }
|
---|
[17952] | 183 | break;
|
---|
| 184 | case 2:
|
---|
[20690] | 185 | iomodel->FetchDataToInput(elements,"md.friction.C",FrictionCEnum);
|
---|
| 186 | iomodel->FetchDataToInput(elements,"md.friction.m",FrictionMEnum);
|
---|
[17952] | 187 | break;
|
---|
[18778] | 188 | case 3:
|
---|
[20690] | 189 | iomodel->FindConstant(&FrictionCoupling,"md.friction.coupling");
|
---|
| 190 | iomodel->FetchDataToInput(elements,"md.friction.C",FrictionCEnum);
|
---|
| 191 | iomodel->FetchDataToInput(elements,"md.friction.As",FrictionAsEnum);
|
---|
| 192 | iomodel->FetchDataToInput(elements,"md.friction.q",FrictionQEnum);
|
---|
[21740] | 193 | if (FrictionCoupling==1){
|
---|
[20690] | 194 | iomodel->FetchDataToInput(elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum);
|
---|
[19161] | 195 | }
|
---|
[18778] | 196 | break;
|
---|
[18732] | 197 | case 4:
|
---|
[20690] | 198 | iomodel->FetchDataToInput(elements,"md.friction.coefficient",FrictionCoefficientEnum);
|
---|
| 199 | iomodel->FetchDataToInput(elements,"md.friction.p",FrictionPEnum);
|
---|
| 200 | iomodel->FetchDataToInput(elements,"md.friction.q",FrictionQEnum);
|
---|
| 201 | iomodel->FetchDataToInput(elements,"md.initialization.pressure",PressureEnum);
|
---|
| 202 | iomodel->FetchDataToInput(elements,"md.initialization.temperature",TemperatureEnum);
|
---|
[18732] | 203 | break;
|
---|
[18772] | 204 | case 5:
|
---|
[20690] | 205 | iomodel->FetchDataToInput(elements,"md.friction.coefficient",FrictionCoefficientEnum);
|
---|
| 206 | iomodel->FetchDataToInput(elements,"md.friction.p",FrictionPEnum);
|
---|
| 207 | iomodel->FetchDataToInput(elements,"md.friction.q",FrictionQEnum);
|
---|
| 208 | iomodel->FetchDataToInput(elements,"md.friction.water_layer",FrictionWaterLayerEnum);
|
---|
[18772] | 209 | break;
|
---|
[18804] | 210 | case 6:
|
---|
[20690] | 211 | iomodel->FetchDataToInput(elements,"md.friction.C",FrictionCEnum);
|
---|
| 212 | iomodel->FetchDataToInput(elements,"md.friction.m",FrictionMEnum);
|
---|
| 213 | iomodel->FetchDataToInput(elements,"md.initialization.pressure",PressureEnum);
|
---|
| 214 | iomodel->FetchDataToInput(elements,"md.initialization.temperature",TemperatureEnum);
|
---|
[18804] | 215 | break;
|
---|
[21556] | 216 | case 9:
|
---|
| 217 | iomodel->FetchDataToInput(elements,"md.friction.coefficient",FrictionCoefficientEnum);
|
---|
| 218 | iomodel->FetchDataToInput(elements,"md.friction.pressure_adjusted_temperature",FrictionPressureAdjustedTemperatureEnum);
|
---|
[21565] | 219 | InputUpdateFromConstantx(elements,1.,FrictionPEnum);
|
---|
| 220 | InputUpdateFromConstantx(elements,1.,FrictionQEnum);
|
---|
[21556] | 221 | break;
|
---|
[17952] | 222 | default:
|
---|
| 223 | _error_("not supported");
|
---|
| 224 | }
|
---|
[20690] | 225 |
|
---|
[16539] | 226 | /*Free data: */
|
---|
[20690] | 227 | iomodel->DeleteData(3,"md.initialization.temperature","md.initialization.waterfraction","md.initialization.pressure");
|
---|
| 228 |
|
---|
[16539] | 229 | }/*}}}*/
|
---|
[18930] | 230 | void EnthalpyAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/
|
---|
[16539] | 231 |
|
---|
[18930] | 232 | int numoutputs;
|
---|
| 233 | char** requestedoutputs = NULL;
|
---|
| 234 |
|
---|
[20690] | 235 | parameters->AddObject(iomodel->CopyConstantObject("md.thermal.stabilization",ThermalStabilizationEnum));
|
---|
| 236 | parameters->AddObject(iomodel->CopyConstantObject("md.thermal.maxiter",ThermalMaxiterEnum));
|
---|
| 237 | parameters->AddObject(iomodel->CopyConstantObject("md.thermal.reltol",ThermalReltolEnum));
|
---|
| 238 | parameters->AddObject(iomodel->CopyConstantObject("md.thermal.isenthalpy",ThermalIsenthalpyEnum));
|
---|
| 239 | parameters->AddObject(iomodel->CopyConstantObject("md.thermal.isdynamicbasalspc",ThermalIsdynamicbasalspcEnum));
|
---|
| 240 | parameters->AddObject(iomodel->CopyConstantObject("md.friction.law",FrictionLawEnum));
|
---|
[18930] | 241 |
|
---|
[20690] | 242 | iomodel->FindConstant(&requestedoutputs,&numoutputs,"md.thermal.requested_outputs");
|
---|
[18930] | 243 | parameters->AddObject(new IntParam(ThermalNumRequestedOutputsEnum,numoutputs));
|
---|
| 244 | if(numoutputs)parameters->AddObject(new StringArrayParam(ThermalRequestedOutputsEnum,requestedoutputs,numoutputs));
|
---|
[20690] | 245 | iomodel->DeleteData(&requestedoutputs,numoutputs,"md.thermal.requested_outputs");
|
---|
[18930] | 246 |
|
---|
| 247 | /*Deal with friction parameters*/
|
---|
| 248 | int frictionlaw;
|
---|
[20690] | 249 | iomodel->FindConstant(&frictionlaw,"md.friction.law");
|
---|
[21776] | 250 | if(frictionlaw==4 || frictionlaw==6){
|
---|
| 251 | parameters->AddObject(iomodel->CopyConstantObject("md.friction.gamma",FrictionGammaEnum));
|
---|
| 252 | }
|
---|
| 253 | if(frictionlaw==3 || frictionlaw==1){
|
---|
| 254 | parameters->AddObject(iomodel->CopyConstantObject("md.friction.coupling",FrictionCouplingEnum));
|
---|
| 255 | }
|
---|
| 256 | if(frictionlaw==9){
|
---|
| 257 | parameters->AddObject(iomodel->CopyConstantObject("md.friction.gamma",FrictionGammaEnum));
|
---|
[21778] | 258 | parameters->AddObject(new IntParam(FrictionCouplingEnum,0));
|
---|
[21776] | 259 | }
|
---|
[16539] | 260 | }/*}}}*/
|
---|
| 261 |
|
---|
[18930] | 262 | /*Finite Element Analysis*/
|
---|
| 263 | void EnthalpyAnalysis::ApplyBasalConstraints(IssmDouble* serial_spc,Element* element){/*{{{*/
|
---|
[16539] | 264 |
|
---|
[21481] | 265 | /* Do not check if ice in element, this may lead to inconsistencies between cpu partitions */
|
---|
[20213] | 266 | /* Only update constraints at the base. */
|
---|
| 267 | if(!(element->IsOnBase())) return;
|
---|
[16539] | 268 |
|
---|
[18930] | 269 | /*Intermediary*/
|
---|
| 270 | bool isdynamicbasalspc;
|
---|
| 271 | int numindices;
|
---|
| 272 | int *indices = NULL;
|
---|
| 273 | Node* node = NULL;
|
---|
| 274 | IssmDouble pressure;
|
---|
[16539] | 275 |
|
---|
[18930] | 276 | /*Check wether dynamic basal boundary conditions are activated */
|
---|
| 277 | element->FindParam(&isdynamicbasalspc,ThermalIsdynamicbasalspcEnum);
|
---|
| 278 | if(!isdynamicbasalspc) return;
|
---|
[16539] | 279 |
|
---|
[18930] | 280 | /*Get parameters and inputs: */
|
---|
| 281 | Input* pressure_input = element->GetInput(PressureEnum); _assert_(pressure_input);
|
---|
[16539] | 282 |
|
---|
[18930] | 283 | /*Fetch indices of basal & surface nodes for this finite element*/
|
---|
| 284 | Penta *penta = (Penta *) element; // TODO: add Basal-/SurfaceNodeIndices to element.h, and change this to Element*
|
---|
| 285 | penta->BasalNodeIndices(&numindices,&indices,element->GetElementType());
|
---|
[16539] | 286 |
|
---|
[18930] | 287 | GaussPenta* gauss=new GaussPenta();
|
---|
| 288 | for(int i=0;i<numindices;i++){
|
---|
| 289 | gauss->GaussNode(element->GetElementType(),indices[i]);
|
---|
[16539] | 290 |
|
---|
[18930] | 291 | pressure_input->GetInputValue(&pressure,gauss);
|
---|
[16539] | 292 |
|
---|
[18930] | 293 | /*apply or release spc*/
|
---|
| 294 | node=element->GetNode(indices[i]);
|
---|
[21481] | 295 | if(!node->IsActive()) continue;
|
---|
[18930] | 296 | if(serial_spc[node->Sid()]==1.){
|
---|
| 297 | pressure_input->GetInputValue(&pressure, gauss);
|
---|
| 298 | node->ApplyConstraint(0,PureIceEnthalpy(element,pressure));
|
---|
[16539] | 299 | }
|
---|
[21481] | 300 | else {
|
---|
[18930] | 301 | node->DofInFSet(0);
|
---|
[21481] | 302 | }
|
---|
[16539] | 303 | }
|
---|
| 304 |
|
---|
[18930] | 305 | /*Free ressources:*/
|
---|
| 306 | xDelete<int>(indices);
|
---|
| 307 | delete gauss;
|
---|
| 308 | }/*}}}*/
|
---|
| 309 | void EnthalpyAnalysis::ComputeBasalMeltingrate(FemModel* femmodel){/*{{{*/
|
---|
| 310 | /*Compute basal melting rates: */
|
---|
| 311 | for(int i=0;i<femmodel->elements->Size();i++){
|
---|
| 312 | Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
|
---|
| 313 | ComputeBasalMeltingrate(element);
|
---|
| 314 | }
|
---|
| 315 | }/*}}}*/
|
---|
| 316 | void EnthalpyAnalysis::ComputeBasalMeltingrate(Element* element){/*{{{*/
|
---|
| 317 | /*Calculate the basal melt rates of the enthalpy model after Aschwanden 2012*/
|
---|
| 318 | /* melting rate is positive when melting, negative when refreezing*/
|
---|
[16539] | 319 |
|
---|
[18930] | 320 | /* Check if ice in element */
|
---|
| 321 | if(!element->IsIceInElement()) return;
|
---|
[16539] | 322 |
|
---|
[18930] | 323 | /* Only compute melt rates at the base of grounded ice*/
|
---|
| 324 | if(!element->IsOnBase() || element->IsFloating()) return;
|
---|
[16539] | 325 |
|
---|
[18930] | 326 | /* Intermediaries */
|
---|
| 327 | bool converged;
|
---|
| 328 | const int dim=3;
|
---|
| 329 | int i,is,state;
|
---|
[21718] | 330 | int nodedown,nodeup,numnodes,numsegments;
|
---|
[18930] | 331 | int enthalpy_enum;
|
---|
| 332 | IssmDouble vec_heatflux[dim],normal_base[dim],d1enthalpy[dim],d1pressure[dim];
|
---|
| 333 | IssmDouble basalfriction,alpha2,geothermalflux,heatflux;
|
---|
| 334 | IssmDouble dt,yts;
|
---|
| 335 | IssmDouble melting_overshoot,lambda;
|
---|
| 336 | IssmDouble vx,vy,vz;
|
---|
| 337 | IssmDouble *xyz_list = NULL;
|
---|
| 338 | IssmDouble *xyz_list_base = NULL;
|
---|
| 339 | int *pairindices = NULL;
|
---|
[16539] | 340 |
|
---|
[18930] | 341 | /*Fetch parameters*/
|
---|
| 342 | element->GetVerticesCoordinates(&xyz_list);
|
---|
| 343 | element->GetVerticesCoordinatesBase(&xyz_list_base);
|
---|
| 344 | element->GetInputValue(&converged,ConvergedEnum);
|
---|
| 345 | element->FindParam(&dt,TimesteppingTimeStepEnum);
|
---|
| 346 | element->FindParam(&yts, ConstantsYtsEnum);
|
---|
| 347 |
|
---|
| 348 | if(dt==0. && !converged) enthalpy_enum=EnthalpyPicardEnum;
|
---|
| 349 | else enthalpy_enum=EnthalpyEnum;
|
---|
| 350 |
|
---|
| 351 | IssmDouble latentheat = element->GetMaterialParameter(MaterialsLatentheatEnum);
|
---|
| 352 | IssmDouble rho_ice = element->GetMaterialParameter(MaterialsRhoIceEnum);
|
---|
| 353 | IssmDouble rho_water = element->GetMaterialParameter(MaterialsRhoFreshwaterEnum);
|
---|
| 354 | IssmDouble beta = element->GetMaterialParameter(MaterialsBetaEnum);
|
---|
| 355 | IssmDouble kappa = EnthalpyDiffusionParameterVolume(element,enthalpy_enum); _assert_(kappa>=0.);
|
---|
| 356 | IssmDouble kappa_mix;
|
---|
| 357 |
|
---|
| 358 | /*retrieve inputs*/
|
---|
| 359 | Input* enthalpy_input = element->GetInput(enthalpy_enum); _assert_(enthalpy_input);
|
---|
| 360 | Input* pressure_input = element->GetInput(PressureEnum); _assert_(pressure_input);
|
---|
| 361 | Input* geothermalflux_input = element->GetInput(BasalforcingsGeothermalfluxEnum); _assert_(geothermalflux_input);
|
---|
| 362 | Input* vx_input = element->GetInput(VxEnum); _assert_(vx_input);
|
---|
| 363 | Input* vy_input = element->GetInput(VyEnum); _assert_(vy_input);
|
---|
| 364 | Input* vz_input = element->GetInput(VzEnum); _assert_(vz_input);
|
---|
| 365 |
|
---|
| 366 | /*Build friction element, needed later: */
|
---|
| 367 | Friction* friction=new Friction(element,dim);
|
---|
| 368 |
|
---|
| 369 | /******** MELTING RATES ************************************//*{{{*/
|
---|
| 370 | element->NormalBase(&normal_base[0],xyz_list_base);
|
---|
[21718] | 371 | element->VerticalSegmentIndicesBase(&pairindices,&numsegments);
|
---|
[18930] | 372 | IssmDouble* meltingrate_enthalpy = xNew<IssmDouble>(numsegments);
|
---|
| 373 | IssmDouble* heating = xNew<IssmDouble>(numsegments);
|
---|
| 374 |
|
---|
[21718] | 375 | numnodes=element->GetNumberOfNodes();
|
---|
| 376 | IssmDouble* enthalpies = xNew<IssmDouble>(numnodes);
|
---|
| 377 | IssmDouble* pressures = xNew<IssmDouble>(numnodes);
|
---|
| 378 | IssmDouble* watercolumns = xNew<IssmDouble>(numnodes);
|
---|
| 379 | IssmDouble* basalmeltingrates = xNew<IssmDouble>(numnodes);
|
---|
| 380 | element->GetInputListOnNodes(enthalpies,enthalpy_enum);
|
---|
| 381 | element->GetInputListOnNodes(pressures,PressureEnum);
|
---|
| 382 | element->GetInputListOnNodes(watercolumns,WatercolumnEnum);
|
---|
| 383 | element->GetInputListOnNodes(basalmeltingrates,BasalforcingsGroundediceMeltingRateEnum);
|
---|
[18930] | 384 |
|
---|
| 385 | Gauss* gauss=element->NewGauss();
|
---|
| 386 | for(is=0;is<numsegments;is++){
|
---|
[21718] | 387 | nodedown = pairindices[is*2+0];
|
---|
| 388 | nodeup = pairindices[is*2+1];
|
---|
| 389 | gauss->GaussNode(element->GetElementType(),nodedown);
|
---|
[18930] | 390 |
|
---|
[21718] | 391 | state=GetThermalBasalCondition(element, enthalpies[nodedown], enthalpies[nodeup], pressures[nodedown], pressures[nodeup], watercolumns[nodedown], basalmeltingrates[nodedown]);
|
---|
[18930] | 392 | switch (state) {
|
---|
| 393 | case 0:
|
---|
| 394 | // cold, dry base: apply basal surface forcing
|
---|
| 395 | for(i=0;i<3;i++) vec_heatflux[i]=0.;
|
---|
| 396 | break;
|
---|
| 397 | case 1: case 2: case 3:
|
---|
| 398 | // case 1 : cold, wet base: keep at pressure melting point
|
---|
| 399 | // case 2: temperate, thin refreezing base: release spc
|
---|
| 400 | // case 3: temperate, thin melting base: set spc
|
---|
| 401 | enthalpy_input->GetInputDerivativeValue(&d1enthalpy[0],xyz_list,gauss);
|
---|
| 402 | for(i=0;i<3;i++) vec_heatflux[i]=-kappa*d1enthalpy[i];
|
---|
| 403 | break;
|
---|
| 404 | case 4:
|
---|
| 405 | // temperate, thick melting base: set grad H*n=0
|
---|
[21718] | 406 | kappa_mix=GetWetIceConductivity(element, enthalpies[nodedown], pressures[nodedown]);
|
---|
[18930] | 407 | pressure_input->GetInputDerivativeValue(&d1pressure[0],xyz_list,gauss);
|
---|
| 408 | for(i=0;i<3;i++) vec_heatflux[i]=kappa_mix*beta*d1pressure[i];
|
---|
| 409 | break;
|
---|
| 410 | default:
|
---|
| 411 | _printf0_(" unknown thermal basal state found!");
|
---|
| 412 | }
|
---|
| 413 | if(state==0) meltingrate_enthalpy[is]=0.;
|
---|
| 414 | else{
|
---|
| 415 | /*heat flux along normal*/
|
---|
| 416 | heatflux=0.;
|
---|
| 417 | for(i=0;i<3;i++) heatflux+=(vec_heatflux[i])*normal_base[i];
|
---|
| 418 |
|
---|
| 419 | /*basal friction*/
|
---|
| 420 | friction->GetAlpha2(&alpha2,gauss);
|
---|
| 421 | vx_input->GetInputValue(&vx,gauss); vy_input->GetInputValue(&vy,gauss); vz_input->GetInputValue(&vz,gauss);
|
---|
| 422 | basalfriction=alpha2*(vx*vx + vy*vy + vz*vz);
|
---|
| 423 | geothermalflux_input->GetInputValue(&geothermalflux,gauss);
|
---|
| 424 | /* -Mb= Fb-(q-q_geo)/((1-w)*L*rho), and (1-w)*rho=rho_ice, cf Aschwanden 2012, eqs.1, 2, 66*/
|
---|
| 425 | heating[is]=(heatflux+basalfriction+geothermalflux);
|
---|
| 426 | meltingrate_enthalpy[is]=heating[is]/(latentheat*rho_ice); // m/s water equivalent
|
---|
| 427 | }
|
---|
| 428 | }/*}}}*/
|
---|
| 429 |
|
---|
| 430 | /******** UPDATE MELTINGRATES AND WATERCOLUMN **************//*{{{*/
|
---|
| 431 | for(is=0;is<numsegments;is++){
|
---|
[21718] | 432 | nodedown = pairindices[is*2+0];
|
---|
| 433 | nodeup = pairindices[is*2+1];
|
---|
[18930] | 434 | if(dt!=0.){
|
---|
[21718] | 435 | if(watercolumns[nodedown]+meltingrate_enthalpy[is]*dt<0.){ // prevent too much freeze on
|
---|
| 436 | lambda = -watercolumns[nodedown]/(dt*meltingrate_enthalpy[is]); _assert_(lambda>=0.); _assert_(lambda<1.);
|
---|
| 437 | watercolumns[nodedown]=0.;
|
---|
| 438 | basalmeltingrates[nodedown]=lambda*meltingrate_enthalpy[is]; // restrict freeze on only to size of watercolumn
|
---|
| 439 | enthalpies[nodedown]+=(1.-lambda)*dt/yts*meltingrate_enthalpy[is]*latentheat*rho_ice; // use rest of energy to cool down base: dE=L*m, m=(1-lambda)*meltingrate*rho_ice
|
---|
[16539] | 440 | }
|
---|
[18930] | 441 | else{
|
---|
[21718] | 442 | basalmeltingrates[nodedown]=meltingrate_enthalpy[is];
|
---|
| 443 | watercolumns[nodedown]+=dt*meltingrate_enthalpy[is];
|
---|
[18930] | 444 | }
|
---|
[16539] | 445 | }
|
---|
[18930] | 446 | else{
|
---|
[21718] | 447 | basalmeltingrates[nodedown]=meltingrate_enthalpy[is];
|
---|
| 448 | if(watercolumns[nodedown]+meltingrate_enthalpy[is]<0.)
|
---|
| 449 | watercolumns[nodedown]=0.;
|
---|
[18930] | 450 | else
|
---|
[21718] | 451 | watercolumns[nodedown]+=meltingrate_enthalpy[is];
|
---|
[18930] | 452 | }
|
---|
[21718] | 453 | basalmeltingrates[nodedown]*=rho_water/rho_ice; // convert meltingrate from water to ice equivalent
|
---|
| 454 | _assert_(watercolumns[nodedown]>=0.);
|
---|
[18930] | 455 | }/*}}}*/
|
---|
| 456 |
|
---|
| 457 | /*feed updated variables back into model*/
|
---|
| 458 | if(dt!=0.){
|
---|
[21718] | 459 | element->AddInput(enthalpy_enum,enthalpies,element->GetElementType());
|
---|
| 460 | element->AddInput(WatercolumnEnum,watercolumns,element->GetElementType());
|
---|
[16539] | 461 | }
|
---|
[21718] | 462 | element->AddInput(BasalforcingsGroundediceMeltingRateEnum,basalmeltingrates,element->GetElementType());
|
---|
[16539] | 463 |
|
---|
[18930] | 464 | /*Clean up and return*/
|
---|
| 465 | delete gauss;
|
---|
| 466 | delete friction;
|
---|
| 467 | xDelete<int>(pairindices);
|
---|
| 468 | xDelete<IssmDouble>(enthalpies);
|
---|
| 469 | xDelete<IssmDouble>(pressures);
|
---|
| 470 | xDelete<IssmDouble>(watercolumns);
|
---|
| 471 | xDelete<IssmDouble>(basalmeltingrates);
|
---|
| 472 | xDelete<IssmDouble>(meltingrate_enthalpy);
|
---|
| 473 | xDelete<IssmDouble>(heating);
|
---|
| 474 | xDelete<IssmDouble>(xyz_list);
|
---|
| 475 | xDelete<IssmDouble>(xyz_list_base);
|
---|
[16539] | 476 | }/*}}}*/
|
---|
[18930] | 477 | void EnthalpyAnalysis::Core(FemModel* femmodel){/*{{{*/
|
---|
[21160] | 478 |
|
---|
| 479 | IssmDouble dt;
|
---|
| 480 | bool isdynamicbasalspc;
|
---|
| 481 |
|
---|
| 482 | femmodel->parameters->FindParam(&dt,TimesteppingTimeStepEnum);
|
---|
| 483 | femmodel->parameters->FindParam(&isdynamicbasalspc,ThermalIsdynamicbasalspcEnum);
|
---|
| 484 |
|
---|
[18591] | 485 | if(VerboseSolution()) _printf0_(" computing enthalpy\n");
|
---|
| 486 | femmodel->SetCurrentConfiguration(EnthalpyAnalysisEnum);
|
---|
[21160] | 487 | if((dt>0.) && isdynamicbasalspc) UpdateBasalConstraints(femmodel);
|
---|
[18591] | 488 | solutionsequence_thermal_nonlinear(femmodel);
|
---|
| 489 |
|
---|
| 490 | /*transfer enthalpy to enthalpy picard for the next step: */
|
---|
| 491 | InputDuplicatex(femmodel,EnthalpyEnum,EnthalpyPicardEnum);
|
---|
| 492 |
|
---|
[21161] | 493 | PostProcessing(femmodel);
|
---|
[18591] | 494 |
|
---|
[17005] | 495 | }/*}}}*/
|
---|
[17000] | 496 | ElementVector* EnthalpyAnalysis::CreateDVector(Element* element){/*{{{*/
|
---|
| 497 | /*Default, return NULL*/
|
---|
| 498 | return NULL;
|
---|
| 499 | }/*}}}*/
|
---|
[16992] | 500 | ElementMatrix* EnthalpyAnalysis::CreateJacobianMatrix(Element* element){/*{{{*/
|
---|
| 501 | _error_("Not implemented");
|
---|
| 502 | }/*}}}*/
|
---|
[16782] | 503 | ElementMatrix* EnthalpyAnalysis::CreateKMatrix(Element* element){/*{{{*/
|
---|
[16888] | 504 |
|
---|
[17434] | 505 | /* Check if ice in element */
|
---|
| 506 | if(!element->IsIceInElement()) return NULL;
|
---|
| 507 |
|
---|
[16888] | 508 | /*compute all stiffness matrices for this element*/
|
---|
| 509 | ElementMatrix* Ke1=CreateKMatrixVolume(element);
|
---|
| 510 | ElementMatrix* Ke2=CreateKMatrixShelf(element);
|
---|
| 511 | ElementMatrix* Ke =new ElementMatrix(Ke1,Ke2);
|
---|
| 512 |
|
---|
| 513 | /*clean-up and return*/
|
---|
| 514 | delete Ke1;
|
---|
| 515 | delete Ke2;
|
---|
| 516 | return Ke;
|
---|
[16782] | 517 | }/*}}}*/
|
---|
[16888] | 518 | ElementMatrix* EnthalpyAnalysis::CreateKMatrixVolume(Element* element){/*{{{*/
|
---|
| 519 |
|
---|
[17434] | 520 | /* Check if ice in element */
|
---|
| 521 | if(!element->IsIceInElement()) return NULL;
|
---|
| 522 |
|
---|
[16888] | 523 | /*Intermediaries */
|
---|
| 524 | int stabilization;
|
---|
| 525 | IssmDouble Jdet,dt,u,v,w,um,vm,wm,vel;
|
---|
| 526 | IssmDouble h,hx,hy,hz,vx,vy,vz;
|
---|
| 527 | IssmDouble tau_parameter,diameter;
|
---|
| 528 | IssmDouble D_scalar;
|
---|
| 529 | IssmDouble* xyz_list = NULL;
|
---|
| 530 |
|
---|
| 531 | /*Fetch number of nodes and dof for this finite element*/
|
---|
| 532 | int numnodes = element->GetNumberOfNodes();
|
---|
| 533 |
|
---|
| 534 | /*Initialize Element vector and other vectors*/
|
---|
| 535 | ElementMatrix* Ke = element->NewElementMatrix();
|
---|
| 536 | IssmDouble* basis = xNew<IssmDouble>(numnodes);
|
---|
| 537 | IssmDouble* dbasis = xNew<IssmDouble>(3*numnodes);
|
---|
| 538 | IssmDouble* B = xNew<IssmDouble>(3*numnodes);
|
---|
| 539 | IssmDouble* Bprime = xNew<IssmDouble>(3*numnodes);
|
---|
| 540 | IssmDouble D[3][3] = {0.};
|
---|
| 541 | IssmDouble K[3][3];
|
---|
| 542 |
|
---|
| 543 | /*Retrieve all inputs and parameters*/
|
---|
| 544 | element->GetVerticesCoordinates(&xyz_list);
|
---|
| 545 | element->FindParam(&dt,TimesteppingTimeStepEnum);
|
---|
| 546 | element->FindParam(&stabilization,ThermalStabilizationEnum);
|
---|
[17946] | 547 | IssmDouble rho_water = element->GetMaterialParameter(MaterialsRhoSeawaterEnum);
|
---|
[16888] | 548 | IssmDouble rho_ice = element->GetMaterialParameter(MaterialsRhoIceEnum);
|
---|
| 549 | IssmDouble gravity = element->GetMaterialParameter(ConstantsGEnum);
|
---|
| 550 | IssmDouble heatcapacity = element->GetMaterialParameter(MaterialsHeatcapacityEnum);
|
---|
| 551 | IssmDouble thermalconductivity = element->GetMaterialParameter(MaterialsThermalconductivityEnum);
|
---|
| 552 | Input* vx_input = element->GetInput(VxEnum); _assert_(vx_input);
|
---|
| 553 | Input* vy_input = element->GetInput(VyEnum); _assert_(vy_input);
|
---|
| 554 | Input* vz_input = element->GetInput(VzEnum); _assert_(vz_input);
|
---|
| 555 | Input* vxm_input = element->GetInput(VxMeshEnum); _assert_(vxm_input);
|
---|
| 556 | Input* vym_input = element->GetInput(VyMeshEnum); _assert_(vym_input);
|
---|
| 557 | Input* vzm_input = element->GetInput(VzMeshEnum); _assert_(vzm_input);
|
---|
| 558 | if(stabilization==2) diameter=element->MinEdgeLength(xyz_list);
|
---|
| 559 |
|
---|
| 560 | /*Enthalpy diffusion parameter*/
|
---|
[17027] | 561 | IssmDouble kappa=this->EnthalpyDiffusionParameterVolume(element,EnthalpyPicardEnum); _assert_(kappa>=0.);
|
---|
[16888] | 562 |
|
---|
| 563 | /* Start looping on the number of gaussian points: */
|
---|
[19637] | 564 | Gauss* gauss=element->NewGauss(4);
|
---|
[16888] | 565 | for(int ig=gauss->begin();ig<gauss->end();ig++){
|
---|
| 566 | gauss->GaussPoint(ig);
|
---|
| 567 |
|
---|
| 568 | element->JacobianDeterminant(&Jdet,xyz_list,gauss);
|
---|
| 569 | D_scalar=gauss->weight*Jdet;
|
---|
| 570 | if(dt!=0.) D_scalar=D_scalar*dt;
|
---|
| 571 |
|
---|
| 572 | /*Conduction: */
|
---|
| 573 | GetBConduct(B,element,xyz_list,gauss);
|
---|
| 574 | D[0][0]=D_scalar*kappa/rho_ice;
|
---|
| 575 | D[1][1]=D_scalar*kappa/rho_ice;
|
---|
| 576 | D[2][2]=D_scalar*kappa/rho_ice;
|
---|
| 577 | TripleMultiply(B,3,numnodes,1,
|
---|
| 578 | &D[0][0],3,3,0,
|
---|
| 579 | B,3,numnodes,0,
|
---|
| 580 | &Ke->values[0],1);
|
---|
| 581 |
|
---|
| 582 | /*Advection: */
|
---|
| 583 | GetBAdvec(B,element,xyz_list,gauss);
|
---|
| 584 | GetBAdvecprime(Bprime,element,xyz_list,gauss);
|
---|
| 585 | vx_input->GetInputValue(&u,gauss); vxm_input->GetInputValue(&um,gauss); vx=u-um;
|
---|
| 586 | vy_input->GetInputValue(&v,gauss); vym_input->GetInputValue(&vm,gauss); vy=v-vm;
|
---|
| 587 | vz_input->GetInputValue(&w,gauss); vzm_input->GetInputValue(&wm,gauss); vz=w-wm;
|
---|
| 588 | D[0][0]=D_scalar*vx;
|
---|
| 589 | D[1][1]=D_scalar*vy;
|
---|
| 590 | D[2][2]=D_scalar*vz;
|
---|
| 591 | TripleMultiply(B,3,numnodes,1,
|
---|
| 592 | &D[0][0],3,3,0,
|
---|
| 593 | Bprime,3,numnodes,0,
|
---|
| 594 | &Ke->values[0],1);
|
---|
| 595 |
|
---|
| 596 | /*Transient: */
|
---|
| 597 | if(dt!=0.){
|
---|
| 598 | D_scalar=gauss->weight*Jdet;
|
---|
| 599 | element->NodalFunctions(basis,gauss);
|
---|
| 600 | TripleMultiply(basis,numnodes,1,0,
|
---|
| 601 | &D_scalar,1,1,0,
|
---|
| 602 | basis,1,numnodes,0,
|
---|
| 603 | &Ke->values[0],1);
|
---|
| 604 | D_scalar=D_scalar*dt;
|
---|
| 605 | }
|
---|
| 606 |
|
---|
[21382] | 607 | /*Artificial diffusivity*/
|
---|
[16888] | 608 | if(stabilization==1){
|
---|
| 609 | element->ElementSizes(&hx,&hy,&hz);
|
---|
| 610 | vel=sqrt(vx*vx + vy*vy + vz*vz)+1.e-14;
|
---|
| 611 | h=sqrt( pow(hx*vx/vel,2) + pow(hy*vy/vel,2) + pow(hz*vz/vel,2));
|
---|
[18484] | 612 | K[0][0]=h/(2.*vel)*fabs(vx*vx); K[0][1]=h/(2.*vel)*fabs(vx*vy); K[0][2]=h/(2.*vel)*fabs(vx*vz);
|
---|
| 613 | K[1][0]=h/(2.*vel)*fabs(vy*vx); K[1][1]=h/(2.*vel)*fabs(vy*vy); K[1][2]=h/(2.*vel)*fabs(vy*vz);
|
---|
| 614 | K[2][0]=h/(2.*vel)*fabs(vz*vx); K[2][1]=h/(2.*vel)*fabs(vz*vy); K[2][2]=h/(2.*vel)*fabs(vz*vz);
|
---|
[16888] | 615 | for(int i=0;i<3;i++) for(int j=0;j<3;j++) K[i][j] = D_scalar*K[i][j];
|
---|
| 616 |
|
---|
| 617 | GetBAdvecprime(Bprime,element,xyz_list,gauss);
|
---|
| 618 | TripleMultiply(Bprime,3,numnodes,1,
|
---|
| 619 | &K[0][0],3,3,0,
|
---|
| 620 | Bprime,3,numnodes,0,
|
---|
| 621 | &Ke->values[0],1);
|
---|
| 622 | }
|
---|
| 623 | else if(stabilization==2){
|
---|
| 624 | element->NodalFunctionsDerivatives(dbasis,xyz_list,gauss);
|
---|
| 625 | tau_parameter=element->StabilizationParameter(u-um,v-vm,w-wm,diameter,kappa/rho_ice);
|
---|
| 626 | for(int i=0;i<numnodes;i++){
|
---|
| 627 | for(int j=0;j<numnodes;j++){
|
---|
| 628 | Ke->values[i*numnodes+j]+=tau_parameter*D_scalar*
|
---|
[16895] | 629 | ((u-um)*dbasis[0*numnodes+i]+(v-vm)*dbasis[1*numnodes+i]+(w-wm)*dbasis[2*numnodes+i])*((u-um)*dbasis[0*numnodes+j]+(v-vm)*dbasis[1*numnodes+j]+(w-wm)*dbasis[2*numnodes+j]);
|
---|
[16888] | 630 | }
|
---|
| 631 | }
|
---|
| 632 | if(dt!=0.){
|
---|
[16896] | 633 | D_scalar=gauss->weight*Jdet;
|
---|
[16888] | 634 | for(int i=0;i<numnodes;i++){
|
---|
| 635 | for(int j=0;j<numnodes;j++){
|
---|
[16895] | 636 | Ke->values[i*numnodes+j]+=tau_parameter*D_scalar*basis[j]*((u-um)*dbasis[0*numnodes+i]+(v-vm)*dbasis[1*numnodes+i]+(w-wm)*dbasis[2*numnodes+i]);
|
---|
[16888] | 637 | }
|
---|
| 638 | }
|
---|
| 639 | }
|
---|
| 640 | }
|
---|
| 641 | }
|
---|
| 642 |
|
---|
| 643 | /*Clean up and return*/
|
---|
| 644 | xDelete<IssmDouble>(xyz_list);
|
---|
| 645 | xDelete<IssmDouble>(basis);
|
---|
| 646 | xDelete<IssmDouble>(dbasis);
|
---|
| 647 | xDelete<IssmDouble>(B);
|
---|
| 648 | xDelete<IssmDouble>(Bprime);
|
---|
| 649 | delete gauss;
|
---|
| 650 | return Ke;
|
---|
| 651 | }/*}}}*/
|
---|
| 652 | ElementMatrix* EnthalpyAnalysis::CreateKMatrixShelf(Element* element){/*{{{*/
|
---|
| 653 |
|
---|
[17434] | 654 | /* Check if ice in element */
|
---|
| 655 | if(!element->IsIceInElement()) return NULL;
|
---|
| 656 |
|
---|
[16888] | 657 | /*Initialize Element matrix and return if necessary*/
|
---|
[17585] | 658 | if(!element->IsOnBase() || !element->IsFloating()) return NULL;
|
---|
[16888] | 659 |
|
---|
[16986] | 660 | /*Intermediaries*/
|
---|
[16888] | 661 | IssmDouble dt,Jdet,D;
|
---|
| 662 | IssmDouble *xyz_list_base = NULL;
|
---|
| 663 |
|
---|
| 664 | /*Fetch number of nodes for this finite element*/
|
---|
| 665 | int numnodes = element->GetNumberOfNodes();
|
---|
| 666 |
|
---|
| 667 | /*Initialize vectors*/
|
---|
| 668 | ElementMatrix* Ke = element->NewElementMatrix();
|
---|
| 669 | IssmDouble* basis = xNew<IssmDouble>(numnodes);
|
---|
| 670 |
|
---|
| 671 | /*Retrieve all inputs and parameters*/
|
---|
| 672 | element->GetVerticesCoordinatesBase(&xyz_list_base);
|
---|
| 673 | element->FindParam(&dt,TimesteppingTimeStepEnum);
|
---|
| 674 | IssmDouble gravity = element->GetMaterialParameter(ConstantsGEnum);
|
---|
[17946] | 675 | IssmDouble rho_water = element->GetMaterialParameter(MaterialsRhoSeawaterEnum);
|
---|
[16888] | 676 | IssmDouble rho_ice = element->GetMaterialParameter(MaterialsRhoIceEnum);
|
---|
| 677 | IssmDouble heatcapacity = element->GetMaterialParameter(MaterialsHeatcapacityEnum);
|
---|
| 678 | IssmDouble mixed_layer_capacity= element->GetMaterialParameter(MaterialsMixedLayerCapacityEnum);
|
---|
| 679 | IssmDouble thermal_exchange_vel= element->GetMaterialParameter(MaterialsThermalExchangeVelocityEnum);
|
---|
| 680 |
|
---|
| 681 | /* Start looping on the number of gaussian points: */
|
---|
[19637] | 682 | Gauss* gauss=element->NewGaussBase(4);
|
---|
[16888] | 683 | for(int ig=gauss->begin();ig<gauss->end();ig++){
|
---|
| 684 | gauss->GaussPoint(ig);
|
---|
| 685 |
|
---|
| 686 | element->JacobianDeterminantBase(&Jdet,xyz_list_base,gauss);
|
---|
| 687 | element->NodalFunctions(basis,gauss);
|
---|
| 688 |
|
---|
| 689 | D=gauss->weight*Jdet*rho_water*mixed_layer_capacity*thermal_exchange_vel/(heatcapacity*rho_ice);
|
---|
| 690 | if(reCast<bool,IssmDouble>(dt)) D=dt*D;
|
---|
| 691 | TripleMultiply(basis,numnodes,1,0,
|
---|
| 692 | &D,1,1,0,
|
---|
| 693 | basis,1,numnodes,0,
|
---|
| 694 | &Ke->values[0],1);
|
---|
| 695 |
|
---|
| 696 | }
|
---|
| 697 |
|
---|
| 698 | /*Clean up and return*/
|
---|
| 699 | delete gauss;
|
---|
| 700 | xDelete<IssmDouble>(basis);
|
---|
| 701 | xDelete<IssmDouble>(xyz_list_base);
|
---|
| 702 | return Ke;
|
---|
| 703 | }/*}}}*/
|
---|
[16782] | 704 | ElementVector* EnthalpyAnalysis::CreatePVector(Element* element){/*{{{*/
|
---|
[16812] | 705 |
|
---|
[17434] | 706 | /* Check if ice in element */
|
---|
| 707 | if(!element->IsIceInElement()) return NULL;
|
---|
| 708 |
|
---|
[16812] | 709 | /*compute all load vectors for this element*/
|
---|
| 710 | ElementVector* pe1=CreatePVectorVolume(element);
|
---|
| 711 | ElementVector* pe2=CreatePVectorSheet(element);
|
---|
| 712 | ElementVector* pe3=CreatePVectorShelf(element);
|
---|
| 713 | ElementVector* pe =new ElementVector(pe1,pe2,pe3);
|
---|
| 714 |
|
---|
| 715 | /*clean-up and return*/
|
---|
| 716 | delete pe1;
|
---|
| 717 | delete pe2;
|
---|
| 718 | delete pe3;
|
---|
| 719 | return pe;
|
---|
[16782] | 720 | }/*}}}*/
|
---|
[16812] | 721 | ElementVector* EnthalpyAnalysis::CreatePVectorVolume(Element* element){/*{{{*/
|
---|
| 722 |
|
---|
[17434] | 723 | /* Check if ice in element */
|
---|
| 724 | if(!element->IsIceInElement()) return NULL;
|
---|
| 725 |
|
---|
[16812] | 726 | /*Intermediaries*/
|
---|
[17014] | 727 | int i, stabilization;
|
---|
[16812] | 728 | IssmDouble Jdet,phi,dt;
|
---|
[17014] | 729 | IssmDouble enthalpy, Hpmp;
|
---|
| 730 | IssmDouble enthalpypicard, d1enthalpypicard[3];
|
---|
| 731 | IssmDouble pressure, d1pressure[3], d2pressure;
|
---|
| 732 | IssmDouble waterfractionpicard;
|
---|
| 733 | IssmDouble kappa,tau_parameter,diameter,kappa_w;
|
---|
[16812] | 734 | IssmDouble u,v,w;
|
---|
[17014] | 735 | IssmDouble scalar_def, scalar_sens ,scalar_transient;
|
---|
[16812] | 736 | IssmDouble* xyz_list = NULL;
|
---|
[17014] | 737 | IssmDouble d1H_d1P, d1P2;
|
---|
[16812] | 738 |
|
---|
| 739 | /*Fetch number of nodes and dof for this finite element*/
|
---|
| 740 | int numnodes = element->GetNumberOfNodes();
|
---|
| 741 | int numvertices = element->GetNumberOfVertices();
|
---|
| 742 |
|
---|
| 743 | /*Initialize Element vector*/
|
---|
| 744 | ElementVector* pe = element->NewElementVector();
|
---|
| 745 | IssmDouble* basis = xNew<IssmDouble>(numnodes);
|
---|
| 746 | IssmDouble* dbasis = xNew<IssmDouble>(3*numnodes);
|
---|
| 747 |
|
---|
| 748 | /*Retrieve all inputs and parameters*/
|
---|
| 749 | element->GetVerticesCoordinates(&xyz_list);
|
---|
| 750 | IssmDouble rho_ice = element->GetMaterialParameter(MaterialsRhoIceEnum);
|
---|
[17014] | 751 | IssmDouble heatcapacity = element->GetMaterialParameter(MaterialsHeatcapacityEnum);
|
---|
[16812] | 752 | IssmDouble thermalconductivity = element->GetMaterialParameter(MaterialsThermalconductivityEnum);
|
---|
[17014] | 753 | IssmDouble temperateiceconductivity = element->GetMaterialParameter(MaterialsTemperateiceconductivityEnum);
|
---|
| 754 | IssmDouble beta = element->GetMaterialParameter(MaterialsBetaEnum);
|
---|
| 755 | IssmDouble latentheat = element->GetMaterialParameter(MaterialsLatentheatEnum);
|
---|
[16812] | 756 | element->FindParam(&dt,TimesteppingTimeStepEnum);
|
---|
| 757 | element->FindParam(&stabilization,ThermalStabilizationEnum);
|
---|
| 758 | Input* vx_input=element->GetInput(VxEnum); _assert_(vx_input);
|
---|
| 759 | Input* vy_input=element->GetInput(VyEnum); _assert_(vy_input);
|
---|
| 760 | Input* vz_input=element->GetInput(VzEnum); _assert_(vz_input);
|
---|
[17014] | 761 | Input* enthalpypicard_input=element->GetInput(EnthalpyPicardEnum); _assert_(enthalpypicard_input);
|
---|
| 762 | Input* pressure_input=element->GetInput(PressureEnum); _assert_(pressure_input);
|
---|
| 763 | Input* enthalpy_input=NULL;
|
---|
[16812] | 764 | if(reCast<bool,IssmDouble>(dt)){enthalpy_input = element->GetInput(EnthalpyEnum); _assert_(enthalpy_input);}
|
---|
| 765 | if(stabilization==2){
|
---|
| 766 | diameter=element->MinEdgeLength(xyz_list);
|
---|
[17027] | 767 | kappa=this->EnthalpyDiffusionParameterVolume(element,EnthalpyPicardEnum); _assert_(kappa>=0.);
|
---|
[16812] | 768 | }
|
---|
| 769 |
|
---|
| 770 | /* Start looping on the number of gaussian points: */
|
---|
[19637] | 771 | Gauss* gauss=element->NewGauss(4);
|
---|
[16812] | 772 | for(int ig=gauss->begin();ig<gauss->end();ig++){
|
---|
| 773 | gauss->GaussPoint(ig);
|
---|
| 774 |
|
---|
| 775 | element->JacobianDeterminant(&Jdet,xyz_list,gauss);
|
---|
| 776 | element->NodalFunctions(basis,gauss);
|
---|
[17014] | 777 |
|
---|
| 778 | /*viscous dissipation*/
|
---|
[16812] | 779 | element->ViscousHeating(&phi,xyz_list,gauss,vx_input,vy_input,vz_input);
|
---|
| 780 |
|
---|
| 781 | scalar_def=phi/rho_ice*Jdet*gauss->weight;
|
---|
[16895] | 782 | if(dt!=0.) scalar_def=scalar_def*dt;
|
---|
[16812] | 783 |
|
---|
[17014] | 784 | for(i=0;i<numnodes;i++) pe->values[i]+=scalar_def*basis[i];
|
---|
[16812] | 785 |
|
---|
[17014] | 786 | /*sensible heat flux in temperate ice*/
|
---|
| 787 | enthalpypicard_input->GetInputValue(&enthalpypicard,gauss);
|
---|
| 788 | pressure_input->GetInputValue(&pressure,gauss);
|
---|
| 789 | Hpmp=this->PureIceEnthalpy(element, pressure);
|
---|
| 790 |
|
---|
| 791 | if(enthalpypicard>=Hpmp){
|
---|
| 792 | enthalpypicard_input->GetInputDerivativeValue(&d1enthalpypicard[0],xyz_list,gauss);
|
---|
| 793 | pressure_input->GetInputDerivativeValue(&d1pressure[0],xyz_list,gauss);
|
---|
| 794 | d2pressure=0.; // for linear elements, 2nd derivative is zero
|
---|
| 795 |
|
---|
| 796 | d1H_d1P=0.;
|
---|
| 797 | for(i=0;i<3;i++) d1H_d1P+=d1enthalpypicard[i]*d1pressure[i];
|
---|
| 798 | d1P2=0.;
|
---|
| 799 | for(i=0;i<3;i++) d1P2+=pow(d1pressure[i],2.);
|
---|
| 800 |
|
---|
| 801 | scalar_sens=-beta*((temperateiceconductivity - thermalconductivity)/latentheat*(d1H_d1P + beta*heatcapacity*d1P2))/rho_ice;
|
---|
| 802 | if(dt!=0.) scalar_sens=scalar_sens*dt;
|
---|
| 803 | for(i=0;i<numnodes;i++) pe->values[i]+=scalar_sens*basis[i];
|
---|
| 804 | }
|
---|
| 805 |
|
---|
[16812] | 806 | /* Build transient now */
|
---|
| 807 | if(reCast<bool,IssmDouble>(dt)){
|
---|
| 808 | enthalpy_input->GetInputValue(&enthalpy, gauss);
|
---|
| 809 | scalar_transient=enthalpy*Jdet*gauss->weight;
|
---|
[17014] | 810 | for(i=0;i<numnodes;i++) pe->values[i]+=scalar_transient*basis[i];
|
---|
[16812] | 811 | }
|
---|
| 812 |
|
---|
| 813 | if(stabilization==2){
|
---|
| 814 | element->NodalFunctionsDerivatives(dbasis,xyz_list,gauss);
|
---|
| 815 |
|
---|
| 816 | vx_input->GetInputValue(&u,gauss);
|
---|
| 817 | vy_input->GetInputValue(&v,gauss);
|
---|
| 818 | vz_input->GetInputValue(&w,gauss);
|
---|
[16895] | 819 | tau_parameter=element->StabilizationParameter(u,v,w,diameter,kappa/rho_ice);
|
---|
[16812] | 820 |
|
---|
[17014] | 821 | for(i=0;i<numnodes;i++) pe->values[i]+=tau_parameter*scalar_def*(u*dbasis[0*numnodes+i]+v*dbasis[1*numnodes+i]+w*dbasis[2*numnodes+i]);
|
---|
[16895] | 822 |
|
---|
| 823 | if(dt!=0.){
|
---|
[17014] | 824 | for(i=0;i<numnodes;i++) pe->values[i]+=tau_parameter*scalar_transient*(u*dbasis[0*numnodes+i]+v*dbasis[1*numnodes+i]+w*dbasis[2*numnodes+i]);
|
---|
[16812] | 825 | }
|
---|
| 826 | }
|
---|
| 827 | }
|
---|
| 828 |
|
---|
| 829 | /*Clean up and return*/
|
---|
| 830 | xDelete<IssmDouble>(basis);
|
---|
| 831 | xDelete<IssmDouble>(dbasis);
|
---|
| 832 | xDelete<IssmDouble>(xyz_list);
|
---|
| 833 | delete gauss;
|
---|
| 834 | return pe;
|
---|
| 835 |
|
---|
| 836 | }/*}}}*/
|
---|
| 837 | ElementVector* EnthalpyAnalysis::CreatePVectorSheet(Element* element){/*{{{*/
|
---|
[16888] | 838 |
|
---|
[17434] | 839 | /* Check if ice in element */
|
---|
| 840 | if(!element->IsIceInElement()) return NULL;
|
---|
| 841 |
|
---|
[17014] | 842 | /* implementation of the basal condition decision chart of Aschwanden 2012, Fig.5 */
|
---|
[17585] | 843 | if(!element->IsOnBase() || element->IsFloating()) return NULL;
|
---|
[16888] | 844 |
|
---|
[20272] | 845 | bool converged, isdynamicbasalspc;
|
---|
[18612] | 846 | int i, state;
|
---|
[20272] | 847 | int enthalpy_enum;
|
---|
[18612] | 848 | IssmDouble dt,Jdet,scalar;
|
---|
| 849 | IssmDouble enthalpy, enthalpyup, pressure, pressureup, watercolumn, meltingrate;
|
---|
| 850 | IssmDouble vx,vy,vz;
|
---|
| 851 | IssmDouble alpha2,basalfriction,geothermalflux,heatflux;
|
---|
[16888] | 852 | IssmDouble *xyz_list_base = NULL;
|
---|
| 853 |
|
---|
| 854 | /*Fetch number of nodes for this finite element*/
|
---|
| 855 | int numnodes = element->GetNumberOfNodes();
|
---|
| 856 |
|
---|
| 857 | /*Initialize vectors*/
|
---|
| 858 | ElementVector* pe = element->NewElementVector();
|
---|
| 859 | IssmDouble* basis = xNew<IssmDouble>(numnodes);
|
---|
| 860 |
|
---|
| 861 | /*Retrieve all inputs and parameters*/
|
---|
| 862 | element->GetVerticesCoordinatesBase(&xyz_list_base);
|
---|
| 863 | element->FindParam(&dt,TimesteppingTimeStepEnum);
|
---|
[18622] | 864 | element->FindParam(&isdynamicbasalspc,ThermalIsdynamicbasalspcEnum);
|
---|
[20272] | 865 | element->GetInputValue(&converged,ConvergedEnum);
|
---|
| 866 | if(dt==0. && !converged) enthalpy_enum=EnthalpyPicardEnum; // use enthalpy from last iteration
|
---|
| 867 | else enthalpy_enum=EnthalpyEnum; // use enthalpy from last time step
|
---|
[16888] | 868 | Input* vx_input = element->GetInput(VxEnum); _assert_(vx_input);
|
---|
| 869 | Input* vy_input = element->GetInput(VyEnum); _assert_(vy_input);
|
---|
| 870 | Input* vz_input = element->GetInput(VzEnum); _assert_(vz_input);
|
---|
[20272] | 871 | Input* enthalpy_input = element->GetInput(enthalpy_enum); _assert_(enthalpy_input);
|
---|
[18612] | 872 | Input* pressure_input = element->GetInput(PressureEnum); _assert_(pressure_input);
|
---|
| 873 | Input* watercolumn_input = element->GetInput(WatercolumnEnum); _assert_(watercolumn_input);
|
---|
| 874 | Input* meltingrate_input = element->GetInput(BasalforcingsGroundediceMeltingRateEnum); _assert_(meltingrate_input);
|
---|
[16888] | 875 | Input* geothermalflux_input = element->GetInput(BasalforcingsGeothermalfluxEnum); _assert_(geothermalflux_input);
|
---|
[18612] | 876 | IssmDouble rho_ice = element->GetMaterialParameter(MaterialsRhoIceEnum);
|
---|
[16888] | 877 |
|
---|
| 878 | /*Build friction element, needed later: */
|
---|
| 879 | Friction* friction=new Friction(element,3);
|
---|
| 880 |
|
---|
| 881 | /* Start looping on the number of gaussian points: */
|
---|
[19637] | 882 | Gauss* gauss=element->NewGaussBase(4);
|
---|
| 883 | Gauss* gaussup=element->NewGaussTop(4);
|
---|
[16888] | 884 | for(int ig=gauss->begin();ig<gauss->end();ig++){
|
---|
| 885 | gauss->GaussPoint(ig);
|
---|
[18665] | 886 | gaussup->GaussPoint(ig);
|
---|
[16888] | 887 |
|
---|
| 888 | element->JacobianDeterminantBase(&Jdet,xyz_list_base,gauss);
|
---|
| 889 | element->NodalFunctions(basis,gauss);
|
---|
| 890 |
|
---|
[18622] | 891 | if(isdynamicbasalspc){
|
---|
| 892 | enthalpy_input->GetInputValue(&enthalpy,gauss);
|
---|
| 893 | enthalpy_input->GetInputValue(&enthalpyup,gaussup);
|
---|
| 894 | pressure_input->GetInputValue(&pressure,gauss);
|
---|
| 895 | pressure_input->GetInputValue(&pressureup,gaussup);
|
---|
| 896 | watercolumn_input->GetInputValue(&watercolumn,gauss);
|
---|
| 897 | meltingrate_input->GetInputValue(&meltingrate,gauss);
|
---|
| 898 | state=GetThermalBasalCondition(element, enthalpy, enthalpyup, pressure, pressureup, watercolumn, meltingrate);
|
---|
| 899 | }
|
---|
| 900 | else
|
---|
| 901 | state=0;
|
---|
[16888] | 902 |
|
---|
[18612] | 903 | switch (state) {
|
---|
[20272] | 904 | case 0: case 1: case 2: case 3:
|
---|
| 905 | // cold, dry base; cold, wet base; refreezing temperate base; thin temperate base:
|
---|
| 906 | // Apply basal surface forcing.
|
---|
| 907 | // Interpolated values of enthalpy on gauss nodes may indicate cold base,
|
---|
| 908 | // although one node might have become temperate. So keep heat flux switched on.
|
---|
[18612] | 909 | geothermalflux_input->GetInputValue(&geothermalflux,gauss);
|
---|
| 910 | friction->GetAlpha2(&alpha2,gauss);
|
---|
| 911 | vx_input->GetInputValue(&vx,gauss);
|
---|
| 912 | vy_input->GetInputValue(&vy,gauss);
|
---|
| 913 | vz_input->GetInputValue(&vz,gauss);
|
---|
| 914 | basalfriction=alpha2*(vx*vx+vy*vy+vz*vz);
|
---|
| 915 | heatflux=(basalfriction+geothermalflux)/(rho_ice);
|
---|
| 916 | scalar=gauss->weight*Jdet*heatflux;
|
---|
| 917 | if(dt!=0.) scalar=dt*scalar;
|
---|
| 918 | for(i=0;i<numnodes;i++)
|
---|
| 919 | pe->values[i]+=scalar*basis[i];
|
---|
| 920 | break;
|
---|
| 921 | case 4:
|
---|
| 922 | // temperate, thick melting base: set grad H*n=0
|
---|
| 923 | for(i=0;i<numnodes;i++)
|
---|
| 924 | pe->values[i]+=0.;
|
---|
| 925 | break;
|
---|
| 926 | default:
|
---|
| 927 | _printf0_(" unknown thermal basal state found!");
|
---|
[16888] | 928 | }
|
---|
| 929 | }
|
---|
| 930 |
|
---|
| 931 | /*Clean up and return*/
|
---|
| 932 | delete gauss;
|
---|
| 933 | delete gaussup;
|
---|
| 934 | delete friction;
|
---|
| 935 | xDelete<IssmDouble>(basis);
|
---|
| 936 | xDelete<IssmDouble>(xyz_list_base);
|
---|
| 937 | return pe;
|
---|
| 938 |
|
---|
[16812] | 939 | }/*}}}*/
|
---|
| 940 | ElementVector* EnthalpyAnalysis::CreatePVectorShelf(Element* element){/*{{{*/
|
---|
| 941 |
|
---|
[17434] | 942 | /* Check if ice in element */
|
---|
| 943 | if(!element->IsIceInElement()) return NULL;
|
---|
| 944 |
|
---|
[16888] | 945 | /*Get basal element*/
|
---|
[17585] | 946 | if(!element->IsOnBase() || !element->IsFloating()) return NULL;
|
---|
[16888] | 947 |
|
---|
[18612] | 948 | IssmDouble Hpmp,dt,Jdet,scalar_ocean,pressure;
|
---|
[16812] | 949 | IssmDouble *xyz_list_base = NULL;
|
---|
| 950 |
|
---|
| 951 | /*Fetch number of nodes for this finite element*/
|
---|
| 952 | int numnodes = element->GetNumberOfNodes();
|
---|
| 953 |
|
---|
| 954 | /*Initialize vectors*/
|
---|
| 955 | ElementVector* pe = element->NewElementVector();
|
---|
| 956 | IssmDouble* basis = xNew<IssmDouble>(numnodes);
|
---|
| 957 |
|
---|
| 958 | /*Retrieve all inputs and parameters*/
|
---|
| 959 | element->GetVerticesCoordinatesBase(&xyz_list_base);
|
---|
| 960 | element->FindParam(&dt,TimesteppingTimeStepEnum);
|
---|
| 961 | Input* pressure_input=element->GetInput(PressureEnum); _assert_(pressure_input);
|
---|
| 962 | IssmDouble gravity = element->GetMaterialParameter(ConstantsGEnum);
|
---|
[17946] | 963 | IssmDouble rho_water = element->GetMaterialParameter(MaterialsRhoSeawaterEnum);
|
---|
[16812] | 964 | IssmDouble rho_ice = element->GetMaterialParameter(MaterialsRhoIceEnum);
|
---|
| 965 | IssmDouble heatcapacity = element->GetMaterialParameter(MaterialsHeatcapacityEnum);
|
---|
| 966 | IssmDouble mixed_layer_capacity= element->GetMaterialParameter(MaterialsMixedLayerCapacityEnum);
|
---|
| 967 | IssmDouble thermal_exchange_vel= element->GetMaterialParameter(MaterialsThermalExchangeVelocityEnum);
|
---|
| 968 |
|
---|
| 969 | /* Start looping on the number of gaussian points: */
|
---|
[19637] | 970 | Gauss* gauss=element->NewGaussBase(4);
|
---|
[16812] | 971 | for(int ig=gauss->begin();ig<gauss->end();ig++){
|
---|
| 972 | gauss->GaussPoint(ig);
|
---|
| 973 |
|
---|
| 974 | element->JacobianDeterminantBase(&Jdet,xyz_list_base,gauss);
|
---|
| 975 | element->NodalFunctions(basis,gauss);
|
---|
| 976 |
|
---|
| 977 | pressure_input->GetInputValue(&pressure,gauss);
|
---|
[18612] | 978 | Hpmp=element->PureIceEnthalpy(pressure);
|
---|
[16812] | 979 |
|
---|
[18612] | 980 | scalar_ocean=gauss->weight*Jdet*rho_water*mixed_layer_capacity*thermal_exchange_vel*Hpmp/(heatcapacity*rho_ice);
|
---|
[16812] | 981 | if(reCast<bool,IssmDouble>(dt)) scalar_ocean=dt*scalar_ocean;
|
---|
| 982 |
|
---|
| 983 | for(int i=0;i<numnodes;i++) pe->values[i]+=scalar_ocean*basis[i];
|
---|
| 984 | }
|
---|
| 985 |
|
---|
| 986 | /*Clean up and return*/
|
---|
| 987 | delete gauss;
|
---|
| 988 | xDelete<IssmDouble>(basis);
|
---|
| 989 | xDelete<IssmDouble>(xyz_list_base);
|
---|
| 990 | return pe;
|
---|
| 991 | }/*}}}*/
|
---|
[18930] | 992 | void EnthalpyAnalysis::DrainWaterfraction(FemModel* femmodel){/*{{{*/
|
---|
| 993 | /*Drain excess water fraction in ice column: */
|
---|
[21721] | 994 | ComputeWaterfractionDrainage(femmodel);
|
---|
| 995 | DrainageUpdateWatercolumn(femmodel);
|
---|
| 996 | DrainageUpdateEnthalpy(femmodel);
|
---|
[17002] | 997 | }/*}}}*/
|
---|
[21721] | 998 | void EnthalpyAnalysis::ComputeWaterfractionDrainage(FemModel* femmodel){/*{{{*/
|
---|
[17002] | 999 |
|
---|
[21721] | 1000 | int i,k,numnodes;
|
---|
| 1001 | IssmDouble dt;
|
---|
| 1002 | Element* element= NULL;
|
---|
[17434] | 1003 |
|
---|
[21721] | 1004 | femmodel->parameters->FindParam(&dt,TimesteppingTimeStepEnum);
|
---|
[17434] | 1005 |
|
---|
[21721] | 1006 | for(i=0;i<femmodel->elements->Size();i++){
|
---|
| 1007 | element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
|
---|
| 1008 | numnodes=element->GetNumberOfNodes();
|
---|
| 1009 | IssmDouble* waterfractions= xNew<IssmDouble>(numnodes);
|
---|
| 1010 | IssmDouble* drainage= xNew<IssmDouble>(numnodes);
|
---|
[17014] | 1011 |
|
---|
[21721] | 1012 | element->GetInputListOnNodes(waterfractions,WaterfractionEnum);
|
---|
| 1013 | for(k=0; k<numnodes;k++){
|
---|
| 1014 | drainage[k]=DrainageFunctionWaterfraction(waterfractions[k], dt);
|
---|
| 1015 | }
|
---|
| 1016 | element->AddInput(WaterfractionDrainageEnum,drainage,element->GetElementType());
|
---|
[18930] | 1017 |
|
---|
[21721] | 1018 | xDelete<IssmDouble>(waterfractions);
|
---|
| 1019 | xDelete<IssmDouble>(drainage);
|
---|
[18930] | 1020 | }
|
---|
[21721] | 1021 | }/*}}}*/
|
---|
| 1022 | void EnthalpyAnalysis::DrainageUpdateWatercolumn(FemModel* femmodel){/*{{{*/
|
---|
| 1023 |
|
---|
| 1024 | int i,k,numnodes, numbasalnodes;
|
---|
| 1025 | IssmDouble dt;
|
---|
| 1026 | int* basalnodeindices=NULL;
|
---|
| 1027 | Element* element= NULL;
|
---|
[18930] | 1028 |
|
---|
[21721] | 1029 | femmodel->parameters->FindParam(&dt,TimesteppingTimeStepEnum);
|
---|
[18667] | 1030 |
|
---|
[21721] | 1031 | /*depth-integrate the drained water fraction */
|
---|
| 1032 | femmodel->parameters->SetParam(WaterfractionDrainageEnum,InputToDepthaverageInEnum);
|
---|
| 1033 | femmodel->parameters->SetParam(WaterfractionDrainageIntegratedEnum,InputToDepthaverageOutEnum);
|
---|
| 1034 | depthaverage_core(femmodel);
|
---|
| 1035 | femmodel->parameters->SetParam(WaterfractionDrainageIntegratedEnum,InputToExtrudeEnum);
|
---|
| 1036 | extrudefrombase_core(femmodel);
|
---|
| 1037 | /*multiply depth-average by ice thickness*/
|
---|
| 1038 | for(i=0;i<femmodel->elements->Size();i++){
|
---|
| 1039 | element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
|
---|
| 1040 | numnodes=element->GetNumberOfNodes();
|
---|
| 1041 | IssmDouble* drainage_int= xNew<IssmDouble>(numnodes);
|
---|
| 1042 | IssmDouble* thicknesses= xNew<IssmDouble>(numnodes);
|
---|
[17014] | 1043 |
|
---|
[21721] | 1044 | element->GetInputListOnNodes(drainage_int,WaterfractionDrainageIntegratedEnum);
|
---|
| 1045 | element->GetInputListOnNodes(thicknesses,ThicknessEnum);
|
---|
| 1046 | for(k=0;k<numnodes;k++){
|
---|
| 1047 | drainage_int[k]*=thicknesses[k];
|
---|
| 1048 | }
|
---|
| 1049 | element->AddInput(WaterfractionDrainageIntegratedEnum, drainage_int, element->GetElementType());
|
---|
[17166] | 1050 |
|
---|
[21721] | 1051 | xDelete<IssmDouble>(drainage_int);
|
---|
| 1052 | xDelete<IssmDouble>(thicknesses);
|
---|
| 1053 | }
|
---|
[17434] | 1054 |
|
---|
[21721] | 1055 | /*update water column*/
|
---|
| 1056 | for(i=0;i<femmodel->elements->Size();i++){
|
---|
| 1057 | element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
|
---|
| 1058 | /* Check if ice in element */
|
---|
| 1059 | if(!element->IsIceInElement()) continue;
|
---|
| 1060 | if(!element->IsOnBase()) continue;
|
---|
[17166] | 1061 |
|
---|
[21721] | 1062 | numnodes=element->GetNumberOfNodes();
|
---|
| 1063 | IssmDouble* watercolumn= xNew<IssmDouble>(numnodes);
|
---|
| 1064 | IssmDouble* drainage_int= xNew<IssmDouble>(numnodes);
|
---|
| 1065 | element->GetInputListOnNodes(watercolumn,WatercolumnEnum);
|
---|
| 1066 | element->GetInputListOnNodes(drainage_int,WaterfractionDrainageIntegratedEnum);
|
---|
[17166] | 1067 |
|
---|
[21721] | 1068 | element->BasalNodeIndices(&numbasalnodes,&basalnodeindices,element->GetElementType());
|
---|
| 1069 | for(k=0;k<numbasalnodes;k++){
|
---|
| 1070 | watercolumn[basalnodeindices[k]]+=dt*drainage_int[basalnodeindices[k]];
|
---|
| 1071 | }
|
---|
| 1072 | element->AddInput(WatercolumnEnum, watercolumn, element->GetElementType());
|
---|
[17166] | 1073 |
|
---|
[21721] | 1074 | xDelete<IssmDouble>(watercolumn);
|
---|
| 1075 | xDelete<IssmDouble>(drainage_int);
|
---|
[21779] | 1076 | xDelete<int>(basalnodeindices);
|
---|
[21721] | 1077 | }
|
---|
| 1078 | }/*}}}*/
|
---|
| 1079 | void EnthalpyAnalysis::DrainageUpdateEnthalpy(FemModel* femmodel){/*{{{*/
|
---|
[17166] | 1080 |
|
---|
[21721] | 1081 | int i,k,numnodes;
|
---|
| 1082 | IssmDouble dt;
|
---|
| 1083 | Element* element= NULL;
|
---|
| 1084 | femmodel->parameters->FindParam(&dt,TimesteppingTimeStepEnum);
|
---|
[17166] | 1085 |
|
---|
[21721] | 1086 | for(i=0;i<femmodel->elements->Size();i++){
|
---|
| 1087 | element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
|
---|
| 1088 | numnodes=element->GetNumberOfNodes();
|
---|
| 1089 | IssmDouble* enthalpies= xNew<IssmDouble>(numnodes);
|
---|
| 1090 | IssmDouble* pressures= xNew<IssmDouble>(numnodes);
|
---|
| 1091 | IssmDouble* temperatures= xNew<IssmDouble>(numnodes);
|
---|
| 1092 | IssmDouble* waterfractions= xNew<IssmDouble>(numnodes);
|
---|
| 1093 | IssmDouble* drainage= xNew<IssmDouble>(numnodes);
|
---|
[21653] | 1094 |
|
---|
[21721] | 1095 | element->GetInputListOnNodes(pressures,PressureEnum);
|
---|
| 1096 | element->GetInputListOnNodes(temperatures,TemperatureEnum);
|
---|
| 1097 | element->GetInputListOnNodes(waterfractions,WaterfractionEnum);
|
---|
| 1098 | element->GetInputListOnNodes(drainage,WaterfractionDrainageEnum);
|
---|
[21653] | 1099 |
|
---|
[21721] | 1100 | for(k=0;k<numnodes;k++){
|
---|
| 1101 | waterfractions[k]-=dt*drainage[k];
|
---|
| 1102 | element->ThermalToEnthalpy(&enthalpies[k], temperatures[k], waterfractions[k], pressures[k]);
|
---|
| 1103 | }
|
---|
| 1104 | element->AddInput(WaterfractionEnum,waterfractions,element->GetElementType());
|
---|
| 1105 | element->AddInput(EnthalpyEnum,enthalpies,element->GetElementType());
|
---|
[17166] | 1106 |
|
---|
[21721] | 1107 | xDelete<IssmDouble>(enthalpies);
|
---|
| 1108 | xDelete<IssmDouble>(pressures);
|
---|
| 1109 | xDelete<IssmDouble>(temperatures);
|
---|
| 1110 | xDelete<IssmDouble>(waterfractions);
|
---|
| 1111 | xDelete<IssmDouble>(drainage);
|
---|
| 1112 | }
|
---|
[17002] | 1113 | }/*}}}*/
|
---|
[18930] | 1114 | IssmDouble EnthalpyAnalysis::EnthalpyDiffusionParameter(Element* element,IssmDouble enthalpy,IssmDouble pressure){/*{{{*/
|
---|
[17014] | 1115 |
|
---|
[18930] | 1116 | IssmDouble heatcapacity = element->GetMaterialParameter(MaterialsHeatcapacityEnum);
|
---|
| 1117 | IssmDouble temperateiceconductivity = element->GetMaterialParameter(MaterialsTemperateiceconductivityEnum);
|
---|
| 1118 | IssmDouble thermalconductivity = element->GetMaterialParameter(MaterialsThermalconductivityEnum);
|
---|
[17434] | 1119 |
|
---|
[18930] | 1120 | if(enthalpy < PureIceEnthalpy(element,pressure)){
|
---|
| 1121 | return thermalconductivity/heatcapacity;
|
---|
| 1122 | }
|
---|
| 1123 | else{
|
---|
| 1124 | return temperateiceconductivity/heatcapacity;
|
---|
| 1125 | }
|
---|
| 1126 | }/*}}}*/
|
---|
| 1127 | IssmDouble EnthalpyAnalysis::EnthalpyDiffusionParameterVolume(Element* element,int enthalpy_enum){/*{{{*/
|
---|
[17014] | 1128 |
|
---|
[18930] | 1129 | int iv;
|
---|
| 1130 | IssmDouble lambda; /* fraction of cold ice */
|
---|
| 1131 | IssmDouble kappa,kappa_c,kappa_t; /* enthalpy conductivities */
|
---|
| 1132 | IssmDouble Hc,Ht;
|
---|
[17014] | 1133 |
|
---|
[18930] | 1134 | /*Get pressures and enthalpies on vertices*/
|
---|
| 1135 | int numvertices = element->GetNumberOfVertices();
|
---|
| 1136 | IssmDouble* pressures = xNew<IssmDouble>(numvertices);
|
---|
| 1137 | IssmDouble* enthalpies = xNew<IssmDouble>(numvertices);
|
---|
| 1138 | IssmDouble* PIE = xNew<IssmDouble>(numvertices);
|
---|
| 1139 | IssmDouble* dHpmp = xNew<IssmDouble>(numvertices);
|
---|
[17014] | 1140 | element->GetInputListOnVertices(pressures,PressureEnum);
|
---|
[18930] | 1141 | element->GetInputListOnVertices(enthalpies,enthalpy_enum);
|
---|
| 1142 | for(iv=0;iv<numvertices;iv++){
|
---|
| 1143 | PIE[iv] = PureIceEnthalpy(element,pressures[iv]);
|
---|
| 1144 | dHpmp[iv] = enthalpies[iv]-PIE[iv];
|
---|
| 1145 | }
|
---|
[17014] | 1146 |
|
---|
[18930] | 1147 | bool allequalsign = true;
|
---|
| 1148 | if(dHpmp[0]<0.){
|
---|
| 1149 | for(iv=1; iv<numvertices;iv++) allequalsign=(allequalsign && (dHpmp[iv]<0.));
|
---|
[17014] | 1150 | }
|
---|
[18930] | 1151 | else{
|
---|
| 1152 | for(iv=1; iv<numvertices;iv++) allequalsign=(allequalsign && (dHpmp[iv]>=0.));
|
---|
[17014] | 1153 | }
|
---|
| 1154 |
|
---|
[18930] | 1155 | if(allequalsign){
|
---|
| 1156 | kappa = EnthalpyDiffusionParameter(element,enthalpies[0],pressures[0]);
|
---|
[17014] | 1157 | }
|
---|
[18930] | 1158 | else{
|
---|
| 1159 | /* return harmonic mean of thermal conductivities, weighted by fraction of cold/temperate ice,
|
---|
| 1160 | cf Patankar 1980, pp44 */
|
---|
| 1161 | kappa_c = EnthalpyDiffusionParameter(element,PureIceEnthalpy(element,0.)-1.,0.);
|
---|
| 1162 | kappa_t = EnthalpyDiffusionParameter(element,PureIceEnthalpy(element,0.)+1.,0.);
|
---|
| 1163 | Hc=0.; Ht=0.;
|
---|
| 1164 | for(iv=0; iv<numvertices;iv++){
|
---|
| 1165 | if(enthalpies[iv]<PIE[iv])
|
---|
| 1166 | Hc+=(PIE[iv]-enthalpies[iv]);
|
---|
| 1167 | else
|
---|
| 1168 | Ht+=(enthalpies[iv]-PIE[iv]);
|
---|
| 1169 | }
|
---|
| 1170 | _assert_((Hc+Ht)>0.);
|
---|
| 1171 | lambda = Hc/(Hc+Ht);
|
---|
| 1172 | kappa = kappa_c*kappa_t/(lambda*kappa_t+(1.-lambda)*kappa_c); // ==(lambda/kappa_c + (1.-lambda)/kappa_t)^-1
|
---|
| 1173 | }
|
---|
[17014] | 1174 |
|
---|
| 1175 | /*Clean up and return*/
|
---|
[18930] | 1176 | xDelete<IssmDouble>(PIE);
|
---|
| 1177 | xDelete<IssmDouble>(dHpmp);
|
---|
| 1178 | xDelete<IssmDouble>(pressures);
|
---|
[17014] | 1179 | xDelete<IssmDouble>(enthalpies);
|
---|
[18930] | 1180 | return kappa;
|
---|
[17002] | 1181 | }/*}}}*/
|
---|
[18930] | 1182 | void EnthalpyAnalysis::GetBAdvec(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/
|
---|
| 1183 | /*Compute B matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF1.
|
---|
| 1184 | * For node i, Bi' can be expressed in the actual coordinate system
|
---|
| 1185 | * by:
|
---|
| 1186 | * Bi_advec =[ h ]
|
---|
| 1187 | * [ h ]
|
---|
| 1188 | * [ h ]
|
---|
| 1189 | * where h is the interpolation function for node i.
|
---|
| 1190 | *
|
---|
| 1191 | * We assume B has been allocated already, of size: 3x(NDOF1*NUMNODESP1)
|
---|
| 1192 | */
|
---|
[18659] | 1193 |
|
---|
[18930] | 1194 | /*Fetch number of nodes for this finite element*/
|
---|
| 1195 | int numnodes = element->GetNumberOfNodes();
|
---|
[18659] | 1196 |
|
---|
[18930] | 1197 | /*Get nodal functions*/
|
---|
| 1198 | IssmDouble* basis=xNew<IssmDouble>(numnodes);
|
---|
| 1199 | element->NodalFunctions(basis,gauss);
|
---|
[18659] | 1200 |
|
---|
[18930] | 1201 | /*Build B: */
|
---|
| 1202 | for(int i=0;i<numnodes;i++){
|
---|
| 1203 | B[numnodes*0+i] = basis[i];
|
---|
| 1204 | B[numnodes*1+i] = basis[i];
|
---|
| 1205 | B[numnodes*2+i] = basis[i];
|
---|
[18659] | 1206 | }
|
---|
| 1207 |
|
---|
[18930] | 1208 | /*Clean-up*/
|
---|
| 1209 | xDelete<IssmDouble>(basis);
|
---|
[18612] | 1210 | }/*}}}*/
|
---|
[18930] | 1211 | void EnthalpyAnalysis::GetBAdvecprime(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/
|
---|
| 1212 | /*Compute B matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF1.
|
---|
| 1213 | * For node i, Bi' can be expressed in the actual coordinate system
|
---|
| 1214 | * by:
|
---|
| 1215 | * Biprime_advec=[ dh/dx ]
|
---|
| 1216 | * [ dh/dy ]
|
---|
| 1217 | * [ dh/dz ]
|
---|
| 1218 | * where h is the interpolation function for node i.
|
---|
| 1219 | *
|
---|
| 1220 | * We assume B has been allocated already, of size: 3x(NDOF1*numnodes)
|
---|
| 1221 | */
|
---|
[17002] | 1222 |
|
---|
[18930] | 1223 | /*Fetch number of nodes for this finite element*/
|
---|
| 1224 | int numnodes = element->GetNumberOfNodes();
|
---|
[17434] | 1225 |
|
---|
[18930] | 1226 | /*Get nodal functions derivatives*/
|
---|
| 1227 | IssmDouble* dbasis=xNew<IssmDouble>(3*numnodes);
|
---|
| 1228 | element->NodalFunctionsDerivatives(dbasis,xyz_list,gauss);
|
---|
[17434] | 1229 |
|
---|
[18930] | 1230 | /*Build B: */
|
---|
| 1231 | for(int i=0;i<numnodes;i++){
|
---|
| 1232 | B[numnodes*0+i] = dbasis[0*numnodes+i];
|
---|
| 1233 | B[numnodes*1+i] = dbasis[1*numnodes+i];
|
---|
| 1234 | B[numnodes*2+i] = dbasis[2*numnodes+i];
|
---|
[18659] | 1235 | }
|
---|
| 1236 |
|
---|
[18930] | 1237 | /*Clean-up*/
|
---|
| 1238 | xDelete<IssmDouble>(dbasis);
|
---|
[18659] | 1239 | }/*}}}*/
|
---|
[18930] | 1240 | void EnthalpyAnalysis::GetBasalConstraints(Vector<IssmDouble>* vec_spc,Element* element){/*{{{*/
|
---|
[18659] | 1241 |
|
---|
| 1242 | /*Intermediary*/
|
---|
| 1243 | bool isdynamicbasalspc;
|
---|
[18612] | 1244 | IssmDouble dt;
|
---|
| 1245 |
|
---|
| 1246 | /*Check wether dynamic basal boundary conditions are activated */
|
---|
| 1247 | element->FindParam(&isdynamicbasalspc,ThermalIsdynamicbasalspcEnum);
|
---|
| 1248 | if(!isdynamicbasalspc) return;
|
---|
| 1249 |
|
---|
| 1250 | element->FindParam(&dt,TimesteppingTimeStepEnum);
|
---|
| 1251 | if(dt==0.){
|
---|
[18659] | 1252 | GetBasalConstraintsSteadystate(vec_spc,element);
|
---|
[18612] | 1253 | }
|
---|
| 1254 | else{
|
---|
[18659] | 1255 | GetBasalConstraintsTransient(vec_spc,element);
|
---|
[18612] | 1256 | }
|
---|
| 1257 | }/*}}}*/
|
---|
[18930] | 1258 | void EnthalpyAnalysis::GetBasalConstraintsSteadystate(Vector<IssmDouble>* vec_spc,Element* element){/*{{{*/
|
---|
[18612] | 1259 |
|
---|
| 1260 | /* Check if ice in element */
|
---|
| 1261 | if(!element->IsIceInElement()) return;
|
---|
| 1262 |
|
---|
[20213] | 1263 | /* Only update constraints at the base.
|
---|
| 1264 | * Floating ice is not affected by basal BC decision chart. */
|
---|
[18612] | 1265 | if(!(element->IsOnBase()) || element->IsFloating()) return;
|
---|
| 1266 |
|
---|
| 1267 | /*Intermediary*/
|
---|
| 1268 | int numindices, numindicesup, state;
|
---|
[17027] | 1269 | int *indices = NULL, *indicesup = NULL;
|
---|
[18612] | 1270 | IssmDouble enthalpy, enthalpyup, pressure, pressureup, watercolumn, meltingrate;
|
---|
[17014] | 1271 |
|
---|
[18612] | 1272 | /*Get parameters and inputs: */
|
---|
[18930] | 1273 | Input* enthalpy_input = element->GetInput(EnthalpyPicardEnum); _assert_(enthalpy_input);
|
---|
[18612] | 1274 | Input* pressure_input = element->GetInput(PressureEnum); _assert_(pressure_input);
|
---|
| 1275 | Input* watercolumn_input = element->GetInput(WatercolumnEnum); _assert_(watercolumn_input);
|
---|
| 1276 | Input* meltingrate_input = element->GetInput(BasalforcingsGroundediceMeltingRateEnum); _assert_(meltingrate_input);
|
---|
| 1277 |
|
---|
[17027] | 1278 | /*Fetch indices of basal & surface nodes for this finite element*/
|
---|
| 1279 | Penta *penta = (Penta *) element; // TODO: add Basal-/SurfaceNodeIndices to element.h, and change this to Element*
|
---|
| 1280 | penta->BasalNodeIndices(&numindices,&indices,element->GetElementType());
|
---|
[18612] | 1281 | penta->SurfaceNodeIndices(&numindicesup,&indicesup,element->GetElementType()); _assert_(numindices==numindicesup);
|
---|
[17014] | 1282 |
|
---|
[18612] | 1283 | GaussPenta* gauss=new GaussPenta();
|
---|
| 1284 | GaussPenta* gaussup=new GaussPenta();
|
---|
| 1285 | for(int i=0;i<numindices;i++){
|
---|
| 1286 | gauss->GaussNode(element->GetElementType(),indices[i]);
|
---|
| 1287 | gaussup->GaussNode(element->GetElementType(),indicesup[i]);
|
---|
[18930] | 1288 |
|
---|
[18612] | 1289 | enthalpy_input->GetInputValue(&enthalpy,gauss);
|
---|
| 1290 | enthalpy_input->GetInputValue(&enthalpyup,gaussup);
|
---|
| 1291 | pressure_input->GetInputValue(&pressure,gauss);
|
---|
| 1292 | pressure_input->GetInputValue(&pressureup,gaussup);
|
---|
| 1293 | watercolumn_input->GetInputValue(&watercolumn,gauss);
|
---|
| 1294 | meltingrate_input->GetInputValue(&meltingrate,gauss);
|
---|
| 1295 |
|
---|
| 1296 | state=GetThermalBasalCondition(element, enthalpy, enthalpyup, pressure, pressureup, watercolumn, meltingrate);
|
---|
| 1297 | switch (state) {
|
---|
| 1298 | case 0:
|
---|
| 1299 | // cold, dry base: apply basal surface forcing
|
---|
[18659] | 1300 | vec_spc->SetValue(element->nodes[i]->Sid(),0.,INS_VAL);
|
---|
[18612] | 1301 | break;
|
---|
| 1302 | case 1:
|
---|
| 1303 | // cold, wet base: keep at pressure melting point
|
---|
[18659] | 1304 | vec_spc->SetValue(element->nodes[i]->Sid(),1.,INS_VAL);
|
---|
[18612] | 1305 | break;
|
---|
| 1306 | case 2:
|
---|
[20098] | 1307 | // temperate, thin refreezing base:
|
---|
| 1308 | vec_spc->SetValue(element->nodes[i]->Sid(),1.,INS_VAL);
|
---|
[18612] | 1309 | break;
|
---|
| 1310 | case 3:
|
---|
| 1311 | // temperate, thin melting base: set spc
|
---|
[18659] | 1312 | vec_spc->SetValue(element->nodes[i]->Sid(),1.,INS_VAL);
|
---|
[18612] | 1313 | break;
|
---|
| 1314 | case 4:
|
---|
[20098] | 1315 | // temperate, thick melting base:
|
---|
[18930] | 1316 | vec_spc->SetValue(element->nodes[i]->Sid(),1.,INS_VAL);
|
---|
[18612] | 1317 | break;
|
---|
| 1318 | default:
|
---|
| 1319 | _printf0_(" unknown thermal basal state found!");
|
---|
| 1320 | }
|
---|
| 1321 | }
|
---|
| 1322 |
|
---|
| 1323 | /*Free ressources:*/
|
---|
| 1324 | xDelete<int>(indices);
|
---|
| 1325 | xDelete<int>(indicesup);
|
---|
| 1326 | delete gauss;
|
---|
| 1327 | delete gaussup;
|
---|
| 1328 | }/*}}}*/
|
---|
[18930] | 1329 | void EnthalpyAnalysis::GetBasalConstraintsTransient(Vector<IssmDouble>* vec_spc,Element* element){/*{{{*/
|
---|
[18612] | 1330 |
|
---|
| 1331 | /* Check if ice in element */
|
---|
| 1332 | if(!element->IsIceInElement()) return;
|
---|
| 1333 |
|
---|
[20213] | 1334 | /* Only update constraints at the base.
|
---|
| 1335 | * Floating ice is not affected by basal BC decision chart.*/
|
---|
[18612] | 1336 | if(!(element->IsOnBase()) || element->IsFloating()) return;
|
---|
| 1337 |
|
---|
| 1338 | /*Intermediary*/
|
---|
| 1339 | int numindices, numindicesup, state;
|
---|
| 1340 | int *indices = NULL, *indicesup = NULL;
|
---|
| 1341 | IssmDouble enthalpy, enthalpyup, pressure, pressureup, watercolumn, meltingrate;
|
---|
| 1342 |
|
---|
[17027] | 1343 | /*Get parameters and inputs: */
|
---|
[18930] | 1344 | Input* enthalpy_input = element->GetInput(EnthalpyEnum); _assert_(enthalpy_input); //TODO: check EnthalpyPicard?
|
---|
[18612] | 1345 | Input* pressure_input = element->GetInput(PressureEnum); _assert_(pressure_input);
|
---|
| 1346 | Input* watercolumn_input = element->GetInput(WatercolumnEnum); _assert_(watercolumn_input);
|
---|
| 1347 | Input* meltingrate_input = element->GetInput(BasalforcingsGroundediceMeltingRateEnum); _assert_(meltingrate_input);
|
---|
[17014] | 1348 |
|
---|
[18612] | 1349 | /*Fetch indices of basal & surface nodes for this finite element*/
|
---|
| 1350 | Penta *penta = (Penta *) element; // TODO: add Basal-/SurfaceNodeIndices to element.h, and change this to Element*
|
---|
| 1351 | penta->BasalNodeIndices(&numindices,&indices,element->GetElementType());
|
---|
| 1352 | penta->SurfaceNodeIndices(&numindicesup,&indicesup,element->GetElementType()); _assert_(numindices==numindicesup);
|
---|
| 1353 |
|
---|
[17027] | 1354 | GaussPenta* gauss=new GaussPenta();
|
---|
| 1355 | GaussPenta* gaussup=new GaussPenta();
|
---|
[18930] | 1356 |
|
---|
[17027] | 1357 | for(int i=0;i<numindices;i++){
|
---|
| 1358 | gauss->GaussNode(element->GetElementType(),indices[i]);
|
---|
| 1359 | gaussup->GaussNode(element->GetElementType(),indicesup[i]);
|
---|
[18930] | 1360 |
|
---|
[18612] | 1361 | enthalpy_input->GetInputValue(&enthalpy,gauss);
|
---|
| 1362 | enthalpy_input->GetInputValue(&enthalpyup,gaussup);
|
---|
| 1363 | pressure_input->GetInputValue(&pressure,gauss);
|
---|
| 1364 | pressure_input->GetInputValue(&pressureup,gaussup);
|
---|
[17027] | 1365 | watercolumn_input->GetInputValue(&watercolumn,gauss);
|
---|
[18612] | 1366 | meltingrate_input->GetInputValue(&meltingrate,gauss);
|
---|
| 1367 |
|
---|
| 1368 | state=GetThermalBasalCondition(element, enthalpy, enthalpyup, pressure, pressureup, watercolumn, meltingrate);
|
---|
[18930] | 1369 |
|
---|
[18612] | 1370 | switch (state) {
|
---|
| 1371 | case 0:
|
---|
| 1372 | // cold, dry base: apply basal surface forcing
|
---|
[18659] | 1373 | vec_spc->SetValue(element->nodes[i]->Sid(),0.,INS_VAL);
|
---|
[18612] | 1374 | break;
|
---|
| 1375 | case 1:
|
---|
| 1376 | // cold, wet base: keep at pressure melting point
|
---|
[18659] | 1377 | vec_spc->SetValue(element->nodes[i]->Sid(),1.,INS_VAL);
|
---|
[18612] | 1378 | break;
|
---|
| 1379 | case 2:
|
---|
| 1380 | // temperate, thin refreezing base: release spc
|
---|
[18659] | 1381 | vec_spc->SetValue(element->nodes[i]->Sid(),0.,INS_VAL);
|
---|
[18612] | 1382 | break;
|
---|
| 1383 | case 3:
|
---|
| 1384 | // temperate, thin melting base: set spc
|
---|
[18659] | 1385 | vec_spc->SetValue(element->nodes[i]->Sid(),1.,INS_VAL);
|
---|
[18612] | 1386 | break;
|
---|
| 1387 | case 4:
|
---|
[18930] | 1388 | // temperate, thick melting base: set grad H*n=0
|
---|
| 1389 | vec_spc->SetValue(element->nodes[i]->Sid(),0.,INS_VAL);
|
---|
[18612] | 1390 | break;
|
---|
| 1391 | default:
|
---|
| 1392 | _printf0_(" unknown thermal basal state found!");
|
---|
[17027] | 1393 | }
|
---|
[18930] | 1394 |
|
---|
[17027] | 1395 | }
|
---|
[17014] | 1396 |
|
---|
[17027] | 1397 | /*Free ressources:*/
|
---|
| 1398 | xDelete<int>(indices);
|
---|
| 1399 | xDelete<int>(indicesup);
|
---|
| 1400 | delete gauss;
|
---|
| 1401 | delete gaussup;
|
---|
[17002] | 1402 | }/*}}}*/
|
---|
[18930] | 1403 | void EnthalpyAnalysis::GetBConduct(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/
|
---|
| 1404 | /*Compute B matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF1.
|
---|
| 1405 | * For node i, Bi' can be expressed in the actual coordinate system
|
---|
| 1406 | * by:
|
---|
| 1407 | * Bi_conduct=[ dh/dx ]
|
---|
| 1408 | * [ dh/dy ]
|
---|
| 1409 | * [ dh/dz ]
|
---|
| 1410 | * where h is the interpolation function for node i.
|
---|
| 1411 | *
|
---|
| 1412 | * We assume B has been allocated already, of size: 3x(NDOF1*numnodes)
|
---|
| 1413 | */
|
---|
[17002] | 1414 |
|
---|
[18930] | 1415 | /*Fetch number of nodes for this finite element*/
|
---|
| 1416 | int numnodes = element->GetNumberOfNodes();
|
---|
| 1417 |
|
---|
| 1418 | /*Get nodal functions derivatives*/
|
---|
| 1419 | IssmDouble* dbasis=xNew<IssmDouble>(3*numnodes);
|
---|
| 1420 | element->NodalFunctionsDerivatives(dbasis,xyz_list,gauss);
|
---|
| 1421 |
|
---|
| 1422 | /*Build B: */
|
---|
| 1423 | for(int i=0;i<numnodes;i++){
|
---|
| 1424 | B[numnodes*0+i] = dbasis[0*numnodes+i];
|
---|
| 1425 | B[numnodes*1+i] = dbasis[1*numnodes+i];
|
---|
| 1426 | B[numnodes*2+i] = dbasis[2*numnodes+i];
|
---|
| 1427 | }
|
---|
| 1428 |
|
---|
| 1429 | /*Clean-up*/
|
---|
| 1430 | xDelete<IssmDouble>(dbasis);
|
---|
| 1431 | }/*}}}*/
|
---|
| 1432 | void EnthalpyAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/
|
---|
| 1433 | element->GetSolutionFromInputsOneDof(solution,EnthalpyEnum);
|
---|
| 1434 | }/*}}}*/
|
---|
| 1435 | int EnthalpyAnalysis::GetThermalBasalCondition(Element* element, IssmDouble enthalpy, IssmDouble enthalpyup, IssmDouble pressure, IssmDouble pressureup, IssmDouble watercolumn, IssmDouble meltingrate){/*{{{*/
|
---|
| 1436 |
|
---|
[18612] | 1437 | /* Check if ice in element */
|
---|
| 1438 | if(!element->IsIceInElement()) return -1;
|
---|
| 1439 |
|
---|
| 1440 | /* Only update Constraints at the base of grounded ice*/
|
---|
| 1441 | if(!(element->IsOnBase())) return -1;
|
---|
| 1442 |
|
---|
| 1443 | /*Intermediary*/
|
---|
| 1444 | int state=-1;
|
---|
| 1445 | IssmDouble dt;
|
---|
| 1446 |
|
---|
| 1447 | /*Get parameters and inputs: */
|
---|
| 1448 | element->FindParam(&dt,TimesteppingTimeStepEnum);
|
---|
| 1449 |
|
---|
[18620] | 1450 | if(enthalpy<PureIceEnthalpy(element,pressure)){
|
---|
| 1451 | if(watercolumn<=0.) state=0; // cold, dry base
|
---|
| 1452 | else state=1; // cold, wet base (refreezing)
|
---|
[18612] | 1453 | }
|
---|
[18620] | 1454 | else{
|
---|
| 1455 | if(enthalpyup<PureIceEnthalpy(element,pressureup)){
|
---|
| 1456 | if((dt==0.) && (meltingrate<0.)) state=2; // refreezing temperate base (non-physical, only for steadystate solver)
|
---|
| 1457 | else state=3; // temperate base, but no temperate layer
|
---|
[18612] | 1458 | }
|
---|
[18620] | 1459 | else state=4; // temperate layer with positive thickness
|
---|
[18612] | 1460 | }
|
---|
| 1461 |
|
---|
| 1462 | _assert_(state>=0);
|
---|
| 1463 | return state;
|
---|
| 1464 | }/*}}}*/
|
---|
[18930] | 1465 | IssmDouble EnthalpyAnalysis::GetWetIceConductivity(Element* element, IssmDouble enthalpy, IssmDouble pressure){/*{{{*/
|
---|
[18612] | 1466 |
|
---|
| 1467 | IssmDouble temperature, waterfraction;
|
---|
| 1468 | IssmDouble kappa_w = 0.6; // thermal conductivity of water (in W/m/K)
|
---|
| 1469 | IssmDouble kappa_i = element->GetMaterialParameter(MaterialsThermalconductivityEnum);
|
---|
| 1470 | element->EnthalpyToThermal(&temperature, &waterfraction, enthalpy, pressure);
|
---|
| 1471 |
|
---|
| 1472 | return (1.-waterfraction)*kappa_i + waterfraction*kappa_w;
|
---|
| 1473 | }/*}}}*/
|
---|
[18930] | 1474 | void EnthalpyAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/
|
---|
| 1475 | _error_("Not implemented yet");
|
---|
| 1476 | }/*}}}*/
|
---|
| 1477 | void EnthalpyAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/
|
---|
[18612] | 1478 |
|
---|
[18930] | 1479 | bool converged;
|
---|
| 1480 | int i,rheology_law;
|
---|
| 1481 | IssmDouble B_average,s_average,T_average=0.,P_average=0.;
|
---|
[21382] | 1482 | IssmDouble n=3.0;
|
---|
[18930] | 1483 | int *doflist = NULL;
|
---|
| 1484 | IssmDouble *xyz_list = NULL;
|
---|
[16888] | 1485 |
|
---|
[18930] | 1486 | /*Fetch number of nodes and dof for this finite element*/
|
---|
| 1487 | int numnodes = element->GetNumberOfNodes();
|
---|
[16888] | 1488 |
|
---|
[18930] | 1489 | /*Fetch dof list and allocate solution vector*/
|
---|
| 1490 | element->GetDofList(&doflist,NoneApproximationEnum,GsetEnum);
|
---|
| 1491 | IssmDouble* values = xNew<IssmDouble>(numnodes);
|
---|
| 1492 | IssmDouble* pressure = xNew<IssmDouble>(numnodes);
|
---|
| 1493 | IssmDouble* surface = xNew<IssmDouble>(numnodes);
|
---|
| 1494 | IssmDouble* B = xNew<IssmDouble>(numnodes);
|
---|
| 1495 | IssmDouble* temperature = xNew<IssmDouble>(numnodes);
|
---|
| 1496 | IssmDouble* waterfraction = xNew<IssmDouble>(numnodes);
|
---|
[16888] | 1497 |
|
---|
[18930] | 1498 | /*Use the dof list to index into the solution vector: */
|
---|
| 1499 | for(i=0;i<numnodes;i++){
|
---|
| 1500 | values[i]=solution[doflist[i]];
|
---|
[16888] | 1501 |
|
---|
[18930] | 1502 | /*Check solution*/
|
---|
| 1503 | if(xIsNan<IssmDouble>(values[i])) _error_("NaN found in solution vector");
|
---|
[20669] | 1504 | if(xIsInf<IssmDouble>(values[i])) _error_("Inf found in solution vector");
|
---|
[16888] | 1505 | }
|
---|
| 1506 |
|
---|
[18930] | 1507 | /*Get all inputs and parameters*/
|
---|
[21382] | 1508 | if(element->material->ObjectEnum()!=MatestarEnum) n=element->GetMaterialParameter(MaterialsRheologyNEnum);
|
---|
[18930] | 1509 | element->GetInputValue(&converged,ConvergedEnum);
|
---|
| 1510 | element->GetInputListOnNodes(&pressure[0],PressureEnum);
|
---|
| 1511 | if(converged){
|
---|
| 1512 | for(i=0;i<numnodes;i++){
|
---|
| 1513 | element->EnthalpyToThermal(&temperature[i],&waterfraction[i],values[i],pressure[i]);
|
---|
| 1514 | if(waterfraction[i]<0.) _error_("Negative water fraction found in solution vector");
|
---|
| 1515 | //if(waterfraction[i]>1.) _error_("Water fraction >1 found in solution vector");
|
---|
| 1516 | }
|
---|
| 1517 | element->AddInput(EnthalpyEnum,values,element->GetElementType());
|
---|
| 1518 | element->AddInput(WaterfractionEnum,waterfraction,element->GetElementType());
|
---|
| 1519 | element->AddInput(TemperatureEnum,temperature,element->GetElementType());
|
---|
| 1520 |
|
---|
| 1521 | /*Update Rheology only if converged (we must make sure that the temperature is below melting point
|
---|
| 1522 | * otherwise the rheology could be negative*/
|
---|
| 1523 | element->FindParam(&rheology_law,MaterialsRheologyLawEnum);
|
---|
| 1524 | element->GetInputListOnNodes(&surface[0],SurfaceEnum);
|
---|
| 1525 | switch(rheology_law){
|
---|
| 1526 | case NoneEnum:
|
---|
| 1527 | /*Do nothing: B is not temperature dependent*/
|
---|
| 1528 | break;
|
---|
[21377] | 1529 | case BuddJackaEnum:
|
---|
| 1530 | for(i=0;i<numnodes;i++) B[i]=BuddJacka(temperature[i]);
|
---|
| 1531 | element->AddInput(MaterialsRheologyBEnum,&B[0],element->GetElementType());
|
---|
| 1532 | break;
|
---|
[18930] | 1533 | case CuffeyEnum:
|
---|
| 1534 | for(i=0;i<numnodes;i++) B[i]=Cuffey(temperature[i]);
|
---|
| 1535 | element->AddInput(MaterialsRheologyBEnum,&B[0],element->GetElementType());
|
---|
| 1536 | break;
|
---|
[20625] | 1537 | case CuffeyTemperateEnum:
|
---|
[21382] | 1538 | for(i=0;i<numnodes;i++) B[i]=CuffeyTemperate(temperature[i], waterfraction[i],n);
|
---|
[20625] | 1539 | element->AddInput(MaterialsRheologyBEnum,&B[0],element->GetElementType());
|
---|
| 1540 | break;
|
---|
[18930] | 1541 | case PatersonEnum:
|
---|
| 1542 | for(i=0;i<numnodes;i++) B[i]=Paterson(temperature[i]);
|
---|
| 1543 | element->AddInput(MaterialsRheologyBEnum,&B[0],element->GetElementType());
|
---|
| 1544 | break;
|
---|
| 1545 | case ArrheniusEnum:
|
---|
| 1546 | element->GetVerticesCoordinates(&xyz_list);
|
---|
[21382] | 1547 | for(i=0;i<numnodes;i++) B[i]=Arrhenius(temperature[i],surface[i]-xyz_list[i*3+2],n);
|
---|
[18930] | 1548 | element->AddInput(MaterialsRheologyBEnum,&B[0],element->GetElementType());
|
---|
| 1549 | break;
|
---|
| 1550 | case LliboutryDuvalEnum:
|
---|
[21382] | 1551 | for(i=0;i<numnodes;i++) B[i]=LliboutryDuval(values[i],pressure[i],n,element->GetMaterialParameter(MaterialsBetaEnum),element->GetMaterialParameter(ConstantsReferencetemperatureEnum),element->GetMaterialParameter(MaterialsHeatcapacityEnum),element->GetMaterialParameter(MaterialsLatentheatEnum));
|
---|
[18930] | 1552 | element->AddInput(MaterialsRheologyBEnum,&B[0],element->GetElementType());
|
---|
| 1553 | break;
|
---|
| 1554 | default: _error_("Rheology law " << EnumToStringx(rheology_law) << " not supported yet");
|
---|
| 1555 | }
|
---|
[16888] | 1556 | }
|
---|
| 1557 | else{
|
---|
[18930] | 1558 | element->AddInput(EnthalpyPicardEnum,values,element->GetElementType());
|
---|
[16888] | 1559 | }
|
---|
| 1560 |
|
---|
[18930] | 1561 | /*Free ressources:*/
|
---|
| 1562 | xDelete<IssmDouble>(values);
|
---|
| 1563 | xDelete<IssmDouble>(pressure);
|
---|
| 1564 | xDelete<IssmDouble>(surface);
|
---|
| 1565 | xDelete<IssmDouble>(B);
|
---|
| 1566 | xDelete<IssmDouble>(temperature);
|
---|
| 1567 | xDelete<IssmDouble>(waterfraction);
|
---|
| 1568 | xDelete<IssmDouble>(xyz_list);
|
---|
| 1569 | xDelete<int>(doflist);
|
---|
| 1570 | }/*}}}*/
|
---|
| 1571 | void EnthalpyAnalysis::PostProcessing(FemModel* femmodel){/*{{{*/
|
---|
[16888] | 1572 |
|
---|
[18930] | 1573 | /*Intermediaries*/
|
---|
| 1574 | bool computebasalmeltingrates=true;
|
---|
| 1575 | bool drainicecolumn=true;
|
---|
| 1576 | IssmDouble dt;
|
---|
| 1577 |
|
---|
| 1578 | femmodel->parameters->FindParam(&dt,TimesteppingTimeStepEnum);
|
---|
| 1579 |
|
---|
[21161] | 1580 | if(drainicecolumn && (dt>0.)) DrainWaterfraction(femmodel);
|
---|
[18930] | 1581 | if(computebasalmeltingrates) ComputeBasalMeltingrate(femmodel);
|
---|
| 1582 |
|
---|
[17027] | 1583 | }/*}}}*/
|
---|
[18930] | 1584 | IssmDouble EnthalpyAnalysis::PureIceEnthalpy(Element* element,IssmDouble pressure){/*{{{*/
|
---|
[16888] | 1585 |
|
---|
| 1586 | IssmDouble heatcapacity = element->GetMaterialParameter(MaterialsHeatcapacityEnum);
|
---|
| 1587 | IssmDouble referencetemperature = element->GetMaterialParameter(ConstantsReferencetemperatureEnum);
|
---|
| 1588 |
|
---|
| 1589 | return heatcapacity*(TMeltingPoint(element,pressure)-referencetemperature);
|
---|
| 1590 | }/*}}}*/
|
---|
[18930] | 1591 | IssmDouble EnthalpyAnalysis::TMeltingPoint(Element* element,IssmDouble pressure){/*{{{*/
|
---|
[16888] | 1592 |
|
---|
| 1593 | IssmDouble meltingpoint = element->GetMaterialParameter(MaterialsMeltingpointEnum);
|
---|
| 1594 | IssmDouble beta = element->GetMaterialParameter(MaterialsBetaEnum);
|
---|
| 1595 |
|
---|
| 1596 | return meltingpoint-beta*pressure;
|
---|
| 1597 | }/*}}}*/
|
---|
[18930] | 1598 | void EnthalpyAnalysis::UpdateBasalConstraints(FemModel* femmodel){/*{{{*/
|
---|
| 1599 |
|
---|
| 1600 | /*Update basal dirichlet BCs for enthalpy: */
|
---|
| 1601 | Vector<IssmDouble>* spc = NULL;
|
---|
| 1602 | IssmDouble* serial_spc = NULL;
|
---|
| 1603 |
|
---|
| 1604 | spc=new Vector<IssmDouble>(femmodel->nodes->NumberOfNodes(EnthalpyAnalysisEnum));
|
---|
| 1605 | /*First create a vector to figure out what elements should be constrained*/
|
---|
| 1606 | for(int i=0;i<femmodel->elements->Size();i++){
|
---|
| 1607 | Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
|
---|
| 1608 | GetBasalConstraints(spc,element);
|
---|
| 1609 | }
|
---|
| 1610 |
|
---|
| 1611 | /*Assemble and serialize*/
|
---|
| 1612 | spc->Assemble();
|
---|
| 1613 | serial_spc=spc->ToMPISerial();
|
---|
| 1614 | delete spc;
|
---|
| 1615 |
|
---|
| 1616 | /*Then update basal constraints nodes accordingly*/
|
---|
| 1617 | for(int i=0;i<femmodel->elements->Size();i++){
|
---|
| 1618 | Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
|
---|
| 1619 | ApplyBasalConstraints(serial_spc,element);
|
---|
| 1620 | }
|
---|
| 1621 |
|
---|
| 1622 | femmodel->UpdateConstraintsx();
|
---|
| 1623 |
|
---|
| 1624 | /*Delete*/
|
---|
| 1625 | xDelete<IssmDouble>(serial_spc);
|
---|
| 1626 | }/*}}}*/
|
---|
| 1627 | void EnthalpyAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/
|
---|
[20453] | 1628 | SetActiveNodesLSMx(femmodel);
|
---|
[18930] | 1629 | }/*}}}*/
|
---|