28#ifndef EWOMS_DISPERSION_MODULE_HH
29#define EWOMS_DISPERSION_MODULE_HH
31#include <dune/common/fvector.hh>
36#include <opm/material/common/MathToolbox.hpp>
37#include <opm/material/common/Valgrind.hpp>
49template <
class TypeTag,
bool enableDispersion>
52template <
class TypeTag,
bool enableDispersion>
58template <
class TypeTag>
66 enum { numPhases = FluidSystem::numPhases };
81 template <
class Context>
88 template<
class Flu
idState,
class Scalar>
89 static void addDispersiveFlux(RateVector&,
100template <
class TypeTag>
115 enum { numPhases = FluidSystem::numPhases };
116 enum { numComponents = FluidSystem::numComponents };
117 enum { conti0EqIdx = Indices::conti0EqIdx };
127 if (!eclState.getSimulationConfig().rock_config().dispersion()) {
131 if (eclState.getSimulationConfig().hasVAPWAT() || eclState.getSimulationConfig().hasVAPOIL()) {
132 OpmLog::warning(
"Dispersion is activated in combination with VAPWAT/VAPOIL. \n"
133 "Water/oil is still allowed to vaporize, but dispersion in the "
134 "gas phase is ignored.");
142 template <
class Context>
147 if (!context.simulator().vanguard().eclState().getSimulationConfig().rock_config().dispersion()) {
153 const auto& dispersivity =
extQuants.dispersivity();
154 const auto& normVelocityAvg =
extQuants.normVelocityAvg();
178 template<
class Flu
idState,
class Scalar>
182 const Evaluation& dispersivity,
183 const Scalar& normVelocityAvg)
185 unsigned pvtRegionIndex =
fluidStateI.pvtRegionIndex();
187 if (!FluidSystem::phaseIsActive(
phaseIdx)) {
192 if (!FluidSystem::enableDissolvedGasInWater() && FluidSystem::waterPhaseIdx ==
phaseIdx) {
200 if (FluidSystem::gasPhaseIdx ==
phaseIdx) {
206 if ((!FluidSystem::enableVaporizedWater() && !FluidSystem::enableVaporizedOil())
217 Evaluation
diffR = 0.0;
218 if (FluidSystem::enableDissolvedGas() && FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx) &&
phaseIdx == FluidSystem::oilPhaseIdx) {
223 if (FluidSystem::enableVaporizedOil() && FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx) &&
phaseIdx == FluidSystem::gasPhaseIdx) {
225 convFactor = toMassFractionGasOil(pvtRegionIndex) / (1.0 +
rvAvg*toMassFractionGasOil(pvtRegionIndex));
228 if (FluidSystem::enableDissolvedGasInWater() &&
phaseIdx == FluidSystem::waterPhaseIdx) {
233 if (FluidSystem::enableVaporizedWater() &&
phaseIdx == FluidSystem::gasPhaseIdx) {
235 convFactor = toMassFractionGasWater(pvtRegionIndex)/ (1.0 +
rvAvg*toMassFractionGasWater(pvtRegionIndex));
263 static Scalar toMassFractionGasOil (
unsigned regionIdx) {
264 Scalar
rhoO = FluidSystem::referenceDensity(FluidSystem::oilPhaseIdx,
regionIdx);
265 Scalar
rhoG = FluidSystem::referenceDensity(FluidSystem::gasPhaseIdx,
regionIdx);
268 static Scalar toMassFractionGasWater (
unsigned regionIdx) {
269 Scalar
rhoW = FluidSystem::referenceDensity(FluidSystem::waterPhaseIdx,
regionIdx);
270 Scalar
rhoG = FluidSystem::referenceDensity(FluidSystem::gasPhaseIdx,
regionIdx);
282template <
class TypeTag,
bool enableDispersion>
288template <
class TypeTag>
301 throw std::logic_error(
"Method normVelocityCell() "
302 "does not make sense if dispersion is disabled");
310 template<
class ElementContext>
320template <
class TypeTag>
329 enum { numPhases = FluidSystem::numPhases };
330 enum { numComponents = FluidSystem::numComponents };
331 enum { oilPhaseIdx = FluidSystem::oilPhaseIdx };
332 enum { gasPhaseIdx = FluidSystem::gasPhaseIdx };
333 enum { waterPhaseIdx = FluidSystem::waterPhaseIdx };
334 enum { gasCompIdx = FluidSystem::gasCompIdx };
335 enum { oilCompIdx = FluidSystem::oilCompIdx };
336 enum { waterCompIdx = FluidSystem::waterCompIdx };
337 enum { conti0EqIdx = Indices::conti0EqIdx };
360 template<
class ElementContext>
364 if (!elemCtx.simulator().vanguard().eclState().getSimulationConfig().rock_config().dispersion()) {
367 const auto& problem = elemCtx.simulator().problem();
368 if (problem.model().linearizer().getVelocityInfo().empty()) {
371 const std::array<int, 3>
phaseIdxs = { gasPhaseIdx, oilPhaseIdx, waterPhaseIdx };
372 const std::array<int, 3>
compIdxs = { gasCompIdx, oilCompIdx, waterCompIdx };
373 const auto&
velocityInf = problem.model().linearizer().getVelocityInfo();
374 unsigned globalDofIdx = elemCtx.globalSpaceIndex(dofIdx,
timeIdx);
376 for (
unsigned i = 0; i <
phaseIdxs.size(); ++i) {
377 normVelocityCell_[i] = 0;
380 for (
unsigned i = 0; i <
phaseIdxs.size(); ++i) {
381 if (FluidSystem::phaseIsActive(
phaseIdxs[i])) {
384 + Indices::canonicalToActiveComponentIndex(
compIdxs[i])] ));
391 Scalar normVelocityCell_[numPhases];
400template <
class TypeTag,
bool enableDispersion>
401class BlackOilDispersionExtensiveQuantities;
406template <
class TypeTag>
415 enum { numPhases = FluidSystem::numPhases };
427 template <
class Context,
class Flu
idState>
428 void updateBoundary_(
const Context&,
435 using ScalarArray = Scalar[numPhases];
437 static void update(ScalarArray&,
438 const IntensiveQuantities&,
439 const IntensiveQuantities&)
448 throw std::logic_error(
"The method dispersivity() does not "
449 "make sense if dispersion is disabled.");
461 throw std::logic_error(
"The method normVelocityAvg() "
462 "does not make sense if dispersion is disabled.");
470template <
class TypeTag>
481 enum { dimWorld = GridView::dimensionworld };
485 using DimVector = Dune::FieldVector<Scalar, dimWorld>;
486 using DimEvalVector = Dune::FieldVector<Evaluation, dimWorld>;
488 using ScalarArray = Scalar[numPhases];
489 static void update(ScalarArray& normVelocityAvg,
494 if (!FluidSystem::phaseIsActive(
phaseIdx)) {
498 if (!FluidSystem::enableDissolvedGasInWater() && FluidSystem::waterPhaseIdx ==
phaseIdx) {
502 if ((!FluidSystem::enableVaporizedWater() && !FluidSystem::enableVaporizedOil()) && FluidSystem::gasPhaseIdx ==
phaseIdx) {
510 Valgrind::CheckDefined(normVelocityAvg[
phaseIdx]);
514 template <
class Context,
class Flu
idState>
515 void updateBoundary_(
const Context&,
520 throw std::runtime_error(
"Not implemented: Dispersion across boundary not implemented for blackoil");
531 {
return dispersivity_; }
541 {
return normVelocityAvg_[
phaseIdx]; }
543 const auto& normVelocityAvg()
const{
544 return normVelocityAvg_;
548 Scalar dispersivity_;
549 ScalarArray normVelocityAvg_;
Definition blackoildispersionmodule.hh:408
void update_(const ElementContext &, unsigned, unsigned)
Update the quantities required to calculate the dispersive fluxes.
Definition blackoildispersionmodule.hh:422
const Scalar & dispersivity() const
The dispersivity the face.
Definition blackoildispersionmodule.hh:446
const Scalar & normVelocityAvg(unsigned) const
The effective filter velocity coefficient in a fluid phase at the face's integration point.
Definition blackoildispersionmodule.hh:459
Provides the quantities required to calculate dispersive mass fluxes.
Definition blackoildispersionmodule.hh:472
const Scalar & dispersivity() const
The dispersivity of the face.
Definition blackoildispersionmodule.hh:530
const Scalar & normVelocityAvg(unsigned phaseIdx) const
The effective velocity coefficient in a fluid phase at the face's integration point.
Definition blackoildispersionmodule.hh:540
Provides the quantities required to calculate dispersive mass fluxes.
Definition blackoildispersionmodule.hh:53
Scalar normVelocityCell(unsigned, unsigned) const
Returns the max.
Definition blackoildispersionmodule.hh:299
void update_(ElementContext &, unsigned, unsigned)
Update the quantities required to calculate dispersive fluxes.
Definition blackoildispersionmodule.hh:311
void update_(const ElementContext &elemCtx, unsigned dofIdx, unsigned timeIdx)
Update the quantities required to calculate dispersive mass fluxes.
Definition blackoildispersionmodule.hh:361
Scalar normVelocityCell(unsigned phaseIdx) const
Returns the max.
Definition blackoildispersionmodule.hh:344
Provides the volumetric quantities required for the calculation of dispersive fluxes.
Definition blackoildispersionmodule.hh:283
static void addDispersiveFlux(RateVector &, const Context &, unsigned, unsigned)
Adds the dispersive flux to the flux vector over a flux integration point.
Definition blackoildispersionmodule.hh:82
static void addDispersiveFlux(RateVector &flux, const FluidState &fluidStateI, const FluidState &fluidStateJ, const Evaluation &dispersivity, const Scalar &normVelocityAvg)
Adds the mass flux due to dispersion to the flux vector over the integration point.
Definition blackoildispersionmodule.hh:179
static void addDispersiveFlux(RateVector &flux, const Context &context, unsigned spaceIdx, unsigned timeIdx)
Adds the mass flux due to dispersion to the flux vector over the flux integration point.
Definition blackoildispersionmodule.hh:143
Provides the auxiliary methods required for consideration of the dispersion equation.
Definition blackoildispersionmodule.hh:50
Declare the properties used by the infrastructure code of the finite volume discretizations.
Defines the common properties required by the porous medium multi-phase models.
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilboundaryratevector.hh:37
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:242
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:235