My Project
Loading...
Searching...
No Matches
Carfin.hpp
1/*
2 Copyright 2022 Equinor
3 This file is part of the Open Porous Media project (OPM).
4 OPM is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8 OPM is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with OPM. If not, see <http://www.gnu.org/licenses/>.
14*/
15
16#ifndef CARFIN_HPP_
17#define CARFIN_HPP_
18
19#include <opm/input/eclipse/EclipseState/Grid/GridDims.hpp>
20
21#include <array>
22#include <cstddef>
23#include <functional>
24#include <vector>
25#include <string>
26
27namespace Opm {
28 class DeckRecord;
29}
30
31namespace Opm
32{
33 class Carfin
34 {
35 public:
36 using IsActive = std::function<bool(const std::size_t globalIdx)>;
37 using ActiveIdx = std::function<std::size_t(const std::size_t globalIdx)>;
38
40 {
41 std::size_t global_index;
42 std::size_t active_index;
43 std::size_t data_index;
44
45 cell_index(std::size_t g,std::size_t a, std::size_t d)
46 : global_index(g)
47 , active_index(a)
48 , data_index(d)
49 {}
50
51 cell_index(std::size_t g, std::size_t d)
52 : global_index(g)
53 , active_index(g)
54 , data_index(d)
55 {}
56 };
57
58 Carfin() = default;
59
60 explicit Carfin(const GridDims& gridDims,
61 IsActive isActive,
62 ActiveIdx activeIdx);
63
64 Carfin(const GridDims& gridDims,
65 IsActive isActive,
66 ActiveIdx activeIdx,
67 std::string name, int i1, int i2,
68 int j1, int j2,
69 int k1, int k2,
70 int nx, int ny,
71 int nz);
72
73 void update(const DeckRecord& deckRecord);
74 void reset();
75
76 bool isGlobal() const;
77 std::size_t size() const;
78 std::size_t getDim(std::size_t idim) const;
79
80 const std::vector<cell_index>& index_list() const;
81 const std::vector<cell_index>& global_index_list() const;
82
83 bool operator==(const Carfin& other) const;
84 bool equal(const Carfin& other) const;
85
86 std::string NAME() const;
87 int I1() const;
88 int I2() const;
89 int J1() const;
90 int J2() const;
91 int K1() const;
92 int K2() const;
93 int NX() const;
94 int NY() const;
95 int NZ() const;
96
97 template<class Serializer>
98 void serializeOp(Serializer& serializer)
99 {
100 serializer(m_dims);
101 serializer(m_offset);
102 serializer(m_end_offset);
103 serializer(name_grid);
104 }
105
106 private:
107 GridDims m_globalGridDims_{};
108 IsActive m_globalIsActive_{};
109 ActiveIdx m_globalActiveIdx_{};
110
111 std::array<std::size_t, 3> m_dims{};
112 std::array<std::size_t, 3> m_offset{};
113 std::array<std::size_t, 3> m_end_offset{};
114 std::string name_grid;
115
116 std::vector<cell_index> m_active_index_list;
117 std::vector<cell_index> m_global_index_list;
118
119 void init(std::string name, int i1, int i2, int j1, int j2, int k1, int k2, int nx , int ny , int nz);
120 void initIndexList();
121 int lower(int dim) const;
122 int upper(int dim) const;
123 int dimension(int dim) const;
124 };
125}
126
127
128#endif
Definition Carfin.hpp:34
Definition DeckRecord.hpp:32
Definition GridDims.hpp:31
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 Carfin.hpp:40