-- added bool return value of hysteresis update.

-- this make it possible to localy update intensive quanities if something changed.
This commit is contained in:
hnil
2023-03-29 09:24:01 +02:00
parent dd34926062
commit d0422bfc74
7 changed files with 40 additions and 34 deletions

View File

@@ -421,8 +421,9 @@ public:
* error. (But not calling it will still work.)
*/
template <class FluidState>
static void updateHysteresis(Params& params, const FluidState& fluidState)
static bool updateHysteresis(Params& params, const FluidState& fluidState)
{
bool changed = false;
const Scalar Swco = params.Swl();
const Scalar Sw = clampSaturation(fluidState, waterPhaseIdx);
@@ -439,11 +440,11 @@ public:
//
// Though be aware that from a physical perspective this is definitively
// incorrect!
params.oilWaterParams().update(/*pcSw=*/ Sw, //1.0 - So, (Effect is significant vs benchmark.)
changed = changed || params.oilWaterParams().update(/*pcSw=*/ Sw, //1.0 - So, (Effect is significant vs benchmark.)
/*krwSw=*/ 1.0 - So,
/*krnSw=*/ 1.0 - So);
params.gasOilParams().update(/*pcSw=*/ 1.0 - Swco - Sg,
changed = changed || params.gasOilParams().update(/*pcSw=*/ 1.0 - Swco - Sg,
/*krwSw=*/ 1.0 - Swco - Sg,
/*krnSw=*/ 1.0 - Swco - Sg);
}
@@ -451,14 +452,15 @@ public:
const Scalar Sw_ow = Sg + std::max(Swco, Sw);
const Scalar So_go = 1.0 - Sw_ow;
params.oilWaterParams().update(/*pcSw=*/ Sw,
changed = changed || params.oilWaterParams().update(/*pcSw=*/ Sw,
/*krwSw=*/ 1 - Sg,
/*krnSw=*/ Sw_ow);
params.gasOilParams().update(/*pcSw=*/ 1.0 - Swco - Sg,
/*krwSw=*/ So_go,
/*krnSw=*/ 1.0 - Swco - Sg);
changed = changed || params.gasOilParams().update(/*pcSw=*/ 1.0 - Swco - Sg,
/*krwSw=*/ So_go,
/*krnSw=*/ 1.0 - Swco - Sg);
}
return changed;
}
template <class FluidState>

View File

@@ -374,7 +374,7 @@ public:
* This updates the scanning curves and the imbibition<->drainage reversal points as
* appropriate.
*/
void update(Scalar pcSw, Scalar /* krwSw */, Scalar krnSw)
bool update(Scalar pcSw, Scalar /* krwSw */, Scalar krnSw)
{
bool updateParams = false;
@@ -412,6 +412,8 @@ public:
if (updateParams)
updateDynamicParams_();
return updateParams;
}
template<class Serializer>

View File

@@ -314,20 +314,20 @@ public:
{ return imbnumRegionArray_[elemIdx]; }
template <class FluidState>
void updateHysteresis(const FluidState& fluidState, unsigned elemIdx)
bool updateHysteresis(const FluidState& fluidState, unsigned elemIdx)
{
if (!enableHysteresis())
return;
MaterialLaw::updateHysteresis(materialLawParams(elemIdx), fluidState);
return false;
bool changed = MaterialLaw::updateHysteresis(materialLawParams(elemIdx), fluidState);
if (hasDirectionalRelperms() || hasDirectionalImbnum()) {
using Dir = FaceDir::DirEnum;
constexpr int ndim = 3;
Dir facedirs[ndim] = {Dir::XPlus, Dir::YPlus, Dir::ZPlus};
for (int i = 0; i<ndim; i++) {
MaterialLaw::updateHysteresis(materialLawParams(elemIdx, facedirs[i]), fluidState);
changed = changed || MaterialLaw::updateHysteresis(materialLawParams(elemIdx, facedirs[i]), fluidState);
}
}
return changed;
}
void oilWaterHysteresisParams(Scalar& pcSwMdc,

View File

@@ -565,29 +565,30 @@ public:
* error. (But not calling it will still work.)
*/
template <class FluidState>
static void updateHysteresis(Params& params, const FluidState& fluidState)
static bool updateHysteresis(Params& params, const FluidState& fluidState)
{
switch (params.approach()) {
case EclMultiplexerApproach::Stone1:
Stone1Material::updateHysteresis(params.template getRealParams<EclMultiplexerApproach::Stone1>(),
return Stone1Material::updateHysteresis(params.template getRealParams<EclMultiplexerApproach::Stone1>(),
fluidState);
break;
case EclMultiplexerApproach::Stone2:
Stone2Material::updateHysteresis(params.template getRealParams<EclMultiplexerApproach::Stone2>(),
return Stone2Material::updateHysteresis(params.template getRealParams<EclMultiplexerApproach::Stone2>(),
fluidState);
break;
case EclMultiplexerApproach::Default:
DefaultMaterial::updateHysteresis(params.template getRealParams<EclMultiplexerApproach::Default>(),
return DefaultMaterial::updateHysteresis(params.template getRealParams<EclMultiplexerApproach::Default>(),
fluidState);
break;
case EclMultiplexerApproach::TwoPhase:
TwoPhaseMaterial::updateHysteresis(params.template getRealParams<EclMultiplexerApproach::TwoPhase>(),
return TwoPhaseMaterial::updateHysteresis(params.template getRealParams<EclMultiplexerApproach::TwoPhase>(),
fluidState);
break;
case EclMultiplexerApproach::OnePhase:
return false;
break;
}
}

View File

@@ -417,16 +417,17 @@ public:
* error. (But not calling it will still work.)
*/
template <class FluidState>
static void updateHysteresis(Params& params, const FluidState& fluidState)
static bool updateHysteresis(Params& params, const FluidState& fluidState)
{
const Scalar Swco = params.Swl();
const Scalar Sw = scalarValue(fluidState.saturation(waterPhaseIdx));
const Scalar Sg = scalarValue(fluidState.saturation(gasPhaseIdx));
params.oilWaterParams().update(/*pcSw=*/Sw, /*krwSw=*/Sw, /*krnSw=*/Sw);
params.gasOilParams().update(/*pcSw=*/ 1.0 - Swco - Sg,
/*krwSw=*/ 1.0 - Swco - Sg,
/*krnSw=*/ 1.0 - Swco - Sg);
bool changed = false;
changed = changed || params.oilWaterParams().update(/*pcSw=*/Sw, /*krwSw=*/Sw, /*krnSw=*/Sw);
changed = changed || params.gasOilParams().update(/*pcSw=*/ 1.0 - Swco - Sg,
/*krwSw=*/ 1.0 - Swco - Sg,
/*krnSw=*/ 1.0 - Swco - Sg);
return changed;
}
};

View File

@@ -401,16 +401,16 @@ public:
* error. (But not calling it will still work.)
*/
template <class FluidState>
static void updateHysteresis(Params& params, const FluidState& fluidState)
static bool updateHysteresis(Params& params, const FluidState& fluidState)
{
const Scalar Swco = params.Swl();
const Scalar Sw = scalarValue(fluidState.saturation(waterPhaseIdx));
const Scalar Sg = scalarValue(fluidState.saturation(gasPhaseIdx));
params.oilWaterParams().update(/*pcSw=*/Sw, /*krwSw=*/Sw, /*krnSw=*/Sw);
params.gasOilParams().update(/*pcSw=*/ 1.0 - Swco - Sg,
/*krwSw=*/ 1.0 - Swco - Sg,
/*krnSw=*/ 1.0 - Swco - Sg);
bool changed = false;
changed = changed || params.oilWaterParams().update(/*pcSw=*/Sw, /*krwSw=*/Sw, /*krnSw=*/Sw);
changed = changed || params.gasOilParams().update(/*pcSw=*/ 1.0 - Swco - Sg,
/*krwSw=*/ 1.0 - Swco - Sg,
/*krnSw=*/ 1.0 - Swco - Sg);
}
};

View File

@@ -390,27 +390,27 @@ public:
* error. (But not calling it will still work.)
*/
template <class FluidState>
static void updateHysteresis(Params& params, const FluidState& fluidState)
static bool updateHysteresis(Params& params, const FluidState& fluidState)
{
switch (params.approach()) {
case EclTwoPhaseApproach::GasOil: {
Scalar So = scalarValue(fluidState.saturation(oilPhaseIdx));
params.gasOilParams().update(/*pcSw=*/So, /*krwSw=*/So, /*krnSw=*/So);
return params.gasOilParams().update(/*pcSw=*/So, /*krwSw=*/So, /*krnSw=*/So);
break;
}
case EclTwoPhaseApproach::OilWater: {
Scalar Sw = scalarValue(fluidState.saturation(waterPhaseIdx));
params.oilWaterParams().update(/*pcSw=*/Sw, /*krwSw=*/Sw, /*krnSw=*/Sw);
return params.oilWaterParams().update(/*pcSw=*/Sw, /*krwSw=*/Sw, /*krnSw=*/Sw);
break;
}
case EclTwoPhaseApproach::GasWater: {
Scalar Sw = scalarValue(fluidState.saturation(waterPhaseIdx));
params.gasWaterParams().update(/*pcSw=*/1.0, /*krwSw=*/0.0, /*krnSw=*/Sw);
return params.gasWaterParams().update(/*pcSw=*/1.0, /*krwSw=*/0.0, /*krnSw=*/Sw);
break;
}
}