My Project
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_ECL_INPUT
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 
39 
40 #include <string>
41 #include <cassert>
42 #include <algorithm>
43 
44 namespace Opm {
50  EclGasOilSystem,
51  EclOilWaterSystem,
52  EclGasWaterSystem
53 };
54 
63 {
64 public:
65  EclEpsConfig()
66  {
67  // by default, do not scale anything
68  enableSatScaling_ = false;
69  enablePcScaling_ = false;
70  enableLeverettScaling_ = false;
71  enableKrwScaling_ = false;
72  enableKrnScaling_ = false;
73  enableThreePointKrSatScaling_ = false;
74  }
75 
79  void setEnableSatScaling(bool yesno)
80  { enableSatScaling_ = yesno; }
81 
85  bool enableSatScaling() const
86  { return enableSatScaling_; }
87 
93  { enableThreePointKrSatScaling_ = yesno; }
94 
100  { return enableThreePointKrSatScaling_; }
101 
105  void setEnableKrwScaling(bool yesno)
106  { enableKrwScaling_ = yesno; }
107 
111  bool enableKrwScaling() const
112  { return enableKrwScaling_; }
113 
118  void setEnableThreePointKrwScaling(const bool enable)
119  { this->enableThreePointKrwScaling_ = enable; }
120 
126  { return this->enableThreePointKrwScaling_; }
127 
132  void setEnableThreePointKrnScaling(const bool enable)
133  { this->enableThreePointKrnScaling_ = enable; }
134 
140  { return this->enableThreePointKrnScaling_; }
141 
145  void setEnableKrnScaling(bool yesno)
146  { enableKrnScaling_ = yesno; }
147 
151  bool enableKrnScaling() const
152  { return enableKrnScaling_; }
153 
157  void setEnablePcScaling(bool yesno)
158  { enablePcScaling_ = yesno; }
159 
163  bool enablePcScaling() const
164  { return enablePcScaling_; }
165 
173  void setEnableLeverettScaling(bool yesno)
174  { enableLeverettScaling_ = yesno; }
175 
184  { return enableLeverettScaling_; }
185 
186 #if HAVE_ECL_INPUT
192  void initFromState(const EclipseState& eclState,
193  EclTwoPhaseSystemType twoPhaseSystemType,
194  const std::string& prefix = "",
195  const std::string& suffix = "")
196  {
197  const auto& endscale = eclState.runspec().endpointScaling();
198  // find out if endpoint scaling is used in the first place
199  if (!endscale) {
200  // it is not used, i.e., just set all enable$Foo attributes to 0 and be done
201  // with it.
202  enableSatScaling_ = false;
203  enableThreePointKrSatScaling_ = false;
204  enablePcScaling_ = false;
205  enableLeverettScaling_ = false;
206  enableKrwScaling_ = false;
207  enableKrnScaling_ = false;
208  return;
209  }
210 
211  // endpoint scaling is used, i.e., at least saturation scaling needs to be enabled
212  enableSatScaling_ = true;
213  enableThreePointKrSatScaling_ = endscale.threepoint();
214 
215  if (eclState.getTableManager().useJFunc()) {
216  const auto flag = eclState.getTableManager().getJFunc().flag();
217 
218  enableLeverettScaling_ = (flag == JFunc::Flag::BOTH)
219  || ((twoPhaseSystemType == EclOilWaterSystem) &&
220  (flag == JFunc::Flag::WATER))
221  || ((twoPhaseSystemType == EclGasOilSystem) &&
222  (flag == JFunc::Flag::GAS));
223  }
224 
225  const auto& fp = eclState.fieldProps();
226  auto hasKR = [&fp, &prefix, &suffix](const std::string& scaling)
227  {
228  return fp.has_double(prefix + "KR" + scaling + suffix);
229  };
230  auto hasPC = [&fp, &prefix](const std::string& scaling)
231  {
232  return fp.has_double(prefix + "PC" + scaling);
233  };
234 
235  // check if we are supposed to scale the Y axis of the capillary pressure
236  if (twoPhaseSystemType == EclOilWaterSystem) {
237  this->setEnableThreePointKrwScaling(hasKR("WR"));
238  this->setEnableThreePointKrnScaling(hasKR("ORW"));
239 
240  this->enableKrnScaling_ = hasKR("O") || this->enableThreePointKrnScaling();
241  this->enableKrwScaling_ = hasKR("W") || this->enableThreePointKrwScaling();
242  this->enablePcScaling_ = hasPC("W") || fp.has_double("SWATINIT");
243  }
244  else if (twoPhaseSystemType == EclGasOilSystem) {
245  this->setEnableThreePointKrwScaling(hasKR("ORG"));
246  this->setEnableThreePointKrnScaling(hasKR("GR"));
247 
248  this->enableKrnScaling_ = hasKR("G") || this->enableThreePointKrnScaling();
249  this->enableKrwScaling_ = hasKR("O") || this->enableThreePointKrwScaling();
250  this->enablePcScaling_ = hasPC("G");
251  }
252  else {
253  assert(twoPhaseSystemType == EclGasWaterSystem);
254  //TODO enable endpoint scaling for gaswater system
255  }
256 
257  if (enablePcScaling_ && enableLeverettScaling_) {
258  throw std::runtime_error {
259  "Capillary pressure scaling and the Leverett scaling function "
260  "are mutually exclusive. The deck contains the PCW/PCG property "
261  "and the JFUNC keyword applies to the water phase."
262  };
263  }
264  }
265 #endif
266 
267 private:
268  // enable scaling of the input saturations (i.e., rescale the x-Axis)
269  bool enableSatScaling_;
270 
271  // use three (instead of two) points to scale the saturations for the relative
272  // permeabilities.
273  //
274  // This means that two piecewise linear functions are used for saturation scaling
275  // instead of a single linear one
276  bool enableThreePointKrSatScaling_;
277 
278  // enable the scaling of the capillary pressure and relative permeability outputs
279  // (i.e., rescale the y-Axis)
280  bool enablePcScaling_;
281  bool enableLeverettScaling_;
282  bool enableKrwScaling_;
283  bool enableKrnScaling_;
284 
285  // Employ three-point vertical scaling (e.g., KRWR and KRW).
286  bool enableThreePointKrwScaling_{false};
287 
288  // Employ three-point vertical scaling (e.g., KRORW and KRO).
289  bool enableThreePointKrnScaling_{false};
290 };
291 
292 } // namespace Opm
293 
294 #endif
EclTwoPhaseSystemType
Specified which fluids are involved in a given twophase material law for endpoint scaling.
Definition: EclEpsConfig.hpp:49
Provides the OPM_UNUSED macro.
Specifies the configuration used by the endpoint scaling code.
Definition: EclEpsConfig.hpp:63
bool enableThreePointKrwScaling() const
Whether or not three-point relative permeability value scaling is enabled for the wetting phase (KRWR...
Definition: EclEpsConfig.hpp:125
bool enableKrwScaling() const
Returns whether relative permeability scaling is enabled for the wetting phase.
Definition: EclEpsConfig.hpp:111
void setEnableKrnScaling(bool yesno)
Specify whether relative permeability scaling is enabled for the non-wetting phase.
Definition: EclEpsConfig.hpp:145
void setEnablePcScaling(bool yesno)
Specify whether capillary pressure scaling is enabled.
Definition: EclEpsConfig.hpp:157
bool enableKrnScaling() const
Returns whether relative permeability scaling is enabled for the non-wetting phase.
Definition: EclEpsConfig.hpp:151
void setEnableKrwScaling(bool yesno)
Specify whether relative permeability scaling is enabled for the wetting phase.
Definition: EclEpsConfig.hpp:105
bool enableLeverettScaling() const
Returns whether the Leverett capillary pressure scaling is enabled.
Definition: EclEpsConfig.hpp:183
void setEnableSatScaling(bool yesno)
Specify whether saturation scaling is enabled.
Definition: EclEpsConfig.hpp:79
void setEnableLeverettScaling(bool yesno)
Specify whether the Leverett capillary pressure scaling is enabled.
Definition: EclEpsConfig.hpp:173
void setEnableThreePointKrwScaling(const bool enable)
Specify whether three-point relative permeability value scaling is enabled for the wetting phase (KRW...
Definition: EclEpsConfig.hpp:118
bool enablePcScaling() const
Returns whether capillary pressure scaling is enabled.
Definition: EclEpsConfig.hpp:163
void setEnableThreePointKrSatScaling(bool yesno)
Specify whether three point saturation scaling is enabled for the relative permeabilities.
Definition: EclEpsConfig.hpp:92
void setEnableThreePointKrnScaling(const bool enable)
Specify whether three-point relative permeability value scaling is enabled for the wetting phase (e....
Definition: EclEpsConfig.hpp:132
bool enableThreePointKrnScaling() const
Whether or not three-point relative permeability value scaling is enabled for the non-wetting phase (...
Definition: EclEpsConfig.hpp:139
bool enableThreePointKrSatScaling() const
Returns whether three point saturation scaling is enabled for the relative permeabilities.
Definition: EclEpsConfig.hpp:99
bool enableSatScaling() const
Returns whether saturation scaling is enabled.
Definition: EclEpsConfig.hpp:85