00001 #ifndef PIHM_H 00002 #define PIHM_H 00003 00004 /****************************************************************************** 00005 * File : pihm.h * 00006 * Function : define data structure and grobal variable * 00007 * Programmers : Yizhong Qu @ Pennsylvania State Univeristy * 00008 * Mukesh Kumar @ Pennsylvania State Univeristy * 00009 * Gopal Bhatt @ Pennsylvania State Univeristy * 00010 * Version : v2.0 (July 10, 2007) * 00011 * * 00012 *-----------------------------------------------------------------------------* 00013 * * 00014 * This is an object oriented model. In this file, all the data structures and * 00015 * global variables are defined. To avoid using real globle variables, this * 00016 * header file and pointers are passed. * 00017 * * 00018 * This code is free for users with research purpose only, if appropriate * 00019 * citation is refered. However, there is no warranty in any format for this * 00020 * product. * 00021 * * 00022 * For questions or comments, please contact the authors of the reference. * 00023 * One who want to use it for other consideration may also contact Dr.Duffy * 00024 * at cxd11@psu.edu. * 00025 *******************************************************************************/ 00026 00028 00029 /* INCLUDE FILES */ 00030 #include <stdio.h> 00031 00032 00033 00034 /* SUNDIALS LIBRARY INCLUDE */ 00035 #include "sundials_types.h" 00036 #include "nvector_serial.h" 00037 00038 00039 00040 /* Define Global Type */ 00042 float Tsteps; /* Variable to store current time */ 00043 00044 00045 00046 /*******************************************************************************/ 00047 /* PIHM data structures */ 00048 /*******************************************************************************/ 00049 00050 /* Data Structure of an Triangular Element */ 00051 typedef struct element_type 00053 { 00054 int index; 00055 int node[3]; 00056 int nabr[3]; 00058 realtype edge[3]; 00059 realtype area; 00061 realtype x; 00062 realtype y; 00063 realtype zmin; 00064 realtype zmax; 00065 realtype NodeZmin; 00066 realtype NodeZmax; 00067 realtype NodeDist; 00069 realtype Ksat; 00070 realtype Porosity; 00071 realtype Alpha; 00072 realtype Beta; 00073 realtype Sf; 00074 realtype RzD; 00077 realtype LAImax; 00078 realtype VegFrac; 00079 realtype Albedo; 00080 realtype Rs_ref; 00081 realtype Rmin; 00082 realtype Rough; 00083 realtype windH; 00085 /* Class/Type associated with an Element */ 00086 int soil; 00087 int LC; 00088 int IC; 00089 int BC; 00091 int prep; 00092 int temp; 00093 int humidity; 00094 int WindVel; 00095 int Rn; 00096 int G; 00097 int pressure; 00098 int source; 00100 } element; 00101 00102 00103 00104 /* Data Structure of an Node/Point */ 00105 typedef struct nodes_type 00107 { 00108 int index; 00110 realtype x; 00111 realtype y; 00112 realtype zmin; 00113 realtype zmax; 00115 } nodes; 00116 00117 00118 /* Data Structure of Initial Condition State of an Element */ 00119 typedef struct element_IC_type 00121 { 00122 int index; 00123 00124 realtype interception; 00125 realtype snow; 00126 realtype surf; 00127 realtype unsat; 00128 realtype sat; 00130 } element_IC; 00131 00132 00133 00134 /* Data Structure of a Soil Type */ 00135 typedef struct soils_type 00137 { 00138 int index; 00140 realtype Ksat; 00141 realtype SitaS; 00142 realtype SitaR; 00143 realtype Alpha; 00144 realtype Beta; 00145 realtype Sf; 00146 realtype RzD; 00148 int Macropore; 00149 realtype base; 00150 realtype gama; 00152 int Inf; 00154 } soils; 00155 00156 00157 00158 /* Data Structure of a Land Cover Type */ 00159 typedef struct lc_type 00161 { 00162 int index; 00164 realtype LAImax; 00165 realtype VegFrac; 00166 realtype Albedo; 00167 realtype Rs_ref; 00168 realtype Rmin; 00169 realtype Rough; 00170 } LC; 00171 00172 00173 00174 /* Data Structure of a River Segment */ 00175 typedef struct river_segment_type 00177 { 00178 int index; 00180 /* Topology of a River Segment */ 00181 realtype x; 00182 realtype y; 00183 realtype zmin; 00184 realtype zmax; 00185 realtype depth; 00186 realtype Length; 00187 realtype Rough; 00188 00189 /* Topological Relations of a River Segment */ 00190 int FromNode; 00191 int ToNode; 00192 int down; 00193 int LeftEle; 00194 int RightEle; 00195 int shape; 00196 int material; 00197 int IC; 00198 int BC; 00199 int reservoir; 00200 00201 } river_segment; 00202 00203 00204 00205 /* Data Structure of a River Shape */ 00206 typedef struct river_shape_type 00208 { 00210 int index; 00212 realtype width; 00213 realtype depth; 00214 realtype bed; 00215 int interpOrd; 00217 realtype coeff; 00219 } river_shape; 00220 00221 00222 00223 /* Data Structure of a River Material Type */ 00224 typedef struct river_material_type 00226 { 00227 int index; 00229 realtype Rough; 00230 realtype Sf; 00231 realtype Cwr; 00233 } river_material; 00234 00235 00236 00237 /* Data Structure of Initial Condition of the River Segment */ 00238 typedef struct river_IC_type 00240 { 00241 int index; 00242 realtype value; 00244 } river_IC; 00245 00246 00247 00248 /* Data Structure of Time Series Data Types */ 00249 typedef struct TSD_type 00251 { 00252 char name[50]; 00253 int index; 00254 int length; 00255 int iCounter; 00256 realtype **TS; 00258 } TSD; 00259 00260 00261 00262 /* Model Data Structure */ 00263 typedef struct model_data_structure 00265 { 00266 /* PIHM Mode Identifiers: Used to switch between several modes */ 00267 int UnsatMode; 00268 int SurfMode; 00269 int RivMode; 00271 /* Number of different model representation components */ 00272 int NumEle; 00273 int NumNode; 00274 int NumRiv; 00276 /* Number of Unique Forcing TimeSeries within the model domain */ 00277 int NumPrep; 00278 int NumTemp; 00279 int NumHumidity; 00280 int NumWindVel; 00281 int NumRn; 00282 int NumG; 00283 int NumP; 00284 int NumSource; 00285 int NumMeltF; 00287 /* Number of Spatial Attributes of the Elements */ 00288 int NumSoil; 00289 int NumRes; 00290 int NumInc; 00291 int NumLC; 00293 /* Number of Initial and Boundary condition TimeSeries for Elements */ 00294 int Num1BC; 00295 int Num2BC; 00296 int NumEleIC; 00298 /* Number of Spatial Attributes of River Segments */ 00299 int NumRivShape; 00300 int NumRivMaterial; 00302 /* Number of Initial and Boundary condition TimeSeries for Rivers */ 00303 int NumRivIC; 00304 int NumRivBC; 00306 /* Objects for feature (element/river) data types */ 00307 element *Ele; 00308 river_segment *Riv; 00310 /* Attributes of Element (triangle) objects in the model domain */ 00311 nodes *Node; 00312 element_IC *Ele_IC; 00313 soils *Soil; 00314 LC *LandC; /* Land Cover Information */ 00315 00316 /* Attributes of River (linear) objects in the model domain */ 00317 river_shape *Riv_Shape; 00318 river_material *Riv_Mat; 00319 river_IC *Riv_IC; 00321 /* Time Series Data in the model domain */ 00322 TSD *TSD_Inc; 00323 TSD *TSD_LAI; 00324 TSD *TSD_DH; 00325 realtype *SIFactor; 00327 TSD *TSD_MeltF; 00329 TSD *TSD_EleBC; 00330 TSD *TSD_Prep; 00331 TSD *TSD_Temp; 00332 TSD *TSD_Humidity; 00333 TSD *TSD_WindVel; 00334 TSD *TSD_Rn; 00335 TSD *TSD_G; 00336 TSD *TSD_Pressure; 00337 TSD *TSD_Source; 00339 realtype *WindH; 00341 TSD *TSD_Riv; 00343 /* Storage for fluxes at Time = t */ 00344 realtype **FluxSurf; 00345 realtype **FluxSub; 00346 realtype **FluxRiv; 00348 realtype *ElePrep; 00349 realtype *Ele2IS; 00350 realtype *EleNetPrep; 00351 realtype *EleVic; 00352 realtype *Recharge; 00353 realtype *EleSnow; 00354 realtype *EleIS; 00355 realtype *EleISmax; 00356 realtype *EleTF; 00357 realtype **EleET; 00358 realtype Q; 00359 00360 } *Model_Data; 00361 00362 00363 00364 /* Control Data Structure */ 00365 typedef struct control_data_structure 00367 { 00368 /* Model Control Option */ 00369 int Verbose; 00370 int Debug; 00371 int int_type; 00372 int res_out; 00373 int flux_out; 00374 int q_out; 00375 int etis_out; 00377 /* Solver Control Options */ 00378 int Solver; 00379 realtype abstol; 00380 realtype reltol; 00381 realtype InitStep; 00382 realtype MaxStep; 00383 realtype ETStep; 00385 int GSType, MaxK; 00386 realtype delt; 00387 00388 realtype StartTime; 00389 realtype EndTime; 00391 /* CVode is called at t = b * a^i */ 00392 int outtype; 00393 realtype a; 00394 realtype b; 00395 int NumSteps; 00396 realtype *Tout; 00398 } Control_Data; 00399 00400 00401 /* 00402 void PrintModelData(Model_Data); 00403 void PrintEle(Model_Data); 00404 void PrintEleAtt(Model_Data); 00405 void PrintNode(Model_Data); 00406 void PrintSoil(Model_Data); 00407 void PrintLC(Model_Data); 00408 void PrintTS(TSD *, int); 00409 void PrintRiv(Model_Data); 00410 void PrintForcing(Model_Data); 00411 void PrintDY(Model_Data, N_Vector, N_Vector); 00412 void PrintY(Model_Data, N_Vector, realtype); 00413 00414 void FPrintYheader(FILE *, Model_Data); 00415 void FPrintY(Model_Data, N_Vector, realtype, FILE *); 00416 void FPrintFlux(Model_Data, realtype, FILE *); 00417 void FPrintETISheader(FILE *, Model_Data); 00418 void FPrintETIS(Model_Data, realtype, FILE *); 00419 void FPrintQ(Model_Data, realtype, FILE *); 00420 void PrintVerbose(int, realtype, long int iopt[], realtype ropt[]); 00421 void PrintFarewell(Control_Data, long int iopt[], realtype ropt[], realtype, realtype); 00422 void PrintFinalStats(long int iopt[], realtype ropt[]); 00423 void FPrintFarewell(Control_Data, FILE *, long int iopt[], realtype ropt[], realtype, realtype); 00424 void FPrintFinalStats(FILE *, long int iopt[], realtype ropt[]); 00425 */ 00426 #endif