EPANET  3.0
EPANET Development Project
network.h
Go to the documentation of this file.
1 /* EPANET 3
2  *
3  * Copyright (c) 2016 Open Water Analytics
4  * Licensed under the terms of the MIT License (see the LICENSE file for details).
5  *
6  */
7 
10 
11 #ifndef NETWORK_H_
12 #define NETWORK_H_
13 
14 #include "Core/options.h"
15 #include "Core/units.h"
16 #include "Core/qualbalance.h"
17 #include "Elements/element.h"
18 #include "Utilities/hashtable.h"
19 #include "Utilities/graph.h"
20 
21 #include <vector>
22 #include <ostream>
23 
24 class Node;
25 class Link;
26 class Pattern;
27 class Curve;
28 class Control;
29 class HeadLossModel;
30 class DemandModel;
31 class LeakageModel;
32 class QualModel;
33 class MemPool;
34 
40 
41 class Network
42 {
43  public:
44 
45  Network();
46  ~Network();
47 
48  // Clears all elements from the network
49  void clear();
50 
51  // Adds an element to the network
52  bool addElement(Element::ElementType eType, int subType, std::string name);
53 
54  // Finds element counts by type and index by id name
55  int count(Element::ElementType eType);
56  int indexOf(Element::ElementType eType, const std::string& name);
57 
58  // Gets an analysis option by type
59  int option(Options::IndexOption type);
60  double option(Options::ValueOption type);
61  long option(Options::TimeOption type);
62  std::string option(Options::StringOption type);
63 
64  // Gets a network element by id name
65  Node* node(const std::string& name);
66  Link* link(const std::string& name);
67  Pattern* pattern(const std::string& name);
68  Curve* curve(const std::string& name);
69  Control* control(const std::string& name);
70 
71  // Gets a network element by index
72  Node* node(const int index);
73  Link* link(const int index);
74  Pattern* pattern(const int index);
75  Curve* curve(const int index);
76  Control* control(const int index);
77 
78  // Creates analysis models
79  bool createHeadLossModel();
80  bool createDemandModel();
81  bool createLeakageModel();
82  bool createQualModel();
83 
84  // Network graph theory operations
85  Graph graph;
86 
87  // Unit conversions
88  double ucf(Units::Quantity quantity); //unit conversion factor
89  std::string getUnits(Units::Quantity quantity); //unit names
90  void convertUnits();
91 
92  // Adds/writes network title
93  void addTitleLine(std::string line);
94  void writeTitle(std::ostream& out);
95 
96  // Elements of a network
97  std::vector<std::string> title;
98  std::vector<Node*> nodes;
99  std::vector<Link*> links;
100  std::vector<Curve*> curves;
101  std::vector<Pattern*> patterns;
102  std::vector<Control*> controls;
106  std::ostringstream msgLog;
107 
108  // Computational sub-models
113 
114  private:
115 
116  // Hash tables that associate an element's ID name with its storage index.
117  HashTable nodeTable;
118  HashTable linkTable;
119  HashTable curveTable;
120  HashTable patternTable;
121  HashTable controlTable;
122  MemPool * memPool;
123 };
124 
125 //-----------------------------------------------------------------------------
126 // Inline Functions
127 //-----------------------------------------------------------------------------
128 
129 // Gets the value of a project option
130 
131 inline int Network::option(Options::IndexOption type)
132  { return options.indexOption(type); }
133 
134 inline double Network::option(Options::ValueOption type)
135  { return options.valueOption(type); }
136 
137 inline long Network::option(Options::TimeOption type)
138  { return options.timeOption(type); }
139 
140 inline std::string Network::option(Options::StringOption type)
141  { return options.stringOption(type); }
142 
143 // Gets the unit conversion factor (user units per internal units) for a quantity
144 
145 inline double Network::ucf(Units::Quantity quantity)
146  { return units.factor(quantity); }
147 
148 // Gets the name of the units for a quantity
149 
150 inline std::string Network::getUnits(Units::Quantity quantity)
151  { return units.name(quantity); }
152 
153 inline void Network::addTitleLine(std::string line)
154  { title.push_back(line); }
155 
156 #endif
std::vector< Node * > nodes
collection of node objects
Definition: network.h:98
Describes the Element class.
std::vector< Link * > links
collection of link objects
Definition: network.h:99
StringOption
Definition: options.h:40
LeakageModel * leakageModel
pipe leakage model
Definition: network.h:111
A connection point between links in a network.
Definition: node.h:30
User-supplied options for analyzing a pipe network.
Definition: options.h:23
A hash table for element ID names and their objects.
Definition: hashtable.h:24
QualModel * qualModel
water quality model
Definition: network.h:112
The interface for a pressure-dependent demand model.
Definition: demandmodel.h:25
std::vector< std::string > title
descriptive title for the network
Definition: network.h:97
A simple pooled memory allocator.
Definition: mempool.h:21
Contains graph theoretic representation of a pipe network.
Definition: graph.h:25
Options options
analysis options
Definition: network.h:104
IndexOption
Definition: options.h:64
std::vector< Curve * > curves
collection of data curve objects
Definition: network.h:100
QualBalance qualBalance
water quality mass balance
Definition: network.h:105
DemandModel * demandModel
nodal demand model
Definition: network.h:110
Defines units conversion factors for network quantities.
Definition: units.h:21
Computes a water quality mass balance across the pipe network.
Definition: qualbalance.h:25
Units units
unit conversion factors
Definition: network.h:103
TimeOption
Definition: options.h:129
Describes the Units class.
std::vector< Control * > controls
collection of control rules
Definition: network.h:102
Describes the Graph class.
HeadLossModel * headLossModel
pipe head loss model
Definition: network.h:109
The interface for a pipe leakage model.
Definition: leakagemodel.h:24
A class that controls pumps and valves based on a single condition.
Definition: control.h:27
Describes the QualBlanace class.
The interface for a water quality analysis model.
Definition: qualmodel.h:28
ValueOption
Definition: options.h:90
Describes the Options class.
A set of multiplier factors associated with points in time.
Definition: pattern.h:29
Contains the data elements that describe a pipe network.
Definition: network.h:41
Describes the HashTable class.
std::vector< Pattern * > patterns
collection of time pattern objects
Definition: network.h:101
std::ostringstream msgLog
status message log.
Definition: network.h:106
An ordered collection of x,y data pairs.
Definition: curve.h:30
The interface for a pipe head loss model.
Definition: headlossmodel.h:26