mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
move processFractions to StandardWellPrimaryVariables
This commit is contained in:
parent
435bd67732
commit
cd3388f7c0
@ -127,105 +127,6 @@ updatePrimaryVariables(const WellState& well_state, DeferredLogger& deferred_log
|
|||||||
this->primary_variables_.update(well_state, deferred_logger);
|
this->primary_variables_.update(well_state, deferred_logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class FluidSystem, class Indices, class Scalar>
|
|
||||||
void
|
|
||||||
StandardWellEval<FluidSystem,Indices,Scalar>::
|
|
||||||
processFractions() const
|
|
||||||
{
|
|
||||||
static constexpr int Gas = WellInterfaceIndices<FluidSystem,Indices,Scalar>::Gas;
|
|
||||||
static constexpr int Oil = WellInterfaceIndices<FluidSystem,Indices,Scalar>::Oil;
|
|
||||||
static constexpr int Water = WellInterfaceIndices<FluidSystem,Indices,Scalar>::Water;
|
|
||||||
const auto pu = baseif_.phaseUsage();
|
|
||||||
std::vector<double> F(baseif_.numPhases(), 0.0);
|
|
||||||
|
|
||||||
if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) {
|
|
||||||
F[pu.phase_pos[Oil]] = 1.0;
|
|
||||||
|
|
||||||
if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) {
|
|
||||||
F[pu.phase_pos[Water]] = primary_variables_.value_[WFrac];
|
|
||||||
F[pu.phase_pos[Oil]] -= F[pu.phase_pos[Water]];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) {
|
|
||||||
F[pu.phase_pos[Gas]] = primary_variables_.value_[GFrac];
|
|
||||||
F[pu.phase_pos[Oil]] -= F[pu.phase_pos[Gas]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) {
|
|
||||||
F[pu.phase_pos[Water]] = 1.0;
|
|
||||||
|
|
||||||
if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) {
|
|
||||||
F[pu.phase_pos[Gas]] = primary_variables_.value_[GFrac];
|
|
||||||
F[pu.phase_pos[Water]] -= F[pu.phase_pos[Gas]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) {
|
|
||||||
F[pu.phase_pos[Gas]] = 1.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[maybe_unused]] double F_solvent;
|
|
||||||
if constexpr (Indices::enableSolvent) {
|
|
||||||
F_solvent = primary_variables_.value_[SFrac];
|
|
||||||
F[pu.phase_pos[Oil]] -= F_solvent;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) {
|
|
||||||
if (F[Water] < 0.0) {
|
|
||||||
if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) {
|
|
||||||
F[pu.phase_pos[Gas]] /= (1.0 - F[pu.phase_pos[Water]]);
|
|
||||||
}
|
|
||||||
if constexpr (Indices::enableSolvent) {
|
|
||||||
F_solvent /= (1.0 - F[pu.phase_pos[Water]]);
|
|
||||||
}
|
|
||||||
if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) {
|
|
||||||
F[pu.phase_pos[Oil]] /= (1.0 - F[pu.phase_pos[Water]]);
|
|
||||||
}
|
|
||||||
F[pu.phase_pos[Water]] = 0.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) {
|
|
||||||
if (F[pu.phase_pos[Gas]] < 0.0) {
|
|
||||||
if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) {
|
|
||||||
F[pu.phase_pos[Water]] /= (1.0 - F[pu.phase_pos[Gas]]);
|
|
||||||
}
|
|
||||||
if constexpr (Indices::enableSolvent) {
|
|
||||||
F_solvent /= (1.0 - F[pu.phase_pos[Gas]]);
|
|
||||||
}
|
|
||||||
if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) {
|
|
||||||
F[pu.phase_pos[Oil]] /= (1.0 - F[pu.phase_pos[Gas]]);
|
|
||||||
}
|
|
||||||
F[pu.phase_pos[Gas]] = 0.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) {
|
|
||||||
if (F[pu.phase_pos[Oil]] < 0.0) {
|
|
||||||
if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) {
|
|
||||||
F[pu.phase_pos[Water]] /= (1.0 - F[pu.phase_pos[Oil]]);
|
|
||||||
}
|
|
||||||
if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) {
|
|
||||||
F[pu.phase_pos[Gas]] /= (1.0 - F[pu.phase_pos[Oil]]);
|
|
||||||
}
|
|
||||||
if constexpr (Indices::enableSolvent) {
|
|
||||||
F_solvent /= (1.0 - F[pu.phase_pos[Oil]]);
|
|
||||||
}
|
|
||||||
F[pu.phase_pos[Oil]] = 0.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if constexpr (has_wfrac_variable) {
|
|
||||||
primary_variables_.value_[WFrac] = F[pu.phase_pos[Water]];
|
|
||||||
}
|
|
||||||
|
|
||||||
if constexpr (has_gfrac_variable) {
|
|
||||||
primary_variables_.value_[GFrac] = F[pu.phase_pos[Gas]];
|
|
||||||
}
|
|
||||||
if constexpr (Indices::enableSolvent) {
|
|
||||||
primary_variables_.value_[SFrac] = F_solvent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class FluidSystem, class Indices, class Scalar>
|
template<class FluidSystem, class Indices, class Scalar>
|
||||||
void
|
void
|
||||||
StandardWellEval<FluidSystem,Indices,Scalar>::
|
StandardWellEval<FluidSystem,Indices,Scalar>::
|
||||||
@ -289,7 +190,7 @@ updatePrimaryVariablesNewton(const BVectorWell& dwells,
|
|||||||
primary_variables_.value_[SFrac] = old_primary_variables[SFrac] - dx4_limited;
|
primary_variables_.value_[SFrac] = old_primary_variables[SFrac] - dx4_limited;
|
||||||
}
|
}
|
||||||
|
|
||||||
processFractions();
|
this->primary_variables_.processFractions();
|
||||||
|
|
||||||
// updating the total rates Q_t
|
// updating the total rates Q_t
|
||||||
const double relaxation_factor_rate = this->relaxationFactorRate(old_primary_variables, dwells[0][WQTotal]);
|
const double relaxation_factor_rate = this->relaxationFactorRate(old_primary_variables, dwells[0][WQTotal]);
|
||||||
|
@ -117,9 +117,6 @@ protected:
|
|||||||
const int num_cells,
|
const int num_cells,
|
||||||
const bool has_polymermw);
|
const bool has_polymermw);
|
||||||
|
|
||||||
// handle the non reasonable fractions due to numerical overshoot
|
|
||||||
void processFractions() const;
|
|
||||||
|
|
||||||
void updatePrimaryVariables(const WellState& well_state,
|
void updatePrimaryVariables(const WellState& well_state,
|
||||||
DeferredLogger& deferred_logger) const;
|
DeferredLogger& deferred_logger) const;
|
||||||
|
|
||||||
|
@ -425,6 +425,105 @@ getQs(const int comp_idx) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class FluidSystem, class Indices, class Scalar>
|
||||||
|
void StandardWellPrimaryVariables<FluidSystem,Indices,Scalar>::
|
||||||
|
processFractions()
|
||||||
|
{
|
||||||
|
static constexpr int Water = BlackoilPhases::Aqua;
|
||||||
|
static constexpr int Oil = BlackoilPhases::Liquid;
|
||||||
|
static constexpr int Gas = BlackoilPhases::Vapour;
|
||||||
|
|
||||||
|
const auto pu = well_.phaseUsage();
|
||||||
|
std::vector<double> F(well_.numPhases(), 0.0);
|
||||||
|
|
||||||
|
if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) {
|
||||||
|
F[pu.phase_pos[Oil]] = 1.0;
|
||||||
|
|
||||||
|
if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) {
|
||||||
|
F[pu.phase_pos[Water]] = value_[WFrac];
|
||||||
|
F[pu.phase_pos[Oil]] -= F[pu.phase_pos[Water]];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) {
|
||||||
|
F[pu.phase_pos[Gas]] = value_[GFrac];
|
||||||
|
F[pu.phase_pos[Oil]] -= F[pu.phase_pos[Gas]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) {
|
||||||
|
F[pu.phase_pos[Water]] = 1.0;
|
||||||
|
|
||||||
|
if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) {
|
||||||
|
F[pu.phase_pos[Gas]] = value_[GFrac];
|
||||||
|
F[pu.phase_pos[Water]] -= F[pu.phase_pos[Gas]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) {
|
||||||
|
F[pu.phase_pos[Gas]] = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[maybe_unused]] double F_solvent;
|
||||||
|
if constexpr (Indices::enableSolvent) {
|
||||||
|
F_solvent = value_[SFrac];
|
||||||
|
F[pu.phase_pos[Oil]] -= F_solvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) {
|
||||||
|
if (F[Water] < 0.0) {
|
||||||
|
if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) {
|
||||||
|
F[pu.phase_pos[Gas]] /= (1.0 - F[pu.phase_pos[Water]]);
|
||||||
|
}
|
||||||
|
if constexpr (Indices::enableSolvent) {
|
||||||
|
F_solvent /= (1.0 - F[pu.phase_pos[Water]]);
|
||||||
|
}
|
||||||
|
if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) {
|
||||||
|
F[pu.phase_pos[Oil]] /= (1.0 - F[pu.phase_pos[Water]]);
|
||||||
|
}
|
||||||
|
F[pu.phase_pos[Water]] = 0.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) {
|
||||||
|
if (F[pu.phase_pos[Gas]] < 0.0) {
|
||||||
|
if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) {
|
||||||
|
F[pu.phase_pos[Water]] /= (1.0 - F[pu.phase_pos[Gas]]);
|
||||||
|
}
|
||||||
|
if constexpr (Indices::enableSolvent) {
|
||||||
|
F_solvent /= (1.0 - F[pu.phase_pos[Gas]]);
|
||||||
|
}
|
||||||
|
if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) {
|
||||||
|
F[pu.phase_pos[Oil]] /= (1.0 - F[pu.phase_pos[Gas]]);
|
||||||
|
}
|
||||||
|
F[pu.phase_pos[Gas]] = 0.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) {
|
||||||
|
if (F[pu.phase_pos[Oil]] < 0.0) {
|
||||||
|
if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) {
|
||||||
|
F[pu.phase_pos[Water]] /= (1.0 - F[pu.phase_pos[Oil]]);
|
||||||
|
}
|
||||||
|
if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) {
|
||||||
|
F[pu.phase_pos[Gas]] /= (1.0 - F[pu.phase_pos[Oil]]);
|
||||||
|
}
|
||||||
|
if constexpr (Indices::enableSolvent) {
|
||||||
|
F_solvent /= (1.0 - F[pu.phase_pos[Oil]]);
|
||||||
|
}
|
||||||
|
F[pu.phase_pos[Oil]] = 0.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if constexpr (has_wfrac_variable) {
|
||||||
|
value_[WFrac] = F[pu.phase_pos[Water]];
|
||||||
|
}
|
||||||
|
|
||||||
|
if constexpr (has_gfrac_variable) {
|
||||||
|
value_[GFrac] = F[pu.phase_pos[Gas]];
|
||||||
|
}
|
||||||
|
if constexpr (Indices::enableSolvent) {
|
||||||
|
value_[SFrac] = F_solvent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#define INSTANCE(...) \
|
#define INSTANCE(...) \
|
||||||
template class StandardWellPrimaryVariables<BlackOilFluidSystem<double,BlackOilDefaultIndexTraits>,__VA_ARGS__,double>;
|
template class StandardWellPrimaryVariables<BlackOilFluidSystem<double,BlackOilDefaultIndexTraits>,__VA_ARGS__,double>;
|
||||||
|
|
||||||
|
@ -129,6 +129,9 @@ public:
|
|||||||
//! \brief Returns scaled rate for a component.
|
//! \brief Returns scaled rate for a component.
|
||||||
EvalWell getQs(const int compIdx) const;
|
EvalWell getQs(const int compIdx) const;
|
||||||
|
|
||||||
|
//! \brief Handle non-reasonable fractions due to numerical overshoot.
|
||||||
|
void processFractions();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//! \brief Returns volume fraction for a component.
|
//! \brief Returns volume fraction for a component.
|
||||||
EvalWell volumeFraction(const unsigned compIdx) const;
|
EvalWell volumeFraction(const unsigned compIdx) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user