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