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