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/parser/eclipse/EclipseState/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 EclipseGrid;
36  class FieldPropsManager;
37  class KeywordLocation;
39  public:
40 
41 
43  WellConnections(Connection::Order ordering, int headI, int headJ);
44  WellConnections(Connection::Order ordering, int headI, int headJ,
45  const std::vector<Connection>& connections);
46 
47  static WellConnections serializeObject();
48 
49  // cppcheck-suppress noExplicitConstructor
50  WellConnections(const WellConnections& src, const EclipseGrid& grid);
51 
52  void addConnection(int i, int j , int k ,
53  std::size_t global_index,
54  double depth,
55  Connection::State state ,
56  double CF,
57  double Kh,
58  double rw,
59  double r0,
60  double re,
61  double connection_length,
62  double skin_factor,
63  const int satTableId,
64  const Connection::Direction direction = Connection::Direction::Z,
65  const Connection::CTFKind ctf_kind = Connection::CTFKind::DeckValue,
66  const std::size_t seqIndex = 0,
67  const bool defaultSatTabId = true);
68  void loadCOMPDAT(const DeckRecord& record, const EclipseGrid& grid, const FieldPropsManager& field_properties, const std::string& wname, const KeywordLocation& location);
69 
70  using const_iterator = std::vector< Connection >::const_iterator;
71 
72  void add( Connection );
73  std::size_t size() const;
74  bool empty() const;
75  std::size_t num_open() const;
76  const Connection& operator[](size_t index) const;
77  const Connection& get(size_t index) const;
78  const Connection& getFromIJK(const int i, const int j, const int k) const;
79  const Connection& getFromGlobalIndex(std::size_t global_index) const;
80  const Connection& lowest() const;
81  Connection& getFromIJK(const int i, const int j, const int k);
82  bool hasGlobalIndex(std::size_t global_index) const;
83  double segment_perf_length(int segment) const;
84 
85  const_iterator begin() const { return this->m_connections.begin(); }
86  const_iterator end() const { return this->m_connections.end(); }
87  void filter(const ActiveGridCells& grid);
88  bool allConnectionsShut() const;
101  void order();
102 
103  bool operator==( const WellConnections& ) const;
104  bool operator!=( const WellConnections& ) const;
105 
106  Connection::Order ordering() const { return this->m_ordering; }
107  std::vector<const Connection *> output(const EclipseGrid& grid) const;
108 
118 
126  void applyWellPIScaling(const double scaleFactor,
127  std::vector<bool>& scalingApplicable);
128 
129  template<class Serializer>
130  void serializeOp(Serializer& serializer)
131  {
132  serializer(m_ordering);
133  serializer(headI);
134  serializer(headJ);
135  serializer.vector(m_connections);
136  }
137 
138  private:
139  void addConnection(int i, int j , int k ,
140  std::size_t global_index,
141  int complnum,
142  double depth,
143  Connection::State state ,
144  double CF,
145  double Kh,
146  double rw,
147  double r0,
148  double re,
149  double connection_length,
150  double skin_factor,
151  const int satTableId,
152  const Connection::Direction direction = Connection::Direction::Z,
153  const Connection::CTFKind ctf_kind = Connection::CTFKind::DeckValue,
154  const std::size_t seqIndex = 0,
155  const bool defaultSatTabId = true);
156 
157  void loadCOMPDAT(const DeckRecord& record,
158  const EclipseGrid& grid,
159  const std::vector<int>& satnum_data,
160  const std::vector<double>* permx,
161  const std::vector<double>* permy,
162  const std::vector<double>* permz,
163  const std::vector<double>& ntg,
164  const std::string& wname,
165  const KeywordLocation& location);
166 
167  size_t findClosestConnection(int oi, int oj, double oz, size_t start_pos);
168  void orderTRACK();
169  void orderMSW();
170  void orderDEPTH();
171 
172  Connection::Order m_ordering = Connection::Order::TRACK;
173  int headI, headJ;
174  std::vector< Connection > m_connections;
175  };
176 
177  std::optional<int>
178  getCompletionNumberFromGlobalConnectionIndex(const WellConnections& connections,
179  const std::size_t global_index);
180 }
181 
182 
183 
184 #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:55
Definition: FieldPropsManager.hpp:37
Definition: KeywordLocation.hpp:27
Definition: Serializer.hpp:38
Definition: WellConnections.hpp:38
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