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