From 21de4d7ad9883eba52d5d9370d3830b36bd0a10d Mon Sep 17 00:00:00 2001 From: Mickey Date: Mon, 21 Jan 2013 17:53:48 -0500 Subject: [PATCH 01/14] base sdk changed to 'current os x' --- build/Xcode/epanet/epanet.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/Xcode/epanet/epanet.xcodeproj/project.pbxproj b/build/Xcode/epanet/epanet.xcodeproj/project.pbxproj index 59a4a81..bb0c2b8 100644 --- a/build/Xcode/epanet/epanet.xcodeproj/project.pbxproj +++ b/build/Xcode/epanet/epanet.xcodeproj/project.pbxproj @@ -334,7 +334,7 @@ HEADER_SEARCH_PATHS = macinclude; ONLY_ACTIVE_ARCH = YES; PREBINDING = NO; - SDKROOT = macosx10.6; + SDKROOT = ""; }; name = Debug; }; @@ -348,7 +348,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = macinclude; PREBINDING = NO; - SDKROOT = macosx10.6; + SDKROOT = ""; }; name = Release; }; From e0582a8bff4cd38b1feb4acfa82806d90f4fbbd9 Mon Sep 17 00:00:00 2001 From: yuniersoad Date: Tue, 14 May 2013 19:38:40 +0000 Subject: [PATCH 02/14] Fixing conversion error in ENgetnodevalue EN_TANKDIAM The Tank.A(area) is calculated as: Tank[j].A = PI*SQR(Tank[j].A/Ucf[ELEV])/4.0; //diameter is stored in Tank[j].A so the right equation to get the diameter back is sqrt(4.0/PI*Tank[index-Njuncs].A)*Ucf[ELEV]; --- src/epanet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/epanet.c b/src/epanet.c index 34e8d53..69095a4 100755 --- a/src/epanet.c +++ b/src/epanet.c @@ -1460,7 +1460,7 @@ int DLLEXPORT ENgetnodevalue(int index, int code, float *value) v = 0.0; if ( index > Njuncs ) { - v = 4.0/PI*sqrt(Tank[index-Njuncs].A)*Ucf[ELEV]; + v = sqrt(4.0/PI*Tank[index-Njuncs].A)*Ucf[ELEV]; } break; From e0f262629c6514d9e79b8f5f637f645249394b8e Mon Sep 17 00:00:00 2001 From: Sam Hatchett Date: Tue, 14 May 2013 17:37:18 -0300 Subject: [PATCH 03/14] Create README.md --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..9aab049 --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +epanet +====== + +epanet base code + +__Note:__ This is not the "official" release of EPANET -- for that, please go to [the USEPA website](http://www.epa.gov/nrmrl/wswrd/dw/epanet.html). + +However, if you are interested in extending EPANET for academic, personal, or commercial use, then this is probably a good place to be. From 18d9f16770a902e88a96811afb2ee821b1593ab5 Mon Sep 17 00:00:00 2001 From: sam hatchett Date: Thu, 23 May 2013 18:57:09 -0400 Subject: [PATCH 04/14] removed mac include (empty file) --- build/Xcode/epanet/macinclude/malloc.h | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 build/Xcode/epanet/macinclude/malloc.h diff --git a/build/Xcode/epanet/macinclude/malloc.h b/build/Xcode/epanet/macinclude/malloc.h deleted file mode 100644 index 1a882e9..0000000 --- a/build/Xcode/epanet/macinclude/malloc.h +++ /dev/null @@ -1,10 +0,0 @@ -/* - * malloc.h - * epanet - * - * Created by Sam Hatchett on 9/21/09. - * Copyright 2009 __MyCompanyName__. All rights reserved. - * - */ - -#include \ No newline at end of file From 434d78c6ed8b5e4a95380e634798406188ef48e9 Mon Sep 17 00:00:00 2001 From: sam hatchett Date: Thu, 23 May 2013 19:36:03 -0400 Subject: [PATCH 05/14] Lemon Tiger changes --- src/epanet.c | 8 ++-- src/hydraul.c | 11 ++++- src/quality.c | 129 +++++++++++++++++++++++++++++++++++++++++--------- src/text.h | 5 ++ src/toolkit.h | 4 ++ src/types.h | 4 ++ src/vars.h | 14 +++++- 7 files changed, 146 insertions(+), 29 deletions(-) diff --git a/src/epanet.c b/src/epanet.c index 69095a4..3512b04 100755 --- a/src/epanet.c +++ b/src/epanet.c @@ -754,7 +754,8 @@ int DLLEXPORT ENopenQ() OpenQflag = FALSE; SaveQflag = FALSE; if (!Openflag) return(102); - if (!SaveHflag) return(104); + // !LT! todo - check for SaveHflag / set sequential/step mode + //if (!SaveHflag) return(104); /* Open WQ solver */ ERRCODE(openqual()); @@ -1680,7 +1681,6 @@ int DLLEXPORT ENgetlinkvalue(int index, int code, float *value) /*** Updated 10/25/00 ***/ if (S[index] <= CLOSED) v = 0.0; - else v = Q[index]*Ucf[FLOW]; break; @@ -3143,6 +3143,8 @@ char *geterrmsg(int errcode) case 307: strcpy(Msg,ERR307); break; case 308: strcpy(Msg,ERR308); break; case 309: strcpy(Msg,ERR309); break; + + case 401: strcpy(Msg,ERR401); break; default: strcpy(Msg,""); } return(Msg); @@ -3222,7 +3224,7 @@ int DLLEXPORT ENgetbasedemand(int nodeIndex, int demandIdx, float *baseDemand) if (nodeIndex <= 0 || nodeIndex > Nnodes) return(203); for(d=Node[nodeIndex].D; nnext) n++; if(n!=demandIdx) return(253); - *baseDemand=d->Base*Ucf[FLOW]; + *baseDemand=(float)(d->Base*Ucf[FLOW]); return 0; } int DLLEXPORT ENgetdemandpattern(int nodeIndex, int demandIdx, int *pattIdx) diff --git a/src/hydraul.c b/src/hydraul.c index a56e14a..eb97ba7 100755 --- a/src/hydraul.c +++ b/src/hydraul.c @@ -259,6 +259,9 @@ int nexthyd(long *tstep) else { Htime++; /* Force completion of analysis */ + if (OpenQflag) { + Qtime++; // force completion of wq analysis too + } } *tstep = hydstep; return(errcode); @@ -1055,8 +1058,12 @@ void tanklevels(long tstep) /*** Updated 6/24/02 ***/ /* Check if tank full/empty within next second */ - if (Tank[i].V + D[n] >= Tank[i].Vmax) Tank[i].V = Tank[i].Vmax; - if (Tank[i].V - D[n] <= Tank[i].Vmin) Tank[i].V = Tank[i].Vmin; + if (Tank[i].V + D[n] >= Tank[i].Vmax) { + Tank[i].V = Tank[i].Vmax; + } + else if (Tank[i].V - D[n] <= Tank[i].Vmin) { + Tank[i].V = Tank[i].Vmin; + } H[n] = tankgrade(i,Tank[i].V); } diff --git a/src/quality.c b/src/quality.c index 8cc1ffe..abf89fc 100755 --- a/src/quality.c +++ b/src/quality.c @@ -106,7 +106,7 @@ int openqual() if (SegPool == NULL) errcode = 101; //(2.00.11 - LR) /* Allocate scratch array & reaction rate array*/ - X = (double *) calloc(MAX((Nnodes+1),(Nlinks+1)),sizeof(double)); + XC = (double *) calloc(MAX((Nnodes+1),(Nlinks+1)),sizeof(double)); R = (double *) calloc((Nlinks+1), sizeof(double)); ERRCODE(MEMCHECK(X)); ERRCODE(MEMCHECK(R)); @@ -154,6 +154,9 @@ void initqual() for (i=1; i<=Nnodes; i++) if (Node[i].S != NULL) Node[i].S->Smass = 0.0; + QTankVolumes = calloc(Ntanks, sizeof(double)); // keep track of previous step's tank volumes. + QLinkFlow = calloc(Nlinks, sizeof(double)); // keep track of previous step's link flows. + /* Set WQ parameters */ Bucf = 1.0; Tucf = 1.0; @@ -189,7 +192,10 @@ void initqual() Wsource = 0.0; /* Re-position hydraulics file */ + if (!OpenHflag) { fseek(HydFile,HydOffset,SEEK_SET); + } + /* Set elapsed times to zero */ Htime = 0; @@ -221,7 +227,24 @@ int runqual(long *t) if (Qtime == Htime) { errcode = gethyd(&hydtime, &hydstep); + if (!OpenHflag) { // test for sequential vs stepwise + // sequential Htime = hydtime + hydstep; + } + else { + // stepwise calculation + for (int i=1; i<= Ntanks; ++i) { + QTankVolumes[i-1] = Tank[i].V; + } + + for (int i=1; i<= Nlinks; ++i) + { + if (S[i] <= CLOSED) { + QLinkFlow[i-1] = Q[i]; + } + } + + } } return(errcode); } @@ -243,7 +266,40 @@ int nextqual(long *tstep) /* Determine time step */ *tstep = 0; - hydstep = Htime - Qtime; + + // hydstep = Htime - Qtime; + + if (Htime <= Dur) hydstep = Htime - Qtime; + else hydstep = 0; + + double *tankVolumes; + + // if we're operating in stepwise mode, capture the tank levels so we can restore them later. + if (OpenHflag) { + tankVolumes = calloc(Ntanks, sizeof(double)); + for (int i=1; i<=Ntanks; ++i) { + if (Tank[i].A != 0) { // skip reservoirs + tankVolumes[i-1] = Tank[i].V; + } + } + + // restore the previous step's tank volumes + for (int i=1; i<=Ntanks; i++) { + if (Tank[i].A != 0) { // skip reservoirs again + int n = Tank[i].Node; + Tank[i].V = QTankVolumes[i-1]; + H[n] = tankgrade(i,Tank[i].V); + } + } + + // restore the previous step's pipe link flows + for (int i=1; i<=Nlinks; i++) { + if (S[i] <= CLOSED) { + Q[i] = 0.0; + } + } + + } /* Perform water quality routing over this time step */ if (Qualflag != NONE && hydstep > 0) transport(hydstep); @@ -255,6 +311,26 @@ int nextqual(long *tstep) /* Save final output if no more time steps */ if (!errcode && Saveflag && *tstep == 0) errcode = savefinaloutput(); + + // restore tank levels to post-runH state, if needed. + if (OpenHflag) { + for (int i=1; i<=Ntanks; i++) { + if (Tank[i].A != 0) { // skip reservoirs again + int n = Tank[i].Node; + Tank[i].V = tankVolumes[i-1]; + H[n] = tankgrade(i,Tank[i].V); + } + } + + for (int i=1; i<=Nlinks; ++i) { + if (S[i] <= CLOSED) { + Q[i] = QLinkFlow[i-1]; + } + } + + free(tankVolumes); + } + return(errcode); } @@ -321,7 +397,9 @@ int closequal() free(VolIn); free(MassIn); free(R); - free(X); + free(XC); + free(QTankVolumes); + free(QLinkFlow); return(errcode); } @@ -344,10 +422,14 @@ int gethyd(long *hydtime, long *hydstep) { int errcode = 0; + // if hydraulics are not open, then we're operating in sequential mode. + // else hydraulics are open, so use the hydraulic results in memory rather than reading from the temp file. + if (!OpenHflag) { /* Read hydraulic results from file */ if (!readhyd(hydtime)) return(307); if (!readhydstep(hydstep)) return(307); Htime = *hydtime; + } /* Save current results to output file */ if (Htime >= Rtime) @@ -666,7 +748,7 @@ void accumulate(long dt) /* Re-set memory used to accumulate mass & volume */ memset(VolIn,0,(Nnodes+1)*sizeof(double)); memset(MassIn,0,(Nnodes+1)*sizeof(double)); - memset(X,0,(Nnodes+1)*sizeof(double)); + memset(XC,0,(Nnodes+1)*sizeof(double)); /* Compute average conc. of segments adjacent to each node */ /* (For use if there is no transport through the node) */ @@ -686,7 +768,7 @@ void accumulate(long dt) } } for (k=1; k<=Nnodes; k++) - if (VolIn[k] > 0.0) X[k] = MassIn[k]/VolIn[k]; + if (VolIn[k] > 0.0) XC[k] = MassIn[k]/VolIn[k]; /* Move mass from first segment of each pipe into downstream node */ memset(VolIn,0,(Nnodes+1)*sizeof(double)); @@ -767,7 +849,7 @@ void updatenodes(long dt) ** Purpose: updates concentration at all nodes to mixture of accumulated ** inflow from connecting pipes. ** -** Note: Does not account for source flow effects. X[i] contains +** Note: Does not account for source flow effects. XC[i] contains ** average concen. of segments adjacent to node i, used in case ** there was no inflow into i. **--------------------------------------------------------------------------- @@ -780,7 +862,7 @@ void updatenodes(long dt) { if (D[i] < 0.0) VolIn[i] -= D[i]*dt; if (VolIn[i] > 0.0) C[i] = MassIn[i]/VolIn[i]; - else C[i] = X[i]; + else C[i] = XC[i]; } /* Update tank quality */ @@ -809,8 +891,8 @@ void sourceinput(long dt) /* Establish a flow cutoff which indicates no outflow from a node */ qcutoff = 10.0*TINY; - /* Zero-out the work array X */ - memset(X,0,(Nnodes+1)*sizeof(double)); + /* Zero-out the work array XC */ + memset(XC,0,(Nnodes+1)*sizeof(double)); if (Qualflag != CHEM) return; /* Consider each node */ @@ -872,7 +954,7 @@ void sourceinput(long dt) } /* Source concen. contribution = (mass added / outflow volume) */ - X[n] = massadded/volout; + XC[n] = massadded/volout; /* Update total mass added for time period & simulation */ source->Smass += massadded; @@ -923,7 +1005,7 @@ void release(long dt) v = q*dt; /* Include source contribution in quality released from node. */ - c = C[n] + X[n]; + c = C[n] + XC[n]; /* If link has a last seg, check if its quality */ /* differs from that of the flow released from node.*/ @@ -952,7 +1034,7 @@ void updatesourcenodes(long dt) ** Input: dt = current WQ time step ** Output: none ** Purpose: updates quality at source nodes. -** (X[n] = concen. added by source at node n) +** (XC[n] = concen. added by source at node n) **--------------------------------------------------- */ { @@ -968,7 +1050,7 @@ void updatesourcenodes(long dt) if (source == NULL) continue; /* Add source to current node concen. */ - C[n] += X[n]; + C[n] += XC[n]; /* For tanks, node concen. = internal concen. */ if (n > Njuncs) @@ -997,21 +1079,24 @@ void updatetanks(long dt) /* Examine each reservoir & tank */ for (i=1; i<=Ntanks; i++) { + n = Tank[i].Node; /* Use initial quality for reservoirs */ if (Tank[i].A == 0.0) { - n = Tank[i].Node; C[n] = Node[n].C0; } /* Update tank WQ based on mixing model */ - else switch(Tank[i].MixModel) - { - case MIX2: tankmix2(i,dt); break; - case FIFO: tankmix3(i,dt); break; - case LIFO: tankmix4(i,dt); break; - default: tankmix1(i,dt); break; + else { + switch(Tank[i].MixModel) + { + case MIX2: tankmix2(i,dt); break; + case FIFO: tankmix3(i,dt); break; + case LIFO: tankmix4(i,dt); break; + default: tankmix1(i,dt); break; + } + } } } @@ -1443,7 +1528,7 @@ void ratecoeffs() { kw = Link[k].Kw; if (kw != 0.0) kw = piperate(k); - Link[k].R = kw; + Link[k].Rc = kw; R[k] = 0.0; } } /* End of ratecoeffs */ @@ -1526,7 +1611,7 @@ double pipereact(int k, double c, double v, long dt) /* Otherwise find bulk & wall reaction rates */ rbulk = bulkrate(c,Link[k].Kb,BulkOrder)*Bucf; - rwall = wallrate(c,Link[k].Diam,Link[k].Kw,Link[k].R); + rwall = wallrate(c,Link[k].Diam,Link[k].Kw,Link[k].Rc); /* Find change in concentration over timestep */ dcbulk = rbulk*(double)dt; diff --git a/src/text.h b/src/text.h index 0a0e5c0..890e099 100755 --- a/src/text.h +++ b/src/text.h @@ -14,6 +14,8 @@ AUTHOR: L. Rossman **************************************************** */ /* ------------ Keyword Dictionary ---------- */ +#ifndef TEXT_H +#define TEXT_H #define w_USE "USE" #define w_SAVE "SAVE" @@ -501,6 +503,8 @@ AUTHOR: L. Rossman #define ERR308 "File Error 308: cannot save results to file." #define ERR309 "File Error 309: cannot save results to report file." +#define ERR401 "Sync Error 401: Qstep is not dividable by Hstep. Can't sync." + #define R_ERR201 "Input Error 201: syntax error in following line of " #define R_ERR202 "Input Error 202: illegal numeric value in following line of " #define R_ERR203 "Input Error 203: undefined node in following line of " @@ -528,3 +532,4 @@ AUTHOR: L. Rossman #define WARN5 "WARNING: Valves cannot deliver enough flow." #define WARN6 "WARNING: System has negative pressures." +#endif \ No newline at end of file diff --git a/src/toolkit.h b/src/toolkit.h index 016a31f..eb54528 100755 --- a/src/toolkit.h +++ b/src/toolkit.h @@ -15,6 +15,8 @@ AUTHOR: L. Rossman ******************************************************************* */ +#ifndef TOOLKIT_H +#define TOOLKIT_H #ifndef DLLEXPORT #ifdef DLL @@ -247,3 +249,5 @@ extern "C" { #if defined(__cplusplus) } #endif + +#endif //TOOLKIT_H \ No newline at end of file diff --git a/src/types.h b/src/types.h index 68a495e..bc135aa 100755 --- a/src/types.h +++ b/src/types.h @@ -17,6 +17,8 @@ AUTHOR: L. Rossman ********************************************************************** */ +#ifndef TYPES_H +#define TYPES_H /*********************************************************/ /* All floats have been re-declared as doubles (7/3/07). */ @@ -206,6 +208,7 @@ typedef struct /* LINK OBJECT */ double Kb; /* Bulk react. coeff */ double Kw; /* Wall react. coeff */ double R; /* Flow resistance */ + double Rc; /* Reaction cal */ char Type; /* Link type */ char Stat; /* Initial status */ char Rpt; /* Reporting flag */ @@ -451,3 +454,4 @@ enum HdrType /* Type of table heading */ NODEHDR, /* Node Results */ LINKHDR}; /* Link Results */ +#endif \ No newline at end of file diff --git a/src/vars.h b/src/vars.h index b8b821b..ef15924 100755 --- a/src/vars.h +++ b/src/vars.h @@ -11,7 +11,13 @@ AUTHOR: L. Rossman ************************************************************************ */ -EXTERN FILE *InFile, /* Input file pointer */ +#ifndef VARS_H +#define VARS_H + +#include +#include "hash.h" + + FILE *InFile, /* Input file pointer */ *OutFile, /* Output file pointer */ *RptFile, /* Report file pointer */ *HydFile, /* Hydraulics file pointer */ @@ -144,8 +150,10 @@ EXTERN double *D, /* Node actual demand */ *K, /* Link settings */ *Q, /* Link flows */ *R, /* Pipe reaction rate */ - *X; /* General purpose array */ + *XC; /* General purpose array */ EXTERN double *H; /* Node heads */ +EXTERN double *QTankVolumes; +EXTERN double *QLinkFlow; EXTERN STmplist *Patlist; /* Temporary time pattern list */ EXTERN STmplist *Curvelist; /* Temporary list of curves */ EXTERN Spattern *Pattern; /* Time patterns */ @@ -195,3 +203,5 @@ EXTERN int *Order, /* Node-to-row of A */ EXTERN int *XLNZ, /* Start position of each column in NZSUB */ *NZSUB, /* Row index of each coeff. in each column */ *LNZ; /* Position of each coeff. in Aij array */ + +#endif \ No newline at end of file From 2bc8d36a55adce0f4338e17dd87b3bbb7be9c753 Mon Sep 17 00:00:00 2001 From: sam hatchett Date: Thu, 23 May 2013 19:40:56 -0400 Subject: [PATCH 06/14] vars and project settings -- incorporating lemon tiger changes --- .../epanet/epanet.xcodeproj/project.pbxproj | 22 +++++++++++++------ src/hash.h | 4 ++++ src/vars.h | 1 + 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/build/Xcode/epanet/epanet.xcodeproj/project.pbxproj b/build/Xcode/epanet/epanet.xcodeproj/project.pbxproj index bb0c2b8..b5b34ba 100644 --- a/build/Xcode/epanet/epanet.xcodeproj/project.pbxproj +++ b/build/Xcode/epanet/epanet.xcodeproj/project.pbxproj @@ -219,6 +219,9 @@ /* Begin PBXProject section */ 08FB7793FE84155DC02AAC07 /* Project object */ = { isa = PBXProject; + attributes = { + LastUpgradeCheck = 0460; + }; buildConfigurationList = 1DEB914E08733D8E0010E9CD /* Build configuration list for PBXProject "epanet" */; compatibilityVersion = "Xcode 3.2"; developmentRegion = English; @@ -295,10 +298,10 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; EXECUTABLE_PREFIX = lib; GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; GCC_MODEL_TUNING = G5; GCC_OPTIMIZATION_LEVEL = 0; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; @@ -312,6 +315,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + COMBINE_HIDPI_IMAGES = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; EXECUTABLE_PREFIX = lib; GCC_MODEL_TUNING = G5; @@ -326,14 +330,18 @@ isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_OPTIMIZATION_LEVEL = 0; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = macinclude; ONLY_ACTIVE_ARCH = YES; - PREBINDING = NO; SDKROOT = ""; }; name = Debug; @@ -342,12 +350,16 @@ isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = macinclude; - PREBINDING = NO; SDKROOT = ""; }; name = Release; @@ -358,14 +370,12 @@ ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; GCC_MODEL_TUNING = G5; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = CLE; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; INFOPLIST_PREPROCESSOR_DEFINITIONS = ""; INSTALL_PATH = /usr/local/bin; - PREBINDING = NO; PRODUCT_NAME = runepanet; }; name = Debug; @@ -376,13 +386,11 @@ ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_ENABLE_FIX_AND_CONTINUE = NO; GCC_MODEL_TUNING = G5; GCC_PREPROCESSOR_DEFINITIONS = CLE; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; INFOPLIST_PREPROCESSOR_DEFINITIONS = ""; INSTALL_PATH = /usr/local/bin; - PREBINDING = NO; PRODUCT_NAME = runepanet; ZERO_LINK = NO; }; diff --git a/src/hash.h b/src/hash.h index 8195afd..38999d1 100755 --- a/src/hash.h +++ b/src/hash.h @@ -4,6 +4,9 @@ ** */ +#ifndef HASH_H +#define HASH_H + #define HTMAXSIZE 1999 #define NOTFOUND 0 @@ -22,3 +25,4 @@ int HTfind(HTtable *, char *); char *HTfindKey(HTtable *, char *); void HTfree(HTtable *); +#endif \ No newline at end of file diff --git a/src/vars.h b/src/vars.h index ef15924..6ca5be4 100755 --- a/src/vars.h +++ b/src/vars.h @@ -150,6 +150,7 @@ EXTERN double *D, /* Node actual demand */ *K, /* Link settings */ *Q, /* Link flows */ *R, /* Pipe reaction rate */ + *X, /* General purpose array */ *XC; /* General purpose array */ EXTERN double *H; /* Node heads */ EXTERN double *QTankVolumes; From 4c1155745b1daf7e028eb75b7af05557fccb20f8 Mon Sep 17 00:00:00 2001 From: sam hatchett Date: Thu, 23 May 2013 19:53:26 -0400 Subject: [PATCH 07/14] setting float type by define --- .../epanet/epanet.xcodeproj/project.pbxproj | 4 -- src/epanet.c | 58 +++++++++---------- src/toolkit.h | 32 +++++----- 3 files changed, 47 insertions(+), 47 deletions(-) diff --git a/build/Xcode/epanet/epanet.xcodeproj/project.pbxproj b/build/Xcode/epanet/epanet.xcodeproj/project.pbxproj index b5b34ba..b3d2027 100644 --- a/build/Xcode/epanet/epanet.xcodeproj/project.pbxproj +++ b/build/Xcode/epanet/epanet.xcodeproj/project.pbxproj @@ -42,7 +42,6 @@ 22322FA51068369500641384 /* rules.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F7F1068369500641384 /* rules.c */; }; 22322FA61068369500641384 /* smatrix.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F801068369500641384 /* smatrix.c */; }; 22322FAA106836BC00641384 /* epanet2.h in Headers */ = {isa = PBXBuildFile; fileRef = 22322FA9106836B000641384 /* epanet2.h */; }; - 22322FAE106836D900641384 /* malloc.h in Headers */ = {isa = PBXBuildFile; fileRef = 22322FAD106836D900641384 /* malloc.h */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -79,7 +78,6 @@ 22322F831068369500641384 /* types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = types.h; path = ../../../src/types.h; sourceTree = SOURCE_ROOT; }; 22322F841068369500641384 /* vars.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = vars.h; path = ../../../src/vars.h; sourceTree = SOURCE_ROOT; }; 22322FA9106836B000641384 /* epanet2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = epanet2.h; path = ../../../include/epanet2.h; sourceTree = SOURCE_ROOT; }; - 22322FAD106836D900641384 /* malloc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = malloc.h; path = macinclude/malloc.h; sourceTree = ""; }; D2AAC0630554660B00DB518D /* libepanet.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libepanet.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -151,7 +149,6 @@ 22322FA8106836A000641384 /* Include */ = { isa = PBXGroup; children = ( - 22322FAD106836D900641384 /* malloc.h */, 22322FA9106836B000641384 /* epanet2.h */, ); name = Include; @@ -173,7 +170,6 @@ 22322F971068369500641384 /* toolkit.h in Headers */, 22322F981068369500641384 /* types.h in Headers */, 22322F991068369500641384 /* vars.h in Headers */, - 22322FAE106836D900641384 /* malloc.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/src/epanet.c b/src/epanet.c index 3512b04..f193147 100755 --- a/src/epanet.c +++ b/src/epanet.c @@ -975,7 +975,7 @@ int DLLEXPORT ENgetversion(int *v) int DLLEXPORT ENgetcontrol(int cindex, int *ctype, int *lindex, - float *setting, int *nindex, float *level) + EN_API_FLOAT_TYPE *setting, int *nindex, EN_API_FLOAT_TYPE *level) /*---------------------------------------------------------------- ** Input: cindex = control index (position of control statement ** in the input file, starting from 1) @@ -1021,9 +1021,9 @@ int DLLEXPORT ENgetcontrol(int cindex, int *ctype, int *lindex, else if (*nindex > 0) lvl = (Control[cindex].Grade - Node[*nindex].El)*Ucf[PRESSURE]; else - lvl = (float)Control[cindex].Time; - *setting = (float)s; - *level = (float)lvl; + lvl = (EN_API_FLOAT_TYPE)Control[cindex].Time; + *setting = (EN_API_FLOAT_TYPE)s; + *level = (EN_API_FLOAT_TYPE)lvl; return(0); } @@ -1054,7 +1054,7 @@ int DLLEXPORT ENgetcount(int code, int *count) } -int DLLEXPORT ENgetoption(int code, float *value) +int DLLEXPORT ENgetoption(int code, EN_API_FLOAT_TYPE *value) /*---------------------------------------------------------------- ** Input: code = option code (see TOOLKIT.H) ** Output: *value = option value @@ -1064,7 +1064,7 @@ int DLLEXPORT ENgetoption(int code, float *value) */ { double v = 0.0; - *value = 0.0f; + *value = 0.0; if (!Openflag) return(102); switch (code) { @@ -1080,7 +1080,7 @@ int DLLEXPORT ENgetoption(int code, float *value) break; default: return(251); } - *value = (float)v; + *value = (EN_API_FLOAT_TYPE)v; return(0); } @@ -1196,7 +1196,7 @@ int DLLEXPORT ENgetpatternlen(int index, int *len) } -int DLLEXPORT ENgetpatternvalue(int index, int period, float *value) +int DLLEXPORT ENgetpatternvalue(int index, int period, EN_API_FLOAT_TYPE *value) /*---------------------------------------------------------------- ** Input: index = index of time pattern ** period = pattern time period @@ -1206,11 +1206,11 @@ int DLLEXPORT ENgetpatternvalue(int index, int period, float *value) ** and pattern **---------------------------------------------------------------- */ -{ *value = 0.0f; +{ *value = 0.0; if (!Openflag) return(102); if (index < 1 || index > Npats) return(205); if (period < 1 || period > Pattern[index].Length) return(251); - *value = (float)Pattern[index].F[period-1]; + *value = (EN_API_FLOAT_TYPE)Pattern[index].F[period-1]; return(0); } @@ -1345,7 +1345,7 @@ int DLLEXPORT ENgetnodetype(int index, int *code) } -int DLLEXPORT ENgetnodevalue(int index, int code, float *value) +int DLLEXPORT ENgetnodevalue(int index, int code, EN_API_FLOAT_TYPE *value) /*---------------------------------------------------------------- ** Input: index = node index ** code = node parameter code (see TOOLKIT.H) @@ -1360,7 +1360,7 @@ int DLLEXPORT ENgetnodevalue(int index, int code, float *value) Psource source; /* Check for valid arguments */ - *value = 0.0f; + *value = 0.0; if (!Openflag) return(102); if (index <= 0 || index > Nnodes) return(203); @@ -1518,7 +1518,7 @@ int DLLEXPORT ENgetnodevalue(int index, int code, float *value) default: return(251); } - *value = (float)v; + *value = (EN_API_FLOAT_TYPE)v; return(0); } @@ -1603,7 +1603,7 @@ int DLLEXPORT ENgetlinknodes(int index, int *node1, int *node2) } -int DLLEXPORT ENgetlinkvalue(int index, int code, float *value) +int DLLEXPORT ENgetlinkvalue(int index, int code, EN_API_FLOAT_TYPE *value) /*------------------------------------------------------------------ ** Input: index = link index ** code = link parameter code (see TOOLKIT.H) @@ -1616,7 +1616,7 @@ int DLLEXPORT ENgetlinkvalue(int index, int code, float *value) double a,h,q, v = 0.0; /* Check for valid arguments */ - *value = 0.0f; + *value = 0.0; if (!Openflag) return(102); if (index <= 0 || index > Nlinks) return(204); @@ -1740,12 +1740,12 @@ int DLLEXPORT ENgetlinkvalue(int index, int code, float *value) default: return(251); } - *value = (float)v; + *value = (EN_API_FLOAT_TYPE)v; return(0); } -int DLLEXPORT ENgetcurve(int curveIndex, int *nValues, float **xValues, float **yValues) // !sph +int DLLEXPORT ENgetcurve(int curveIndex, int *nValues, EN_API_FLOAT_TYPE **xValues, EN_API_FLOAT_TYPE **yValues) // !sph /*---------------------------------------------------------------- ** Input: curveIndex = curve index ** Output: *nValues = number of points on curve @@ -1761,14 +1761,14 @@ int DLLEXPORT ENgetcurve(int curveIndex, int *nValues, float **xValues, float * Scurve curve = Curve[curveIndex]; int nPoints = curve.Npts; - float *pointX = calloc(nPoints, sizeof(float)); - float *pointY = calloc(nPoints, sizeof(float)); + EN_API_FLOAT_TYPE *pointX = calloc(nPoints, sizeof(EN_API_FLOAT_TYPE)); + EN_API_FLOAT_TYPE *pointY = calloc(nPoints, sizeof(EN_API_FLOAT_TYPE)); for (int iPoint = 0; iPoint < nPoints; iPoint++) { double x = curve.X[iPoint] * Ucf[LENGTH]; double y = curve.Y[iPoint] * Ucf[VOLUME]; - pointX[iPoint] = (float)x; - pointY[iPoint] = (float)y; + pointX[iPoint] = (EN_API_FLOAT_TYPE)x; + pointY[iPoint] = (EN_API_FLOAT_TYPE)y; } *nValues = nPoints; @@ -1786,7 +1786,7 @@ int DLLEXPORT ENgetcurve(int curveIndex, int *nValues, float **xValues, float * int DLLEXPORT ENsetcontrol(int cindex, int ctype, int lindex, - float setting, int nindex, float level) + EN_API_FLOAT_TYPE setting, int nindex, EN_API_FLOAT_TYPE level) /*---------------------------------------------------------------- ** Input: cindex = control index (position of control statement ** in the input file, starting from 1) @@ -1874,7 +1874,7 @@ int DLLEXPORT ENsetcontrol(int cindex, int ctype, int lindex, } -int DLLEXPORT ENsetnodevalue(int index, int code, float v) +int DLLEXPORT ENsetnodevalue(int index, int code, EN_API_FLOAT_TYPE v) /*---------------------------------------------------------------- ** Input: index = node index ** code = node parameter code (see TOOLKIT.H) @@ -2083,7 +2083,7 @@ int DLLEXPORT ENsetnodevalue(int index, int code, float v) } -int DLLEXPORT ENsetlinkvalue(int index, int code, float v) +int DLLEXPORT ENsetlinkvalue(int index, int code, EN_API_FLOAT_TYPE v) /*---------------------------------------------------------------- ** Input: index = link index ** code = link parameter code (see TOOLKIT.H) @@ -2270,7 +2270,7 @@ int DLLEXPORT ENaddpattern(char *id) } -int DLLEXPORT ENsetpattern(int index, float *f, int n) +int DLLEXPORT ENsetpattern(int index, EN_API_FLOAT_TYPE *f, int n) /*---------------------------------------------------------------- ** Input: index = time pattern index ** *f = array of pattern multipliers @@ -2299,7 +2299,7 @@ int DLLEXPORT ENsetpattern(int index, float *f, int n) } -int DLLEXPORT ENsetpatternvalue(int index, int period, float value) +int DLLEXPORT ENsetpatternvalue(int index, int period, EN_API_FLOAT_TYPE value) /*---------------------------------------------------------------- ** Input: index = time pattern index ** period = time pattern period @@ -2379,7 +2379,7 @@ int DLLEXPORT ENsettimeparam(int code, long value) } -int DLLEXPORT ENsetoption(int code, float v) +int DLLEXPORT ENsetoption(int code, EN_API_FLOAT_TYPE v) /*---------------------------------------------------------------- ** Input: code = option code (see TOOLKIT.H) ** v = option value @@ -3215,7 +3215,7 @@ int DLLEXPORT ENgetnumdemands(int nodeIndex, int *numDemands) *numDemands=n; return 0; } -int DLLEXPORT ENgetbasedemand(int nodeIndex, int demandIdx, float *baseDemand) +int DLLEXPORT ENgetbasedemand(int nodeIndex, int demandIdx, EN_API_FLOAT_TYPE *baseDemand) { Pdemand d; int n=0; @@ -3224,7 +3224,7 @@ int DLLEXPORT ENgetbasedemand(int nodeIndex, int demandIdx, float *baseDemand) if (nodeIndex <= 0 || nodeIndex > Nnodes) return(203); for(d=Node[nodeIndex].D; nnext) n++; if(n!=demandIdx) return(253); - *baseDemand=(float)(d->Base*Ucf[FLOW]); + *baseDemand=(EN_API_FLOAT_TYPE)(d->Base*Ucf[FLOW]); return 0; } int DLLEXPORT ENgetdemandpattern(int nodeIndex, int demandIdx, int *pattIdx) diff --git a/src/toolkit.h b/src/toolkit.h index eb54528..814fc39 100755 --- a/src/toolkit.h +++ b/src/toolkit.h @@ -18,6 +18,10 @@ AUTHOR: L. Rossman #ifndef TOOLKIT_H #define TOOLKIT_H +#ifndef EN_API_FLOAT_TYPE + #define EN_API_FLOAT_TYPE float +#endif + #ifndef DLLEXPORT #ifdef DLL #ifdef __cplusplus @@ -202,16 +206,16 @@ extern "C" { int DLLEXPORT ENresetreport(void); int DLLEXPORT ENsetreport(char *); - int DLLEXPORT ENgetcontrol(int, int *, int *, float *, - int *, float *); + int DLLEXPORT ENgetcontrol(int, int *, int *, EN_API_FLOAT_TYPE *, + int *, EN_API_FLOAT_TYPE *); int DLLEXPORT ENgetcount(int, int *); - int DLLEXPORT ENgetoption(int, float *); + int DLLEXPORT ENgetoption(int, EN_API_FLOAT_TYPE *); int DLLEXPORT ENgettimeparam(int, long *); int DLLEXPORT ENgetflowunits(int *); int DLLEXPORT ENgetpatternindex(char *, int *); int DLLEXPORT ENgetpatternid(int, char *); int DLLEXPORT ENgetpatternlen(int, int *); - int DLLEXPORT ENgetpatternvalue(int, int, float *); + int DLLEXPORT ENgetpatternvalue(int, int, EN_API_FLOAT_TYPE *); int DLLEXPORT ENgetqualtype(int *, int *); int DLLEXPORT ENgeterror(int, char *, int); int DLLEXPORT ENgetstatistic(int code, int* value); @@ -219,30 +223,30 @@ extern "C" { int DLLEXPORT ENgetnodeindex(char *, int *); int DLLEXPORT ENgetnodeid(int, char *); int DLLEXPORT ENgetnodetype(int, int *); - int DLLEXPORT ENgetnodevalue(int, int, float *); + int DLLEXPORT ENgetnodevalue(int, int, EN_API_FLOAT_TYPE *); int DLLEXPORT ENgetnumdemands(int, int *); - int DLLEXPORT ENgetbasedemand(int, int, float *); + int DLLEXPORT ENgetbasedemand(int, int, EN_API_FLOAT_TYPE *); int DLLEXPORT ENgetdemandpattern(int, int, int *); int DLLEXPORT ENgetlinkindex(char *, int *); int DLLEXPORT ENgetlinkid(int, char *); int DLLEXPORT ENgetlinktype(int, int *); int DLLEXPORT ENgetlinknodes(int, int *, int *); - int DLLEXPORT ENgetlinkvalue(int, int, float *); + int DLLEXPORT ENgetlinkvalue(int, int, EN_API_FLOAT_TYPE *); - int DLLEXPORT ENgetcurve(int curveIndex, int *nValues, float **xValues, float **yValues); + int DLLEXPORT ENgetcurve(int curveIndex, int *nValues, EN_API_FLOAT_TYPE **xValues, EN_API_FLOAT_TYPE **yValues); int DLLEXPORT ENgetversion(int *); - int DLLEXPORT ENsetcontrol(int, int, int, float, int, float); - int DLLEXPORT ENsetnodevalue(int, int, float); - int DLLEXPORT ENsetlinkvalue(int, int, float); + int DLLEXPORT ENsetcontrol(int, int, int, EN_API_FLOAT_TYPE, int, EN_API_FLOAT_TYPE); + int DLLEXPORT ENsetnodevalue(int, int, EN_API_FLOAT_TYPE); + int DLLEXPORT ENsetlinkvalue(int, int, EN_API_FLOAT_TYPE); int DLLEXPORT ENaddpattern(char *); - int DLLEXPORT ENsetpattern(int, float *, int); - int DLLEXPORT ENsetpatternvalue(int, int, float); + int DLLEXPORT ENsetpattern(int, EN_API_FLOAT_TYPE *, int); + int DLLEXPORT ENsetpatternvalue(int, int, EN_API_FLOAT_TYPE); int DLLEXPORT ENsettimeparam(int, long); - int DLLEXPORT ENsetoption(int, float); + int DLLEXPORT ENsetoption(int, EN_API_FLOAT_TYPE); int DLLEXPORT ENsetstatusreport(int); int DLLEXPORT ENsetqualtype(int, char *, char *, char *); From 9da5f4f658164abf0a562476287452db904fa4ae Mon Sep 17 00:00:00 2001 From: Sam Hatchett Date: Fri, 24 May 2013 15:54:02 -0400 Subject: [PATCH 08/14] rtx mods, epanet gets coords --- src/epanet.c | 44 +++++++++++++++-- src/funcs.h | 3 ++ src/input2.c | 133 ++++++++++++++++++++++++++++++++++++++++++++------ src/input3.c | 55 +++++++++++++++++++++ src/toolkit.h | 1 + src/types.h | 7 +++ src/vars.h | 4 ++ 7 files changed, 228 insertions(+), 19 deletions(-) diff --git a/src/epanet.c b/src/epanet.c index f193147..5b7edb1 100755 --- a/src/epanet.c +++ b/src/epanet.c @@ -318,6 +318,7 @@ int DLLEXPORT ENopen(char *f1, char *f2, char *f3) /* Free temporary linked lists used for Patterns & Curves */ freeTmplist(Patlist); freeTmplist(Curvelist); + freeTmplist(Coordlist); /* If using previously saved hydraulics then open its file */ if (Hydflag == USE) ERRCODE(openhydfile()); @@ -1345,6 +1346,21 @@ int DLLEXPORT ENgetnodetype(int index, int *code) } +int DLLEXPORT ENgetcoord(int index, EN_API_FLOAT_TYPE *x, EN_API_FLOAT_TYPE *y) +/*---------------------------------------------------------------- + ** Input: index = node index + ** Output: *x = value of node's coordinate + ** *x = value of node's coordinate + ** Returns: error code + ** Purpose: retrieves coordinate x, y for a node + **---------------------------------------------------------------- + */ +{ + *x = Coord[index].X[0]; + *y = Coord[index].Y[0]; + return 0; +} + int DLLEXPORT ENgetnodevalue(int index, int code, EN_API_FLOAT_TYPE *value) /*---------------------------------------------------------------- ** Input: index = node index @@ -2330,10 +2346,16 @@ int DLLEXPORT ENsettimeparam(int code, long value) { if (!Openflag) return(102); if (OpenHflag || OpenQflag) { - // --> there's nothing wrong with changing certain time parameters during a simulation run - if (code != EN_DURATION) { + // --> there's nothing wrong with changing certain time parameters during a simulation run, or before the run has started. + // todo -- how to tell? + /* + if (code == EN_DURATION || code == EN_HTIME || code == EN_REPORTSTEP || code == EN_DURATION || Htime == 0) { + // it's ok + } + else { return(109); } + */ } if (value < 0) return(202); switch(code) @@ -2730,10 +2752,12 @@ void initpointers() Pattern = NULL; Curve = NULL; Control = NULL; + Coord = NULL; X = NULL; Patlist = NULL; Curvelist = NULL; + Coordlist = NULL; Adjlist = NULL; Aii = NULL; Aij = NULL; @@ -2813,12 +2837,14 @@ int allocdata() Control = (Scontrol *) calloc(MaxControls+1,sizeof(Scontrol)); Pattern = (Spattern *) calloc(MaxPats+1, sizeof(Spattern)); Curve = (Scurve *) calloc(MaxCurves+1, sizeof(Scurve)); + Coord = (Scoord *) calloc(MaxNodes+1, sizeof(Scoord)); ERRCODE(MEMCHECK(Tank)); ERRCODE(MEMCHECK(Pump)); ERRCODE(MEMCHECK(Valve)); ERRCODE(MEMCHECK(Control)); ERRCODE(MEMCHECK(Pattern)); ERRCODE(MEMCHECK(Curve)); + ERRCODE(MEMCHECK(Coord)); } /* Initialize pointers used in patterns, curves, and demand category lists */ @@ -2836,7 +2862,19 @@ int allocdata() Curve[n].X = NULL; Curve[n].Y = NULL; } - for (n=0; n<=MaxNodes; n++) Node[n].D = NULL; + + for (n=0; n<=MaxNodes; n++) + { + // node demand + Node[n].D = NULL; + /* Allocate memory for coord data */ + Coord[n].X = (double *) calloc(1, sizeof(double)); + Coord[n].Y = (double *) calloc(1, sizeof(double)); + if (Coord[n].X == NULL || Coord[n].Y == NULL) return(101); + Coord[n].X[0] = 0; + Coord[n].Y[0] = 0; + } + } /* Allocate memory for rule base (see RULES.C) */ diff --git a/src/funcs.h b/src/funcs.h index 1fa5677..c7907f8 100755 --- a/src/funcs.h +++ b/src/funcs.h @@ -61,11 +61,13 @@ int addnodeID(int, char *); /* Adds node ID to data base */ int addlinkID(int, char *); /* Adds link ID to data base */ int addpattern(char *); /* Adds pattern to data base */ int addcurve(char *); /* Adds curve to data base */ +int addcoord(char *); /* Adds coord to data base */ STmplist *findID(char *, STmplist *); /* Locates ID on linked list */ int unlinked(void); /* Checks for unlinked nodes */ int getpumpparams(void); /* Computes pump curve coeffs.*/ int getpatterns(void); /* Gets pattern data from list*/ int getcurves(void); /* Gets curve data from list */ +int getcoords(void); /* Gets coordinate data from list */ int findmatch(char *,char *[]); /* Finds keyword in line */ int match(char *, char *); /* Checks for word match */ int gettokens(char *); /* Tokenizes input line */ @@ -82,6 +84,7 @@ int pumpdata(void); /* Processes pump data */ int valvedata(void); /* Processes valve data */ int patterndata(void); /* Processes pattern data */ int curvedata(void); /* Processes curve data */ +int coordata(void); /* Processes coordinate data */ int demanddata(void); /* Processes demand data */ int controldata(void); /* Processes simple controls */ int energydata(void); /* Processes energy data */ diff --git a/src/input2.c b/src/input2.c index a0fa344..1c8b873 100755 --- a/src/input2.c +++ b/src/input2.c @@ -48,6 +48,7 @@ char *Tok[MAXTOKS]; /* Array of token strings */ /* Used in INPUT3.C: */ STmplist *PrevPat; /* Pointer to pattern list element */ STmplist *PrevCurve; /* Pointer to curve list element */ +STmplist *PrevCoord; /* Pointer to coordinate list element */ /* Defined in enumstxt.h in EPANET.C */ extern char *SectTxt[]; /* Input section keywords */ @@ -78,7 +79,8 @@ int netsize() MaxRules = 0; MaxCurves = 0; sect = -1; - + MaxCoords = 0; + /* Add a default pattern 0 */ MaxPats = -1; addpattern(""); @@ -106,20 +108,22 @@ int netsize() /* Add to count of current component */ switch(sect) - { - case _JUNCTIONS: MaxJuncs++; break; - case _RESERVOIRS: - case _TANKS: MaxTanks++; break; - case _PIPES: MaxPipes++; break; - case _PUMPS: MaxPumps++; break; - case _VALVES: MaxValves++; break; - case _CONTROLS: MaxControls++; break; - case _RULES: addrule(tok); break; /* See RULES.C */ - case _PATTERNS: errcode = addpattern(tok); - break; - case _CURVES: errcode = addcurve(tok); - break; - } + { + case _JUNCTIONS: MaxJuncs++; break; + case _RESERVOIRS: + case _TANKS: MaxTanks++; break; + case _PIPES: MaxPipes++; break; + case _PUMPS: MaxPumps++; break; + case _VALVES: MaxValves++; break; + case _CONTROLS: MaxControls++; break; + case _RULES: addrule(tok); break; /* See RULES.C */ + case _PATTERNS: errcode = addpattern(tok); + break; + case _CURVES: errcode = addcurve(tok); + break; + case _COORDS: errcode = addcoord(tok); //06.02.2010-woohn + break; + } if (errcode) break; } @@ -172,6 +176,8 @@ int readdata() Npats = MaxPats; PrevPat = NULL; PrevCurve = NULL; + PrevCoord = NULL; + sect = -1; errsum = 0; @@ -239,6 +245,7 @@ int readdata() /* Get pattern & curve data from temp. lists */ if (!errcode) errcode = getpatterns(); if (!errcode) errcode = getcurves(); + if (!errcode) errcode = getcoords(); if (!errcode) errcode = getpumpparams(); /* Free input buffer */ @@ -293,7 +300,7 @@ int newline(int sect, char *line) case _OPTIONS: return(optiondata()); /* Data in these sections are not used for any computations */ - case _COORDS: return(0); + case _COORDS: return(coordata()); case _LABELS: return(0); case _TAGS: return(0); case _VERTICES: return(0); @@ -513,6 +520,42 @@ int addcurve(char *id) return(0); } +int addcoord(char *id) +/* + **------------------------------------------------------------- + ** Input: id = curve ID label + ** Output: returns error code + ** Purpose: adds a new curve to the database + **-------------------------------------------------------------- + */ +{ + STmplist *c; + + /* Check if ID is same as last one processed */ + if (Coordlist != NULL && strcmp(id,Coordlist->ID) == 0) return(0); + + /* Check that coordinate was not already created */ + if (findID(id,Coordlist) == NULL) + { + + /* Update coordinate count & create new list element */ + (MaxCoords)++; + c = (STmplist *) malloc(sizeof(STmplist)); + if (c == NULL) { + return(101); + } + else { + /* Initialize list element properties */ + c->i = MaxCoords; + strncpy(c->ID,id,MAXID); + c->x = NULL; + c->y = NULL; + c->next = Coordlist; + Coordlist = c; + } + } + return(0); +} STmplist *findID(char *id, STmplist *list) /* @@ -705,6 +748,64 @@ int getcurves(void) return(0); } +int getcoords(void) +/* + **----------------------------------------------------------- + ** Input: none + ** Output: returns error code + ** Purpose: retrieves curve data from temporary linked list + **----------------------------------------------------------- + */ +{ + int i,j,n; + double x; + SFloatlist *xFloatList, *yFloatList; + STmplist *coordinateList; + + /* Start at head of coordinate list */ + coordinateList = Coordlist; + + /* Traverse list of coordinates */ + while (coordinateList != NULL) + { + i = coordinateList->i; + if (i >= 1 && i <= MaxNodes) + { + /* Save coordinate ID */ + strcpy(Coord[i].ID, coordinateList->ID); + + n = 1; //Coord[i].Npts + + /* Traverse list of x,y data */ + x = BIG; + xFloatList = coordinateList->x; + yFloatList = coordinateList->y; + j = n - 1; + while (xFloatList != NULL && yFloatList != NULL && j >= 0) + { + + /* Check that x data is in ascending order */ + if (xFloatList->value >= x) + { + sprintf(Msg,ERR230,coordinateList->ID); + writeline(Msg); + return(200); + } + x = xFloatList->value; + + /* Save x,y data in Curve structure */ + Coord[i].X[j] = xFloatList->value; + xFloatList = xFloatList->next; + Coord[i].Y[j] = yFloatList->value; + yFloatList = yFloatList->next; + j--; + } + } + coordinateList = coordinateList->next; + } + return(0); +} + int findmatch(char *line, char *keyword[]) /* diff --git a/src/input3.c b/src/input3.c index 0d72c37..a19bfdc 100755 --- a/src/input3.c +++ b/src/input3.c @@ -42,6 +42,8 @@ extern char *Fldname[]; extern char *Tok[MAXTOKS]; extern STmplist *PrevPat; extern STmplist *PrevCurve; + +extern STmplist *PrevCoord; extern int Ntokens; @@ -577,6 +579,59 @@ int curvedata() return(0); } +int coordata() +/* + **-------------------------------------------------------------- + ** Input: none + ** Output: returns error code + ** Purpose: processes coordinate data + ** Format: + ** [COORD] + ** id x y + **-------------------------------------------------------------- + */ +{ + double x,y; + SFloatlist *fx, *fy; + STmplist *c; + + /* Check for valid curve ID */ + if (Ntokens < 3) return(201); + + if ( + PrevCoord != NULL && + strcmp(Tok[0],PrevCoord->ID) == 0 + ) c = PrevCoord; + else c = findID(Tok[0],Coordlist); + + // c = findID(Tok[0],Coordlist); + if (c == NULL) return(205); + + /* Check for valid data */ + if (!getfloat(Tok[1],&x)) return(202); + if (!getfloat(Tok[2],&y)) return(202); + + /* Add new data point to curve's linked list */ + fx = (SFloatlist *) malloc(sizeof(SFloatlist)); + fy = (SFloatlist *) malloc(sizeof(SFloatlist)); + if (fx == NULL || fy == NULL) return(101); + fx->value = x; + fx->next = c->x; + c->x = fx; + fy->value = y; + fy->next = c->y; + c->y = fy; + //Curve[c->i].Npts++; + + /* Save the pointer to this curve */ + PrevCoord = c; + return(0); + + /* Save coordn data */ + //Coord[Njuncs].X = x; + //Coord[Njuncs].Y = y; + +} /* end of coordata */ int demanddata() /* diff --git a/src/toolkit.h b/src/toolkit.h index 814fc39..b2fa8a7 100755 --- a/src/toolkit.h +++ b/src/toolkit.h @@ -224,6 +224,7 @@ extern "C" { int DLLEXPORT ENgetnodeid(int, char *); int DLLEXPORT ENgetnodetype(int, int *); int DLLEXPORT ENgetnodevalue(int, int, EN_API_FLOAT_TYPE *); + int DLLEXPORT ENgetcoord(int , EN_API_FLOAT_TYPE *, EN_API_FLOAT_TYPE *); int DLLEXPORT ENgetnumdemands(int, int *); int DLLEXPORT ENgetbasedemand(int, int, EN_API_FLOAT_TYPE *); diff --git a/src/types.h b/src/types.h index bc135aa..becf1b2 100755 --- a/src/types.h +++ b/src/types.h @@ -167,6 +167,13 @@ typedef struct /* CURVE OBJECT */ double *Y; /* Y-values */ } Scurve; +typedef struct /* Coord OBJECT */ +{ + char ID[MAXID+1]; /* Coord ID */ + double *X; /* X-values */ + double *Y; /* Y-values */ +} Scoord; + struct Sdemand /* DEMAND CATEGORY OBJECT */ { double Base; /* Baseline demand */ diff --git a/src/vars.h b/src/vars.h index 6ca5be4..99273e3 100755 --- a/src/vars.h +++ b/src/vars.h @@ -76,6 +76,7 @@ EXTERN int MaxNodes, /* Node count from input file */ MaxRules, /* Rule count */ MaxPats, /* Pattern count */ MaxCurves, /* Curve count */ + MaxCoords, /* Coords count */ Nnodes, /* Number of network nodes */ Ntanks, /* Number of tanks */ Njuncs, /* Number of junction nodes */ @@ -87,6 +88,7 @@ EXTERN int MaxNodes, /* Node count from input file */ Nrules, /* Number of control rules */ Npats, /* Number of time patterns */ Ncurves, /* Number of data curves */ + Ncoords, /* Number of Coords */ Nperiods, /* Number of reporting periods */ Ncoeffs, /* Number of non-0 matrix coeffs*/ DefPat, /* Default demand pattern */ @@ -157,8 +159,10 @@ EXTERN double *QTankVolumes; EXTERN double *QLinkFlow; EXTERN STmplist *Patlist; /* Temporary time pattern list */ EXTERN STmplist *Curvelist; /* Temporary list of curves */ +EXTERN STmplist *Coordlist; /* Temporary list of coordinates*/ EXTERN Spattern *Pattern; /* Time patterns */ EXTERN Scurve *Curve; /* Curve data */ +EXTERN Scoord *Coord; /* Coordinate data */ EXTERN Snode *Node; /* Node data */ EXTERN Slink *Link; /* Link data */ EXTERN Stank *Tank; /* Tank data */ From d72162114a6bf5f6f8e209a78d78ae42caf31430 Mon Sep 17 00:00:00 2001 From: Sam Hatchett Date: Tue, 28 May 2013 09:47:25 -0400 Subject: [PATCH 09/14] double-typed en toolkit for compilation --- build/Xcode/epanet/epanet.xcodeproj/project.pbxproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build/Xcode/epanet/epanet.xcodeproj/project.pbxproj b/build/Xcode/epanet/epanet.xcodeproj/project.pbxproj index b3d2027..ec5a5ae 100644 --- a/build/Xcode/epanet/epanet.xcodeproj/project.pbxproj +++ b/build/Xcode/epanet/epanet.xcodeproj/project.pbxproj @@ -300,6 +300,7 @@ GCC_DYNAMIC_NO_PIC = NO; GCC_MODEL_TUNING = G5; GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = "EN_API_FLOAT_TYPE=double"; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; INSTALL_PATH = /usr/local/lib; PRODUCT_NAME = epanet; @@ -315,6 +316,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; EXECUTABLE_PREFIX = lib; GCC_MODEL_TUNING = G5; + GCC_PREPROCESSOR_DEFINITIONS = "EN_API_FLOAT_TYPE=double"; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; INSTALL_PATH = /usr/local/lib; PRODUCT_NAME = epanet; From 067c0fd95025eb56440d3f26bd6e5788914d240c Mon Sep 17 00:00:00 2001 From: Sam Hatchett Date: Fri, 31 May 2013 11:59:09 -0400 Subject: [PATCH 10/14] fixing coordinates bug, adding useful methods --- .../epanet/epanet.xcodeproj/project.pbxproj | 118 ++++++++++++++++++ src/input2.c | 6 +- 2 files changed, 122 insertions(+), 2 deletions(-) diff --git a/build/Xcode/epanet/epanet.xcodeproj/project.pbxproj b/build/Xcode/epanet/epanet.xcodeproj/project.pbxproj index ec5a5ae..3ef27ef 100644 --- a/build/Xcode/epanet/epanet.xcodeproj/project.pbxproj +++ b/build/Xcode/epanet/epanet.xcodeproj/project.pbxproj @@ -42,6 +42,19 @@ 22322FA51068369500641384 /* rules.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F7F1068369500641384 /* rules.c */; }; 22322FA61068369500641384 /* smatrix.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F801068369500641384 /* smatrix.c */; }; 22322FAA106836BC00641384 /* epanet2.h in Headers */ = {isa = PBXBuildFile; fileRef = 22322FA9106836B000641384 /* epanet2.h */; }; + 2255753F17551234009946B1 /* epanet.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F711068369500641384 /* epanet.c */; }; + 2255754017551234009946B1 /* hash.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F731068369500641384 /* hash.c */; }; + 2255754117551234009946B1 /* hydraul.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F751068369500641384 /* hydraul.c */; }; + 2255754217551234009946B1 /* inpfile.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F761068369500641384 /* inpfile.c */; }; + 2255754317551234009946B1 /* input1.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F771068369500641384 /* input1.c */; }; + 2255754417551234009946B1 /* input2.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F781068369500641384 /* input2.c */; }; + 2255754517551234009946B1 /* input3.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F791068369500641384 /* input3.c */; }; + 2255754617551234009946B1 /* mempool.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F7A1068369500641384 /* mempool.c */; }; + 2255754717551234009946B1 /* output.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F7C1068369500641384 /* output.c */; }; + 2255754817551234009946B1 /* quality.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F7D1068369500641384 /* quality.c */; }; + 2255754917551234009946B1 /* report.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F7E1068369500641384 /* report.c */; }; + 2255754A17551234009946B1 /* rules.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F7F1068369500641384 /* rules.c */; }; + 2255754B17551234009946B1 /* smatrix.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F801068369500641384 /* smatrix.c */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -78,6 +91,7 @@ 22322F831068369500641384 /* types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = types.h; path = ../../../src/types.h; sourceTree = SOURCE_ROOT; }; 22322F841068369500641384 /* vars.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = vars.h; path = ../../../src/vars.h; sourceTree = SOURCE_ROOT; }; 22322FA9106836B000641384 /* epanet2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = epanet2.h; path = ../../../include/epanet2.h; sourceTree = SOURCE_ROOT; }; + 2255753B17551217009946B1 /* libepanet-static.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libepanet-static.a"; sourceTree = BUILT_PRODUCTS_DIR; }; D2AAC0630554660B00DB518D /* libepanet.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libepanet.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -89,6 +103,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 2255753817551217009946B1 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; D289988505E68E00004EDB86 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -142,6 +163,7 @@ children = ( D2AAC0630554660B00DB518D /* libepanet.dylib */, 22322F66106833BB00641384 /* runepanet */, + 2255753B17551217009946B1 /* libepanet-static.a */, ); name = Products; sourceTree = ""; @@ -157,6 +179,13 @@ /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ + 2255753917551217009946B1 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; D2AAC0600554660B00DB518D /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; @@ -193,6 +222,23 @@ productReference = 22322F66106833BB00641384 /* runepanet */; productType = "com.apple.product-type.tool"; }; + 2255753A17551217009946B1 /* epanet-static */ = { + isa = PBXNativeTarget; + buildConfigurationList = 2255753E17551217009946B1 /* Build configuration list for PBXNativeTarget "epanet-static" */; + buildPhases = ( + 2255753717551217009946B1 /* Sources */, + 2255753817551217009946B1 /* Frameworks */, + 2255753917551217009946B1 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "epanet-static"; + productName = "epanet-static"; + productReference = 2255753B17551217009946B1 /* libepanet-static.a */; + productType = "com.apple.product-type.library.static"; + }; D2AAC0620554660B00DB518D /* epanet */ = { isa = PBXNativeTarget; buildConfigurationList = 1DEB914A08733D8E0010E9CD /* Build configuration list for PBXNativeTarget "epanet" */; @@ -234,6 +280,7 @@ targets = ( D2AAC0620554660B00DB518D /* epanet */, 22322F65106833BB00641384 /* runepanet */, + 2255753A17551217009946B1 /* epanet-static */, ); }; /* End PBXProject section */ @@ -259,6 +306,26 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 2255753717551217009946B1 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 2255753F17551234009946B1 /* epanet.c in Sources */, + 2255754017551234009946B1 /* hash.c in Sources */, + 2255754117551234009946B1 /* hydraul.c in Sources */, + 2255754217551234009946B1 /* inpfile.c in Sources */, + 2255754317551234009946B1 /* input1.c in Sources */, + 2255754417551234009946B1 /* input2.c in Sources */, + 2255754517551234009946B1 /* input3.c in Sources */, + 2255754617551234009946B1 /* mempool.c in Sources */, + 2255754717551234009946B1 /* output.c in Sources */, + 2255754817551234009946B1 /* quality.c in Sources */, + 2255754917551234009946B1 /* report.c in Sources */, + 2255754A17551234009946B1 /* rules.c in Sources */, + 2255754B17551234009946B1 /* smatrix.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; D2AAC0610554660B00DB518D /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -394,6 +461,49 @@ }; name = Release; }; + 2255753C17551217009946B1 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_WARN_EMPTY_BODY = YES; + COPY_PHASE_STRIP = NO; + EXECUTABLE_PREFIX = lib; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + MACOSX_DEPLOYMENT_TARGET = 10.8; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + }; + name = Debug; + }; + 2255753D17551217009946B1 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_WARN_EMPTY_BODY = YES; + COPY_PHASE_STRIP = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + EXECUTABLE_PREFIX = lib; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + MACOSX_DEPLOYMENT_TARGET = 10.8; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -424,6 +534,14 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 2255753E17551217009946B1 /* Build configuration list for PBXNativeTarget "epanet-static" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 2255753C17551217009946B1 /* Debug */, + 2255753D17551217009946B1 /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; /* End XCConfigurationList section */ }; rootObject = 08FB7793FE84155DC02AAC07 /* Project object */; diff --git a/src/input2.c b/src/input2.c index 1c8b873..41fe783 100755 --- a/src/input2.c +++ b/src/input2.c @@ -546,7 +546,8 @@ int addcoord(char *id) } else { /* Initialize list element properties */ - c->i = MaxCoords; + // c->i = MaxCoords; // bug! if coordinates are not in the same order as junctions, then this is a BAD assumption + // do this later: c->i = findnode(id); strncpy(c->ID,id,MAXID); c->x = NULL; c->y = NULL; @@ -768,7 +769,8 @@ int getcoords(void) /* Traverse list of coordinates */ while (coordinateList != NULL) { - i = coordinateList->i; + // BAD! ---> i = coordinateList->i; + i = findnode(coordinateList->ID); if (i >= 1 && i <= MaxNodes) { /* Save coordinate ID */ From a55f5e3e79331202f5df86d0169a8690c0fa73c3 Mon Sep 17 00:00:00 2001 From: Sam Hatchett Date: Tue, 4 Jun 2013 17:33:44 -0400 Subject: [PATCH 11/14] fixing coordinates (as in, disabling) --- src/input2.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/input2.c b/src/input2.c index 41fe783..9f569e0 100755 --- a/src/input2.c +++ b/src/input2.c @@ -121,8 +121,8 @@ int netsize() break; case _CURVES: errcode = addcurve(tok); break; - case _COORDS: errcode = addcoord(tok); //06.02.2010-woohn - break; +// case _COORDS: errcode = addcoord(tok); //06.02.2010-woohn +// break; } if (errcode) break; } @@ -245,7 +245,7 @@ int readdata() /* Get pattern & curve data from temp. lists */ if (!errcode) errcode = getpatterns(); if (!errcode) errcode = getcurves(); - if (!errcode) errcode = getcoords(); + //if (!errcode) errcode = getcoords(); if (!errcode) errcode = getpumpparams(); /* Free input buffer */ @@ -300,7 +300,7 @@ int newline(int sect, char *line) case _OPTIONS: return(optiondata()); /* Data in these sections are not used for any computations */ - case _COORDS: return(coordata()); + case _COORDS: return (0); //return(coordata()); case _LABELS: return(0); case _TAGS: return(0); case _VERTICES: return(0); From 7e731b78abb17ace3257f1bea5ba8419eff2e293 Mon Sep 17 00:00:00 2001 From: jamesuber Date: Wed, 5 Jun 2013 11:33:17 -0400 Subject: [PATCH 12/14] added method ENgetaveragepatternvalue. modified ENgetbasedemand and ENgetdemandpattern to use pattern index starting with 1, consistent with other API functions. --- include/epanet2.h | 1 + src/epanet.c | 41 ++++++++++++++++++++++++++++++++++------- src/toolkit.h | 1 + 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/include/epanet2.h b/include/epanet2.h index d1d37f1..ff05d27 100755 --- a/include/epanet2.h +++ b/include/epanet2.h @@ -212,6 +212,7 @@ extern "C" { int DLLEXPORT ENgetpatternid(int, char *); int DLLEXPORT ENgetpatternlen(int, int *); int DLLEXPORT ENgetpatternvalue(int, int, float *); + int DLLEXPORT ENgetaveragepatternvalue(int index, EN_API_FLOAT_TYPE *value); int DLLEXPORT ENgetqualtype(int *, int *); int DLLEXPORT ENgeterror(int, char *, int); diff --git a/src/epanet.c b/src/epanet.c index 5b7edb1..4c12d43 100755 --- a/src/epanet.c +++ b/src/epanet.c @@ -3255,20 +3255,25 @@ int DLLEXPORT ENgetnumdemands(int nodeIndex, int *numDemands) } int DLLEXPORT ENgetbasedemand(int nodeIndex, int demandIdx, EN_API_FLOAT_TYPE *baseDemand) { - Pdemand d; - int n=0; - /* Check for valid arguments */ - if (!Openflag) return(102); - if (nodeIndex <= 0 || nodeIndex > Nnodes) return(203); + Pdemand d; + int n=1; + /* Check for valid arguments */ + if (!Openflag) return(102); + if (nodeIndex <= 0 || nodeIndex > Nnodes) return(203); + if (nodeIndex <= Njuncs) { for(d=Node[nodeIndex].D; nnext) n++; if(n!=demandIdx) return(253); *baseDemand=(EN_API_FLOAT_TYPE)(d->Base*Ucf[FLOW]); - return 0; + } + else { + *baseDemand=(EN_API_FLOAT_TYPE)(0.0); + } + return 0; } int DLLEXPORT ENgetdemandpattern(int nodeIndex, int demandIdx, int *pattIdx) { Pdemand d; - int n=0; + int n=1; /* Check for valid arguments */ if (!Openflag) return(102); if (nodeIndex <= 0 || nodeIndex > Nnodes) return(203); @@ -3278,5 +3283,27 @@ int DLLEXPORT ENgetdemandpattern(int nodeIndex, int demandIdx, int *pattIdx) return 0; } +int DLLEXPORT ENgetaveragepatternvalue(int index, EN_API_FLOAT_TYPE *value) +/*---------------------------------------------------------------- + ** Input: index = index of time pattern + ** period = pattern time period + ** Output: *value = pattern multiplier + ** Returns: error code + ** Purpose: retrieves multiplier for a specific time period + ** and pattern + **---------------------------------------------------------------- + */ +{ *value = 0.0; + if (!Openflag) return(102); + if (index < 1 || index > Npats) return(205); + //if (period < 1 || period > Pattern[index].Length) return(251); + for (int i=0; i Date: Mon, 15 Jul 2013 13:47:01 -0400 Subject: [PATCH 13/14] llvm compilation changes (enum scoping) - added useful setMultiplierForSource method to Aggregator. --- build/Xcode/epanet/epanet.xcodeproj/project.pbxproj | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/build/Xcode/epanet/epanet.xcodeproj/project.pbxproj b/build/Xcode/epanet/epanet.xcodeproj/project.pbxproj index 3ef27ef..377eb61 100644 --- a/build/Xcode/epanet/epanet.xcodeproj/project.pbxproj +++ b/build/Xcode/epanet/epanet.xcodeproj/project.pbxproj @@ -473,10 +473,7 @@ EXECUTABLE_PREFIX = lib; GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_OBJC_EXCEPTIONS = YES; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); + GCC_PREPROCESSOR_DEFINITIONS = "EN_API_FLOAT_TYPE=double"; GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; MACOSX_DEPLOYMENT_TARGET = 10.8; @@ -497,6 +494,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; EXECUTABLE_PREFIX = lib; GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_PREPROCESSOR_DEFINITIONS = "EN_API_FLOAT_TYPE=double"; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; MACOSX_DEPLOYMENT_TARGET = 10.8; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -541,6 +539,7 @@ 2255753D17551217009946B1 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; From 3e92016beecbb20dfc72ed4645b6289ee1b2928d Mon Sep 17 00:00:00 2001 From: Sam Hatchett Date: Fri, 19 Jul 2013 11:13:58 -0400 Subject: [PATCH 14/14] zones are now DMAs --- build/Xcode/epanet/epanet.xcodeproj/project.pbxproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build/Xcode/epanet/epanet.xcodeproj/project.pbxproj b/build/Xcode/epanet/epanet.xcodeproj/project.pbxproj index 377eb61..c66b47b 100644 --- a/build/Xcode/epanet/epanet.xcodeproj/project.pbxproj +++ b/build/Xcode/epanet/epanet.xcodeproj/project.pbxproj @@ -70,7 +70,7 @@ /* Begin PBXFileReference section */ 22322F66106833BB00641384 /* runepanet */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = runepanet; sourceTree = BUILT_PRODUCTS_DIR; }; 22322F701068369500641384 /* enumstxt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = enumstxt.h; path = ../../../src/enumstxt.h; sourceTree = SOURCE_ROOT; }; - 22322F711068369500641384 /* epanet.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = epanet.c; path = ../../../src/epanet.c; sourceTree = SOURCE_ROOT; }; + 22322F711068369500641384 /* epanet.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 2; name = epanet.c; path = ../../../src/epanet.c; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.c; }; 22322F721068369500641384 /* funcs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = funcs.h; path = ../../../src/funcs.h; sourceTree = SOURCE_ROOT; }; 22322F731068369500641384 /* hash.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = hash.c; path = ../../../src/hash.c; sourceTree = SOURCE_ROOT; }; 22322F741068369500641384 /* hash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = hash.h; path = ../../../src/hash.h; sourceTree = SOURCE_ROOT; }; @@ -82,7 +82,7 @@ 22322F7A1068369500641384 /* mempool.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mempool.c; path = ../../../src/mempool.c; sourceTree = SOURCE_ROOT; }; 22322F7B1068369500641384 /* mempool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mempool.h; path = ../../../src/mempool.h; sourceTree = SOURCE_ROOT; }; 22322F7C1068369500641384 /* output.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = output.c; path = ../../../src/output.c; sourceTree = SOURCE_ROOT; }; - 22322F7D1068369500641384 /* quality.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = quality.c; path = ../../../src/quality.c; sourceTree = SOURCE_ROOT; }; + 22322F7D1068369500641384 /* quality.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 2; name = quality.c; path = ../../../src/quality.c; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.c; }; 22322F7E1068369500641384 /* report.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = report.c; path = ../../../src/report.c; sourceTree = SOURCE_ROOT; }; 22322F7F1068369500641384 /* rules.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = rules.c; path = ../../../src/rules.c; sourceTree = SOURCE_ROOT; }; 22322F801068369500641384 /* smatrix.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = smatrix.c; path = ../../../src/smatrix.c; sourceTree = SOURCE_ROOT; }; @@ -90,7 +90,7 @@ 22322F821068369500641384 /* toolkit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = toolkit.h; path = ../../../src/toolkit.h; sourceTree = SOURCE_ROOT; }; 22322F831068369500641384 /* types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = types.h; path = ../../../src/types.h; sourceTree = SOURCE_ROOT; }; 22322F841068369500641384 /* vars.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = vars.h; path = ../../../src/vars.h; sourceTree = SOURCE_ROOT; }; - 22322FA9106836B000641384 /* epanet2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = epanet2.h; path = ../../../include/epanet2.h; sourceTree = SOURCE_ROOT; }; + 22322FA9106836B000641384 /* epanet2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 2; name = epanet2.h; path = ../../../include/epanet2.h; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 2255753B17551217009946B1 /* libepanet-static.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libepanet-static.a"; sourceTree = BUILT_PRODUCTS_DIR; }; D2AAC0630554660B00DB518D /* libepanet.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libepanet.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */