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