My Project
EclEpsGridProperties.hpp
Go to the documentation of this file.
1 /*
2  This file is part of the Open Porous Media project (OPM).
3 
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 2 of the License, or
7  (at your option) any later version.
8 
9  OPM is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with OPM. If not, see <http://www.gnu.org/licenses/>.
16 
17  Consult the COPYING file in the top-level source directory of this
18  module for the precise wording of the license and the list of
19  copyright holders.
20 */
25 #ifndef OPM_ECL_EPS_GRID_PROPERTIES_HPP
26 #define OPM_ECL_EPS_GRID_PROPERTIES_HPP
27 
28 #include "EclEpsConfig.hpp"
29 
30 #if HAVE_ECL_INPUT
31 #include <opm/parser/eclipse/Deck/Deck.hpp>
32 #include <opm/parser/eclipse/Deck/DeckRecord.hpp>
33 #include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
34 #include <opm/parser/eclipse/EclipseState/Grid/FieldPropsManager.hpp>
35 #include <opm/parser/eclipse/EclipseState/Tables/SgfnTable.hpp>
36 #include <opm/parser/eclipse/EclipseState/Tables/SgofTable.hpp>
37 #include <opm/parser/eclipse/EclipseState/Tables/SlgofTable.hpp>
38 #include <opm/parser/eclipse/EclipseState/Tables/Sof2Table.hpp>
39 #include <opm/parser/eclipse/EclipseState/Tables/Sof3Table.hpp>
40 #include <opm/parser/eclipse/EclipseState/Tables/SwfnTable.hpp>
41 #include <opm/parser/eclipse/EclipseState/Tables/SwofTable.hpp>
42 #include <opm/parser/eclipse/EclipseState/Tables/TableManager.hpp>
43 #endif
44 
46 
47 #include <algorithm>
48 #include <array>
49 #include <cassert>
50 #include <memory>
51 #include <string>
52 #include <vector>
53 
54 namespace Opm {
62 namespace {
63 
64 std::vector<double> try_get(const FieldPropsManager& fp, const std::string& keyword) {
65  if (fp.has_double(keyword))
66  return fp.get_double(keyword);
67 
68  return {};
69 }
70 
71 }
72 
73 
74 
76 {
77 
78 public:
79 #if HAVE_ECL_INPUT
80 
81  EclEpsGridProperties(const EclipseState& eclState,
82  bool useImbibition)
83  {
84  const std::string kwPrefix = useImbibition ? "I" : "";
85 
86  const auto& fp = eclState.fieldProps();
87 
88  compressed_satnum = useImbibition
89  ? fp.get_int("IMBNUM") : fp.get_int("SATNUM");
90 
91  this->compressed_swl = try_get( fp, kwPrefix+"SWL");
92  this->compressed_sgl = try_get( fp, kwPrefix+"SGL");
93  this->compressed_swcr = try_get( fp, kwPrefix+"SWCR");
94  this->compressed_sgcr = try_get( fp, kwPrefix+"SGCR");
95  this->compressed_sowcr = try_get( fp, kwPrefix+"SOWCR");
96  this->compressed_sogcr = try_get( fp, kwPrefix+"SOGCR");
97  this->compressed_swu = try_get( fp, kwPrefix+"SWU");
98  this->compressed_sgu = try_get( fp, kwPrefix+"SGU");
99  this->compressed_pcw = try_get( fp, kwPrefix+"PCW");
100  this->compressed_pcg = try_get( fp, kwPrefix+"PCG");
101  this->compressed_krw = try_get( fp, kwPrefix+"KRW");
102  this->compressed_krwr = try_get( fp, kwPrefix+"KRWR");
103  this->compressed_kro = try_get( fp, kwPrefix+"KRO");
104  this->compressed_krorg = try_get( fp, kwPrefix+"KRORG");
105  this->compressed_krorw = try_get( fp, kwPrefix+"KRORW");
106  this->compressed_krg = try_get( fp, kwPrefix+"KRG");
107  this->compressed_krgr = try_get( fp, kwPrefix+"KRGR");
108 
109  // _may_ be needed to calculate the Leverett capillary pressure scaling factor
110  if (fp.has_double("PORO"))
111  this->compressed_poro = fp.get_double("PORO");
112 
113  this->compressed_permx = fp.has_double("PERMX")
114  ? fp.get_double("PERMX")
115  : std::vector<double>(this->compressed_satnum.size());
116 
117  this->compressed_permy = fp.has_double("PERMY")
118  ? fp.get_double("PERMY") : this->compressed_permx;
119 
120  this->compressed_permz = fp.has_double("PERMZ")
121  ? fp.get_double("PERMZ") : this->compressed_permx;
122  }
123 
124 #endif
125 
126 
127 
128  unsigned satRegion(std::size_t active_index) const {
129  return this->compressed_satnum[active_index] - 1;
130  }
131 
132  double permx(std::size_t active_index) const {
133  return this->compressed_permx[active_index];
134  }
135 
136  double permy(std::size_t active_index) const {
137  return this->compressed_permy[active_index];
138  }
139 
140  double permz(std::size_t active_index) const {
141  return this->compressed_permz[active_index];
142  }
143 
144  double poro(std::size_t active_index) const {
145  return this->compressed_poro[active_index];
146  }
147 
148  const double * swl(std::size_t active_index) const {
149  return this->satfunc(this->compressed_swl, active_index);
150  }
151 
152  const double * sgl(std::size_t active_index) const {
153  return this->satfunc(this->compressed_sgl, active_index);
154  }
155 
156  const double * swcr(std::size_t active_index) const {
157  return this->satfunc(this->compressed_swcr, active_index);
158  }
159 
160  const double * sgcr(std::size_t active_index) const {
161  return this->satfunc(this->compressed_sgcr, active_index);
162  }
163 
164  const double * sowcr(std::size_t active_index) const {
165  return this->satfunc(this->compressed_sowcr, active_index);
166  }
167 
168  const double * sogcr(std::size_t active_index) const {
169  return this->satfunc(this->compressed_sogcr, active_index);
170  }
171 
172  const double * swu(std::size_t active_index) const {
173  return this->satfunc(this->compressed_swu, active_index);
174  }
175 
176  const double * sgu(std::size_t active_index) const {
177  return this->satfunc(this->compressed_sgu, active_index);
178  }
179 
180  const double * pcw(std::size_t active_index) const {
181  return this->satfunc(this->compressed_pcw, active_index);
182  }
183 
184  const double * pcg(std::size_t active_index) const {
185  return this->satfunc(this->compressed_pcg, active_index);
186  }
187 
188  const double * krw(std::size_t active_index) const {
189  return this->satfunc(this->compressed_krw, active_index);
190  }
191 
192  const double * krwr(std::size_t active_index) const {
193  return this->satfunc(this->compressed_krwr, active_index);
194  }
195 
196  const double * krg(std::size_t active_index) const {
197  return this->satfunc(this->compressed_krg, active_index);
198  }
199 
200  const double * krgr(std::size_t active_index) const {
201  return this->satfunc(this->compressed_krgr, active_index);
202  }
203 
204  const double * kro(std::size_t active_index) const {
205  return this->satfunc(this->compressed_kro, active_index);
206  }
207 
208  const double * krorg(std::size_t active_index) const {
209  return this->satfunc(this->compressed_krorg, active_index);
210  }
211 
212  const double * krorw(std::size_t active_index) const {
213  return this->satfunc(this->compressed_krorw, active_index);
214  }
215 
216 private:
217  const double *
218  satfunc(const std::vector<double>& data,
219  const std::size_t active_index) const
220  {
221  return data.empty() ? nullptr : &data[active_index];
222  }
223 
224 
225  std::vector<int> compressed_satnum;
226  std::vector<double> compressed_swl;
227  std::vector<double> compressed_sgl;
228  std::vector<double> compressed_swcr;
229  std::vector<double> compressed_sgcr;
230  std::vector<double> compressed_sowcr;
231  std::vector<double> compressed_sogcr;
232  std::vector<double> compressed_swu;
233  std::vector<double> compressed_sgu;
234  std::vector<double> compressed_pcw;
235  std::vector<double> compressed_pcg;
236  std::vector<double> compressed_krw;
237  std::vector<double> compressed_krwr;
238  std::vector<double> compressed_kro;
239  std::vector<double> compressed_krorg;
240  std::vector<double> compressed_krorw;
241  std::vector<double> compressed_krg;
242  std::vector<double> compressed_krgr;
243 
244  std::vector<double> compressed_permx;
245  std::vector<double> compressed_permy;
246  std::vector<double> compressed_permz;
247  std::vector<double> compressed_poro;
248 };
249 }
250 #endif
251 
Specifies the configuration used by the endpoint scaling code.
Implements some common averages.
Definition: EclEpsGridProperties.hpp:76