All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
EclEpsConfig.hpp
Go to the documentation of this file.
1 // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 // vi: set et ts=4 sw=4 sts=4:
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
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 2 of the License, or
9  (at your option) any later version.
10 
11  OPM is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OPM. If not, see <http://www.gnu.org/licenses/>.
18 
19  Consult the COPYING file in the top-level source directory of this
20  module for the precise wording of the license and the list of
21  copyright holders.
22 */
27 #ifndef OPM_ECL_EPS_CONFIG_HPP
28 #define OPM_ECL_EPS_CONFIG_HPP
29 
30 #if HAVE_OPM_PARSER
31 #include <opm/parser/eclipse/Deck/Deck.hpp>
32 #include <opm/parser/eclipse/Deck/DeckItem.hpp>
33 #include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
34 #include <opm/parser/eclipse/Deck/DeckRecord.hpp>
35 #include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
36 #endif
37 
38 #include <opm/common/ErrorMacros.hpp>
39 #include <opm/common/Exceptions.hpp>
40 #include <opm/common/Unused.hpp>
41 
42 #include <string>
43 #include <cassert>
44 #include <algorithm>
45 
46 namespace Opm {
51 enum EclTwoPhaseSystemType {
52  EclGasOilSystem,
53  EclOilWaterSystem,
54 };
55 
64 {
65 public:
66  EclEpsConfig()
67  {
68  // by default, do not scale anything
69  enableSatScaling_ = false;
70  enablePcScaling_ = false;
71  enableLeverettScaling_ = false;
72  enableKrwScaling_ = false;
73  enableKrnScaling_ = false;
74  enableThreePointKrSatScaling_ = false;
75  }
76 
80  void setEnableSatScaling(bool yesno)
81  { enableSatScaling_ = yesno; }
82 
86  bool enableSatScaling() const
87  { return enableSatScaling_; }
88 
94  { enableThreePointKrSatScaling_ = yesno; }
95 
101  { return enableThreePointKrSatScaling_; }
102 
106  void setEnableKrwScaling(bool yesno)
107  { enableKrwScaling_ = yesno; }
108 
112  bool enableKrwScaling() const
113  { return enableKrwScaling_; }
114 
118  void setEnableKrnScaling(bool yesno)
119  { enableKrnScaling_ = yesno; }
120 
124  bool enableKrnScaling() const
125  { return enableKrnScaling_; }
126 
130  void setEnablePcScaling(bool yesno)
131  { enablePcScaling_ = yesno; }
132 
136  bool enablePcScaling() const
137  { return enablePcScaling_; }
138 
146  void setEnableLeverettScaling(bool yesno)
147  { enableLeverettScaling_ = yesno; }
148 
157  { return enableLeverettScaling_; }
158 
159 #if HAVE_OPM_PARSER
160 
165  void initFromDeck(const Opm::Deck& deck OPM_UNUSED,
166  const Opm::EclipseState& eclState,
167  Opm::EclTwoPhaseSystemType twoPhaseSystemType)
168  {
169  const auto& endscale = eclState.runspec().endpointScaling();
170  // find out if endpoint scaling is used in the first place
171  if (!endscale) {
172  // it is not used, i.e., just set all enable$Foo attributes to 0 and be done
173  // with it.
174  enableSatScaling_ = false;
175  enableThreePointKrSatScaling_ = false;
176  enablePcScaling_ = false;
177  enableLeverettScaling_ = false;
178  enableKrwScaling_ = false;
179  enableKrnScaling_ = false;
180  return;
181  }
182 
183  // endpoint scaling is used, i.e., at least saturation scaling needs to be enabled
184  enableSatScaling_ = true;
185 
186  enableThreePointKrSatScaling_ = endscale.threepoint();
187 
188  auto& props = eclState.get3DProperties();
189  // check if we are supposed to scale the Y axis of the capillary pressure
190  if (twoPhaseSystemType == EclOilWaterSystem) {
191  enablePcScaling_ =
192  props.hasDeckDoubleGridProperty("PCW")
193  || props.hasDeckDoubleGridProperty("SWATINIT");
194 
195  // check if Leverett capillary pressure scaling is requested
196  if (eclState.getTableManager().useJFunc()) {
197  const auto& jfunc = eclState.getTableManager().getJFunc();
198  auto flag = jfunc.flag();
199  if (flag == Opm::JFunc::Flag::BOTH || flag == Opm::JFunc::Flag::WATER)
200  enableLeverettScaling_ = true;
201  }
202 
203  if (enablePcScaling_ && enableLeverettScaling_)
204  OPM_THROW(std::runtime_error,
205  "Capillary pressure scaling and the Leverett scaling function are "
206  "mutually exclusive: The deck contains the PCW property and the "
207  "JFUNC keyword applies to the water phase.");
208  }
209  else {
210  assert(twoPhaseSystemType == EclGasOilSystem);
211  enablePcScaling_ = props.hasDeckDoubleGridProperty("PCG");
212 
213  // check if Leverett capillary pressure scaling is requested
214  if (eclState.getTableManager().useJFunc()) {
215  const auto& jfunc = eclState.getTableManager().getJFunc();
216  auto flag = jfunc.flag();
217  if (flag == Opm::JFunc::Flag::BOTH || flag == Opm::JFunc::Flag::GAS)
218  enableLeverettScaling_ = true;
219  }
220 
221  if (enablePcScaling_ && enableLeverettScaling_)
222  OPM_THROW(std::runtime_error,
223  "Capillary pressure scaling and the Leverett scaling function are "
224  "mutually exclusive: The deck contains the PCG property and the "
225  "JFUNC keyword applies to the gas phase.");
226  }
227 
228  // check if we are supposed to scale the Y axis of the wetting phase relperm
229  if (twoPhaseSystemType == EclOilWaterSystem)
230  enableKrwScaling_ = props.hasDeckDoubleGridProperty("KRW");
231  else {
232  assert(twoPhaseSystemType == EclGasOilSystem);
233  enableKrwScaling_ = props.hasDeckDoubleGridProperty("KRO");
234  }
235 
236  // check if we are supposed to scale the Y axis of the non-wetting phase relperm
237  if (twoPhaseSystemType == EclOilWaterSystem)
238  enableKrnScaling_ = props.hasDeckDoubleGridProperty("KRO");
239  else {
240  assert(twoPhaseSystemType == EclGasOilSystem);
241  enableKrnScaling_ = props.hasDeckDoubleGridProperty("KRG");
242  }
243  }
244 #endif
245 
246 private:
247  // enable scaling of the input saturations (i.e., rescale the x-Axis)
248  bool enableSatScaling_;
249 
250  // use three (instead of two) points to scale the saturations for the relative
251  // permeabilities.
252  //
253  // This means that two piecewise linear functions are used for saturation scaling
254  // instead of a single linear one
255  bool enableThreePointKrSatScaling_;
256 
257  // enable the scaling of the capillary pressure and relative permeability outputs
258  // (i.e., rescale the y-Axis)
259  bool enablePcScaling_;
260  bool enableLeverettScaling_;
261  bool enableKrwScaling_;
262  bool enableKrnScaling_;
263 };
264 
265 } // namespace Opm
266 
267 #endif
bool enableKrnScaling() const
Returns whether relative permeability scaling is enabled for the non-wetting phase.
Definition: EclEpsConfig.hpp:124
bool enableThreePointKrSatScaling() const
Returns whether three point saturation scaling is enabled for the relative permeabilities.
Definition: EclEpsConfig.hpp:100
bool enablePcScaling() const
Returns whether capillary pressure scaling is enabled.
Definition: EclEpsConfig.hpp:136
Specifies the configuration used by the endpoint scaling code.
Definition: EclEpsConfig.hpp:63
void setEnableKrnScaling(bool yesno)
Specify whether relative permeability scaling is enabled for the non-wetting phase.
Definition: EclEpsConfig.hpp:118
void setEnableKrwScaling(bool yesno)
Specify whether relative permeability scaling is enabled for the wetting phase.
Definition: EclEpsConfig.hpp:106
bool enableKrwScaling() const
Returns whether relative permeability scaling is enabled for the wetting phase.
Definition: EclEpsConfig.hpp:112
void setEnableSatScaling(bool yesno)
Specify whether saturation scaling is enabled.
Definition: EclEpsConfig.hpp:80
bool enableSatScaling() const
Returns whether saturation scaling is enabled.
Definition: EclEpsConfig.hpp:86
void setEnableThreePointKrSatScaling(bool yesno)
Specify whether three point saturation scaling is enabled for the relative permeabilities.
Definition: EclEpsConfig.hpp:93
void setEnableLeverettScaling(bool yesno)
Specify whether the Leverett capillary pressure scaling is enabled.
Definition: EclEpsConfig.hpp:146
void setEnablePcScaling(bool yesno)
Specify whether capillary pressure scaling is enabled.
Definition: EclEpsConfig.hpp:130
bool enableLeverettScaling() const
Returns whether the Leverett capillary pressure scaling is enabled.
Definition: EclEpsConfig.hpp:156