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