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 
21 #ifndef CONNECTIONSET_HPP_
22 #define CONNECTIONSET_HPP_
23 
24 #include <opm/input/eclipse/Schedule/Well/Connection.hpp>
25 
26 #include <cstddef>
27 #include <optional>
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 
41  public:
42 
43 
45  WellConnections(Connection::Order ordering, int headI, int headJ);
46  WellConnections(Connection::Order ordering, int headI, int headJ,
47  const std::vector<Connection>& connections);
48 
49  static WellConnections serializeObject();
50 
51  // cppcheck-suppress noExplicitConstructor
52  template<class Grid>
53  WellConnections(const WellConnections& src, const Grid& grid) :
54  m_ordering(src.ordering()),
55  headI(src.headI),
56  headJ(src.headJ)
57  {
58  for (const auto& c : src) {
59  if (grid.isCellActive(c.getI(), c.getJ(), c.getK()))
60  this->add(c);
61  }
62  }
63 
64 
65 
66 
67  void addConnection(int i, int j , int k ,
68  std::size_t global_index,
69  double depth,
70  Connection::State state ,
71  double CF,
72  double Kh,
73  double rw,
74  double r0,
75  double re,
76  double connection_length,
77  double skin_factor,
78  const int satTableId,
79  const Connection::Direction direction = Connection::Direction::Z,
80  const Connection::CTFKind ctf_kind = Connection::CTFKind::DeckValue,
81  const std::size_t seqIndex = 0,
82  const bool defaultSatTabId = true);
83  void loadCOMPDAT(const DeckRecord& record, const ScheduleGrid& grid, const std::string& wname, const KeywordLocation& location);
84 
85  using const_iterator = std::vector< Connection >::const_iterator;
86 
87  void add( Connection );
88  std::size_t size() const;
89  bool empty() const;
90  std::size_t num_open() const;
91  const Connection& operator[](size_t index) const;
92  const Connection& get(size_t index) const;
93  const Connection& getFromIJK(const int i, const int j, const int k) const;
94  const Connection& getFromGlobalIndex(std::size_t global_index) const;
95  const Connection& lowest() const;
96  Connection& getFromIJK(const int i, const int j, const int k);
97  bool hasGlobalIndex(std::size_t global_index) const;
98  double segment_perf_length(int segment) const;
99 
100  const_iterator begin() const { return this->m_connections.begin(); }
101  const_iterator end() const { return this->m_connections.end(); }
102  void filter(const ActiveGridCells& grid);
103  bool allConnectionsShut() const;
116  void order();
117 
118  bool operator==( const WellConnections& ) const;
119  bool operator!=( const WellConnections& ) const;
120 
121  Connection::Order ordering() const { return this->m_ordering; }
122  std::vector<const Connection *> output(const EclipseGrid& grid) const;
123 
133 
141  void applyWellPIScaling(const double scaleFactor,
142  std::vector<bool>& scalingApplicable);
143 
144  template<class Serializer>
145  void serializeOp(Serializer& serializer)
146  {
147  serializer(m_ordering);
148  serializer(headI);
149  serializer(headJ);
150  serializer.vector(m_connections);
151  }
152 
153  private:
154  void addConnection(int i, int j , int k ,
155  std::size_t global_index,
156  int complnum,
157  double depth,
158  Connection::State state ,
159  double CF,
160  double Kh,
161  double rw,
162  double r0,
163  double re,
164  double connection_length,
165  double skin_factor,
166  const int satTableId,
167  const Connection::Direction direction = Connection::Direction::Z,
168  const Connection::CTFKind ctf_kind = Connection::CTFKind::DeckValue,
169  const std::size_t seqIndex = 0,
170  const bool defaultSatTabId = true);
171 
172  size_t findClosestConnection(int oi, int oj, double oz, size_t start_pos);
173  void orderTRACK();
174  void orderMSW();
175  void orderDEPTH();
176 
177  Connection::Order m_ordering = Connection::Order::TRACK;
178  int headI, headJ;
179  std::vector< Connection > m_connections;
180  };
181 
182  std::optional<int>
183  getCompletionNumberFromGlobalConnectionIndex(const WellConnections& connections,
184  const std::size_t global_index);
185 }
186 
187 
188 
189 #endif
Simple class capturing active cells of a grid.
Definition: ActiveGridCells.hpp:35
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
Definition: Serializer.hpp:38
Definition: WellConnections.hpp:40
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