My Project
WellConnections.hpp
1 /*
2  Copyright 2013 Statoil ASA.
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 CONNECTIONSET_HPP_
21 #define CONNECTIONSET_HPP_
22 
23 #include <opm/input/eclipse/Schedule/Well/Connection.hpp>
24 
25 #include <cstddef>
26 #include <optional>
27 #include <string>
28 #include <vector>
29 
30 #include <stddef.h>
31 
32 namespace Opm {
33  class ActiveGridCells;
34  class DeckRecord;
35  class FieldPropsManager;
36  class KeywordLocation;
37  class ScheduleGrid;
38  class EclipseGrid;
39 } // namespace Opm
40 
41 namespace Opm {
42 
44  {
45  public:
46  using const_iterator = std::vector<Connection>::const_iterator;
47 
48  WellConnections() = default;
49  WellConnections(const Connection::Order ordering, const int headI, const int headJ);
50  WellConnections(const Connection::Order ordering, const int headI, const int headJ,
51  const std::vector<Connection>& connections);
52 
53  static WellConnections serializationTestObject();
54 
55  // cppcheck-suppress noExplicitConstructor
56  template <class Grid>
57  WellConnections(const WellConnections& src, const Grid& grid)
58  : m_ordering(src.ordering())
59  , headI (src.headI)
60  , headJ (src.headJ)
61  {
62  for (const auto& c : src) {
63  if (grid.isCellActive(c.getI(), c.getJ(), c.getK())) {
64  this->add(c);
65  }
66  }
67  }
68 
69  void addConnection(const int i, const int j, const int k,
70  const std::size_t global_index,
71  const double depth,
72  const Connection::State state,
73  const double CF,
74  const double Kh,
75  const double rw,
76  const double r0,
77  const double re,
78  const double connection_length,
79  const double skin_factor,
80  const int satTableId,
81  const Connection::Direction direction = Connection::Direction::Z,
82  const Connection::CTFKind ctf_kind = Connection::CTFKind::DeckValue,
83  const std::size_t seqIndex = 0,
84  const bool defaultSatTabId = true);
85 
86  void loadCOMPDAT(const DeckRecord& record,
87  const ScheduleGrid& grid,
88  const std::string& wname,
89  const KeywordLocation& location);
90 
91  void add(Connection);
92  std::size_t size() const;
93  bool empty() const;
94  std::size_t num_open() const;
95  const Connection& operator[](size_t index) const;
96  const Connection& get(size_t index) const;
97  const Connection& getFromIJK(const int i, const int j, const int k) const;
98  const Connection& getFromGlobalIndex(std::size_t global_index) const;
99  const Connection& lowest() const;
100  Connection& getFromIJK(const int i, const int j, const int k);
101  bool hasGlobalIndex(std::size_t global_index) const;
102  double segment_perf_length(int segment) const;
103 
104  const_iterator begin() const { return this->m_connections.begin(); }
105  const_iterator end() const { return this->m_connections.end(); }
106  void filter(const ActiveGridCells& grid);
107  bool allConnectionsShut() const;
120  void order();
121 
122  bool operator==( const WellConnections& ) const;
123  bool operator!=( const WellConnections& ) const;
124 
125  Connection::Order ordering() const { return this->m_ordering; }
126  std::vector<const Connection *> output(const EclipseGrid& grid) const;
127 
137 
145  void applyWellPIScaling(const double scaleFactor,
146  std::vector<bool>& scalingApplicable);
147 
148  template <class Serializer>
149  void serializeOp(Serializer& serializer)
150  {
151  serializer(this->m_ordering);
152  serializer(this->headI);
153  serializer(this->headJ);
154  serializer(this->m_connections);
155  }
156 
157  private:
158  Connection::Order m_ordering { Connection::Order::TRACK };
159  int headI{0};
160  int headJ{0};
161  std::vector<Connection> m_connections{};
162 
163  void addConnection(const int i, const int j, const int k,
164  const std::size_t global_index,
165  const int complnum,
166  const double depth,
167  const Connection::State state,
168  const double CF,
169  const double Kh,
170  const double rw,
171  const double r0,
172  const double re,
173  const double connection_length,
174  const double skin_factor,
175  const int satTableId,
176  const Connection::Direction direction = Connection::Direction::Z,
177  const Connection::CTFKind ctf_kind = Connection::CTFKind::DeckValue,
178  const std::size_t seqIndex = 0,
179  const bool defaultSatTabId = true);
180 
181  size_t findClosestConnection(int oi, int oj, double oz, size_t start_pos);
182  void orderTRACK();
183  void orderMSW();
184  void orderDEPTH();
185  };
186 
187  std::optional<int>
188  getCompletionNumberFromGlobalConnectionIndex(const WellConnections& connections,
189  const std::size_t global_index);
190 } // namespace Opm
191 
192 #endif // CONNECTIONSET_HPP_
Simple class capturing active cells of a grid.
Definition: ActiveGridCells.hpp:36
Definition: Connection.hpp:43
Definition: DeckRecord.hpp:32
About cell information and dimension: The actual grid information is held in a pointer to an ERT ecl_...
Definition: EclipseGrid.hpp:54
Definition: KeywordLocation.hpp:27
Definition: ScheduleGrid.hpp:29
Class for (de-)serializing.
Definition: Serializer.hpp:75
Definition: WellConnections.hpp:44
void order()
Order connections irrespective of input order.
void applyWellPIScaling(const double scaleFactor, std::vector< bool > &scalingApplicable)
Scale pertinent connections' CF value by supplied value.
bool prepareWellPIScaling()
Activate or reactivate WELPI scaling for this connection set.
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:29