From 4df40ebc3db02df49d60861461cb40e5aac9bcdf Mon Sep 17 00:00:00 2001 From: Sam Hatchett Date: Fri, 1 Feb 2013 17:19:23 -0500 Subject: [PATCH] new branch for lemon-tiger with no new api functions --- .../epanet/epanet.xcodeproj/project.pbxproj | 98 ++++++----------- src/testLemonTiger.cpp | 104 ++++++++++++++++++ src/testLemonTiger.h | 14 +++ 3 files changed, 151 insertions(+), 65 deletions(-) create mode 100644 src/testLemonTiger.cpp create mode 100644 src/testLemonTiger.h diff --git a/build/Xcode/epanet/epanet.xcodeproj/project.pbxproj b/build/Xcode/epanet/epanet.xcodeproj/project.pbxproj index 36e011b..ff6645d 100644 --- a/build/Xcode/epanet/epanet.xcodeproj/project.pbxproj +++ b/build/Xcode/epanet/epanet.xcodeproj/project.pbxproj @@ -42,23 +42,9 @@ 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 */; }; - 227CECA016BB0D5E00E8E7C8 /* lemontiger.c in Sources */ = {isa = PBXBuildFile; fileRef = 2298EBDF16B17E440088A6DC /* lemontiger.c */; }; - 227CECA116BB0D5E00E8E7C8 /* epanet.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F711068369500641384 /* epanet.c */; }; - 227CECA216BB0D5E00E8E7C8 /* hash.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F731068369500641384 /* hash.c */; }; - 227CECA316BB0D5E00E8E7C8 /* hydraul.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F751068369500641384 /* hydraul.c */; }; - 227CECA416BB0D5E00E8E7C8 /* inpfile.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F761068369500641384 /* inpfile.c */; }; - 227CECA516BB0D5E00E8E7C8 /* input1.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F771068369500641384 /* input1.c */; }; - 227CECA616BB0D5E00E8E7C8 /* input2.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F781068369500641384 /* input2.c */; }; - 227CECA716BB0D5E00E8E7C8 /* input3.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F791068369500641384 /* input3.c */; }; - 227CECA816BB0D5E00E8E7C8 /* mempool.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F7A1068369500641384 /* mempool.c */; }; - 227CECA916BB0D5E00E8E7C8 /* output.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F7C1068369500641384 /* output.c */; }; - 227CECAA16BB0D5E00E8E7C8 /* quality.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F7D1068369500641384 /* quality.c */; }; - 227CECAB16BB0D5E00E8E7C8 /* report.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F7E1068369500641384 /* report.c */; }; - 227CECAC16BB0D5E00E8E7C8 /* rules.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F7F1068369500641384 /* rules.c */; }; - 227CECAD16BB0D5E00E8E7C8 /* smatrix.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F801068369500641384 /* smatrix.c */; }; - 2298EBDE16B17DE50088A6DC /* testLT.c in Sources */ = {isa = PBXBuildFile; fileRef = 2298EBDC16B17DCE0088A6DC /* testLT.c */; }; 2298EBE116B17E440088A6DC /* lemontiger.c in Sources */ = {isa = PBXBuildFile; fileRef = 2298EBDF16B17E440088A6DC /* lemontiger.c */; }; 2298EBE216B17E440088A6DC /* lemontiger.h in Headers */ = {isa = PBXBuildFile; fileRef = 2298EBE016B17E440088A6DC /* lemontiger.h */; }; + 22EF555716BC744C00F3988A /* testLemonTiger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 22EF555516BC744C00F3988A /* testLemonTiger.cpp */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -69,17 +55,10 @@ remoteGlobalIDString = D2AAC0620554660B00DB518D; remoteInfo = epanet; }; - 2298EBD816B17B830088A6DC /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = D2AAC0620554660B00DB518D; - remoteInfo = epanet; - }; /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ - 2298EBC816B178E70088A6DC /* CopyFiles */ = { + 22EF554A16BC740400F3988A /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; dstPath = /usr/share/man/man1/; @@ -114,10 +93,12 @@ 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; }; - 2298EBCA16B178E70088A6DC /* testLemonTiger */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testLemonTiger; sourceTree = BUILT_PRODUCTS_DIR; }; 2298EBDC16B17DCE0088A6DC /* testLT.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testLT.c; path = ../../../src/testLT.c; sourceTree = ""; }; 2298EBDF16B17E440088A6DC /* lemontiger.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = lemontiger.c; path = ../../../src/lemontiger.c; sourceTree = ""; }; 2298EBE016B17E440088A6DC /* lemontiger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = lemontiger.h; path = ../../../src/lemontiger.h; sourceTree = ""; }; + 22EF554C16BC740400F3988A /* TestLemonTiger */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = TestLemonTiger; sourceTree = BUILT_PRODUCTS_DIR; }; + 22EF555516BC744C00F3988A /* testLemonTiger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = testLemonTiger.cpp; path = ../../../src/testLemonTiger.cpp; sourceTree = ""; }; + 22EF555616BC744C00F3988A /* testLemonTiger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = testLemonTiger.h; path = ../../../src/testLemonTiger.h; sourceTree = ""; }; D2AAC0630554660B00DB518D /* libepanet.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libepanet.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -129,7 +110,7 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 2298EBC716B178E70088A6DC /* Frameworks */ = { + 22EF554916BC740400F3988A /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( @@ -190,7 +171,7 @@ children = ( D2AAC0630554660B00DB518D /* libepanet.dylib */, 22322F66106833BB00641384 /* runepanet */, - 2298EBCA16B178E70088A6DC /* testLemonTiger */, + 22EF554C16BC740400F3988A /* TestLemonTiger */, ); name = Products; sourceTree = ""; @@ -209,6 +190,8 @@ 2298EBDF16B17E440088A6DC /* lemontiger.c */, 2298EBE016B17E440088A6DC /* lemontiger.h */, 2298EBDC16B17DCE0088A6DC /* testLT.c */, + 22EF555516BC744C00F3988A /* testLemonTiger.cpp */, + 22EF555616BC744C00F3988A /* testLemonTiger.h */, ); name = LemonTiger; sourceTree = ""; @@ -253,22 +236,21 @@ productReference = 22322F66106833BB00641384 /* runepanet */; productType = "com.apple.product-type.tool"; }; - 2298EBC916B178E70088A6DC /* testLemonTiger */ = { + 22EF554B16BC740400F3988A /* TestLemonTiger */ = { isa = PBXNativeTarget; - buildConfigurationList = 2298EBD116B178E70088A6DC /* Build configuration list for PBXNativeTarget "testLemonTiger" */; + buildConfigurationList = 22EF555416BC740400F3988A /* Build configuration list for PBXNativeTarget "TestLemonTiger" */; buildPhases = ( - 2298EBC616B178E70088A6DC /* Sources */, - 2298EBC716B178E70088A6DC /* Frameworks */, - 2298EBC816B178E70088A6DC /* CopyFiles */, + 22EF554816BC740400F3988A /* Sources */, + 22EF554916BC740400F3988A /* Frameworks */, + 22EF554A16BC740400F3988A /* CopyFiles */, ); buildRules = ( ); dependencies = ( - 2298EBD916B17B830088A6DC /* PBXTargetDependency */, ); - name = testLemonTiger; - productName = testLemonTiger; - productReference = 2298EBCA16B178E70088A6DC /* testLemonTiger */; + name = TestLemonTiger; + productName = TestLemonTiger; + productReference = 22EF554C16BC740400F3988A /* TestLemonTiger */; productType = "com.apple.product-type.tool"; }; D2AAC0620554660B00DB518D /* epanet */ = { @@ -309,7 +291,7 @@ targets = ( D2AAC0620554660B00DB518D /* epanet */, 22322F65106833BB00641384 /* runepanet */, - 2298EBC916B178E70088A6DC /* testLemonTiger */, + 22EF554B16BC740400F3988A /* TestLemonTiger */, ); }; /* End PBXProject section */ @@ -335,25 +317,11 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 2298EBC616B178E70088A6DC /* Sources */ = { + 22EF554816BC740400F3988A /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 227CECA016BB0D5E00E8E7C8 /* lemontiger.c in Sources */, - 227CECA116BB0D5E00E8E7C8 /* epanet.c in Sources */, - 227CECA216BB0D5E00E8E7C8 /* hash.c in Sources */, - 227CECA316BB0D5E00E8E7C8 /* hydraul.c in Sources */, - 227CECA416BB0D5E00E8E7C8 /* inpfile.c in Sources */, - 227CECA516BB0D5E00E8E7C8 /* input1.c in Sources */, - 227CECA616BB0D5E00E8E7C8 /* input2.c in Sources */, - 227CECA716BB0D5E00E8E7C8 /* input3.c in Sources */, - 227CECA816BB0D5E00E8E7C8 /* mempool.c in Sources */, - 227CECA916BB0D5E00E8E7C8 /* output.c in Sources */, - 227CECAA16BB0D5E00E8E7C8 /* quality.c in Sources */, - 227CECAB16BB0D5E00E8E7C8 /* report.c in Sources */, - 227CECAC16BB0D5E00E8E7C8 /* rules.c in Sources */, - 227CECAD16BB0D5E00E8E7C8 /* smatrix.c in Sources */, - 2298EBDE16B17DE50088A6DC /* testLT.c in Sources */, + 22EF555716BC744C00F3988A /* testLemonTiger.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -386,11 +354,6 @@ target = D2AAC0620554660B00DB518D /* epanet */; targetProxy = 22322FAF1068370B00641384 /* PBXContainerItemProxy */; }; - 2298EBD916B17B830088A6DC /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = D2AAC0620554660B00DB518D /* epanet */; - targetProxy = 2298EBD816B17B830088A6DC /* PBXContainerItemProxy */; - }; /* End PBXTargetDependency section */ /* Begin XCBuildConfiguration section */ @@ -491,14 +454,17 @@ }; name = Release; }; - 2298EBD216B178E70088A6DC /* Debug */ = { + 22EF555216BC740400F3988A /* 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_CONSTANT_CONVERSION = YES; CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; GCC_DYNAMIC_NO_PIC = NO; @@ -512,18 +478,21 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES; MACOSX_DEPLOYMENT_TARGET = 10.8; PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = macosx; + SDKROOT = ""; }; name = Debug; }; - 2298EBD316B178E70088A6DC /* Release */ = { + 22EF555316BC740400F3988A /* 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_CONSTANT_CONVERSION = YES; CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; @@ -532,7 +501,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES; MACOSX_DEPLOYMENT_TARGET = 10.8; PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = macosx; + SDKROOT = ""; }; name = Release; }; @@ -566,14 +535,13 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 2298EBD116B178E70088A6DC /* Build configuration list for PBXNativeTarget "testLemonTiger" */ = { + 22EF555416BC740400F3988A /* Build configuration list for PBXNativeTarget "TestLemonTiger" */ = { isa = XCConfigurationList; buildConfigurations = ( - 2298EBD216B178E70088A6DC /* Debug */, - 2298EBD316B178E70088A6DC /* Release */, + 22EF555216BC740400F3988A /* Debug */, + 22EF555316BC740400F3988A /* Release */, ); defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/src/testLemonTiger.cpp b/src/testLemonTiger.cpp new file mode 100644 index 0000000..6cfbf28 --- /dev/null +++ b/src/testLemonTiger.cpp @@ -0,0 +1,104 @@ +// +// testLemonTiger.cpp +// epanet +// +// Created by Sam Hatchett on 2/1/13. +// +// + +#include "testLemonTiger.h" +#include "epanet2.h" + +using namespace std; + +int main(int argc, char * argv[]) { + + cout << "Lemon Tiger TEST" << endl; + + int err = 0; //error code + long stime = 0; //simulation time point, = t = Htime + long step = 1; //time to next time point, = tstep = hydstep + long tleft = 0; //time left in the simulation + int id, id2, id3; // some node id + float value; // some node/link value + int TIME_A = 3600*3; + int TIME_B = 3600*6; //two time points for testing + int TIME_C = 3600*10; + + + /* Asychronous solver (old epanet) */ + printf("*****Original EPANET results******\n"); + + if (err=ENopen(argv[1], argv[2], "")) return err; + + + for (ENopenH(), ENinitH(1), step=1; + // must save intermediate results to disk (initH(1)), otherwise WQ solver won't execute + step>0; ENnextH(&step)) { + ENrunH(&stime); + } + ENcloseH(); + + printf("\nReset time pointer and run WQ.\n"); + for (step=1, ENopenQ(), ENinitQ(0); // this operation resets the internal time pointer (back to 0) + step>0; ENnextQ(&step)) { + + ENrunQ(&stime); + + + // grab some results + if (stime == TIME_A || stime == TIME_B || stime == TIME_C) { + printf("WQ simulation time = %d sec, step = %d sec.\n", stime, step); + + ENgetnodevalue(id, EN_QUALITY, &value); + printf("Node 184's quality = \t%f.\n", value); + ENgetnodevalue(id3, EN_QUALITY, &value); + printf("Node 199's quality = \t%f.\n", value); + } + } + ENcloseQ(); + ENclose(); + + + /* Sychronous solver (LemonTiger) */ + printf("\n\n*****LemonTiger results******\n\n"); + + if (err=ENopen(argv[1], argv[2], "")) return err; + + for (ENopeninitHQ(), tleft=Dur; tleft>0; ) { + + //ENrunstepHQ(&stime, &tleft); + ENrunnextHQ(&stime, &tleft); //well I know it should be tstep + + if (stime == TIME_A || stime == TIME_B || stime == TIME_C) { + //if (! (stime%1800)){ + printf("Simulation = %d sec, time left = %d sec.\n", stime, tleft); + ENgetnodevalue(id, EN_HEAD, &value); + printf("Node 184's head = \t%f.\n", value); + + ENgetnodevalue(id, EN_QUALITY, &value); + printf("Node 184's quality = \t%f.\n", value); + + ENgetnodevalue(id3, EN_HEAD, &value); + printf("Node 199's head = \t%f.\n", value); + + ENgetnodevalue(id3, EN_QUALITY, &value); + printf("Node 199's quality = \t%f.\n", value); + + ENgetlinkvalue(id2, EN_FLOW, &value); + printf("Link 101's flowrate = \t%f. \n", value); + + + printf("\n"); + } + } + ENcloseHQ(); + ENclose(); + + +} + + + + +} diff --git a/src/testLemonTiger.h b/src/testLemonTiger.h new file mode 100644 index 0000000..6e16ad2 --- /dev/null +++ b/src/testLemonTiger.h @@ -0,0 +1,14 @@ +// +// testLemonTiger.h +// epanet +// +// Created by Sam Hatchett on 2/1/13. +// +// + +#ifndef __epanet__testLemonTiger__ +#define __epanet__testLemonTiger__ + +#include + +#endif /* defined(__epanet__testLemonTiger__) */