move wellVolumeFraction to StandardWellPrimaryVariables

This commit is contained in:
Arne Morten Kvarving 2022-11-08 07:09:51 +01:00
parent 93a151f6e1
commit d6a6671eb0
4 changed files with 57 additions and 55 deletions

View File

@ -116,57 +116,6 @@ relaxationFactorFractionsProducer(const std::vector<double>& primary_variables,
return relaxation_factor;
}
template<class FluidSystem, class Indices, class Scalar>
typename StandardWellEval<FluidSystem,Indices,Scalar>::EvalWell
StandardWellEval<FluidSystem,Indices,Scalar>::
wellVolumeFraction(const unsigned compIdx) const
{
if (FluidSystem::numActivePhases() == 1) {
return EvalWell(primary_variables_.numWellEq() + Indices::numEq, 1.0);
}
if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) {
if (has_wfrac_variable && compIdx == Indices::canonicalToActiveComponentIndex(FluidSystem::waterCompIdx)) {
return primary_variables_.evaluation_[WFrac];
}
if (has_gfrac_variable && compIdx == Indices::canonicalToActiveComponentIndex(FluidSystem::gasCompIdx)) {
return primary_variables_.evaluation_[GFrac];
}
if (Indices::enableSolvent && compIdx == (unsigned)Indices::contiSolventEqIdx) {
return primary_variables_.evaluation_[SFrac];
}
}
else if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) {
if (has_gfrac_variable && compIdx == Indices::canonicalToActiveComponentIndex(FluidSystem::gasCompIdx)) {
return primary_variables_.evaluation_[GFrac];
}
}
// Oil or WATER fraction
EvalWell well_fraction(primary_variables_.numWellEq() + Indices::numEq, 1.0);
if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) {
if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) {
well_fraction -= primary_variables_.evaluation_[WFrac];
}
if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) {
well_fraction -= primary_variables_.evaluation_[GFrac];
}
if (Indices::enableSolvent) {
well_fraction -= primary_variables_.evaluation_[SFrac];
}
}
else if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx) && (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx))) {
well_fraction -= primary_variables_.evaluation_[GFrac];
}
return well_fraction;
}
template<class FluidSystem, class Indices, class Scalar>
typename StandardWellEval<FluidSystem,Indices,Scalar>::EvalWell
StandardWellEval<FluidSystem,Indices,Scalar>::
@ -222,10 +171,10 @@ wellVolumeFractionScaled(const int compIdx) const
const int legacyCompIdx = baseif_.ebosCompIdxToFlowCompIdx(compIdx);
const double scal = baseif_.scalingFactor(legacyCompIdx);
if (scal > 0)
return wellVolumeFraction(compIdx) / scal;
return this->primary_variables_.volumeFraction(compIdx) / scal;
// the scaling factor may be zero for RESV controlled wells.
return wellVolumeFraction(compIdx);
return this->primary_variables_.volumeFraction(compIdx);
}
template<class FluidSystem, class Indices, class Scalar>
@ -708,7 +657,7 @@ init(std::vector<double>& perf_depth,
}
}
// with the updated numWellEq_, we can initialize the primary variables and matrices now
// with the updated numWellEq, we can initialize the primary variables and matrices now
primary_variables_.resize(numWellEq);
// setup sparsity pattern for the matrices

View File

@ -86,7 +86,6 @@ protected:
EvalWell extendEval(const Eval& in) const;
EvalWell getQs(const int compIdx) const;
EvalWell wellSurfaceVolumeFraction(const int compIdx) const;
EvalWell wellVolumeFraction(const unsigned compIdx) const;
EvalWell wellVolumeFractionScaled(const int phase) const;
// calculate a relaxation factor to avoid overshoot of the fractions for producers

View File

@ -298,6 +298,57 @@ copyToWellStatePolyMW(WellState& well_state) const
}
}
template<class FluidSystem, class Indices, class Scalar>
typename StandardWellPrimaryVariables<FluidSystem,Indices,Scalar>::EvalWell
StandardWellPrimaryVariables<FluidSystem,Indices,Scalar>::
volumeFraction(const unsigned compIdx) const
{
if (FluidSystem::numActivePhases() == 1) {
return EvalWell(numWellEq_ + Indices::numEq, 1.0);
}
if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) {
if (has_wfrac_variable && compIdx == Indices::canonicalToActiveComponentIndex(FluidSystem::waterCompIdx)) {
return evaluation_[WFrac];
}
if (has_gfrac_variable && compIdx == Indices::canonicalToActiveComponentIndex(FluidSystem::gasCompIdx)) {
return evaluation_[GFrac];
}
if (Indices::enableSolvent && compIdx == (unsigned)Indices::contiSolventEqIdx) {
return evaluation_[SFrac];
}
}
else if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) {
if (has_gfrac_variable && compIdx == Indices::canonicalToActiveComponentIndex(FluidSystem::gasCompIdx)) {
return evaluation_[GFrac];
}
}
// Oil or WATER fraction
EvalWell well_fraction(numWellEq_ + Indices::numEq, 1.0);
if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) {
if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) {
well_fraction -= evaluation_[WFrac];
}
if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) {
well_fraction -= evaluation_[GFrac];
}
if constexpr (Indices::enableSolvent) {
well_fraction -= evaluation_[SFrac];
}
}
else if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx) &&
FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) {
well_fraction -= evaluation_[GFrac];
}
return well_fraction;
}
#define INSTANCE(...) \
template class StandardWellPrimaryVariables<BlackOilFluidSystem<double,BlackOilDefaultIndexTraits>,__VA_ARGS__,double>;

View File

@ -120,6 +120,9 @@ public:
//! \brief Copy polymer molecular weight values to well state.
void copyToWellStatePolyMW(WellState& well_state) const;
//! \brief Returns volume fraction for a component.
EvalWell volumeFraction(const unsigned compIdx) const;
private:
const WellInterfaceIndices<FluidSystem,Indices,Scalar>& well_; //!< Reference to well interface