[19528] | 1 | #include "./SmbAnalysis.h"
|
---|
| 2 | #include "../toolkits/toolkits.h"
|
---|
| 3 | #include "../classes/classes.h"
|
---|
| 4 | #include "../shared/shared.h"
|
---|
| 5 | #include "../modules/modules.h"
|
---|
| 6 |
|
---|
[23317] | 7 | // FIX
|
---|
| 8 | #include "./shared/io/Print/Print.h"
|
---|
| 9 |
|
---|
[19528] | 10 | /*Model processing*/
|
---|
| 11 | void SmbAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/
|
---|
| 12 | /*No constraints*/
|
---|
| 13 | }/*}}}*/
|
---|
| 14 | void SmbAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/
|
---|
| 15 | /*No loads*/
|
---|
| 16 | }/*}}}*/
|
---|
[23585] | 17 | void SmbAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel,bool isamr){/*{{{*/
|
---|
[19528] | 18 | ::CreateNodes(nodes,iomodel,SmbAnalysisEnum,P1Enum);
|
---|
| 19 | }/*}}}*/
|
---|
| 20 | int SmbAnalysis::DofsPerNode(int** doflist,int domaintype,int approximation){/*{{{*/
|
---|
| 21 | return 1;
|
---|
| 22 | }/*}}}*/
|
---|
[25379] | 23 | void SmbAnalysis::UpdateElements(Elements* elements,Inputs* inputs,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/
|
---|
[23066] | 24 |
|
---|
[19528] | 25 | int smb_model;
|
---|
[26750] | 26 | bool isdelta18o,ismungsm,isd18opd,issetpddfac,isprecipscaled,istemperaturescaled,isfirnwarming,isstochastic;
|
---|
[23066] | 27 |
|
---|
[19528] | 28 | /*Update elements: */
|
---|
| 29 | int counter=0;
|
---|
| 30 | for(int i=0;i<iomodel->numberofelements;i++){
|
---|
| 31 | if(iomodel->my_elements[i]){
|
---|
| 32 | Element* element=(Element*)elements->GetObjectByOffset(counter);
|
---|
[25379] | 33 | element->Update(inputs,i,iomodel,analysis_counter,analysis_type,P1Enum);
|
---|
[19528] | 34 | counter++;
|
---|
| 35 | }
|
---|
| 36 | }
|
---|
[23066] | 37 |
|
---|
[19554] | 38 | /*Figure out smb model: */
|
---|
[20690] | 39 | iomodel->FindConstant(&smb_model,"md.smb.model");
|
---|
[26750] | 40 | iomodel->FindConstant(&isstochastic,"md.stochasticforcing.isstochasticforcing");
|
---|
[19528] | 41 | switch(smb_model){
|
---|
| 42 | case SMBforcingEnum:
|
---|
[25379] | 43 | iomodel->FetchDataToInput(inputs,elements,"md.smb.mass_balance",SmbMassBalanceEnum,0.);
|
---|
[26750] | 44 | if(isstochastic){
|
---|
| 45 | iomodel->FetchDataToInput(inputs,elements,"md.stochasticforcing.default_id",StochasticForcingDefaultIdEnum);
|
---|
| 46 | iomodel->FetchDataToInput(inputs,elements,"md.smb.mass_balance",BaselineSmbMassBalanceEnum,0.);
|
---|
| 47 | }
|
---|
[19528] | 48 | break;
|
---|
[19554] | 49 | case SMBgembEnum:
|
---|
[25379] | 50 | iomodel->FetchDataToInput(inputs,elements,"md.smb.Ta",SmbTaEnum);
|
---|
| 51 | iomodel->FetchDataToInput(inputs,elements,"md.smb.V",SmbVEnum);
|
---|
| 52 | iomodel->FetchDataToInput(inputs,elements,"md.smb.dswrf",SmbDswrfEnum);
|
---|
[25997] | 53 | iomodel->FetchDataToInput(inputs,elements,"md.smb.dswdiffrf",SmbDswdiffrfEnum);
|
---|
[25379] | 54 | iomodel->FetchDataToInput(inputs,elements,"md.smb.dlwrf",SmbDlwrfEnum);
|
---|
| 55 | iomodel->FetchDataToInput(inputs,elements,"md.smb.P",SmbPEnum);
|
---|
| 56 | iomodel->FetchDataToInput(inputs,elements,"md.smb.eAir",SmbEAirEnum);
|
---|
| 57 | iomodel->FetchDataToInput(inputs,elements,"md.smb.pAir",SmbPAirEnum);
|
---|
| 58 | iomodel->FetchDataToInput(inputs,elements,"md.smb.zTop",SmbZTopEnum);
|
---|
| 59 | iomodel->FetchDataToInput(inputs,elements,"md.smb.dzTop",SmbDzTopEnum);
|
---|
| 60 | iomodel->FetchDataToInput(inputs,elements,"md.smb.dzMin",SmbDzMinEnum);
|
---|
| 61 | iomodel->FetchDataToInput(inputs,elements,"md.smb.zY",SmbZYEnum);
|
---|
| 62 | iomodel->FetchDataToInput(inputs,elements,"md.smb.zMax",SmbZMaxEnum);
|
---|
| 63 | iomodel->FetchDataToInput(inputs,elements,"md.smb.zMin",SmbZMinEnum);
|
---|
| 64 | iomodel->FetchDataToInput(inputs,elements,"md.smb.Tmean",SmbTmeanEnum);
|
---|
| 65 | iomodel->FetchDataToInput(inputs,elements,"md.smb.Vmean",SmbVmeanEnum);
|
---|
| 66 | iomodel->FetchDataToInput(inputs,elements,"md.smb.C",SmbCEnum);
|
---|
| 67 | iomodel->FetchDataToInput(inputs,elements,"md.smb.Tz",SmbTzEnum);
|
---|
| 68 | iomodel->FetchDataToInput(inputs,elements,"md.smb.Vz",SmbVzEnum);
|
---|
| 69 | InputUpdateFromConstantx(inputs,elements,false,SmbIsInitializedEnum);
|
---|
| 70 | iomodel->FetchDataToInput(inputs,elements,"md.smb.Dzini",SmbDziniEnum);
|
---|
| 71 | iomodel->FetchDataToInput(inputs,elements,"md.smb.Dini",SmbDiniEnum);
|
---|
| 72 | iomodel->FetchDataToInput(inputs,elements,"md.smb.Reini",SmbReiniEnum);
|
---|
| 73 | iomodel->FetchDataToInput(inputs,elements,"md.smb.Gdnini",SmbGdniniEnum);
|
---|
| 74 | iomodel->FetchDataToInput(inputs,elements,"md.smb.Gspini",SmbGspiniEnum);
|
---|
| 75 | iomodel->FetchDataToInput(inputs,elements,"md.smb.ECini",SmbECiniEnum);
|
---|
| 76 | iomodel->FetchDataToInput(inputs,elements,"md.smb.Wini",SmbWiniEnum);
|
---|
| 77 | iomodel->FetchDataToInput(inputs,elements,"md.smb.Aini",SmbAiniEnum);
|
---|
[25997] | 78 | iomodel->FetchDataToInput(inputs,elements,"md.smb.Adiffini",SmbAdiffiniEnum);
|
---|
[25379] | 79 | iomodel->FetchDataToInput(inputs,elements,"md.smb.Tini",SmbTiniEnum);
|
---|
| 80 | iomodel->FetchDataToInput(inputs,elements,"md.smb.Sizeini",SmbSizeiniEnum);
|
---|
| 81 | iomodel->FetchDataToInput(inputs,elements,"md.smb.aValue",SmbAValueEnum);
|
---|
[26550] | 82 | iomodel->FetchDataToInput(inputs,elements,"md.smb.dulwrfValue",SmbDulwrfValueEnum);
|
---|
[25379] | 83 | iomodel->FetchDataToInput(inputs,elements,"md.smb.teValue",SmbTeValueEnum);
|
---|
[25997] | 84 | iomodel->FetchDataToInput(inputs,elements,"md.smb.szaValue",SmbSzaValueEnum);
|
---|
| 85 | iomodel->FetchDataToInput(inputs,elements,"md.smb.cotValue",SmbCotValueEnum);
|
---|
| 86 | iomodel->FetchDataToInput(inputs,elements,"md.smb.ccsnowValue",SmbCcsnowValueEnum);
|
---|
| 87 | iomodel->FetchDataToInput(inputs,elements,"md.smb.cciceValue",SmbCciceValueEnum);
|
---|
[19554] | 88 | break;
|
---|
[19528] | 89 | case SMBpddEnum:
|
---|
[20690] | 90 | iomodel->FindConstant(&isdelta18o,"md.smb.isdelta18o");
|
---|
| 91 | iomodel->FindConstant(&ismungsm,"md.smb.ismungsm");
|
---|
[25374] | 92 | iomodel->FindConstant(&issetpddfac,"md.smb.issetpddfac");
|
---|
[25379] | 93 | iomodel->FetchDataToInput(inputs,elements,"md.thermal.spctemperature",ThermalSpctemperatureEnum);
|
---|
| 94 | iomodel->FetchDataToInput(inputs,elements,"md.smb.s0p",SmbS0pEnum);
|
---|
| 95 | iomodel->FetchDataToInput(inputs,elements,"md.smb.s0t",SmbS0tEnum);
|
---|
[19528] | 96 | if(isdelta18o || ismungsm){
|
---|
[25379] | 97 | iomodel->FetchDataToDatasetInput(inputs,elements,"md.smb.temperatures_lgm",SmbTemperaturesLgmEnum);
|
---|
| 98 | iomodel->FetchDataToDatasetInput(inputs,elements,"md.smb.temperatures_presentday",SmbTemperaturesPresentdayEnum);
|
---|
| 99 | iomodel->FetchDataToDatasetInput(inputs,elements,"md.smb.precipitations_presentday",SmbPrecipitationsPresentdayEnum);
|
---|
| 100 | iomodel->FetchDataToDatasetInput(inputs,elements,"md.smb.precipitations_lgm",SmbPrecipitationsLgmEnum);
|
---|
[22852] | 101 | }else{
|
---|
[25379] | 102 | iomodel->FetchDataToDatasetInput(inputs,elements,"md.smb.precipitation",SmbPrecipitationEnum);
|
---|
| 103 | iomodel->FetchDataToDatasetInput(inputs,elements,"md.smb.monthlytemperatures",SmbMonthlytemperaturesEnum);
|
---|
[19528] | 104 | }
|
---|
[25374] | 105 | if(issetpddfac){
|
---|
[25379] | 106 | iomodel->FetchDataToInput(inputs,elements,"md.smb.pddfac_snow",SmbPddfacSnowEnum,-1.);
|
---|
| 107 | iomodel->FetchDataToInput(inputs,elements,"md.smb.pddfac_ice",SmbPddfacIceEnum,-1.);
|
---|
[25374] | 108 | }
|
---|
[19528] | 109 | break;
|
---|
[23317] | 110 | case SMBpddSicopolisEnum:
|
---|
[25379] | 111 | iomodel->FetchDataToInput(inputs,elements,"md.smb.s0p",SmbS0pEnum);
|
---|
| 112 | iomodel->FetchDataToInput(inputs,elements,"md.smb.s0t",SmbS0tEnum);
|
---|
[23317] | 113 | iomodel->FindConstant(&isfirnwarming,"md.smb.isfirnwarming");
|
---|
[25379] | 114 | iomodel->FetchDataToInput(inputs,elements,"md.smb.smb_corr",SmbSmbCorrEnum);
|
---|
| 115 | iomodel->FetchDataToInput(inputs,elements,"md.smb.precipitation_anomaly",SmbPrecipitationsAnomalyEnum);
|
---|
| 116 | iomodel->FetchDataToInput(inputs,elements,"md.smb.temperature_anomaly",SmbTemperaturesAnomalyEnum);
|
---|
| 117 | iomodel->FetchDataToDatasetInput(inputs,elements,"md.smb.monthlytemperatures",SmbMonthlytemperaturesEnum);
|
---|
| 118 | iomodel->FetchDataToDatasetInput(inputs,elements,"md.smb.precipitation",SmbPrecipitationEnum);
|
---|
[23317] | 119 | break;
|
---|
[19528] | 120 | case SMBd18opddEnum:
|
---|
[22852] | 121 | iomodel->FindConstant(&istemperaturescaled,"md.smb.istemperaturescaled");
|
---|
| 122 | iomodel->FindConstant(&isprecipscaled,"md.smb.isprecipscaled");
|
---|
[20690] | 123 | iomodel->FindConstant(&ismungsm,"md.smb.ismungsm");
|
---|
| 124 | iomodel->FindConstant(&isd18opd,"md.smb.isd18opd");
|
---|
[22448] | 125 | iomodel->FindConstant(&issetpddfac,"md.smb.issetpddfac");
|
---|
[25379] | 126 | iomodel->FetchDataToInput(inputs,elements,"md.thermal.spctemperature",ThermalSpctemperatureEnum);
|
---|
| 127 | iomodel->FetchDataToInput(inputs,elements,"md.smb.s0p",SmbS0pEnum);
|
---|
| 128 | iomodel->FetchDataToInput(inputs,elements,"md.smb.s0t",SmbS0tEnum);
|
---|
[20690] | 129 | if(isd18opd){
|
---|
[25379] | 130 | iomodel->FetchDataToDatasetInput(inputs,elements,"md.smb.temperatures_presentday",SmbTemperaturesPresentdayEnum);
|
---|
| 131 | iomodel->FetchDataToDatasetInput(inputs,elements,"md.smb.precipitations_presentday",SmbPrecipitationsPresentdayEnum);
|
---|
[22852] | 132 | if(!istemperaturescaled){
|
---|
[24626] | 133 | /*Fetch array*/
|
---|
| 134 | IssmDouble* doublearray = NULL;
|
---|
| 135 | int M,N;
|
---|
| 136 | iomodel->FetchData(&doublearray,&M,&N,"md.smb.temperatures_reconstructed");
|
---|
| 137 | if(M!=iomodel->numberofvertices+1) _error_("md.smb.temperatures_reconstructed should have nbv+1 rows");
|
---|
| 138 | if(N%12!=0) _error_("md.smb.temperatures_reconstructed should have a multiple of 12 columns (since it is monthly)");
|
---|
| 139 |
|
---|
| 140 | /*Build indices*/
|
---|
| 141 | int* ids = xNew<int>(N); for(int i=0;i<N;i++) ids[i] = i;
|
---|
| 142 |
|
---|
[25539] | 143 | for(Object* & object : elements->objects){
|
---|
| 144 | Element* element=xDynamicCast<Element*>(object);
|
---|
[25379] | 145 | element->DatasetInputCreate(doublearray,M-1,N,ids,N,inputs,iomodel,SmbTemperaturesReconstructedEnum);
|
---|
[24626] | 146 | }
|
---|
| 147 | xDelete<int>(ids);
|
---|
| 148 | iomodel->DeleteData(doublearray,"md.smb.temperatures_reconstructed");
|
---|
[22852] | 149 | }
|
---|
| 150 | if(!isprecipscaled){
|
---|
[24626] | 151 | /*Fetch array*/
|
---|
| 152 | IssmDouble* doublearray = NULL;
|
---|
| 153 | int M,N;
|
---|
| 154 | iomodel->FetchData(&doublearray,&M,&N,"md.smb.precipitations_reconstructed");
|
---|
| 155 | if(M!=iomodel->numberofvertices+1) _error_("md.smb.precipitations_reconstructed should have nbv+1 rows");
|
---|
| 156 | if(N%12!=0) _error_("md.smb.precipitations_reconstructed should have a multiple of 12 columns (since it is monthly)");
|
---|
| 157 |
|
---|
| 158 | /*Build indices*/
|
---|
| 159 | int* ids = xNew<int>(N); for(int i=0;i<N;i++) ids[i] = i;
|
---|
| 160 |
|
---|
[25539] | 161 | for(Object* & object : elements->objects){
|
---|
| 162 | Element* element=xDynamicCast<Element*>(object);
|
---|
[25379] | 163 | element->DatasetInputCreate(doublearray,M-1,N,ids,N,inputs,iomodel,SmbPrecipitationsReconstructedEnum);
|
---|
[24626] | 164 | }
|
---|
| 165 | xDelete<int>(ids);
|
---|
| 166 | iomodel->DeleteData(doublearray,"md.smb.precipitations_reconstructed");
|
---|
[22852] | 167 | }
|
---|
[19528] | 168 | }
|
---|
[22448] | 169 | if(issetpddfac){
|
---|
[25379] | 170 | iomodel->FetchDataToInput(inputs,elements,"md.smb.pddfac_snow",SmbPddfacSnowEnum,-1.);
|
---|
| 171 | iomodel->FetchDataToInput(inputs,elements,"md.smb.pddfac_ice",SmbPddfacIceEnum,-1.);
|
---|
[22448] | 172 | }
|
---|
[19528] | 173 | break;
|
---|
| 174 | case SMBgradientsEnum:
|
---|
[25379] | 175 | iomodel->FetchDataToInput(inputs,elements,"md.smb.href",SmbHrefEnum);
|
---|
| 176 | iomodel->FetchDataToInput(inputs,elements,"md.smb.smbref",SmbSmbrefEnum);
|
---|
| 177 | iomodel->FetchDataToInput(inputs,elements,"md.smb.b_pos",SmbBPosEnum);
|
---|
| 178 | iomodel->FetchDataToInput(inputs,elements,"md.smb.b_neg",SmbBNegEnum);
|
---|
[19528] | 179 | break;
|
---|
[21469] | 180 | case SMBgradientselaEnum:
|
---|
[25379] | 181 | iomodel->FetchDataToInput(inputs,elements,"md.smb.ela",SmbElaEnum);
|
---|
| 182 | iomodel->FetchDataToInput(inputs,elements,"md.smb.b_pos",SmbBPosEnum);
|
---|
| 183 | iomodel->FetchDataToInput(inputs,elements,"md.smb.b_neg",SmbBNegEnum);
|
---|
| 184 | iomodel->FetchDataToInput(inputs,elements,"md.smb.b_max",SmbBMaxEnum);
|
---|
| 185 | iomodel->FetchDataToInput(inputs,elements,"md.smb.b_min",SmbBMinEnum);
|
---|
[21469] | 186 | break;
|
---|
[27250] | 187 | case SMBarmaEnum:
|
---|
[26477] | 188 | iomodel->FetchDataToInput(inputs,elements,"md.smb.basin_id",SmbBasinsIdEnum);
|
---|
| 189 | break;
|
---|
[19528] | 190 | case SMBhenningEnum:
|
---|
[25379] | 191 | iomodel->FetchDataToInput(inputs,elements,"md.smb.smbref",SmbSmbrefEnum,0.);
|
---|
[19528] | 192 | break;
|
---|
| 193 | case SMBcomponentsEnum:
|
---|
[25379] | 194 | iomodel->FetchDataToInput(inputs,elements,"md.smb.accumulation",SmbAccumulationEnum,0.);
|
---|
| 195 | iomodel->FetchDataToInput(inputs,elements,"md.smb.evaporation",SmbEvaporationEnum,0.);
|
---|
| 196 | iomodel->FetchDataToInput(inputs,elements,"md.smb.runoff",SmbRunoffEnum,0.);
|
---|
[19528] | 197 | break;
|
---|
| 198 | case SMBmeltcomponentsEnum:
|
---|
[25379] | 199 | iomodel->FetchDataToInput(inputs,elements,"md.smb.accumulation",SmbAccumulationEnum,0.);
|
---|
| 200 | iomodel->FetchDataToInput(inputs,elements,"md.smb.evaporation",SmbEvaporationEnum,0.);
|
---|
| 201 | iomodel->FetchDataToInput(inputs,elements,"md.smb.melt",SmbMeltEnum,0.);
|
---|
| 202 | iomodel->FetchDataToInput(inputs,elements,"md.smb.refreeze",SmbRefreezeEnum,0.);
|
---|
[19528] | 203 | break;
|
---|
[23366] | 204 | case SMBgradientscomponentsEnum:
|
---|
[24385] | 205 | /* Nothing to add to input */
|
---|
[23366] | 206 | break;
|
---|
[23540] | 207 | case SMBsemicEnum:
|
---|
[25379] | 208 | iomodel->FetchDataToInput(inputs,elements,"md.thermal.spctemperature",ThermalSpctemperatureEnum);
|
---|
| 209 | iomodel->FetchDataToInput(inputs,elements,"md.smb.s0gcm",SmbS0gcmEnum);
|
---|
| 210 | iomodel->FetchDataToInput(inputs,elements,"md.smb.dailysnowfall",SmbDailysnowfallEnum);
|
---|
| 211 | iomodel->FetchDataToInput(inputs,elements,"md.smb.dailyrainfall",SmbDailyrainfallEnum);
|
---|
| 212 | iomodel->FetchDataToInput(inputs,elements,"md.smb.dailydsradiation",SmbDailydsradiationEnum);
|
---|
| 213 | iomodel->FetchDataToInput(inputs,elements,"md.smb.dailydlradiation",SmbDailydlradiationEnum);
|
---|
| 214 | iomodel->FetchDataToInput(inputs,elements,"md.smb.dailywindspeed",SmbDailywindspeedEnum);
|
---|
| 215 | iomodel->FetchDataToInput(inputs,elements,"md.smb.dailypressure",SmbDailypressureEnum);
|
---|
| 216 | iomodel->FetchDataToInput(inputs,elements,"md.smb.dailyairdensity",SmbDailyairdensityEnum);
|
---|
| 217 | iomodel->FetchDataToInput(inputs,elements,"md.smb.dailyairhumidity",SmbDailyairhumidityEnum);
|
---|
| 218 | iomodel->FetchDataToInput(inputs,elements,"md.smb.dailytemperature",SmbDailytemperatureEnum);
|
---|
[23540] | 219 | break;
|
---|
[19528] | 220 | default:
|
---|
| 221 | _error_("Surface mass balance model "<<EnumToStringx(smb_model)<<" not supported yet");
|
---|
| 222 | }
|
---|
| 223 |
|
---|
| 224 | }/*}}}*/
|
---|
| 225 | void SmbAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/
|
---|
| 226 |
|
---|
| 227 | int numoutputs;
|
---|
| 228 | char** requestedoutputs = NULL;
|
---|
[26196] | 229 | bool isdelta18o,ismungsm,isd18opd,issetpddfac,interp,cycle,isfirnwarming;
|
---|
[24791] | 230 | int smb_model, smbslices, averaging;
|
---|
[19528] | 231 | IssmDouble *temp = NULL;
|
---|
| 232 | int N,M;
|
---|
[23066] | 233 |
|
---|
[20690] | 234 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.model",SmbEnum));
|
---|
[23066] | 235 |
|
---|
[20690] | 236 | iomodel->FindConstant(&smb_model,"md.smb.model");
|
---|
[26208] | 237 | iomodel->FindConstant(&interp,"md.timestepping.interp_forcing");
|
---|
[26196] | 238 | iomodel->FindConstant(&cycle,"md.timestepping.cycle_forcing");
|
---|
[23066] | 239 |
|
---|
[24791] | 240 | iomodel->FindConstant(&smbslices,"md.smb.steps_per_step");
|
---|
[24240] | 241 | parameters->AddObject(new IntParam(SmbStepsPerStepEnum,smbslices));
|
---|
| 242 |
|
---|
[24791] | 243 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.averaging",SmbAveragingEnum));
|
---|
| 244 |
|
---|
[19528] | 245 | switch(smb_model){
|
---|
| 246 | case SMBforcingEnum:
|
---|
| 247 | break;
|
---|
[19554] | 248 | case SMBgembEnum:
|
---|
[20690] | 249 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.aIdx",SmbAIdxEnum));
|
---|
[26550] | 250 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.eIdx",SmbEIdxEnum));
|
---|
[27229] | 251 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.tcIdx",SmbTcIdxEnum));
|
---|
[20690] | 252 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.swIdx",SmbSwIdxEnum));
|
---|
| 253 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.denIdx",SmbDenIdxEnum));
|
---|
[23468] | 254 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.dsnowIdx",SmbDsnowIdxEnum));
|
---|
[20690] | 255 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.cldFrac",SmbCldFracEnum));
|
---|
| 256 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.t0wet",SmbT0wetEnum));
|
---|
| 257 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.t0dry",SmbT0dryEnum));
|
---|
| 258 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.K",SmbKEnum));
|
---|
| 259 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.aSnow",SmbASnowEnum));
|
---|
| 260 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.aIce",SmbAIceEnum));
|
---|
| 261 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.dt",SmbDtEnum));
|
---|
| 262 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.isgraingrowth",SmbIsgraingrowthEnum));
|
---|
| 263 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.isalbedo",SmbIsalbedoEnum));
|
---|
| 264 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.isshortwave",SmbIsshortwaveEnum));
|
---|
| 265 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.isthermal",SmbIsthermalEnum));
|
---|
| 266 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.isaccumulation",SmbIsaccumulationEnum));
|
---|
| 267 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.ismelt",SmbIsmeltEnum));
|
---|
| 268 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.isdensification",SmbIsdensificationEnum));
|
---|
| 269 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.isturbulentflux",SmbIsturbulentfluxEnum));
|
---|
[24735] | 270 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.isconstrainsurfaceT",SmbIsconstrainsurfaceTEnum));
|
---|
[26550] | 271 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.isdeltaLWup",SmbIsdeltaLWupEnum));
|
---|
[20690] | 272 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.InitDensityScaling",SmbInitDensityScalingEnum));
|
---|
[22475] | 273 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.ThermoDeltaTScaling",SmbThermoDeltaTScalingEnum));
|
---|
[22482] | 274 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.adThresh",SmbAdThreshEnum));
|
---|
[26550] | 275 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.teThresh",SmbTeThreshEnum));
|
---|
[19554] | 276 | break;
|
---|
[19528] | 277 | case SMBpddEnum:
|
---|
[20690] | 278 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.isdelta18o",SmbIsdelta18oEnum));
|
---|
| 279 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.ismungsm",SmbIsmungsmEnum));
|
---|
[22448] | 280 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.issetpddfac",SmbIssetpddfacEnum));
|
---|
[20690] | 281 | iomodel->FindConstant(&isdelta18o,"md.smb.isdelta18o");
|
---|
| 282 | iomodel->FindConstant(&ismungsm,"md.smb.ismungsm");
|
---|
[19528] | 283 |
|
---|
| 284 | if(ismungsm){
|
---|
[20690] | 285 | iomodel->FetchData(&temp,&N,&M,"md.smb.Pfac"); _assert_(N==2);
|
---|
[26196] | 286 | parameters->AddObject(new TransientParam(SmbPfacEnum,&temp[0],&temp[M],interp,cycle,M));
|
---|
[20690] | 287 | iomodel->DeleteData(temp,"md.smb.Pfac");
|
---|
[23066] | 288 |
|
---|
[20690] | 289 | iomodel->FetchData(&temp,&N,&M,"md.smb.Tdiff"); _assert_(N==2);
|
---|
[26196] | 290 | parameters->AddObject(new TransientParam(SmbTdiffEnum,&temp[0],&temp[M],interp,cycle,M));
|
---|
[20690] | 291 | iomodel->DeleteData(temp,"md.smb.Tdiff");
|
---|
[19528] | 292 |
|
---|
[20690] | 293 | iomodel->FetchData(&temp,&N,&M,"md.smb.sealev"); _assert_(N==2);
|
---|
[26196] | 294 | parameters->AddObject(new TransientParam(SmbSealevEnum,&temp[0],&temp[M],interp,cycle,M));
|
---|
[20690] | 295 | iomodel->DeleteData(temp,"md.smb.sealev");
|
---|
[19528] | 296 | }
|
---|
| 297 | if(isdelta18o){
|
---|
[20690] | 298 | iomodel->FetchData(&temp,&N,&M,"md.smb.delta18o"); _assert_(N==2);
|
---|
[26196] | 299 | parameters->AddObject(new TransientParam(SmbDelta18oEnum,&temp[0],&temp[M],interp,cycle,M));
|
---|
[20690] | 300 | iomodel->DeleteData(temp,"md.smb.delta18o");
|
---|
[19528] | 301 |
|
---|
[20690] | 302 | iomodel->FetchData(&temp,&N,&M,"md.smb.delta18o_surface"); _assert_(N==2);
|
---|
[26196] | 303 | parameters->AddObject(new TransientParam(SmbDelta18oSurfaceEnum,&temp[0],&temp[M],interp,cycle,M));
|
---|
[20690] | 304 | iomodel->DeleteData(temp,"md.smb.delta18o_surface");
|
---|
[19528] | 305 | }
|
---|
[24626] | 306 |
|
---|
[19528] | 307 | break;
|
---|
[23317] | 308 | case SMBpddSicopolisEnum:
|
---|
[23328] | 309 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.isfirnwarming",SmbIsfirnwarmingEnum));
|
---|
[23317] | 310 | break;
|
---|
[19528] | 311 | case SMBd18opddEnum:
|
---|
[20690] | 312 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.ismungsm",SmbIsmungsmEnum));
|
---|
| 313 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.isd18opd",SmbIsd18opdEnum));
|
---|
[22448] | 314 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.issetpddfac",SmbIssetpddfacEnum));
|
---|
[20690] | 315 | iomodel->FindConstant(&ismungsm,"md.smb.ismungsm");
|
---|
| 316 | iomodel->FindConstant(&isd18opd,"md.smb.isd18opd");
|
---|
[22448] | 317 | iomodel->FindConstant(&issetpddfac,"md.smb.issetpddfac");
|
---|
[19528] | 318 | if(isd18opd){
|
---|
[22608] | 319 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.f",SmbFEnum));
|
---|
[22495] | 320 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.istemperaturescaled",SmbIstemperaturescaledEnum));
|
---|
[22852] | 321 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.isprecipscaled",SmbIsprecipscaledEnum));
|
---|
[20690] | 322 | iomodel->FetchData(&temp,&N,&M,"md.smb.delta18o"); _assert_(N==2);
|
---|
[26196] | 323 | parameters->AddObject(new TransientParam(SmbDelta18oEnum,&temp[0],&temp[M],interp,cycle,M));
|
---|
[20690] | 324 | iomodel->DeleteData(temp,"md.smb.delta18o");
|
---|
[24626] | 325 |
|
---|
| 326 | IssmDouble yts;
|
---|
| 327 | bool istemperaturescaled,isprecipscaled;
|
---|
| 328 | iomodel->FindConstant(&yts,"md.constants.yts");
|
---|
| 329 | iomodel->FindConstant(&istemperaturescaled,"md.smb.istemperaturescaled");
|
---|
| 330 | iomodel->FindConstant(&isprecipscaled,"md.smb.isprecipscaled");
|
---|
| 331 | if(!istemperaturescaled){
|
---|
| 332 | /*Fetch array*/
|
---|
| 333 | IssmDouble* doublearray = NULL;
|
---|
| 334 | int M,N;
|
---|
| 335 | iomodel->FetchData(&doublearray,&M,&N,"md.smb.temperatures_reconstructed");
|
---|
| 336 | if(M!=iomodel->numberofvertices+1) _error_("md.smb.temperatures_reconstructed should have nbv+1 rows");
|
---|
| 337 | if(N%12!=0) _error_("md.smb.temperatures_reconstructed should have a multiple of 12 columns (since it is monthly)");
|
---|
| 338 | int numyears = N/12; _assert_(numyears*12==N);
|
---|
| 339 |
|
---|
| 340 | /*Check times*/
|
---|
| 341 | #ifdef _ISSM_DEBUG_
|
---|
| 342 | for(int i=0;i<numyears;i++){
|
---|
| 343 | for(int j=1;j<12;j++){
|
---|
| 344 | //_assert_(floor(doublearray[(M-1)*N+i*12+j]/yts)==floor(doublearray[(M-1)*N+i*12]/yts));
|
---|
| 345 | _assert_(doublearray[(M-1)*N+i*12+j]>doublearray[(M-1)*N+i*12+j-1]);
|
---|
| 346 | }
|
---|
| 347 | }
|
---|
| 348 | #endif
|
---|
| 349 |
|
---|
| 350 | /*Build time*/
|
---|
| 351 | IssmDouble* times = xNew<IssmDouble>(numyears); for(int i=0;i<numyears;i++) times[i] = doublearray[(M-1)*N+i*12];
|
---|
| 352 | parameters->AddObject(new DoubleVecParam(SmbTemperaturesReconstructedYearsEnum,times,numyears));
|
---|
| 353 | xDelete<IssmDouble>(times);
|
---|
| 354 | iomodel->DeleteData(doublearray,"md.smb.temperatures_reconstructed");
|
---|
| 355 | }
|
---|
| 356 | if(!isprecipscaled){
|
---|
| 357 | /*Fetch array*/
|
---|
| 358 | IssmDouble* doublearray = NULL;
|
---|
| 359 | int M,N;
|
---|
| 360 | iomodel->FetchData(&doublearray,&M,&N,"md.smb.precipitations_reconstructed");
|
---|
| 361 | if(M!=iomodel->numberofvertices+1) _error_("md.smb.precipitations_reconstructed should have nbv+1 rows");
|
---|
| 362 | if(N%12!=0) _error_("md.smb.precipitations_reconstructed should have a multiple of 12 columns (since it is monthly)");
|
---|
| 363 | int numyears = N/12; _assert_(numyears*12==N);
|
---|
| 364 |
|
---|
| 365 | /*Check times*/
|
---|
| 366 | #ifdef _ISSM_DEBUG_
|
---|
| 367 | for(int i=0;i<numyears;i++){
|
---|
| 368 | for(int j=1;j<12;j++){
|
---|
| 369 | //_assert_(floor(doublearray[(M-1)*N+i*12+j]/yts)==floor(doublearray[(M-1)*N+i*12]/yts));
|
---|
| 370 | _assert_(doublearray[(M-1)*N+i*12+j]>doublearray[(M-1)*N+i*12+j-1]);
|
---|
| 371 | }
|
---|
| 372 | }
|
---|
| 373 | #endif
|
---|
| 374 |
|
---|
| 375 | /*Build time*/
|
---|
| 376 | IssmDouble* times = xNew<IssmDouble>(numyears); for(int i=0;i<numyears;i++) times[i] = doublearray[(M-1)*N+i*12];
|
---|
| 377 | parameters->AddObject(new DoubleVecParam(SmbPrecipitationsReconstructedYearsEnum,times,numyears));
|
---|
| 378 | xDelete<IssmDouble>(times);
|
---|
| 379 | iomodel->DeleteData(doublearray,"md.smb.precipitations_reconstructed");
|
---|
| 380 | }
|
---|
[19528] | 381 | }
|
---|
[24626] | 382 |
|
---|
[19528] | 383 | break;
|
---|
| 384 | case SMBgradientsEnum:
|
---|
| 385 | /*Nothing to add to parameters*/
|
---|
| 386 | break;
|
---|
[21469] | 387 | case SMBgradientselaEnum:
|
---|
| 388 | /*Nothing to add to parameters*/
|
---|
| 389 | break;
|
---|
[27250] | 390 | case SMBarmaEnum:
|
---|
[26477] | 391 | /*Nothing to add to parameters*/
|
---|
| 392 | break;
|
---|
[19528] | 393 | case SMBhenningEnum:
|
---|
| 394 | /*Nothing to add to parameters*/
|
---|
| 395 | break;
|
---|
| 396 | case SMBcomponentsEnum:
|
---|
| 397 | break;
|
---|
| 398 | case SMBmeltcomponentsEnum:
|
---|
| 399 | break;
|
---|
[23366] | 400 | case SMBgradientscomponentsEnum:
|
---|
| 401 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.accualti",SmbAccualtiEnum));
|
---|
| 402 | parameters->AddObject(iomodel->CopyConstantObject("md.smb.runoffalti",SmbRunoffaltiEnum));
|
---|
| 403 |
|
---|
[25209] | 404 | iomodel->FetchData(&temp,&N,&M,"md.smb.accugrad"); _assert_(N==2);
|
---|
[26196] | 405 | parameters->AddObject(new TransientParam(SmbAccugradEnum,&temp[0],&temp[M],interp,cycle,M));
|
---|
[25209] | 406 | iomodel->DeleteData(temp,"md.smb.accugrad");
|
---|
| 407 | iomodel->FetchData(&temp,&N,&M,"md.smb.runoffgrad"); _assert_(N==2);
|
---|
[26196] | 408 | parameters->AddObject(new TransientParam(SmbRunoffgradEnum,&temp[0],&temp[M],interp,cycle,M));
|
---|
[25209] | 409 | iomodel->DeleteData(temp,"md.smb.runoffgrad");
|
---|
[23366] | 410 |
|
---|
[25209] | 411 | iomodel->FetchData(&temp,&N,&M,"md.smb.accuref"); _assert_(N==2);
|
---|
[26196] | 412 | parameters->AddObject(new TransientParam(SmbAccurefEnum,&temp[0],&temp[M],interp,cycle,M));
|
---|
[25209] | 413 | iomodel->DeleteData(temp,"md.smb.accuref");
|
---|
| 414 | iomodel->FetchData(&temp,&N,&M,"md.smb.runoffref"); _assert_(N==2);
|
---|
[26196] | 415 | parameters->AddObject(new TransientParam(SmbRunoffrefEnum,&temp[0],&temp[M],interp,cycle,M));
|
---|
[25209] | 416 | iomodel->DeleteData(temp,"md.smb.runoffref");
|
---|
[23366] | 417 | break;
|
---|
[23540] | 418 | case SMBsemicEnum:
|
---|
| 419 | /*Nothing to add to parameters*/
|
---|
| 420 | break;
|
---|
[27297] | 421 | case SMBdebrisMLEnum:
|
---|
| 422 | /*Nothing to add to parameters*/
|
---|
| 423 | break;
|
---|
[19528] | 424 | default:
|
---|
| 425 | _error_("Surface mass balance model "<<EnumToStringx(smb_model)<<" not supported yet");
|
---|
| 426 | }
|
---|
| 427 |
|
---|
[20690] | 428 | iomodel->FindConstant(&requestedoutputs,&numoutputs,"md.smb.requested_outputs");
|
---|
[19528] | 429 | parameters->AddObject(new IntParam(SmbNumRequestedOutputsEnum,numoutputs));
|
---|
| 430 | if(numoutputs)parameters->AddObject(new StringArrayParam(SmbRequestedOutputsEnum,requestedoutputs,numoutputs));
|
---|
[20690] | 431 | iomodel->DeleteData(&requestedoutputs,numoutputs,"md.smb.requested_outputs");
|
---|
[19528] | 432 |
|
---|
| 433 | }/*}}}*/
|
---|
| 434 |
|
---|
| 435 | /*Finite Element Analysis*/
|
---|
| 436 | void SmbAnalysis::Core(FemModel* femmodel){/*{{{*/
|
---|
| 437 |
|
---|
| 438 | int smb_model;
|
---|
| 439 |
|
---|
| 440 | /*Figure out smb model: */
|
---|
| 441 | femmodel->parameters->FindParam(&smb_model,SmbEnum);
|
---|
[23066] | 442 |
|
---|
[19528] | 443 | /*branch to correct module*/
|
---|
| 444 | switch(smb_model){
|
---|
| 445 | case SMBforcingEnum:
|
---|
[23814] | 446 | SmbForcingx(femmodel);
|
---|
[19528] | 447 | break;
|
---|
[19554] | 448 | case SMBgembEnum:
|
---|
| 449 | Gembx(femmodel);
|
---|
| 450 | break;
|
---|
[19528] | 451 | case SMBpddEnum:
|
---|
| 452 | bool isdelta18o,ismungsm;
|
---|
| 453 | femmodel->parameters->FindParam(&isdelta18o,SmbIsdelta18oEnum);
|
---|
| 454 | femmodel->parameters->FindParam(&ismungsm,SmbIsmungsmEnum);
|
---|
| 455 | if(isdelta18o){
|
---|
| 456 | if(VerboseSolution()) _printf0_(" call Delta18oParameterization module\n");
|
---|
| 457 | Delta18oParameterizationx(femmodel);
|
---|
[23366] | 458 | }
|
---|
[19528] | 459 | if(ismungsm){
|
---|
| 460 | if(VerboseSolution()) _printf0_(" call MungsmtpParameterization module\n");
|
---|
| 461 | MungsmtpParameterizationx(femmodel);
|
---|
[23366] | 462 | }
|
---|
[19528] | 463 | if(VerboseSolution()) _printf0_(" call positive degree day module\n");
|
---|
| 464 | PositiveDegreeDayx(femmodel);
|
---|
| 465 | break;
|
---|
[23317] | 466 | case SMBpddSicopolisEnum:
|
---|
| 467 | if(VerboseSolution()) _printf0_(" call SICOPOLIS positive degree day module\n");
|
---|
| 468 | PositiveDegreeDaySicopolisx(femmodel);
|
---|
| 469 | break;
|
---|
[19528] | 470 | case SMBd18opddEnum:
|
---|
| 471 | bool isd18opd;
|
---|
| 472 | femmodel->parameters->FindParam(&isd18opd,SmbIsd18opdEnum);
|
---|
| 473 | if(isd18opd){
|
---|
| 474 | if(VerboseSolution()) _printf0_(" call Delta18opdParameterization module\n");
|
---|
| 475 | Delta18opdParameterizationx(femmodel);
|
---|
| 476 | if(VerboseSolution()) _printf0_(" call positive degree day module\n");
|
---|
| 477 | PositiveDegreeDayx(femmodel);
|
---|
[23317] | 478 | }
|
---|
[19528] | 479 | break;
|
---|
| 480 | case SMBgradientsEnum:
|
---|
| 481 | if(VerboseSolution())_printf0_(" call smb gradients module\n");
|
---|
| 482 | SmbGradientsx(femmodel);
|
---|
| 483 | break;
|
---|
[21469] | 484 | case SMBgradientselaEnum:
|
---|
| 485 | if(VerboseSolution())_printf0_(" call smb gradients ela module\n");
|
---|
| 486 | SmbGradientsElax(femmodel);
|
---|
| 487 | break;
|
---|
[27250] | 488 | case SMBarmaEnum:
|
---|
[27297] | 489 | if(VerboseSolution())_printf0_(" call smb arma module\n");
|
---|
| 490 | Smbarmax(femmodel);
|
---|
| 491 | break;
|
---|
[19528] | 492 | case SMBhenningEnum:
|
---|
| 493 | if(VerboseSolution())_printf0_(" call smb Henning module\n");
|
---|
| 494 | SmbHenningx(femmodel);
|
---|
| 495 | break;
|
---|
| 496 | case SMBcomponentsEnum:
|
---|
| 497 | if(VerboseSolution())_printf0_(" call smb Components module\n");
|
---|
| 498 | SmbComponentsx(femmodel);
|
---|
| 499 | break;
|
---|
| 500 | case SMBmeltcomponentsEnum:
|
---|
| 501 | if(VerboseSolution())_printf0_(" call smb Melt Components module\n");
|
---|
| 502 | SmbMeltComponentsx(femmodel);
|
---|
| 503 | break;
|
---|
| 504 | case SMBgcmEnum:
|
---|
| 505 | /*Nothing to be done*/
|
---|
| 506 | break;
|
---|
[23366] | 507 | case SMBgradientscomponentsEnum:
|
---|
| 508 | if(VerboseSolution())_printf0_(" call smb gradients components module\n");
|
---|
| 509 | SmbGradientsComponentsx(femmodel);
|
---|
| 510 | break;
|
---|
[23540] | 511 | case SMBsemicEnum:
|
---|
| 512 | #ifdef _HAVE_SEMIC_
|
---|
| 513 | if(VerboseSolution())_printf0_(" call smb SEMIC module\n");
|
---|
| 514 | SmbSemicx(femmodel);
|
---|
| 515 | #else
|
---|
| 516 | _error_("SEMIC not installed");
|
---|
| 517 | #endif //_HAVE_SEMIC_
|
---|
| 518 | break;
|
---|
[27297] | 519 | case SMBdebrisMLEnum:
|
---|
| 520 | if(VerboseSolution())_printf0_(" call smb debris Mayer & Liculli module\n");
|
---|
| 521 | SmbDebrisMLx(femmodel);
|
---|
| 522 | break;
|
---|
[19528] | 523 | default:
|
---|
| 524 | _error_("Surface mass balance model "<<EnumToStringx(smb_model)<<" not supported yet");
|
---|
| 525 | }
|
---|
| 526 |
|
---|
| 527 | }/*}}}*/
|
---|
[26047] | 528 | void SmbAnalysis::PreCore(FemModel* femmodel){/*{{{*/
|
---|
| 529 | _error_("not implemented");
|
---|
| 530 | }/*}}}*/
|
---|
[19528] | 531 | ElementVector* SmbAnalysis::CreateDVector(Element* element){/*{{{*/
|
---|
| 532 | _error_("not implemented");
|
---|
| 533 | }/*}}}*/
|
---|
| 534 | ElementMatrix* SmbAnalysis::CreateJacobianMatrix(Element* element){/*{{{*/
|
---|
| 535 | _error_("Not implemented");
|
---|
| 536 | }/*}}}*/
|
---|
| 537 | ElementMatrix* SmbAnalysis::CreateKMatrix(Element* element){/*{{{*/
|
---|
| 538 | _error_("not implemented yet");
|
---|
| 539 | }/*}}}*/
|
---|
| 540 | ElementVector* SmbAnalysis::CreatePVector(Element* element){/*{{{*/
|
---|
| 541 | _error_("not implemented yet");
|
---|
| 542 | }/*}}}*/
|
---|
| 543 | void SmbAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/
|
---|
| 544 | _error_("not implemented yet");
|
---|
| 545 | }/*}}}*/
|
---|
[25317] | 546 | void SmbAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_interp,int control_index){/*{{{*/
|
---|
[19528] | 547 | _error_("Not implemented yet");
|
---|
| 548 | }/*}}}*/
|
---|
| 549 | void SmbAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/
|
---|
| 550 | _error_("not implemented yet");
|
---|
| 551 | }/*}}}*/
|
---|
| 552 | void SmbAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/
|
---|
| 553 | /*Default, do nothing*/
|
---|
| 554 | return;
|
---|
| 555 | }/*}}}*/
|
---|