move getQs to StandardWellPrimaryVariables

This commit is contained in:
Arne Morten Kvarving 2022-11-08 07:09:51 +01:00
parent 1aa74a9830
commit 435bd67732
5 changed files with 52 additions and 51 deletions

View File

@ -116,54 +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>::
getQs(const int comp_idx) const
{
// Note: currently, the WQTotal definition is still depends on Injector/Producer.
assert(comp_idx < baseif_.numComponents());
if (baseif_.isInjector()) { // only single phase injection
double inj_frac = 0.0;
switch (baseif_.wellEcl().injectorType()) {
case InjectorType::WATER:
if (comp_idx == int(Indices::canonicalToActiveComponentIndex(FluidSystem::waterCompIdx))) {
inj_frac = 1.0;
}
break;
case InjectorType::GAS:
if (Indices::enableSolvent && comp_idx == Indices::contiSolventEqIdx) { // solvent
inj_frac = baseif_.wsolvent();
} else if (comp_idx == int(Indices::canonicalToActiveComponentIndex(FluidSystem::gasCompIdx))) {
inj_frac = 1.0 - baseif_.rsRvInj();
if (Indices::enableSolvent) {
inj_frac -= baseif_.wsolvent();
}
} else if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx) && comp_idx == int(Indices::canonicalToActiveComponentIndex(FluidSystem::oilCompIdx))) {
inj_frac = baseif_.rsRvInj();
}
break;
case InjectorType::OIL:
if (comp_idx == int(Indices::canonicalToActiveComponentIndex(FluidSystem::oilCompIdx))) {
inj_frac = 1.0 - baseif_.rsRvInj();
} else if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx) && comp_idx == int(Indices::canonicalToActiveComponentIndex(FluidSystem::gasCompIdx))) {
inj_frac = baseif_.rsRvInj();
}
break;
case InjectorType::MULTI:
// Not supported.
// deferred_logger.warning("MULTI_PHASE_INJECTOR_NOT_SUPPORTED",
// "Multi phase injectors are not supported, requested for well " + name());
break;
}
return inj_frac * primary_variables_.evaluation_[WQTotal];
} else { // producers
return primary_variables_.evaluation_[WQTotal] *
primary_variables_.volumeFractionScaled(comp_idx);
}
}
template<class FluidSystem, class Indices, class Scalar>
void
StandardWellEval<FluidSystem,Indices,Scalar>::

View File

@ -84,7 +84,6 @@ protected:
}
EvalWell extendEval(const Eval& in) const;
EvalWell getQs(const int compIdx) const;
// calculate a relaxation factor to avoid overshoot of the fractions for producers
// which might result in negative rates

View File

@ -378,6 +378,53 @@ surfaceVolumeFraction(const int compIdx) const
return this->volumeFractionScaled(compIdx) / sum_volume_fraction_scaled;
}
template<class FluidSystem, class Indices, class Scalar>
typename StandardWellPrimaryVariables<FluidSystem,Indices,Scalar>::EvalWell
StandardWellPrimaryVariables<FluidSystem,Indices,Scalar>::
getQs(const int comp_idx) const
{
// Note: currently, the WQTotal definition is still depends on Injector/Producer.
assert(comp_idx < well_.numComponents());
if (well_.isInjector()) { // only single phase injection
double inj_frac = 0.0;
switch (well_.wellEcl().injectorType()) {
case InjectorType::WATER:
if (comp_idx == int(Indices::canonicalToActiveComponentIndex(FluidSystem::waterCompIdx))) {
inj_frac = 1.0;
}
break;
case InjectorType::GAS:
if (Indices::enableSolvent && comp_idx == Indices::contiSolventEqIdx) { // solvent
inj_frac = well_.wsolvent();
} else if (comp_idx == int(Indices::canonicalToActiveComponentIndex(FluidSystem::gasCompIdx))) {
inj_frac = 1.0 - well_.rsRvInj();
if constexpr (Indices::enableSolvent) {
inj_frac -= well_.wsolvent();
}
} else if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx) && comp_idx == int(Indices::canonicalToActiveComponentIndex(FluidSystem::oilCompIdx))) {
inj_frac = well_.rsRvInj();
}
break;
case InjectorType::OIL:
if (comp_idx == int(Indices::canonicalToActiveComponentIndex(FluidSystem::oilCompIdx))) {
inj_frac = 1.0 - well_.rsRvInj();
} else if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx) && comp_idx == int(Indices::canonicalToActiveComponentIndex(FluidSystem::gasCompIdx))) {
inj_frac = well_.rsRvInj();
}
break;
case InjectorType::MULTI:
// Not supported.
// deferred_logger.warning("MULTI_PHASE_INJECTOR_NOT_SUPPORTED",
// "Multi phase injectors are not supported, requested for well " + name());
break;
}
return inj_frac * evaluation_[WQTotal];
} else { // producers
return evaluation_[WQTotal] * this->volumeFractionScaled(comp_idx);
}
}
#define INSTANCE(...) \
template class StandardWellPrimaryVariables<BlackOilFluidSystem<double,BlackOilDefaultIndexTraits>,__VA_ARGS__,double>;

View File

@ -126,6 +126,9 @@ public:
//! \brief Returns surface volume fraction for a component.
EvalWell surfaceVolumeFraction(const int compIdx) const;
//! \brief Returns scaled rate for a component.
EvalWell getQs(const int compIdx) const;
private:
//! \brief Returns volume fraction for a component.
EvalWell volumeFraction(const unsigned compIdx) const;

View File

@ -532,7 +532,7 @@ namespace Opm
resWell_loc += (this->primary_variables_.surfaceVolumeFraction(componentIdx) -
this->F0_[componentIdx]) * volume / dt;
}
resWell_loc -= this->getQs(componentIdx) * this->well_efficiency_factor_;
resWell_loc -= this->primary_variables_.getQs(componentIdx) * this->well_efficiency_factor_;
StandardWellAssemble<FluidSystem,Indices,Scalar>(*this).
assembleSourceEq(resWell_loc,
componentIdx,
@ -542,7 +542,7 @@ namespace Opm
const auto& summaryState = ebosSimulator.vanguard().summaryState();
const Schedule& schedule = ebosSimulator.vanguard().schedule();
std::function<EvalWell(int)> gQ = [this](int a) { return this->getQs(a); };
std::function<EvalWell(int)> gQ = [this](int a) { return this->primary_variables_.getQs(a); };
StandardWellAssemble<FluidSystem,Indices,Scalar>(*this).
assembleControlEq(well_state, group_state,
schedule, summaryState,