Skip to content

Commit

Permalink
Fixes to the special case with almost only water
Browse files Browse the repository at this point in the history
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) Chop the water saturation at 1.01 and not 1.0 in order to improve convergence
3) Restrict update of rs/rv, rsw/rvw and zfraction in the extended blackoil model by the saturation scaling factor from the Appleyard-chopping.
  • Loading branch information
Tor Harald Sandve committed May 24, 2023
1 parent 48e41b2 commit 36a0976
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
8 changes: 8 additions & 0 deletions opm/models/blackoil/blackoilnewtonmethod.hh
Expand Up @@ -307,7 +307,11 @@ protected:
else if (pvIdx == Indices::waterSwitchIdx)
if (currentValue.primaryVarsMeaningWater() == PrimaryVariables::WaterMeaning::Sw)
delta *= satAlpha;

else {
// The damping from the saturation change also applies to the rsw/rvw factors
// for consistency
delta *= satAlpha;
//Ensure Rvw and Rsw factor does not become negative
if (delta > currentValue[ Indices::waterSwitchIdx])
delta = currentValue[ Indices::waterSwitchIdx];
Expand All @@ -321,6 +325,9 @@ protected:
if (currentValue.primaryVarsMeaningGas() == PrimaryVariables::GasMeaning::Sg)
delta *= satAlpha;
else {
// The damping from the saturation change also applies to the rs/rv factors
// for consistency
delta *= satAlpha;
//Ensure Rv and Rs factor does not become negative
if (delta > currentValue[Indices::compositionSwitchIdx])
delta = currentValue[Indices::compositionSwitchIdx];
Expand All @@ -330,6 +337,7 @@ protected:
// solvent saturation updates are also subject to the Appleyard chop
delta *= satAlpha;
else if (enableExtbo && pvIdx == Indices::zFractionIdx) {
delta *= satAlpha;
// z fraction updates are also subject to the Appleyard chop
if (delta > currentValue[Indices::zFractionIdx])
delta = currentValue[Indices::zFractionIdx];
Expand Down
19 changes: 11 additions & 8 deletions opm/models/blackoil/blackoilprimaryvariables.hh
Expand Up @@ -495,8 +495,6 @@ public:
*/
bool adaptPrimaryVariables(const Problem& problem, unsigned globalDofIdx, Scalar eps = 0.0)
{
static const Scalar thresholdWaterFilledCell = 1.0 - eps;

// this function accesses quite a few black-oil specific low-level functions
// directly for better performance (instead of going the canonical way through
// the IntensiveQuantities). The reason is that most intensive quantities are not
Expand Down Expand Up @@ -548,25 +546,30 @@ public:

// special case cells with almost only water
// use both saturations (if the phase is enabled)
// to avoid a singular matrix.
// almost is defined as sw >= 1.0-1e-6.
static const Scalar thresholdWaterFilledCell = 1.0 - 1e-6;

// if dissolved gas in water is enabled we shouldn't enter
// here but instead switch to Rsw as primary variable
// as sw >= 1.0 -> gas <= 0 (i.e. gas phase disappears)
// as sw >= 1.0 -> sg <= 0 (i.e. gas phase disappears)
if (sw >= thresholdWaterFilledCell && !FluidSystem::enableDissolvedGasInWater()) {

// make sure water saturations does not exceed 1.0
// make sure water saturations does not exceed 1.01
// we dont stricly force it to 1.0 to avoid convergence issue.
if constexpr (waterEnabled) {
(*this)[Indices::waterSwitchIdx] = 1.0;
(*this)[Indices::waterSwitchIdx] = std::min(1.01, sw);
assert(primaryVarsMeaningWater() == WaterMeaning::Sw);
}

// the hydrocarbon gas saturation is set to 0.0
if constexpr (compositionSwitchEnabled)
(*this)[Indices::compositionSwitchIdx] = 0.0;

changed = primaryVarsMeaningGas() != GasMeaning::Sg;
if(changed) {
if constexpr (compositionSwitchEnabled)
if constexpr (compositionSwitchEnabled) {
setPrimaryVarsMeaningGas(GasMeaning::Sg);

}
// use water pressure?
}
return changed;
Expand Down

0 comments on commit 36a0976

Please sign in to comment.