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/input/eclipse/EclipseState/EclipseState.hpp>
32 #include <opm/input/eclipse/EclipseState/Grid/FieldPropsManager.hpp>
33 #include <opm/input/eclipse/EclipseState/Tables/SgfnTable.hpp>
34 #include <opm/input/eclipse/EclipseState/Tables/SgofTable.hpp>
35 #include <opm/input/eclipse/EclipseState/Tables/SlgofTable.hpp>
36 #include <opm/input/eclipse/EclipseState/Tables/Sof2Table.hpp>
37 #include <opm/input/eclipse/EclipseState/Tables/Sof3Table.hpp>
38 #include <opm/input/eclipse/EclipseState/Tables/SwfnTable.hpp>
39 #include <opm/input/eclipse/EclipseState/Tables/SwofTable.hpp>
40 #include <opm/input/eclipse/EclipseState/Tables/TableManager.hpp>
41 #endif
42 
43 #include <cstddef>
44 #include <string>
45 #include <vector>
46 
47 namespace Opm {
55 namespace {
56 
57 std::vector<double> try_get(const FieldPropsManager& fp, const std::string& keyword) {
58  if (fp.has_double(keyword))
59  return fp.get_double(keyword);
60 
61  return {};
62 }
63 
64 }
65 
66 
67 
69 {
70 
71 public:
72 #if HAVE_ECL_INPUT
73 
74  EclEpsGridProperties(const EclipseState& eclState,
75  bool useImbibition)
76  {
77  const std::string kwPrefix = useImbibition ? "I" : "";
78 
79  const auto& fp = eclState.fieldProps();
80 
81  compressed_satnum = useImbibition
82  ? fp.get_int("IMBNUM") : fp.get_int("SATNUM");
83 
84  this->compressed_swl = try_get( fp, kwPrefix+"SWL");
85  this->compressed_sgl = try_get( fp, kwPrefix+"SGL");
86  this->compressed_swcr = try_get( fp, kwPrefix+"SWCR");
87  this->compressed_sgcr = try_get( fp, kwPrefix+"SGCR");
88  this->compressed_sowcr = try_get( fp, kwPrefix+"SOWCR");
89  this->compressed_sogcr = try_get( fp, kwPrefix+"SOGCR");
90  this->compressed_swu = try_get( fp, kwPrefix+"SWU");
91  this->compressed_sgu = try_get( fp, kwPrefix+"SGU");
92  this->compressed_pcw = try_get( fp, kwPrefix+"PCW");
93  this->compressed_pcg = try_get( fp, kwPrefix+"PCG");
94  this->compressed_krw = try_get( fp, kwPrefix+"KRW");
95  this->compressed_krwr = try_get( fp, kwPrefix+"KRWR");
96  this->compressed_kro = try_get( fp, kwPrefix+"KRO");
97  this->compressed_krorg = try_get( fp, kwPrefix+"KRORG");
98  this->compressed_krorw = try_get( fp, kwPrefix+"KRORW");
99  this->compressed_krg = try_get( fp, kwPrefix+"KRG");
100  this->compressed_krgr = try_get( fp, kwPrefix+"KRGR");
101 
102  // _may_ be needed to calculate the Leverett capillary pressure scaling factor
103  if (fp.has_double("PORO"))
104  this->compressed_poro = fp.get_double("PORO");
105 
106  this->compressed_permx = fp.has_double("PERMX")
107  ? fp.get_double("PERMX")
108  : std::vector<double>(this->compressed_satnum.size());
109 
110  this->compressed_permy = fp.has_double("PERMY")
111  ? fp.get_double("PERMY") : this->compressed_permx;
112 
113  this->compressed_permz = fp.has_double("PERMZ")
114  ? fp.get_double("PERMZ") : this->compressed_permx;
115  }
116 
117 #endif
118 
119 
120 
121  unsigned satRegion(std::size_t active_index) const {
122  return this->compressed_satnum[active_index] - 1;
123  }
124 
125  double permx(std::size_t active_index) const {
126  return this->compressed_permx[active_index];
127  }
128 
129  double permy(std::size_t active_index) const {
130  return this->compressed_permy[active_index];
131  }
132 
133  double permz(std::size_t active_index) const {
134  return this->compressed_permz[active_index];
135  }
136 
137  double poro(std::size_t active_index) const {
138  return this->compressed_poro[active_index];
139  }
140 
141  const double * swl(std::size_t active_index) const {
142  return this->satfunc(this->compressed_swl, active_index);
143  }
144 
145  const double * sgl(std::size_t active_index) const {
146  return this->satfunc(this->compressed_sgl, active_index);
147  }
148 
149  const double * swcr(std::size_t active_index) const {
150  return this->satfunc(this->compressed_swcr, active_index);
151  }
152 
153  const double * sgcr(std::size_t active_index) const {
154  return this->satfunc(this->compressed_sgcr, active_index);
155  }
156 
157  const double * sowcr(std::size_t active_index) const {
158  return this->satfunc(this->compressed_sowcr, active_index);
159  }
160 
161  const double * sogcr(std::size_t active_index) const {
162  return this->satfunc(this->compressed_sogcr, active_index);
163  }
164 
165  const double * swu(std::size_t active_index) const {
166  return this->satfunc(this->compressed_swu, active_index);
167  }
168 
169  const double * sgu(std::size_t active_index) const {
170  return this->satfunc(this->compressed_sgu, active_index);
171  }
172 
173  const double * pcw(std::size_t active_index) const {
174  return this->satfunc(this->compressed_pcw, active_index);
175  }
176 
177  const double * pcg(std::size_t active_index) const {
178  return this->satfunc(this->compressed_pcg, active_index);
179  }
180 
181  const double * krw(std::size_t active_index) const {
182  return this->satfunc(this->compressed_krw, active_index);
183  }
184 
185  const double * krwr(std::size_t active_index) const {
186  return this->satfunc(this->compressed_krwr, active_index);
187  }
188 
189  const double * krg(std::size_t active_index) const {
190  return this->satfunc(this->compressed_krg, active_index);
191  }
192 
193  const double * krgr(std::size_t active_index) const {
194  return this->satfunc(this->compressed_krgr, active_index);
195  }
196 
197  const double * kro(std::size_t active_index) const {
198  return this->satfunc(this->compressed_kro, active_index);
199  }
200 
201  const double * krorg(std::size_t active_index) const {
202  return this->satfunc(this->compressed_krorg, active_index);
203  }
204 
205  const double * krorw(std::size_t active_index) const {
206  return this->satfunc(this->compressed_krorw, active_index);
207  }
208 
209 private:
210  const double *
211  satfunc(const std::vector<double>& data,
212  const std::size_t active_index) const
213  {
214  return data.empty() ? nullptr : &data[active_index];
215  }
216 
217 
218  std::vector<int> compressed_satnum;
219  std::vector<double> compressed_swl;
220  std::vector<double> compressed_sgl;
221  std::vector<double> compressed_swcr;
222  std::vector<double> compressed_sgcr;
223  std::vector<double> compressed_sowcr;
224  std::vector<double> compressed_sogcr;
225  std::vector<double> compressed_swu;
226  std::vector<double> compressed_sgu;
227  std::vector<double> compressed_pcw;
228  std::vector<double> compressed_pcg;
229  std::vector<double> compressed_krw;
230  std::vector<double> compressed_krwr;
231  std::vector<double> compressed_kro;
232  std::vector<double> compressed_krorg;
233  std::vector<double> compressed_krorw;
234  std::vector<double> compressed_krg;
235  std::vector<double> compressed_krgr;
236 
237  std::vector<double> compressed_permx;
238  std::vector<double> compressed_permy;
239  std::vector<double> compressed_permz;
240  std::vector<double> compressed_poro;
241 };
242 }
243 #endif
244 
Specifies the configuration used by the endpoint scaling code.
Definition: EclEpsGridProperties.hpp:69