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
26namespace Opm {
27
29public:
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 serializationTestObject(){
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 serializationTestObject() {
95 Cell cell(0,1,1,1);
96 cell.depth = 12345;
97 cell.dimensions = {1.0,2.0,3.0};
98 return cell;
99 }
100
101 template<class Serializer>
102 void serializeOp(Serializer& serializer)
103 {
104 serializer(this->global_index);
105 serializer(this->i);
106 serializer(this->j);
107 serializer(this->k);
108 serializer(this->depth);
109 serializer(this->props);
110 serializer(this->dimensions);
111 }
112
113 Cell(std::size_t g, std::size_t i_, std::size_t j_, std::size_t k_)
114 : global_index(g)
115 , i(i_)
116 , j(j_)
117 , k(k_)
118 {}
119
120 Cell() = default;
121 };
122
123 CompletedCells() = default;
124 CompletedCells(const GridDims& dims);
125 CompletedCells(std::size_t nx, std::size_t ny, std::size_t nz);
126 const Cell& get(std::size_t i, std::size_t j, std::size_t k) const;
127 std::pair<bool, Cell&> try_get(std::size_t i, std::size_t j, std::size_t k);
128
129 bool operator==(const CompletedCells& other) const;
130 static CompletedCells serializationTestObject();
131
132 template<class Serializer>
133 void serializeOp(Serializer& serializer)
134 {
135 serializer(this->dims);
136 serializer(this->cells);
137 }
138
139private:
140 GridDims dims;
141 std::unordered_map<std::size_t, Cell> cells;
142};
143}
144#endif
145
Definition: CompletedCells.hpp:28
Class for (de-)serializing.
Definition: Serializer.hpp:84
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
Definition: CompletedCells.hpp:35
Definition: CompletedCells.hpp:31