My Project
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 
30 namespace Opm { namespace EclIO {
31 
32 class EGrid : public EclFile
33 {
34 public:
35  explicit EGrid(const std::string& filename, 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 is_radial() const { return m_radial; }
57 
58  const std::vector<int>& hostCellsGlobalIndex() const { return host_cells; }
59  std::vector<std::array<int, 3>> hostCellsIJK();
60 
61  // zero based: i1, j1,k1, i2,j2,k2, transmisibility
62  using NNCentry = std::tuple<int, int, int, int, int, int, float>;
63  std::vector<NNCentry> get_nnc_ijk();
64 
65  const std::vector<std::string>& list_of_lgrs() const { return lgr_names; }
66 
67  const std::vector<float>& get_mapaxes() const { return m_mapaxes; }
68  const std::string& get_mapunits() const { return m_mapunits; }
69 
70 private:
71  std::filesystem::path inputFileName, initFileName;
72  std::string m_grid_name;
73  bool m_radial;
74 
75  std::vector<float> m_mapaxes;
76  std::string m_mapunits;
77 
78  std::array<int, 3> nijk;
79  std::array<int, 3> host_nijk;
80 
81  int nactive;
82  mutable bool m_nncs_loaded;
83 
84  std::vector<int> act_index;
85  std::vector<int> glob_index;
86 
87  std::vector<float> coord_array;
88  std::vector<float> zcorn_array;
89 
90  std::vector<int> nnc1_array;
91  std::vector<int> nnc2_array;
92  std::vector<float> transnnc_array;
93  std::vector<int> host_cells;
94 
95  std::vector<std::string> lgr_names;
96 
97  int zcorn_array_index;
98  int coord_array_index;
99  int actnum_array_index;
100  int nnc1_array_index;
101  int nnc2_array_index;
102 
103  std::vector<float> get_zcorn_from_disk(int layer, bool bottom);
104 
105  void getCellCorners(const std::array<int, 3>& ijk, const std::vector<float>& zcorn_layer,
106  std::array<double,4>& X, std::array<double,4>& Y, std::array<double,4>& Z);
107 
108 };
109 
110 }} // namespace Opm::EclIO
111 
112 #endif // OPM_IO_EGRID_HPP
Definition: EGrid.hpp:33
Definition: EclFile.hpp:35
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:29