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 <iostream>
27 #include <string>
28 #include <fstream>
29 #include <vector>
30 #include <ctime>
31 #include <map>
32 
33 namespace Opm { namespace EclIO {
34 
35 class EGrid : public EclFile
36 {
37 public:
38  explicit EGrid(const std::string& filename, std::string grid_name = "global");
39 
40  int global_index(int i, int j, int k) const;
41  int active_index(int i, int j, int k) const;
42 
43  const std::array<int, 3>& dimension() const { return nijk; }
44 
45  std::array<int, 3> ijk_from_active_index(int actInd) const;
46  std::array<int, 3> ijk_from_global_index(int globInd) const;
47 
48  void getCellCorners(int globindex, std::array<double,8>& X, std::array<double,8>& Y, std::array<double,8>& Z);
49  void getCellCorners(const std::array<int, 3>& ijk, std::array<double,8>& X, std::array<double,8>& Y, std::array<double,8>& Z);
50 
51  std::vector<std::array<float, 3>> getXYZ_layer(int layer, bool bottom=false);
52  std::vector<std::array<float, 3>> getXYZ_layer(int layer, const std::array<int, 4>& box, bool bottom=false);
53 
54  int activeCells() const { return nactive; }
55  int totalNumberOfCells() const { return nijk[0] * nijk[1] * nijk[2]; }
56 
57  void load_grid_data();
58  void load_nnc_data();
59  bool is_radial() const { return m_radial; }
60 
61  const std::vector<int>& hostCellsGlobalIndex() const { return host_cells; }
62  std::vector<std::array<int, 3>> hostCellsIJK();
63 
64  // zero based: i1, j1,k1, i2,j2,k2, transmisibility
65  using NNCentry = std::tuple<int, int, int, int, int, int, float>;
66  std::vector<NNCentry> get_nnc_ijk();
67 
68  const std::vector<std::string>& list_of_lgrs() const { return lgr_names; }
69 
70  const std::vector<float>& get_mapaxes() const { return m_mapaxes; }
71  const std::string& get_mapunits() const { return m_mapunits; }
72 
73 private:
74  std::filesystem::path inputFileName, initFileName;
75  std::string m_grid_name;
76  bool m_radial;
77 
78  std::vector<float> m_mapaxes;
79  std::string m_mapunits;
80 
81  std::array<int, 3> nijk;
82  std::array<int, 3> host_nijk;
83 
84  int nactive;
85  mutable bool m_nncs_loaded;
86 
87  std::vector<int> act_index;
88  std::vector<int> glob_index;
89 
90  std::vector<float> coord_array;
91  std::vector<float> zcorn_array;
92 
93  std::vector<int> nnc1_array;
94  std::vector<int> nnc2_array;
95  std::vector<float> transnnc_array;
96  std::vector<int> host_cells;
97 
98  std::vector<std::string> lgr_names;
99 
100  int zcorn_array_index;
101  int coord_array_index;
102  int actnum_array_index;
103  int nnc1_array_index;
104  int nnc2_array_index;
105 
106  std::vector<float> get_zcorn_from_disk(int layer, bool bottom);
107 
108  void getCellCorners(const std::array<int, 3>& ijk, const std::vector<float>& zcorn_layer,
109  std::array<double,4>& X, std::array<double,4>& Y, std::array<double,4>& Z);
110 
111 };
112 
113 }} // namespace Opm::EclIO
114 
115 #endif // OPM_IO_EGRID_HPP
Definition: EGrid.hpp:36
Definition: EclFile.hpp:35
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:29