26 #ifndef OPM_ECL_EPS_SCALING_POINTS_HPP
27 #define OPM_ECL_EPS_SCALING_POINTS_HPP
32 #include <opm/parser/eclipse/Deck/Deck.hpp>
33 #include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
51 typedef std::vector<int> IntData;
52 typedef std::vector<double> DoubleData;
56 void initFromDeck(Opm::DeckConstPtr ,
57 Opm::EclipseStateConstPtr eclState,
60 std::string kwPrefix = useImbibition?
"I":
"";
63 satnum = &eclState->getIntGridProperty(
"IMBNUM")->getData();
65 satnum = &eclState->getIntGridProperty(
"SATNUM")->getData();
67 retrieveGridPropertyData_(&
swl, eclState, kwPrefix+
"SWL");
68 retrieveGridPropertyData_(&
sgl, eclState, kwPrefix+
"SGL");
69 retrieveGridPropertyData_(&
swcr, eclState, kwPrefix+
"SWCR");
70 retrieveGridPropertyData_(&
sgcr, eclState, kwPrefix+
"SGCR");
71 retrieveGridPropertyData_(&
sowcr, eclState, kwPrefix+
"SOWCR");
72 retrieveGridPropertyData_(&
sogcr, eclState, kwPrefix+
"SOGCR");
73 retrieveGridPropertyData_(&
swu, eclState, kwPrefix+
"SWU");
74 retrieveGridPropertyData_(&
sgu, eclState, kwPrefix+
"SGU");
75 retrieveGridPropertyData_(&
pcw, eclState, kwPrefix+
"PCW");
76 retrieveGridPropertyData_(&
pcg, eclState, kwPrefix+
"PCG");
77 retrieveGridPropertyData_(&
krw, eclState, kwPrefix+
"KRW");
78 retrieveGridPropertyData_(&
kro, eclState, kwPrefix+
"KRO");
79 retrieveGridPropertyData_(&
krg, eclState, kwPrefix+
"KRG");
85 const DoubleData*
swl;
86 const DoubleData*
sgl;
91 const DoubleData*
swu;
92 const DoubleData*
sgu;
93 const DoubleData*
pcw;
94 const DoubleData*
pcg;
95 const DoubleData*
krw;
96 const DoubleData*
kro;
97 const DoubleData*
krg;
103 void retrieveGridPropertyData_(
const DoubleData **data,
104 Opm::EclipseStateConstPtr eclState,
105 const std::string& properyName)
108 if (eclState->hasDoubleGridProperty(properyName))
109 (*data) = &eclState->getDoubleGridProperty(properyName)->getData();
121 template <
class Scalar>
154 std::cout <<
" Swl: " << Swl <<
"\n"
155 <<
" Sgl: " << Sgl <<
"\n"
156 <<
" Sowl: " << Sowl <<
"\n"
157 <<
" Sogl: " << Sogl <<
"\n"
158 <<
" Swcr: " << Swcr <<
"\n"
159 <<
" Sgcr: " << Sgcr <<
"\n"
160 <<
" Sowcr: " << Sowcr <<
"\n"
161 <<
" Sogcr: " << Sogcr <<
"\n"
162 <<
" Swu: " << Swu <<
"\n"
163 <<
" Sgu: " << Sgu <<
"\n"
164 <<
" Sowu: " << Sowu <<
"\n"
165 <<
" Sogu: " << Sogu <<
"\n"
166 <<
" maxPcow: " << maxPcow <<
"\n"
167 <<
" maxPcgo: " << maxPcgo <<
"\n"
168 <<
" maxKrw: " << maxKrw <<
"\n"
169 <<
" maxKrg: " << maxKrg <<
"\n"
170 <<
" maxKrow: " << maxKrow <<
"\n"
171 <<
" maxKrog: " << maxKrog <<
"\n";
181 void extractUnscaled(Opm::DeckConstPtr deck,
182 Opm::EclipseStateConstPtr eclState,
183 unsigned satRegionIdx)
186 auto tables = eclState->getTableManager();
187 const TableContainer& swofTables = tables->getSwofTables();
188 const TableContainer& sgofTables = tables->getSgofTables();
189 const TableContainer& slgofTables = tables->getSlgofTables();
190 const TableContainer& swfnTables = tables->getSwfnTables();
191 const TableContainer& sgfnTables = tables->getSgfnTables();
192 const TableContainer& sof3Tables = tables->getSof3Tables();
194 bool hasWater = deck->hasKeyword(
"WATER");
195 bool hasGas = deck->hasKeyword(
"GAS");
196 bool hasOil = deck->hasKeyword(
"OIL");
202 if (!sgofTables.empty())
203 extractUnscaledSgof_(sgofTables.getTable<SgofTable>(satRegionIdx));
205 assert(!slgofTables.empty());
206 extractUnscaledSlgof_(slgofTables.getTable<SlgofTable>(satRegionIdx));
211 assert(!swofTables.empty());
215 extractUnscaledSwof_(swofTables.getTable<SwofTable>(satRegionIdx));
221 if (!hasWater || !hasGas || !hasOil)
222 throw std::domain_error(
"The specified phase configuration is not suppored");
224 bool family1 = (!sgofTables.empty() || !slgofTables.empty()) && !swofTables.empty();
225 bool family2 = !swfnTables.empty() && !sgfnTables.empty() && !sof3Tables.empty();
228 extractUnscaledSwof_(swofTables.getTable<SwofTable>(satRegionIdx));
230 if (!sgofTables.empty()) {
232 extractUnscaledSgof_(sgofTables.getTable<SgofTable>(satRegionIdx));
236 assert(!slgofTables.empty());
238 extractUnscaledSlgof_(slgofTables.getTable<SlgofTable>(satRegionIdx));
242 extractUnscaledSwfn_(swfnTables.getTable<SwfnTable>(satRegionIdx));
243 extractUnscaledSgfn_(sgfnTables.getTable<SgfnTable>(satRegionIdx));
244 extractUnscaledSof3_(sof3Tables.getTable<Sof3Table>(satRegionIdx));
247 assert(
std::abs(Sowu - (1 - swfnTables.getTable<SwfnTable>(satRegionIdx).getSwColumn().front())) < 1e-30);
250 throw std::domain_error(
"No valid saturation keyword family specified");
265 extractGridPropertyValue_(Swl, epsProperties.
swl, cartesianCellIdx);
266 extractGridPropertyValue_(Sgl, epsProperties.
sgl, cartesianCellIdx);
267 extractGridPropertyValue_(Swcr, epsProperties.
swcr, cartesianCellIdx);
268 extractGridPropertyValue_(Sgcr, epsProperties.
sgcr, cartesianCellIdx);
269 extractGridPropertyValue_(Sowcr, epsProperties.
sowcr, cartesianCellIdx);
270 extractGridPropertyValue_(Sogcr, epsProperties.
sogcr, cartesianCellIdx);
271 extractGridPropertyValue_(Swu, epsProperties.
swu, cartesianCellIdx);
272 extractGridPropertyValue_(Sgu, epsProperties.
sgu, cartesianCellIdx);
274 extractGridPropertyValue_(maxPcow, epsProperties.
pcw, cartesianCellIdx);
275 extractGridPropertyValue_(maxPcgo, epsProperties.
pcg, cartesianCellIdx);
277 extractGridPropertyValue_(maxKrw, epsProperties.
krw, cartesianCellIdx);
278 extractGridPropertyValue_(maxKrg, epsProperties.
krg, cartesianCellIdx);
281 extractGridPropertyValue_(maxKrow, epsProperties.
kro, cartesianCellIdx);
282 extractGridPropertyValue_(maxKrog, epsProperties.
kro, cartesianCellIdx);
287 void extractUnscaledSgof_(
const Opm::SgofTable& sgofTable)
290 Sgl = sgofTable.getSgColumn().front();
291 Sogl = 1.0 - sgofTable.getSgColumn().back();
294 Sgu = sgofTable.getSgColumn().back();
295 Sogu = 1.0 - sgofTable.getSgColumn().front();
298 for (
unsigned rowIdx = 0; rowIdx < sgofTable.numRows(); ++ rowIdx) {
299 if (sgofTable.getKrgColumn()[rowIdx] > 0) {
301 Sgcr = sgofTable.getSgColumn()[rowIdx - 1];
307 for (
int rowIdx = static_cast<int>(sgofTable.numRows()) - 1; rowIdx >= 0; -- rowIdx) {
308 if (sgofTable.getKrogColumn()[
static_cast<size_t>(rowIdx)] > 0) {
309 assert(rowIdx < static_cast<int>(sgofTable.numRows()) - 1);
310 Sogcr = 1.0 - sgofTable.getSgColumn()[
static_cast<unsigned>(rowIdx) + 1];
316 maxPcgo = sgofTable.getPcogColumn().back();
319 maxKrg = sgofTable.getKrgColumn().back();
320 maxKrog = sgofTable.getKrogColumn().front();
323 void extractUnscaledSlgof_(
const Opm::SlgofTable& slgofTable)
326 Sgl = 1.0 - slgofTable.getSlColumn().back();
327 Sogl = slgofTable.getSlColumn().front();
332 Sgu = 1.0 - slgofTable.getSlColumn().front();
333 Sogu = slgofTable.getSlColumn().back();
336 for (
int rowIdx = static_cast<int>(slgofTable.numRows()) - 1; rowIdx >= 0; -- rowIdx) {
337 if (slgofTable.getKrgColumn()[
static_cast<size_t>(rowIdx)] > 0) {
338 assert(rowIdx < static_cast<int>(slgofTable.numRows()) - 1);
339 Sgcr = 1 - slgofTable.getSlColumn()[
static_cast<unsigned>(rowIdx) + 1];
345 for (
size_t rowIdx = 0; rowIdx < slgofTable.numRows(); ++ rowIdx) {
346 if (slgofTable.getKrogColumn()[rowIdx] > 0) {
348 Sogcr = slgofTable.getSlColumn()[rowIdx - 1];
354 maxPcgo = slgofTable.getPcogColumn().front();
357 maxKrg = slgofTable.getKrgColumn().front();
358 maxKrog = slgofTable.getKrogColumn().back();
361 void extractUnscaledSwof_(
const Opm::SwofTable& swofTable)
364 Swl = swofTable.getSwColumn().front();
365 Sowl = 1.0 - swofTable.getSwColumn().back();
368 Swu = swofTable.getSwColumn().back();
369 Sowu = 1.0 - swofTable.getSwColumn().front();
372 for (
size_t rowIdx = 0; rowIdx < swofTable.numRows(); ++ rowIdx) {
373 if (swofTable.getKrwColumn()[rowIdx] > 0) {
375 Swcr = swofTable.getSwColumn()[rowIdx - 1];
381 for (
int rowIdx = static_cast<int>(swofTable.numRows()) - 1; rowIdx >= 0; -- rowIdx) {
382 if (swofTable.getKrowColumn()[
static_cast<size_t>(rowIdx)] > 0) {
383 assert(rowIdx < static_cast<int>(swofTable.numRows()) - 1);
384 Sowcr = 1.0 - swofTable.getSwColumn()[
static_cast<unsigned>(rowIdx) + 1];
390 maxPcow = swofTable.getPcowColumn().front();
393 maxKrw = swofTable.getKrwColumn().back();
394 maxKrow = swofTable.getKrowColumn().front();
397 void extractUnscaledSwfn_(
const Opm::SwfnTable& swfnTable)
400 Swl = swfnTable.getSwColumn().front();
403 Swu = swfnTable.getSwColumn().back();
406 for (
unsigned rowIdx = 0; rowIdx < swfnTable.numRows(); ++ rowIdx) {
407 if (swfnTable.getKrwColumn()[rowIdx] > 0) {
409 Swcr = swfnTable.getSwColumn()[rowIdx - 1];
415 maxPcow = swfnTable.getPcowColumn().front();
418 maxKrw = swfnTable.getKrwColumn().back();
421 void extractUnscaledSgfn_(
const Opm::SgfnTable& sgfnTable)
424 Sgl = sgfnTable.getSgColumn().front();
427 Sgu = sgfnTable.getSgColumn().back();
428 Sogu = 1 - sgfnTable.getSgColumn().front();
431 for (
unsigned rowIdx = 0; rowIdx < sgfnTable.numRows(); ++ rowIdx) {
432 if (sgfnTable.getKrgColumn()[rowIdx] > 0) {
434 Sgcr = sgfnTable.getSgColumn()[rowIdx - 1];
440 maxPcgo = sgfnTable.getPcogColumn().back();
443 maxKrg = sgfnTable.getKrgColumn().back();
446 void extractUnscaledSof3_(
const Opm::Sof3Table& sof3Table)
449 Sowl = sof3Table.getSoColumn().front() +
Sgl;
450 Sogl = sof3Table.getSoColumn().front() +
Swl;
453 Sowu = sof3Table.getSoColumn().back();
456 for (
size_t rowIdx = 0 ; rowIdx < sof3Table.numRows(); ++ rowIdx) {
457 if (sof3Table.getKrowColumn()[rowIdx] > 0) {
459 Sowcr = sof3Table.getSoColumn()[rowIdx - 1];
465 for (
size_t rowIdx = 0 ; rowIdx < sof3Table.numRows(); ++ rowIdx) {
466 if (sof3Table.getKrogColumn()[rowIdx] > 0) {
468 Sogcr = sof3Table.getSoColumn()[rowIdx - 1];
474 maxKrow = sof3Table.getKrowColumn().back();
475 maxKrog = sof3Table.getKrogColumn().back();
477 #endif // HAVE_OPM_PARSER
479 void extractGridPropertyValue_(Scalar& targetValue,
480 const std::vector<double>* propData,
481 unsigned cartesianCellIdx)
486 targetValue = (*propData)[cartesianCellIdx];
496 template <
class Scalar>
509 saturationPcPoints_[0] = epsInfo.
Swl;
510 saturationPcPoints_[1] = epsInfo.
Swu;
514 saturationKrwPoints_[0] = epsInfo.
Swcr;
515 saturationKrwPoints_[1] = 1.0 - epsInfo.
Sowcr - epsInfo.
Sgl;
516 saturationKrwPoints_[2] = epsInfo.
Swu;
519 saturationKrwPoints_[0] = epsInfo.
Swcr;
520 saturationKrwPoints_[1] = epsInfo.
Swu;
528 saturationKrnPoints_[2] = 1.0 - epsInfo.
Sowcr;
529 saturationKrnPoints_[1] = epsInfo.
Swcr + epsInfo.
Sgl;
530 saturationKrnPoints_[0] = epsInfo.
Swl + epsInfo.
Sgl;
533 saturationKrnPoints_[1] = 1 - epsInfo.
Sowcr;
534 saturationKrnPoints_[0] = epsInfo.
Swl + epsInfo.
Sgl;
545 saturationPcPoints_[0] = 1.0 - epsInfo.
Sgu;
546 saturationPcPoints_[1] = 1.0 - epsInfo.
Sgl;
550 saturationKrwPoints_[0] = epsInfo.
Sogcr;
551 saturationKrwPoints_[1] = 1 - epsInfo.
Sgcr - epsInfo.
Swl;
552 saturationKrwPoints_[2] = 1 - epsInfo.
Swl - epsInfo.
Sgl;
555 saturationKrwPoints_[0] = epsInfo.
Sogcr;
556 saturationKrwPoints_[1] = 1 - epsInfo.
Swl - epsInfo.
Sgl;
564 saturationKrnPoints_[2] = 1.0 - epsInfo.
Sgcr;
565 saturationKrnPoints_[1] = epsInfo.
Sogcr + epsInfo.
Swl;
566 saturationKrnPoints_[0] = 1.0 - epsInfo.
Sgu;
569 saturationKrnPoints_[1] = 1.0 - epsInfo.
Sgcr;
570 saturationKrnPoints_[0] = 1.0 - epsInfo.
Sgu;
583 { saturationPcPoints_[pointIdx] = value; }
589 {
return saturationPcPoints_; }
595 { saturationKrwPoints_[pointIdx] = value; }
601 {
return saturationKrwPoints_; }
607 { saturationKrnPoints_[pointIdx] = value; }
613 {
return saturationKrnPoints_; }
619 { maxPcnw_ = value; }
653 std::cout <<
" saturationKrnPoints_[0]: " << saturationKrnPoints_[0] <<
"\n"
654 <<
" saturationKrnPoints_[1]: " << saturationKrnPoints_[1] <<
"\n"
655 <<
" saturationKrnPoints_[2]: " << saturationKrnPoints_[2] <<
"\n";
669 std::array<Scalar, 2> saturationPcPoints_;
672 std::array<Scalar, 3> saturationKrwPoints_;
675 std::array<Scalar, 3> saturationKrnPoints_;
Scalar Sowl
Definition: EclEpsScalingPoints.hpp:127
void init(const EclEpsScalingPointsInfo< Scalar > &epsInfo, const EclEpsConfig &config, EclTwoPhaseSystemType epsSystemType)
Assigns the scaling points which actually ought to be used.
Definition: EclEpsScalingPoints.hpp:503
void setSaturationPcPoint(unsigned pointIdx, Scalar value)
Sets an saturation value for capillary pressure saturation scaling.
Definition: EclEpsScalingPoints.hpp:582
void setMaxKrw(Scalar value)
Sets the maximum wetting phase relative permeability.
Definition: EclEpsScalingPoints.hpp:630
Scalar Sgcr
Definition: EclEpsScalingPoints.hpp:132
EclTwoPhaseSystemType
Specified which fluids are involved in a given twophase material law for endpoint scaling...
Definition: EclEpsConfig.hpp:42
const DoubleData * sogcr
Definition: EclEpsScalingPoints.hpp:90
void setMaxPcnw(Scalar value)
Sets the maximum capillary pressure.
Definition: EclEpsScalingPoints.hpp:618
const DoubleData * swu
Definition: EclEpsScalingPoints.hpp:91
Scalar maxKrw() const
Returns the maximum wetting phase relative permeability.
Definition: EclEpsScalingPoints.hpp:636
const IntData * satnum
Definition: EclEpsScalingPoints.hpp:83
Definition: Air_Mesitylene.hpp:31
const DoubleData * sgl
Definition: EclEpsScalingPoints.hpp:86
Collects all grid properties which are relevant for end point scaling.
Definition: EclEpsScalingPoints.hpp:49
Scalar Sgu
Definition: EclEpsScalingPoints.hpp:138
Scalar Sogl
Definition: EclEpsScalingPoints.hpp:128
const DoubleData * krw
Definition: EclEpsScalingPoints.hpp:95
Scalar Swl
Definition: EclEpsScalingPoints.hpp:125
Represents the points on the X and Y axis to be scaled if endpoint scaling is used.
Definition: EclEpsScalingPoints.hpp:497
Scalar maxKrw
Definition: EclEpsScalingPoints.hpp:147
const DoubleData * kro
Definition: EclEpsScalingPoints.hpp:96
Scalar maxPcgo
Definition: EclEpsScalingPoints.hpp:144
const DoubleData * swl
Definition: EclEpsScalingPoints.hpp:85
const std::array< Scalar, 2 > & saturationPcPoints() const
Returns the points used for capillary pressure saturation scaling.
Definition: EclEpsScalingPoints.hpp:588
Scalar maxPcow
Definition: EclEpsScalingPoints.hpp:143
Scalar maxKrow
Definition: EclEpsScalingPoints.hpp:148
Scalar maxKrog
Definition: EclEpsScalingPoints.hpp:149
const DoubleData * sowcr
Definition: EclEpsScalingPoints.hpp:89
This structure represents all values which can be possibly used as scaling points in the endpoint sca...
Definition: EclEpsScalingPoints.hpp:122
Scalar maxKrg
Definition: EclEpsScalingPoints.hpp:150
Scalar Sowcr
Definition: EclEpsScalingPoints.hpp:133
void print() const
Definition: EclEpsScalingPoints.hpp:651
Scalar maxPcnw() const
Returns the maximum capillary pressure.
Definition: EclEpsScalingPoints.hpp:624
Scalar Swcr
Definition: EclEpsScalingPoints.hpp:131
Scalar Sogcr
Definition: EclEpsScalingPoints.hpp:134
const DoubleData * pcw
Definition: EclEpsScalingPoints.hpp:93
Evaluation< Scalar, VarSetTag, numVars > abs(const Evaluation< Scalar, VarSetTag, numVars > &)
Definition: Math.hpp:41
Definition: EclEpsConfig.hpp:44
void setSaturationKrnPoint(unsigned pointIdx, Scalar value)
Sets an saturation value for non-wetting phase relperm saturation scaling.
Definition: EclEpsScalingPoints.hpp:606
const DoubleData * sgu
Definition: EclEpsScalingPoints.hpp:92
bool enableThreePointKrSatScaling() const
Returns whether three point saturation scaling is enabled for the relative permeabilities.
Definition: EclEpsConfig.hpp:90
void setSaturationKrwPoint(unsigned pointIdx, Scalar value)
Sets an saturation value for wetting-phase relperm saturation scaling.
Definition: EclEpsScalingPoints.hpp:594
const std::array< Scalar, 3 > & saturationKrnPoints() const
Returns the points used for non-wetting phase relperm saturation scaling.
Definition: EclEpsScalingPoints.hpp:612
const DoubleData * pcg
Definition: EclEpsScalingPoints.hpp:94
Scalar Sowu
Definition: EclEpsScalingPoints.hpp:139
Specifies the configuration used by the endpoint scaling code.
Definition: EclEpsConfig.hpp:54
Scalar maxKrn() const
Returns the maximum wetting phase relative permeability.
Definition: EclEpsScalingPoints.hpp:648
const DoubleData * swcr
Definition: EclEpsScalingPoints.hpp:87
void setMaxKrn(Scalar value)
Sets the maximum wetting phase relative permeability.
Definition: EclEpsScalingPoints.hpp:642
Scalar Sogu
Definition: EclEpsScalingPoints.hpp:140
Specifies the configuration used by the endpoint scaling code.
const DoubleData * krg
Definition: EclEpsScalingPoints.hpp:97
Scalar Swu
Definition: EclEpsScalingPoints.hpp:137
Definition: EclEpsConfig.hpp:43
void extractScaled(const EclEpsGridProperties &epsProperties, unsigned cartesianCellIdx)
Extract the values of the scaled scaling parameters.
Definition: EclEpsScalingPoints.hpp:261
const DoubleData * sgcr
Definition: EclEpsScalingPoints.hpp:88
void print() const
Definition: EclEpsScalingPoints.hpp:152
const std::array< Scalar, 3 > & saturationKrwPoints() const
Returns the points used for wetting phase relperm saturation scaling.
Definition: EclEpsScalingPoints.hpp:600
Scalar Sgl
Definition: EclEpsScalingPoints.hpp:126