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