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->active_index);
60 serializer(this->permx);
61 serializer(this->permy);
62 serializer(this->permz);
63 serializer(this->poro);
64 serializer(this->satnum);
65 serializer(this->pvtnum);
66 serializer(this->ntg);
67 }
68 };
69
70 std::optional<Props> props{};
71 std::size_t active_index() const;
72 bool is_active() const;
73
74 double depth{};
75 std::array<double, 3> dimensions{};
76
77 bool operator==(const Cell& other) const;
78
79 static Cell serializationTestObject();
80
81 template<class Serializer>
82 void serializeOp(Serializer& serializer)
83 {
84 serializer(this->global_index);
85 serializer(this->i);
86 serializer(this->j);
87 serializer(this->k);
88 serializer(this->props);
89 serializer(this->depth);
90 serializer(this->dimensions);
91 }
92
93 Cell(std::size_t g, std::size_t i_, std::size_t j_, std::size_t k_)
94 : global_index(g)
95 , i(i_)
96 , j(j_)
97 , k(k_)
98 {}
99
100 Cell() = default;
101 };
102
103 CompletedCells() = default;
104 ~CompletedCells() = default;
105 explicit CompletedCells(const GridDims& dims);
106 CompletedCells(std::size_t nx, std::size_t ny, std::size_t nz);
107
108 const Cell& get(std::size_t i, std::size_t j, std::size_t k) const;
109 std::pair<bool, Cell&> try_get(std::size_t i, std::size_t j, std::size_t k);
110
111 bool operator==(const CompletedCells& other) const;
112 static CompletedCells serializationTestObject();
113
114 template<class Serializer>
115 void serializeOp(Serializer& serializer)
116 {
117 serializer(this->dims);
118 serializer(this->cells);
119 }
120
121private:
122 GridDims dims;
123 std::unordered_map<std::size_t, Cell> cells;
124};
125}
126
127#endif // COMPLETED_CELLS
Definition CompletedCells.hpp:34
Class for (de-)serializing.
Definition Serializer.hpp:91
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