opm-common
CompletedCells.hpp
1 /*
2  Copyright 2021 Equinor 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 COMPLETED_CELLS
21 #define COMPLETED_CELLS
22 
23 #include <opm/input/eclipse/EclipseState/Grid/GridDims.hpp>
24 
25 #include <array>
26 #include <cstddef>
27 #include <optional>
28 #include <unordered_map>
29 #include <utility>
30 
31 namespace Opm {
32 
36 {
37 public:
40  struct Cell
41  {
43  struct Props
44  {
48  std::size_t active_index{};
49 
51  double permx{};
52 
54  double permy{};
55 
57  double permz{};
58 
60  double poro{};
61 
63  double ntg{};
64 
66  int satnum{};
67 
69  int pvtnum{};
70 
78  bool operator==(const Props& other) const;
79 
82 
88  template<class Serializer>
89  void serializeOp(Serializer& serializer)
90  {
91  serializer(this->active_index);
92  serializer(this->permx);
93  serializer(this->permy);
94  serializer(this->permz);
95  serializer(this->poro);
96  serializer(this->satnum);
97  serializer(this->pvtnum);
98  serializer(this->ntg);
99  }
100  };
101 
106  Cell() = default;
107 
121  Cell(const std::size_t g,
122  const std::size_t i_,
123  const std::size_t j_,
124  const std::size_t k_)
125  : global_index(g)
126  , i(i_)
127  , j(j_)
128  , k(k_)
129  {}
130 
134  std::size_t global_index{};
135 
137  std::size_t i{};
138 
140  std::size_t j{};
141 
143  std::size_t k{};
144 
146  double depth{};
147 
149  std::array<double, 3> dimensions{};
150 
154  std::optional<Props> props{};
155 
157  bool is_active() const;
158 
162  std::size_t active_index() const;
163 
171  bool operator==(const Cell& other) const;
172 
174  static Cell serializationTestObject();
175 
181  template<class Serializer>
182  void serializeOp(Serializer& serializer)
183  {
184  serializer(this->global_index);
185  serializer(this->i);
186  serializer(this->j);
187  serializer(this->k);
188  serializer(this->props);
189  serializer(this->depth);
190  serializer(this->dimensions);
191  }
192  };
193 
198  CompletedCells() = default;
199 
204  explicit CompletedCells(const GridDims& dims);
205 
211  CompletedCells(std::size_t nx, std::size_t ny, std::size_t nz);
212 
223  const Cell& get(std::size_t i, std::size_t j, std::size_t k) const;
224 
237  std::pair<Cell*, bool>
238  try_get(std::size_t i, std::size_t j, std::size_t k);
239 
246  bool operator==(const CompletedCells& other) const;
247 
250 
256  template<class Serializer>
257  void serializeOp(Serializer& serializer)
258  {
259  serializer(this->dims);
260  serializer(this->cells);
261  }
262 
263 private:
265  GridDims dims;
266 
270  std::unordered_map<std::size_t, Cell> cells{};
271 };
272 
273 } // namespace Opm
274 
275 #endif // COMPLETED_CELLS
bool operator==(const CompletedCells &other) const
Equality predicate.
Definition: CompletedCells.cpp:125
double permz
Cell&#39;s permeability component in the grid&#39;s Z direction.
Definition: CompletedCells.hpp:57
std::size_t active_index() const
Retrieve cell&#39;s active index grid.
Definition: CompletedCells.cpp:64
std::size_t i
Cartesian I index relative to grid origin.
Definition: CompletedCells.hpp:137
std::optional< Props > props
Cell property data.
Definition: CompletedCells.hpp:154
double ntg
Cell&#39;s net-to-gross ratio.
Definition: CompletedCells.hpp:63
std::size_t active_index
Cell&#39;s active index in the range [0 .
Definition: CompletedCells.hpp:48
void serializeOp(Serializer &serializer)
Convert between byte array and object representation.
Definition: CompletedCells.hpp:182
Sparse collection of cells, and their properties, intersected by one or more well connections...
Definition: CompletedCells.hpp:35
std::pair< Cell *, bool > try_get(std::size_t i, std::size_t j, std::size_t k)
Retrieve, and possibly create, an intersected cell.
Definition: CompletedCells.cpp:114
void serializeOp(Serializer &serializer)
Convert between byte array and object representation.
Definition: CompletedCells.hpp:257
bool operator==(const Props &other) const
Equality predicate.
Definition: CompletedCells.cpp:28
double permx
Cell&#39;s permeability component in the grid&#39;s X direction.
Definition: CompletedCells.hpp:51
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
Cell(const std::size_t g, const std::size_t i_, const std::size_t j_, const std::size_t k_)
Constructor.
Definition: CompletedCells.hpp:121
static Cell serializationTestObject()
Create a serialisation test object.
Definition: CompletedCells.cpp:82
void serializeOp(Serializer &serializer)
Convert between byte array and object representation.
Definition: CompletedCells.hpp:89
Property data of intersected cell.
Definition: CompletedCells.hpp:43
std::size_t k
Cartesian K index relative to grid origin.
Definition: CompletedCells.hpp:143
int pvtnum
Cell&#39;s PVT region index.
Definition: CompletedCells.hpp:69
bool is_active() const
Check if cell is discovered and has associated property data.
Definition: CompletedCells.cpp:59
int satnum
Cell&#39;s saturation region.
Definition: CompletedCells.hpp:66
CompletedCells()=default
Default constructor.
double permy
Cell&#39;s permeability component in the grid&#39;s Y direction.
Definition: CompletedCells.hpp:54
std::array< double, 3 > dimensions
Physical cell extents.
Definition: CompletedCells.hpp:149
Identification and associate properties of cell intersected by one or more well connections.
Definition: CompletedCells.hpp:40
Cell()=default
Default constructor.
static CompletedCells serializationTestObject()
Create a serialisation test object.
Definition: CompletedCells.cpp:133
Definition: GridDims.hpp:30
bool operator==(const Cell &other) const
Equality predicate.
Definition: CompletedCells.cpp:69
double depth
Depth of cell centre.
Definition: CompletedCells.hpp:146
static Props serializationTestObject()
Create a serialisation test object.
Definition: CompletedCells.cpp:42
double poro
Cell&#39;s porosity.
Definition: CompletedCells.hpp:60
std::size_t j
Cartesian J index relative to grid origin.
Definition: CompletedCells.hpp:140
std::size_t global_index
Linearised Cartesian cell index.
Definition: CompletedCells.hpp:134
Class for (de-)serializing.
Definition: Serializer.hpp:94