My Project
Loading...
Searching...
No Matches
EGrid.hpp
1/*
2 Copyright 2019 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 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 OPM is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with OPM. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef OPM_IO_EGRID_HPP
20#define OPM_IO_EGRID_HPP
21
22#include <opm/io/eclipse/EclFile.hpp>
23
24#include <array>
25#include <filesystem>
26#include <string>
27#include <vector>
28#include <map>
29
30namespace Opm { namespace EclIO {
31
32class EGrid : public EclFile
33{
34public:
35 explicit EGrid(const std::string& filename, const std::string& grid_name = "global");
36
37 int global_index(int i, int j, int k) const;
38 int active_index(int i, int j, int k) const;
39
40 const std::array<int, 3>& dimension() const { return nijk; }
41
42 std::array<int, 3> ijk_from_active_index(int actInd) const;
43 std::array<int, 3> ijk_from_global_index(int globInd) const;
44
45 void getCellCorners(int globindex, std::array<double, 8>& X, std::array<double, 8>& Y, std::array<double, 8>& Z);
46 void getCellCorners(const std::array<int, 3>& ijk, std::array<double, 8>& X, std::array<double, 8>& Y, std::array<double, 8>& Z);
47
48 std::vector<std::array<float, 3>> getXYZ_layer(int layer, bool bottom=false);
49 std::vector<std::array<float, 3>> getXYZ_layer(int layer, const std::array<int, 4>& box, bool bottom=false);
50
51 int activeCells() const { return nactive; }
52 int totalNumberOfCells() const { return nijk[0] * nijk[1] * nijk[2]; }
53
54 void load_grid_data();
55 void load_nnc_data();
56 bool with_mapaxes() const { return m_mapaxes_loaded; }
57 void mapaxes_transform(double& x, double& y) const;
58 bool is_radial() const { return m_radial; }
59
60 const std::vector<int>& hostCellsGlobalIndex() const { return host_cells; }
61 std::vector<std::array<int, 3>> hostCellsIJK();
62
63 // zero based: i1,j1,k1, i2,j2,k2, transmisibility
64 using NNCentry = std::tuple<int, int, int, int, int, int, float>;
65 std::vector<NNCentry> get_nnc_ijk();
66
67 const std::vector<std::string>& list_of_lgrs() const { return lgr_names; }
68
69 const std::array<double, 6>& get_mapaxes() const { return m_mapaxes; }
70 const std::string& get_mapunits() const { return m_mapunits; }
71 const std::vector<float>& get_coord() const { return coord_array; }
72 const std::vector<float>& get_zcorn() const { return zcorn_array; }
73
74
75
76
77private:
78 std::filesystem::path inputFileName, initFileName;
79 std::string m_grid_name;
80 bool m_radial;
81
82 std::array<double, 6> m_mapaxes;
83 std::string m_mapunits;
84 bool m_mapaxes_loaded;
85 std::array<double, 4> origin;
86 std::array<double, 2> unit_x;
87 std::array<double, 2> unit_y;
88
89 std::array<int, 3> nijk;
90 std::array<int, 3> host_nijk;
91
92 int nactive;
93 mutable bool m_nncs_loaded;
94
95 std::vector<int> act_index;
96 std::vector<int> glob_index;
97
98 std::vector<float> coord_array;
99 std::vector<float> zcorn_array;
100
101 std::vector<int> nnc1_array;
102 std::vector<int> nnc2_array;
103 std::vector<float> transnnc_array;
104 std::vector<int> host_cells;
105 std::map<int,int> res;
106
107 std::vector<std::string> lgr_names;
108
109 int numres;
110
111 int zcorn_array_index;
112 int coord_array_index;
113 int coordsys_array_index;
114 int actnum_array_index;
115 int nnc1_array_index;
116 int nnc2_array_index;
117
118 std::vector<float> get_zcorn_from_disk(int layer, bool bottom);
119
120 void getCellCorners(const std::array<int, 3>& ijk, const std::vector<float>& zcorn_layer,
121 std::array<double, 4>& X, std::array<double, 4>& Y, std::array<double, 4>& Z);
122
123 void mapaxes_init();
124
125};
126
127}} // namespace Opm::EclIO
128
129#endif // OPM_IO_EGRID_HPP
Definition EGrid.hpp:33
Definition EclFile.hpp:36
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30