28#ifndef EWOMS_BLACK_OIL_LOCAL_RESIDUAL_HH
29#define EWOMS_BLACK_OIL_LOCAL_RESIDUAL_HH
31#include <opm/material/common/MathToolbox.hpp>
32#include <opm/material/fluidstates/BlackOilFluidState.hpp>
54template <
class TypeTag>
66 enum { conti0EqIdx = Indices::conti0EqIdx };
71 enum { gasPhaseIdx = FluidSystem::gasPhaseIdx };
72 enum { oilPhaseIdx = FluidSystem::oilPhaseIdx };
73 enum { waterPhaseIdx = FluidSystem::waterPhaseIdx };
75 enum { gasCompIdx = FluidSystem::gasCompIdx };
76 enum { oilCompIdx = FluidSystem::oilCompIdx };
77 enum { waterCompIdx = FluidSystem::waterCompIdx };
78 enum { compositionSwitchIdx = Indices::compositionSwitchIdx };
80 static constexpr bool waterEnabled = Indices::waterEnabled;
81 static constexpr bool gasEnabled = Indices::gasEnabled;
82 static constexpr bool oilEnabled = Indices::oilEnabled;
83 static constexpr bool compositionSwitchEnabled = (compositionSwitchIdx >= 0);
105 template <
class LhsEval>
107 const ElementContext& elemCtx,
112 const IntensiveQuantities& intQuants = elemCtx.intensiveQuantities(dofIdx,
timeIdx);
113 const auto& fs = intQuants.fluidState();
118 if (!FluidSystem::phaseIsActive(
phaseIdx)) {
119 if (Indices::numPhases == 3) {
121 FluidSystem::canonicalToActiveCompIdx(FluidSystem::solventComponentIndex(
phaseIdx));
133 FluidSystem::canonicalToActiveCompIdx(FluidSystem::solventComponentIndex(
phaseIdx));
142 if (
phaseIdx == oilPhaseIdx && FluidSystem::enableDissolvedGas()) {
143 const unsigned activeGasCompIdx = FluidSystem::canonicalToActiveCompIdx(gasCompIdx);
150 if (
phaseIdx == waterPhaseIdx && FluidSystem::enableDissolvedGasInWater()) {
151 const unsigned activeGasCompIdx = FluidSystem::canonicalToActiveCompIdx(gasCompIdx);
158 if (
phaseIdx == gasPhaseIdx && FluidSystem::enableVaporizedOil()) {
159 const unsigned activeOilCompIdx = FluidSystem::canonicalToActiveCompIdx(oilCompIdx);
166 if (
phaseIdx == gasPhaseIdx && FluidSystem::enableVaporizedWater()) {
167 const unsigned activeWaterCompIdx = FluidSystem::canonicalToActiveCompIdx(waterCompIdx);
177 SolventModule::addStorage(
storage, intQuants);
180 ExtboModule::addStorage(
storage, intQuants);
183 PolymerModule::addStorage(
storage, intQuants);
186 EnergyModule::addStorage(
storage, intQuants);
189 FoamModule::addStorage(
storage, intQuants);
192 BrineModule::addStorage(
storage, intQuants);
195 BioeffectsModule::addStorage(
storage, intQuants);
202 const ElementContext& elemCtx,
213 if (!FluidSystem::phaseIsActive(
phaseIdx)) {
218 const IntensiveQuantities&
up = elemCtx.intensiveQuantities(
upIdx,
timeIdx);
219 const unsigned pvtRegionIdx =
up.pvtRegionIndex();
259 const ElementContext& elemCtx,
264 elemCtx.problem().source(source, elemCtx, dofIdx,
timeIdx);
267 BioeffectsModule::addSource(source, elemCtx, dofIdx,
timeIdx);
270 if constexpr (enableEnergy) {
271 source[Indices::contiEnergyEqIdx] *=
280 template <
class UpEval,
class Flu
idState>
283 unsigned pvtRegionIdx,
285 const FluidState&
upFs)
290 FluidSystem::canonicalToActiveCompIdx(FluidSystem::solventComponentIndex(
phaseIdx));
292 if constexpr (blackoilConserveSurfaceVolume) {
297 FluidSystem::referenceDensity(
phaseIdx, pvtRegionIdx);
302 if (FluidSystem::enableDissolvedGas()) {
303 const auto& Rs = BlackOil::getRs_<FluidSystem, FluidState, UpEval>(
upFs, pvtRegionIdx);
305 const unsigned activeGasCompIdx = FluidSystem::canonicalToActiveCompIdx(gasCompIdx);
306 if constexpr (blackoilConserveSurfaceVolume) {
312 FluidSystem::referenceDensity(gasPhaseIdx, pvtRegionIdx);
315 }
else if (
phaseIdx == waterPhaseIdx) {
317 if (FluidSystem::enableDissolvedGasInWater()) {
318 const auto& Rsw = BlackOil::getRsw_<FluidSystem, FluidState, UpEval>(
upFs, pvtRegionIdx);
320 const unsigned activeGasCompIdx = FluidSystem::canonicalToActiveCompIdx(gasCompIdx);
321 if constexpr (blackoilConserveSurfaceVolume) {
327 FluidSystem::referenceDensity(gasPhaseIdx, pvtRegionIdx);
333 if (FluidSystem::enableVaporizedOil()) {
334 const auto& Rv = BlackOil::getRv_<FluidSystem, FluidState, UpEval>(
upFs, pvtRegionIdx);
336 const unsigned activeOilCompIdx = FluidSystem::canonicalToActiveCompIdx(oilCompIdx);
337 if constexpr (blackoilConserveSurfaceVolume) {
343 FluidSystem::referenceDensity(oilPhaseIdx, pvtRegionIdx);
347 if (FluidSystem::enableVaporizedWater()) {
348 const auto& Rvw = BlackOil::getRvw_<FluidSystem, FluidState, UpEval>(
upFs, pvtRegionIdx);
350 const unsigned activeWaterCompIdx = FluidSystem::canonicalToActiveCompIdx(waterCompIdx);
351 if constexpr (blackoilConserveSurfaceVolume) {
357 FluidSystem::referenceDensity(waterPhaseIdx, pvtRegionIdx);
374 template <
class Scalar>
376 unsigned pvtRegionIdx)
378 if constexpr (!blackoilConserveSurfaceVolume) {
383 if constexpr (waterEnabled) {
384 const unsigned activeWaterCompIdx = FluidSystem::canonicalToActiveCompIdx(waterCompIdx);
386 FluidSystem::referenceDensity(waterPhaseIdx, pvtRegionIdx);
389 if constexpr (gasEnabled) {
390 const unsigned activeGasCompIdx = FluidSystem::canonicalToActiveCompIdx(gasCompIdx);
392 FluidSystem::referenceDensity(gasPhaseIdx, pvtRegionIdx);
395 if constexpr (oilEnabled) {
396 const unsigned activeOilCompIdx = FluidSystem::canonicalToActiveCompIdx(oilCompIdx);
398 FluidSystem::referenceDensity(oilPhaseIdx, pvtRegionIdx);
Contains the classes required to extend the black-oil model by bioeffects.
Contains the classes required to extend the black-oil model by brine.
Classes required for dynamic convective mixing.
Classes required for molecular diffusion.
Contains the classes required to extend the black-oil model by energy.
Contains the classes required to extend the black-oil model by solvent component.
Contains the classes required to extend the black-oil model to include the effects of foam.
Contains the classes required to extend the black-oil model by polymer.
Declares the properties required by the black oil model.
Contains the classes required to extend the black-oil model by solvents.
Contains the high level supplements required to extend the black oil model by bioeffects.
Definition blackoilbioeffectsmodules.hh:93
Contains the high level supplements required to extend the black oil model by brine.
Definition blackoilbrinemodules.hh:56
Definition blackoilconvectivemixingmodule.hh:64
Provides the auxiliary methods required for consideration of the diffusion equation.
Definition blackoildiffusionmodule.hh:50
Contains the high level supplements required to extend the black oil model by energy.
Definition blackoilenergymodules.hh:58
Contains the high level supplements required to extend the black oil model.
Definition blackoilextbomodules.hh:62
Contains the high level supplements required to extend the black oil model to include the effects of ...
Definition blackoilfoammodules.hh:58
Calculates the local residual of the black oil model.
Definition blackoillocalresidual.hh:56
void computeFlux(RateVector &flux, const ElementContext &elemCtx, unsigned scvfIdx, unsigned timeIdx) const
Evaluates the total mass flux of all conservation quantities over a face of a sub-control volume.
Definition blackoillocalresidual.hh:201
void computeSource(RateVector &source, const ElementContext &elemCtx, unsigned dofIdx, unsigned timeIdx) const
Calculate the source term of the equation.
Definition blackoillocalresidual.hh:258
static void evalPhaseFluxes_(RateVector &flux, unsigned phaseIdx, unsigned pvtRegionIdx, const ExtensiveQuantities &extQuants, const FluidState &upFs)
Helper function to calculate the flux of mass in terms of conservation quantities via specific fluid ...
Definition blackoillocalresidual.hh:281
static void adaptMassConservationQuantities_(Dune::FieldVector< Scalar, numEq > &container, unsigned pvtRegionIdx)
Helper function to convert the mass-related parts of a Dune::FieldVector that stores conservation qua...
Definition blackoillocalresidual.hh:375
void computeStorage(Dune::FieldVector< LhsEval, numEq > &storage, const ElementContext &elemCtx, unsigned dofIdx, unsigned timeIdx) const
Evaluate the amount all conservation quantities (e.g.
Definition blackoillocalresidual.hh:106
Contains the high level supplements required to extend the black oil model by polymer.
Definition blackoilpolymermodules.hh:64
Contains the high level supplements required to extend the black oil model by solvents.
Definition blackoilsolventmodules.hh:68
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilbioeffectsmodules.hh:43
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:240
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition propertysystem.hh:233