EPANET  3.0
EPANET Development Project
link.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 LINK_H_
12 #define LINK_H_
13 
14 #include "Elements/element.h"
15 
16 #include <string>
17 #include <iostream>
18 
19 class Node;
20 class Network;
21 class MemPool;
22 
29 
30 class Link: public Element
31 {
32  public:
33 
34  enum LinkType {PIPE, PUMP, VALVE};
35  enum LinkStatus {LINK_CLOSED, LINK_OPEN, VALVE_ACTIVE, TEMP_CLOSED};
36  enum LinkReaction {BULK, WALL};
37 
38  Link(std::string name_);
39  virtual ~Link();
40 
41  static Link* factory(int type_, std::string name_, MemPool* memPool);
42 
43  virtual int type() = 0;
44  virtual std::string typeStr() = 0;
45  virtual void convertUnits(Network* nw) = 0;
46  virtual double convertSetting(Network* nw, double s) { return s; }
47  virtual void validate(Network* nw) { }
48  virtual bool isReactive() { return false; }
49 
50  // Initializes hydraulic settings
51  virtual void initialize(bool initFlow);
52  virtual void setInitFlow() {}
53  virtual void setInitStatus(int s) {}
54  virtual void setInitSetting(double s) {}
55  virtual void setResistance(Network* nw) {}
56  virtual void setFlowThreshold(const double viscos);
57  virtual bool reduceFlowThreshold();
58 
59  // Retrieves hydraulic variables
60  virtual double getVelocity() {return 0.0;}
61  virtual double getRe(const double q, const double viscos) {return 0.0;}
62  virtual double getResistance() {return 0.0;}
63  virtual double getUnitHeadLoss();
64  virtual double getSetting(Network* nw) { return setting; }
65 
66  // Computes head loss, energy usage, and leakage
67  virtual void findHeadLoss(Network* nw, double q) = 0;
68  virtual double updateEnergyUsage(Network* nw, int dt) { return 0.0; }
69  virtual bool canLeak() { return false; }
70  virtual double findLeakage(Network* nw, double h, double& dqdh) { return 0.0; }
71 
72 
73  // Determines special types of links
74  virtual bool isPRV() {return false;}
75  virtual bool isPSV() {return false;}
76  virtual bool isHpPump() {return false;}
77 
78  // Used to update and adjust link status/setting
79  virtual void updateStatus(double q, double h1, double h2) { }
80  virtual bool changeStatus(int newStatus,
81  bool makeChange,
82  const std::string reason,
83  std::ostream& msgLog)
84  { return false; }
85  virtual bool changeSetting(double newSetting,
86  bool makeChange,
87  const std::string reason,
88  std::ostream& msgLog)
89  { return false; }
90  virtual void validateStatus(Network* nw, double qTol) { }
91  virtual void applyControlPattern(std::ostream& msgLog) { }
92  std::string writeStatusChange(int oldStatus);
93 
94  // Used for water quality routing
95  virtual double getVolume() { return 0.0; }
96 
97  // Properties
98  bool rptFlag;
102  double diameter;
103  double lossCoeff;
104  double initSetting;
105 
106  // Computed Variables
107  int status;
108  double flowThresh0;
109  double flowThresh;
110  double flow;
111  double leakage;
112  double hLoss;
113  double hGrad;
114  double setting;
115  double quality;
116 };
117 
118 #endif
Abstract parent class for all pipe network components.
Definition: element.h:19
Describes the Element class.
A connection point between links in a network.
Definition: node.h:30
A simple pooled memory allocator.
Definition: mempool.h:21
Contains the data elements that describe a pipe network.
Definition: network.h:41