Skip to content

Commit b86c865

Browse files
author
Tor Harald Sandve
committed
add parameter to set threshold for only water cells. Default is 1.0
1 parent 0b4cf21 commit b86c865

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

opm/models/blackoil/blackoilnewtonmethod.hh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ template<class TypeTag, class MyTypeTag>
5757
struct TemperatureMin { using type = UndefinedProperty; };
5858
template<class TypeTag, class MyTypeTag>
5959
struct MaximumWaterSaturation { using type = UndefinedProperty; };
60+
template<class TypeTag, class MyTypeTag>
61+
struct WaterOnlyThreshold { using type = UndefinedProperty; };
6062
template<class TypeTag>
6163
struct DpMaxRel<TypeTag, TTag::NewtonMethod>
6264
{
@@ -101,6 +103,12 @@ struct MaximumWaterSaturation<TypeTag, TTag::NewtonMethod>
101103
using type = GetPropType<TypeTag, Scalar>;
102104
static constexpr type value = 1.0;
103105
};
106+
template<class TypeTag>
107+
struct WaterOnlyThreshold<TypeTag, TTag::NewtonMethod>
108+
{
109+
using type = GetPropType<TypeTag, Scalar>;
110+
static constexpr type value = 1.0;
111+
};
104112
} // namespace Opm::Properties
105113

106114
namespace Opm {
@@ -139,6 +147,7 @@ public:
139147
tempMax_ = EWOMS_GET_PARAM(TypeTag, Scalar, TemperatureMax);
140148
tempMin_ = EWOMS_GET_PARAM(TypeTag, Scalar, TemperatureMin);
141149
waterSaturationMax_ = EWOMS_GET_PARAM(TypeTag, Scalar, MaximumWaterSaturation);
150+
waterOnlyThreshold_ = EWOMS_GET_PARAM(TypeTag, Scalar, WaterOnlyThreshold);
142151
}
143152

144153
/*!
@@ -168,6 +177,7 @@ public:
168177
EWOMS_REGISTER_PARAM(TypeTag, Scalar, TemperatureMax, "Maximum absolute temperature");
169178
EWOMS_REGISTER_PARAM(TypeTag, Scalar, TemperatureMin, "Minimum absolute temperature");
170179
EWOMS_REGISTER_PARAM(TypeTag, Scalar, MaximumWaterSaturation, "Maximum water saturation");
180+
EWOMS_REGISTER_PARAM(TypeTag, Scalar, WaterOnlyThreshold, "Cells with water saturation above or equal is considered one-phase water only");
171181
}
172182

173183
/*!
@@ -458,9 +468,9 @@ protected:
458468
// use a threshold value after a switch to make it harder to switch back
459469
// immediately.
460470
if (wasSwitched_[globalDofIdx])
461-
wasSwitched_[globalDofIdx] = nextValue.adaptPrimaryVariables(this->problem(), globalDofIdx, waterSaturationMax_, priVarOscilationThreshold_);
471+
wasSwitched_[globalDofIdx] = nextValue.adaptPrimaryVariables(this->problem(), globalDofIdx, waterSaturationMax_, waterOnlyThreshold_, priVarOscilationThreshold_);
462472
else
463-
wasSwitched_[globalDofIdx] = nextValue.adaptPrimaryVariables(this->problem(), globalDofIdx, waterSaturationMax_);
473+
wasSwitched_[globalDofIdx] = nextValue.adaptPrimaryVariables(this->problem(), globalDofIdx, waterSaturationMax_, waterOnlyThreshold_);
464474

465475
if (wasSwitched_[globalDofIdx])
466476
++ numPriVarsSwitched_;
@@ -476,6 +486,8 @@ private:
476486

477487
Scalar priVarOscilationThreshold_;
478488
Scalar waterSaturationMax_;
489+
Scalar waterOnlyThreshold_;
490+
479491
Scalar dpMaxRel_;
480492
Scalar dsMax_;
481493
bool projectSaturations_;

opm/models/blackoil/blackoilprimaryvariables.hh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -493,10 +493,8 @@ public:
493493
*
494494
* \return true Iff the interpretation of one of the switching variables was changed
495495
*/
496-
bool adaptPrimaryVariables(const Problem& problem, unsigned globalDofIdx, Scalar swMaximum, Scalar eps = 0.0)
496+
bool adaptPrimaryVariables(const Problem& problem, unsigned globalDofIdx, Scalar swMaximum, Scalar thresholdWaterFilledCell, Scalar eps = 0.0)
497497
{
498-
static const Scalar thresholdWaterFilledCell = 1.0 - eps;
499-
500498
// this function accesses quite a few black-oil specific low-level functions
501499
// directly for better performance (instead of going the canonical way through
502500
// the IntensiveQuantities). The reason is that most intensive quantities are not
@@ -546,8 +544,11 @@ public:
546544
// keep track if any meaning has changed
547545
bool changed = false;
548546

549-
// special case cells with almost only water
550-
// use both saturations (if the phase is enabled)
547+
// special case for cells with almost only water
548+
thresholdWaterFilledCell = std::min(thresholdWaterFilledCell, 1.0 - eps);
549+
// for these cells both saturations (if the phase is enabled) is used
550+
// to avoid singular systems
551+
551552
// if dissolved gas in water is enabled we shouldn't enter
552553
// here but instead switch to Rsw as primary variable
553554
// as sw >= 1.0 -> gas <= 0 (i.e. gas phase disappears)

0 commit comments

Comments
 (0)