28#ifndef OPM_MIXING_RATE_CONTROLS_HPP
29#define OPM_MIXING_RATE_CONTROLS_HPP
31#include <opm/input/eclipse/Schedule/Schedule.hpp>
33#include <opm/material/fluidsystems/BlackOilFluidSystem.hpp>
34#include <opm/material/common/MathToolbox.hpp>
44template<
class Flu
idSystem>
48 using Scalar =
typename FluidSystem::Scalar;
58 void init(std::size_t numDof,
int episodeIdx,
const unsigned ntpvt);
64 bool drsdtActive(
int episodeIdx, std::size_t pvtRegionIdx)
const;
65 bool drvdtActive(
int episodeIdx, std::size_t pvtRegionIdx)
const;
72 const int pvtRegionIdx)
const;
79 unsigned globalDofIdx,
81 const int pvtRegionIdx)
const;
88 const unsigned globalDofIdx,
90 const int pvtRegionIdx)
const;
93 const Scalar timeStepSize);
100 const Scalar timeStepSize);
102 template<
class Serializer>
107 serializer(convectiveDrs_);
110 serializer(dRsDtOnlyFreeGas_);
113 template<
class IntensiveQuantities>
115 const IntensiveQuantities& iq,
116 const int episodeIdx,
120 const int pvtRegionIdx)
122 const auto& oilVaporizationControl = schedule_[episodeIdx].oilvap();
124 if (oilVaporizationControl.drsdtConvective(pvtRegionIdx)) {
129 const auto& fs = iq.fluidState();
131 const auto& temperature = (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) ?
132 getValue(fs.temperature(FluidSystem::waterPhaseIdx)) :
133 getValue(fs.temperature(FluidSystem::oilPhaseIdx));
134 const auto& pressure = (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) ?
135 getValue(fs.pressure(FluidSystem::waterPhaseIdx)) :
136 getValue(fs.pressure(FluidSystem::oilPhaseIdx));
137 const auto& pressuregas = getValue(fs.pressure(FluidSystem::gasPhaseIdx));
138 const auto& rs = (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) ?
142 const auto& salt = getValue(fs.saltSaturation());
144 this->updateConvectiveDRsDt_(compressedDofIdx,
149 getValue(fs.saturation(FluidSystem::gasPhaseIdx)),
150 getValue(iq.porosity()),
155 oilVaporizationControl.getMaxDRSDT(fs.pvtRegionIndex()),
156 oilVaporizationControl.getPsi(fs.pvtRegionIndex()),
157 oilVaporizationControl.getOmega(fs.pvtRegionIndex()),
158 fs.pvtRegionIndex());
161 if (oilVaporizationControl.drsdtActive(pvtRegionIdx)) {
162 const auto& fs = iq.fluidState();
164 using FluidState =
typename std::decay<
decltype(fs)>::type;
165 constexpr Scalar freeGasMinSaturation_ = 1e-7;
166 if (oilVaporizationControl.getOption(pvtRegionIdx) ||
167 fs.saturation(FluidSystem::gasPhaseIdx) > freeGasMinSaturation_) {
168 lastRs_[compressedDofIdx]
169 = ((FluidSystem::enableDissolvedGasInWater())) ?
170 BlackOil::template getRsw_<FluidSystem, FluidState, Scalar>(fs, iq.pvtRegionIndex()) :
171 BlackOil::template getRs_<FluidSystem, FluidState, Scalar>(fs, iq.pvtRegionIndex());
174 lastRs_[compressedDofIdx] = std::numeric_limits<Scalar>::infinity();
177 if (oilVaporizationControl.drvdtActive(pvtRegionIdx)) {
178 const auto& fs = iq.fluidState();
179 using FluidState =
typename std::decay<
decltype(fs)>::type;
180 lastRv_[compressedDofIdx]
181 = BlackOil::template getRv_<FluidSystem, FluidState, Scalar>(fs, iq.pvtRegionIndex());
186 void updateConvectiveDRsDt_(
const unsigned compressedDofIdx,
200 const int pvtRegionIndex);
202 std::vector<Scalar> lastRv_;
203 std::vector<Scalar> maxDRv_;
205 std::vector<Scalar> convectiveDrs_;
206 std::vector<Scalar> lastRs_;
207 std::vector<Scalar> maxDRs_;
208 std::vector<bool> dRsDtOnlyFreeGas_;
210 const Schedule& schedule_;
Class handling mixing rate controls for a FlowProblemBlackoil.
Definition: MixingRateControls.hpp:46
Scalar maxOilVaporizationFactor(const unsigned timeIdx, const unsigned globalDofIdx, const int episodeIdx, const int pvtRegionIdx) const
Returns the maximum value of the oil vaporization factor at the current time for a given degree of fr...
void updateExplicitQuantities(const int episodeIdx, const Scalar timeStepSize)
bool drsdtActive(int episodeIdx, std::size_t pvtRegionIdx) const
typename FluidSystem::Scalar Scalar
Definition: MixingRateControls.hpp:48
bool drsdtConvective(int episodeIdx) const
Scalar maxGasDissolutionFactor(unsigned timeIdx, unsigned globalDofIdx, const int episodeIdx, const int pvtRegionIdx) const
Returns the maximum value of the gas dissolution factor at the current time for a given degree of fre...
MixingRateControls(const MixingRateControls &rhs)
void serializeOp(Serializer &serializer)
Definition: MixingRateControls.hpp:103
void init(std::size_t numDof, int episodeIdx, const unsigned ntpvt)
bool drsdtActive(int episodeIdx) const
bool operator==(const MixingRateControls &rhs) const
MixingRateControls & operator=(const MixingRateControls &rhs)
bool drvdtActive(int episodeIdx, std::size_t pvtRegionIdx) const
void updateLastValues(const unsigned elemIdx, const Scalar Rs, const Scalar Rv)
bool drvdtActive(int episodeIdx) const
static MixingRateControls serializationTestObject(const Schedule &schedule)
MixingRateControls(const Schedule &schedule)
Scalar drsdtcon(const unsigned elemIdx, int episodeIdx, const int pvtRegionIdx) const
Returns the dynamic drsdt convective mixing value.
void updateMaxValues(const int episodeIdx, const Scalar timeStepSize)
bool drsdtConvective(int episodeIdx, std::size_t pvtRegionIdx) const
void update(unsigned compressedDofIdx, const IntensiveQuantities &iq, const int episodeIdx, const Scalar gravity, const Scalar permZ, const Scalar distZ, const int pvtRegionIdx)
Definition: MixingRateControls.hpp:114
Definition: blackoilboundaryratevector.hh:37