Skip to content

Commit b3b0a1d

Browse files
author
Tor Harald Sandve
committed
Fixes to the special case with almost only water
For the almost only water case the primary variables are p, sg and sw. 1) Use sw>=1-1e-6 as threshold for defining almost only water 2) Add sg to sw if sg<0 to make the oil saturation concistent even though sg is set to zero 3) Chop the water saturation at 1.01 and not 1.0 in order to improve convergence 4) Restrict update of rs/rv and rsw/rvw by the saturation scaling factor from the Appleyard-chopping.
1 parent 7b35226 commit b3b0a1d

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

opm/models/blackoil/blackoilnewtonmethod.hh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,11 @@ protected:
307307
else if (pvIdx == Indices::waterSwitchIdx)
308308
if (currentValue.primaryVarsMeaningWater() == PrimaryVariables::WaterMeaning::Sw)
309309
delta *= satAlpha;
310+
310311
else {
312+
// The damping from the saturation change also applies to the rsw/rvw factors
313+
// for consistency
314+
delta *= satAlpha;
311315
//Ensure Rvw and Rsw factor does not become negative
312316
if (delta > currentValue[ Indices::waterSwitchIdx])
313317
delta = currentValue[ Indices::waterSwitchIdx];
@@ -321,6 +325,9 @@ protected:
321325
if (currentValue.primaryVarsMeaningGas() == PrimaryVariables::GasMeaning::Sg)
322326
delta *= satAlpha;
323327
else {
328+
// The damping from the saturation change also applies to the rs/rv factors
329+
// for consistency
330+
delta *= satAlpha;
324331
//Ensure Rv and Rs factor does not become negative
325332
if (delta > currentValue[Indices::compositionSwitchIdx])
326333
delta = currentValue[Indices::compositionSwitchIdx];

opm/models/blackoil/blackoilprimaryvariables.hh

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,6 @@ public:
495495
*/
496496
bool adaptPrimaryVariables(const Problem& problem, unsigned globalDofIdx, 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
@@ -548,25 +546,33 @@ public:
548546

549547
// special case cells with almost only water
550548
// use both saturations (if the phase is enabled)
549+
// to avoid a singular matrix.
550+
// almost is defined as sw >= 1.0-1e-6.
551+
static const Scalar thresholdWaterFilledCell = 1.0 - 1e-6;
552+
551553
// if dissolved gas in water is enabled we shouldn't enter
552554
// here but instead switch to Rsw as primary variable
553-
// as sw >= 1.0 -> gas <= 0 (i.e. gas phase disappears)
554-
if (sw >= thresholdWaterFilledCell && !FluidSystem::enableDissolvedGasInWater()) {
555-
556-
// make sure water saturations does not exceed 1.0
555+
// as sw >= 1.0 -> sg <= 0 (i.e. gas phase disappears)
556+
if ((sw - std::min(sg, 0.0)) >= thresholdWaterFilledCell && !FluidSystem::enableDissolvedGasInWater()) {
557+
// make sure water saturations does not exceed 1.01
558+
// we dont stricly force it to 1.0 to avoid convergence issue.
559+
// note that for sg < 0 we add the "negative" saturation of the gas to the water
560+
// phase. Since So = 1 - sg - sw. This will give the correct oil saturation.
561+
// even though the gas saturation is set to zero below.
557562
if constexpr (waterEnabled) {
558-
(*this)[Indices::waterSwitchIdx] = 1.0;
563+
(*this)[Indices::waterSwitchIdx] = std::min(1.01, sw - std::min(sg, 0.0));
559564
assert(primaryVarsMeaningWater() == WaterMeaning::Sw);
560565
}
566+
561567
// the hydrocarbon gas saturation is set to 0.0
562568
if constexpr (compositionSwitchEnabled)
563569
(*this)[Indices::compositionSwitchIdx] = 0.0;
564570

565571
changed = primaryVarsMeaningGas() != GasMeaning::Sg;
566572
if(changed) {
567-
if constexpr (compositionSwitchEnabled)
573+
if constexpr (compositionSwitchEnabled) {
568574
setPrimaryVarsMeaningGas(GasMeaning::Sg);
569-
575+
}
570576
// use water pressure?
571577
}
572578
return changed;

0 commit comments

Comments
 (0)