My Project
Loading...
Searching...
No Matches
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
31namespace Opm {
32
34{
35public:
36 struct Cell
37 {
38 std::size_t global_index;
39 std::size_t i, j, k;
40
41 struct Props
42 {
43 std::size_t active_index{};
44 double permx{};
45 double permy{};
46 double permz{};
47 double poro{};
48 int satnum{};
49 int pvtnum{};
50 double ntg{};
51
52 bool operator==(const Props& other) const;
53
54 static Props serializationTestObject();
55
56 template<class Serializer>
57 void serializeOp(Serializer& serializer)
58 {
59 serializer(this->permx);
60 serializer(this->permy);
61 serializer(this->permz);
62 serializer(this->poro);
63 serializer(this->satnum);
64 serializer(this->pvtnum);
65 serializer(this->ntg);
66 }
67 };
68
69 std::optional<Props> props;
70 std::size_t active_index() const;
71 bool is_active() const;
72
73 double depth{};
74 std::array<double, 3> dimensions{};
75
76 bool operator==(const Cell& other) const;
77
78 static Cell serializationTestObject();
79
80 template<class Serializer>
81 void serializeOp(Serializer& serializer)
82 {
83 serializer(this->global_index);
84 serializer(this->i);
85 serializer(this->j);
86 serializer(this->k);
87 serializer(this->depth);
88 serializer(this->props);
89 serializer(this->dimensions);
90 }
91
92 Cell(std::size_t g, std::size_t i_, std::size_t j_, std::size_t k_)
93 : global_index(g)
94 , i(i_)
95 , j(j_)
96 , k(k_)
97 {}
98
99 Cell() = default;
100 };
101
102 CompletedCells() = default;
103 ~CompletedCells() = default;
104 explicit CompletedCells(const GridDims& dims);
105 CompletedCells(std::size_t nx, std::size_t ny, std::size_t nz);
106
107 const Cell& get(std::size_t i, std::size_t j, std::size_t k) const;
108 std::pair<bool, Cell&> try_get(std::size_t i, std::size_t j, std::size_t k);
109
110 bool operator==(const CompletedCells& other) const;
111 static CompletedCells serializationTestObject();
112
113 template<class Serializer>
114 void serializeOp(Serializer& serializer)
115 {
116 serializer(this->dims);
117 serializer(this->cells);
118 }
119
120private:
121 GridDims dims;
122 std::unordered_map<std::size_t, Cell> cells;
123};
124}
125
126#endif // COMPLETED_CELLS
Definition CompletedCells.hpp:34
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:42
Definition CompletedCells.hpp:37