14#ifndef DUMUX_3P2CNI_LOCAL_RESIDUAL_HH 
   15#define DUMUX_3P2CNI_LOCAL_RESIDUAL_HH 
   28template<
class TypeTag>
 
   44    using GridView = 
typename GridGeometry::GridView;
 
   45    using Element = 
typename GridView::template Codim<0>::Entity;
 
   69    using ParentType::ParentType;
 
   88        const auto massOrMoleDensity = [](
const auto& volVars, 
const int phaseIdx)
 
   89        { 
return useMoles ? volVars.molarDensity(phaseIdx) : volVars.density(phaseIdx); };
 
   91        const auto massOrMoleFraction= [](
const auto& volVars, 
const int phaseIdx, 
const int compIdx)
 
   92        { 
return useMoles ? volVars.moleFraction(phaseIdx, compIdx) : volVars.massFraction(phaseIdx, compIdx); };
 
   95        for (
int phaseIdx = 0; phaseIdx < 
numPhases; ++phaseIdx)
 
  100                    storage[eqIdx] += volVars.porosity()
 
  101                                      * volVars.saturation(phaseIdx)
 
  102                                      * massOrMoleDensity(volVars, phaseIdx)
 
  107            EnergyLocalResidual::fluidPhaseStorage(storage, problem, scv, volVars, phaseIdx);
 
  111        EnergyLocalResidual::solidPhaseStorage(storage, scv, volVars);
 
 
  135        fluxVars.init(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
 
  140        const auto massOrMoleDensity = [](
const auto& volVars, 
const int phaseIdx)
 
  141        { 
return useMoles ? volVars.molarDensity(phaseIdx) : volVars.density(phaseIdx); };
 
  143        const auto massOrMoleFraction= [](
const auto& volVars, 
const int phaseIdx, 
const int compIdx)
 
  144        { 
return useMoles ? volVars.moleFraction(phaseIdx, compIdx) : volVars.massFraction(phaseIdx, compIdx); };
 
  147        for (
int phaseIdx = 0; phaseIdx < 
numPhases; ++phaseIdx)
 
  151                 const auto upwindTerm = [&massOrMoleDensity, &
massOrMoleFraction, phaseIdx, compIdx] (
const auto& volVars)
 
  152                { 
return massOrMoleDensity(volVars, phaseIdx)*
massOrMoleFraction(volVars, phaseIdx, compIdx)*volVars.mobility(phaseIdx); };
 
  156                flux[eqIdx] += fluxVars.advectiveFlux(phaseIdx, upwindTerm);
 
  160            EnergyLocalResidual::heatConvectionFlux(flux, fluxVars, phaseIdx);
 
  164        EnergyLocalResidual::heatConductionFlux(flux, fluxVars);
 
  167        static constexpr auto referenceSystemFormulation = FluxVariables::MolecularDiffusionType::referenceSystemFormulation();
 
  168        const auto diffusionFluxesWPhase = fluxVars.molecularDiffusionFlux(
wPhaseIdx);
 
  174            jNW /=  FluidSystem::molarMass(
nCompIdx);
 
  175            jWW /=  FluidSystem::molarMass(
wCompIdx);
 
  178        const auto diffusionFluxesGPhase = fluxVars.molecularDiffusionFlux(
gPhaseIdx);
 
  184            jWG /= FluidSystem::molarMass(
wCompIdx);
 
  185            jNG /= FluidSystem::molarMass(
nCompIdx);
 
  188        const auto diffusionFluxesNPhase = fluxVars.molecularDiffusionFlux(
nPhaseIdx);
 
  194            jWN /= FluidSystem::molarMass(
wCompIdx);
 
  195            jNN /= FluidSystem::molarMass(
nCompIdx);
 
 
 
Element-wise calculation of the local residual for problems using the ThreePWaterOil fully implicit m...
Definition porousmediumflow/3pwateroil/localresidual.hh:31
@ numComponents
Definition porousmediumflow/3pwateroil/localresidual.hh:53
@ conti0EqIdx
Index of the mass conservation equation for the water component.
Definition porousmediumflow/3pwateroil/localresidual.hh:55
@ nPhaseIdx
Definition porousmediumflow/3pwateroil/localresidual.hh:59
@ gPhaseIdx
Definition porousmediumflow/3pwateroil/localresidual.hh:60
@ conti1EqIdx
Index of the mass conservation equation for the contaminant component.
Definition porousmediumflow/3pwateroil/localresidual.hh:56
@ wPhaseIdx
Definition porousmediumflow/3pwateroil/localresidual.hh:58
@ nCompIdx
Definition porousmediumflow/3pwateroil/localresidual.hh:63
@ numPhases
Definition porousmediumflow/3pwateroil/localresidual.hh:52
@ wCompIdx
Definition porousmediumflow/3pwateroil/localresidual.hh:62
NumEqVector computeFlux(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolumeFace &scvf, const ElementFluxVariablesCache &elemFluxVarsCache) const
Evaluates the total flux of all conservation quantities over a face of a sub-control volume.
Definition porousmediumflow/3pwateroil/localresidual.hh:127
typename GridGeometry::GridView GridView
Definition porousmediumflow/3pwateroil/localresidual.hh:44
typename GetPropType< TypeTag, Properties::GridFluxVariablesCache >::LocalView ElementFluxVariablesCache
Definition porousmediumflow/3pwateroil/localresidual.hh:42
GetPropType< TypeTag, Properties::VolumeVariables > VolumeVariables
Definition porousmediumflow/3pwateroil/localresidual.hh:47
NumEqVector computeStorage(const Problem &problem, const SubControlVolume &scv, const VolumeVariables &volVars) const
Evaluates the amount of all conservation quantities (e.g. phase mass) within a sub-control volume.
Definition porousmediumflow/3pwateroil/localresidual.hh:82
GetPropType< TypeTag, Properties::GridGeometry > GridGeometry
Definition porousmediumflow/3pwateroil/localresidual.hh:33
typename GridView::template Codim< 0 >::Entity Element
Definition porousmediumflow/3pwateroil/localresidual.hh:45
GetPropType< TypeTag, Properties::Problem > Problem
Definition porousmediumflow/3pwateroil/localresidual.hh:35
typename GetPropType< TypeTag, Properties::ModelTraits >::Indices Indices
Definition porousmediumflow/3pwateroil/localresidual.hh:43
typename GridGeometry::LocalView FVElementGeometry
Definition porousmediumflow/3pwateroil/localresidual.hh:37
typename GetPropType< TypeTag, Properties::GridVolumeVariables >::LocalView ElementVolumeVariables
Definition porousmediumflow/3pwateroil/localresidual.hh:46
GetPropType< TypeTag, Properties::FluxVariables > FluxVariables
Definition porousmediumflow/3pwateroil/localresidual.hh:41
Dumux::NumEqVector< GetPropType< TypeTag, Properties::PrimaryVariables > > NumEqVector
Definition porousmediumflow/3pwateroil/localresidual.hh:40
GetPropType< TypeTag, Properties::FluidSystem > FluidSystem
Definition porousmediumflow/3pwateroil/localresidual.hh:49
DiscretizationDefaultLocalOperator< TypeTag > ParentType
Definition porousmediumflow/3pwateroil/localresidual.hh:34
typename FVElementGeometry::SubControlVolumeFace SubControlVolumeFace
Definition porousmediumflow/3pwateroil/localresidual.hh:39
GetPropType< TypeTag, Properties::EnergyLocalResidual > EnergyLocalResidual
Definition porousmediumflow/3pwateroil/localresidual.hh:48
static constexpr bool useMoles
Property that defines whether mole or mass fractions are used.
Definition porousmediumflow/3pwateroil/localresidual.hh:67
typename FVElementGeometry::SubControlVolume SubControlVolume
Definition porousmediumflow/3pwateroil/localresidual.hh:38
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition porousmediumflow/3pwateroil/localresidual.hh:36
Defines all properties used in Dumux.
The default local operator than can be specialized for each discretization scheme.
typename NumEqVectorTraits< PrimaryVariables >::type NumEqVector
A vector with the same size as numbers of equations This is the default implementation and has to be ...
Definition numeqvector.hh:34
VolumeVariables::PrimaryVariables::value_type massOrMoleFraction(const VolumeVariables &volVars, ReferenceSystemFormulation referenceSys, const int phaseIdx, const int compIdx)
returns the mass or mole fraction to be used in Fick's law based on the reference system
Definition referencesystemformulation.hh:54
@ massAveraged
Definition referencesystemformulation.hh:34
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:310
typename GetProp< TypeTag, Property >::type GetPropType
get the type alias defined in the property
Definition propertysystem.hh:296
typename Detail::DiscretizationDefaultLocalOperator< TypeTag >::type DiscretizationDefaultLocalOperator
Definition defaultlocaloperator.hh:26
A helper to deduce a vector with the same size as numbers of equations.