My Project
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 #ifndef COMPLETED_CELLS
20 #define COMPLETED_CELLS
21 #include <optional>
22 #include <unordered_map>
23 
24 #include <opm/input/eclipse/EclipseState/Grid/GridDims.hpp>
25 
26 namespace Opm {
27 
29 public:
30 
31  struct Cell {
32  std::size_t global_index;
33  std::size_t i, j, k;
34 
35  struct Props{
36  std::size_t active_index;
37  double permx;
38  double permy;
39  double permz;
40  int satnum;
41  int pvtnum;
42  double ntg;
43 
44  bool operator==(const Props& other) const{
45  return this->active_index == other.active_index &&
46  this->permx == other.permx &&
47  this->permy == other.permy &&
48  this->permz == other.permz &&
49  this->satnum == other.satnum &&
50  this->pvtnum == other.pvtnum &&
51  this->ntg == other.ntg;
52  }
53 
54  template<class Serializer>
55  void serializeOp(Serializer& serializer)
56  {
57  serializer(this->permx);
58  serializer(this->permy);
59  serializer(this->permz);
60  serializer(this->satnum);
61  serializer(this->pvtnum);
62  serializer(this->ntg);
63  }
64 
65  static Props serializeObject(){
66  Props props;
67  props.permx = 10.0;
68  props.permy = 78.0;
69  props.permz = 45.4;
70  props.satnum = 3;
71  props.pvtnum = 5;
72  props.ntg = 45.1;
73  return props;
74  }
75  };
76 
77  std::optional<Props> props;
78  std::size_t active_index() const;
79  bool is_active() const;
80 
81  double depth;
82  std::array<double, 3> dimensions;
83 
84  bool operator==(const Cell& other) const {
85  return this->global_index == other.global_index &&
86  this->i == other.i &&
87  this->j == other.j &&
88  this->k == other.k &&
89  this->depth == other.depth &&
90  this->dimensions == other.dimensions &&
91  this->props == other.props;
92  }
93 
94  static Cell serializeObject() {
95  Cell cell(0,1,1,1);
96  cell.depth = 12345;
97  return cell;
98  }
99 
100  template<class Serializer>
101  void serializeOp(Serializer& serializer)
102  {
103  serializer(this->global_index);
104  serializer(this->i);
105  serializer(this->j);
106  serializer(this->k);
107  serializer(this->depth);
108  serializer(this->props);
109  serializer.template array<std::array<double,3>, false>(this->dimensions);
110  }
111 
112  Cell(std::size_t g, std::size_t i_, std::size_t j_, std::size_t k_)
113  : global_index(g)
114  , i(i_)
115  , j(j_)
116  , k(k_)
117  {}
118 
119  Cell() = default;
120  };
121 
122  CompletedCells() = default;
123  CompletedCells(const GridDims& dims);
124  CompletedCells(std::size_t nx, std::size_t ny, std::size_t nz);
125  const Cell& get(std::size_t i, std::size_t j, std::size_t k) const;
126  std::pair<bool, Cell&> try_get(std::size_t i, std::size_t j, std::size_t k);
127 
128  bool operator==(const CompletedCells& other) const;
129  static CompletedCells serializeObject();
130 
131  template<class Serializer>
132  void serializeOp(Serializer& serializer)
133  {
134  this->dims.serializeOp(serializer);
135  serializer.map(this->cells);
136  }
137 
138 private:
139  GridDims dims;
140  std::unordered_map<std::size_t, Cell> cells;
141 };
142 }
143 #endif
144 
Definition: CompletedCells.hpp:28
Definition: Serializer.hpp:38
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:29
Definition: CompletedCells.hpp:35
Definition: CompletedCells.hpp:31