opm-common
Valve.hpp
1 /*
2  Copyright 2019 Equinor.
3 
4  This file is part of the Open Porous Media project (OPM).
5 
6  OPM is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  OPM is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OPM. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef VALVE_HPP_HEADER_INCLUDED
21 #define VALVE_HPP_HEADER_INCLUDED
22 
23 #include <opm/input/eclipse/Schedule/MSW/icd.hpp>
24 #include <opm/input/eclipse/Schedule/SummaryState.hpp>
25 
26 #include <opm/input/eclipse/Deck/UDAValue.hpp>
27 
28 #include <cstddef>
29 #include <map>
30 #include <optional>
31 #include <string>
32 #include <utility>
33 #include <vector>
34 
35 namespace Opm {
36 
37  class DeckRecord;
38  class DeckKeyword;
39  class Segment;
40 
41 } // namespace Opm
42 
43 namespace Opm { namespace RestartIO {
44  struct RstSegment;
45 }} // namespace Opm::RestartIO
46 
47 namespace Opm {
48 
49  struct ValveUDAEval
50  {
51  const SummaryState& summary_state;
52  const std::string& well_name;
53  const std::size_t segment_number;
54 
55  ValveUDAEval(const SummaryState& summary_state_,
56  const std::string& well_name_,
57  const std::size_t segment_number_);
58 
59  double value(const UDAValue& value, const double udq_default = 0.0) const;
60  };
61 
62  class Valve
63  {
64  public:
65  Valve() = default;
66  explicit Valve(const DeckRecord& record, const double udq_default = 0.0);
67  explicit Valve(const RestartIO::RstSegment& rstSegment);
68 
69  Valve(double conFlowCoeff,
70  double conCrossA,
71  double conMaxCrossA,
72  double pipeAddLength,
73  double pipeDiam,
74  double pipeRough,
75  double pipeCrossA,
76  ICDStatus stat);
77 
78  static Valve serializationTestObject();
79 
80  // the function will return a map
81  // [
82  // "WELL1" : [<seg1, valv1>, <seg2, valv2> ...]
83  // ....
84  static std::map<std::string, std::vector<std::pair<int, Valve>>>
85  fromWSEGVALV(const DeckKeyword& keyword, const double udq_default = 0.0);
86 
87  // parameters for constriction pressure loss
88  double conFlowCoefficient() const;
89  double conCrossArea(const std::optional<const ValveUDAEval>& uda_eval = std::nullopt) const;
90  inline double conCrossAreaValue() const { return m_con_cross_area_value; }
91  double conMaxCrossArea() const;
92  double pipeDiameter() const;
93  double pipeRoughness() const;
94  double pipeCrossArea() const;
95 
96  // parameters for pressure loss along the pipe
97  double pipeAdditionalLength() const;
98 
99  // Status: OPEN or SHUT
100  ICDStatus status() const;
101  int ecl_status() const;
102 
103  void setConMaxCrossArea(const double area);
104 
105  void setPipeAdditionalLength(const double length);
106  void setPipeDiameter(const double dia);
107  void setPipeRoughness(const double rou);
108  void setPipeCrossArea(const double area);
109 
110  bool operator==(const Valve& data) const;
111 
112  template<class Serializer>
113  void serializeOp(Serializer& serializer)
114  {
115  serializer(m_con_flow_coeff);
116  serializer(m_con_cross_area);
117  serializer(m_con_cross_area_value);
118  serializer(m_con_max_cross_area);
119  serializer(m_pipe_additional_length);
120  serializer(m_pipe_diameter);
121  serializer(m_pipe_roughness);
122  serializer(m_pipe_cross_area);
123  serializer(m_status);
124  serializer(m_udq_default);
125  }
126 
127  private:
128  double m_con_flow_coeff {0.0};
129  UDAValue m_con_cross_area {0.0};
130  mutable double m_con_cross_area_value {0.0};
131  double m_con_max_cross_area {0.0};
132 
133  double m_pipe_additional_length {0.0};
134  double m_pipe_diameter {0.0};
135  double m_pipe_roughness {0.0};
136  double m_pipe_cross_area {0.0};
137  ICDStatus m_status {ICDStatus::SHUT};
138 
139  double m_udq_default{0.0};
140  };
141 
142 } // namespace Opm
143 
144 #endif // VALVE_HPP_HEADER_INCLUDED
Definition: Valve.hpp:62
Definition: UDAValue.hpp:31
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
Definition: Valve.hpp:49
Definition: SummaryState.hpp:72
Definition: segment.hpp:33
Definition: DeckRecord.hpp:32
Class for (de-)serializing.
Definition: Serializer.hpp:94
Definition: DeckKeyword.hpp:36