13#ifndef DUMUX_TWOPVE_VOLUMEVARIABLES_HH
14#define DUMUX_TWOPVE_VOLUMEVARIABLES_HH
18#include <dune/common/exceptions.hh>
28template<
class PV,
class FS,
class FST,
class PT,
class MT>
45template <
class Traits>
50 using PermeabilityType =
typename Traits::PermeabilityType;
51 using ModelTraits =
typename Traits::ModelTraits;
52 using Idx =
typename ModelTraits::Indices;
53 using Scalar =
typename Traits::PrimaryVariables::value_type;
54 using FS =
typename Traits::FluidSystem;
55 static constexpr int pressureIdx = Idx::pressureIdx;
56 static constexpr int saturationIdx = Idx::saturationIdx;
57 static constexpr int phase0Idx = FS::phase0Idx;
58 static constexpr int phase1Idx = FS::phase1Idx;
60 static constexpr auto formulation = ModelTraits::priVarFormulation();
61 static_assert(formulation ==
TwoPFormulation::p0s1,
"TwoPVEVolumeVariables only supports the p0s1 formulation");
62 static_assert(!ModelTraits::enableEnergyBalance(),
"TwoPVEVolumeVariables only supports isothermal flow");
78 using Indices =
typename ModelTraits::Indices;
88 template<
class ElemSol,
class Problem,
class Element,
class Scv>
90 const Problem &problem,
91 const Element &element,
96 const auto columnIdx = problem.gridGeometry().elementMapper().index(element);
97 const auto& fineLevelView = problem.fineLevelView();
98 const auto columnState = fineLevelView.makeColumnState(element, this->
priVars(), problem.spatialParams());
99 const Scalar deltaZ = fineLevelView.fineCellHeight();
100 constexpr int dim = std::decay_t<
decltype(fineLevelView.gridGeometry())>::GridView::dimensionworld;
102 const auto& column = fineLevelView.columnMap().column(columnIdx);
105 fluidState_.setDensity(phase0Idx, columnState.densityW);
106 fluidState_.setViscosity(phase0Idx, columnState.viscosityW);
107 fluidState_.setDensity(phase1Idx, columnState.densityNw);
108 fluidState_.setViscosity(phase1Idx, columnState.viscosityNw);
110 const Scalar pcCoarse = fineLevelView.quantityReconstructor().computeCapillaryPressureCoarse(
111 columnState.gasPlumeDistance,
112 PhaseDensities{columnState.densityW, columnState.densityNw},
113 columnState.gravityNorm,
114 columnState.entryPressure);
115 const Scalar
permeabilityIntegral = problem.spatialParams().permeabilityIntegralAtElement(element);
116 columnHeight_ = problem.spatialParams().columnHeightAtElement(element);
117 porosity_ = problem.spatialParams().porosityIntegralAtElement(element)/columnHeight_;
120 mobility_[phase0Idx] = 0.0;
121 mobility_[phase1Idx] = 0.0;
122 const auto& spatialParamsFine = problem.spatialParams().spatialParamsFine();
123 for (
const auto& fineElement : column)
126 const Scalar fineElementHeight = fineElement.geometry().center()[dim - 1] - fineLevelView.gridGeometry().bBoxMin()[dim - 1];
128 const auto reconstructedMobilities = fineLevelView.quantityReconstructor().reconstructMobilitiesFine(
129 GasPlumeDistances{columnState.gasPlumeDistance, columnState.minimumGasPlumeDistance},
130 PhaseDensities{columnState.densityW, columnState.densityNw},
131 PhaseViscosities{columnState.viscosityW, columnState.viscosityNw},
132 columnState.gravityNorm,
135 BrooksCoreyParameters{columnState.brooksCoreyLambda,columnState.entryPressure});
137 const Scalar permeabilityFine = spatialParamsFine.permeabilityAtElement(fineElement);
138 mobility_[phase0Idx] += permeabilityFine * reconstructedMobilities[phase0Idx] * deltaZ;
139 mobility_[phase1Idx] += permeabilityFine * reconstructedMobilities[phase1Idx] * deltaZ;
165 template<
class ElemSol,
class Problem,
class Element,
class Scv>
167 const Problem& problemCoarse,
168 const Element& element,
175 for (
int phaseIdx = 0; phaseIdx < FluidSystem::numPhases; ++phaseIdx)
177 const auto&
priVars = elemSol[scv.localDofIndex()];
180 if (wPhaseIdx != phase0Idx)
181 DUNE_THROW(Dune::InvalidStateException,
"The two-phase VE model requires the first phase to be the wetting phase");
261 {
return mobility_[phaseIdx]; }
267 {
return porosity_; }
273 {
return permeability_; }
277 {
return porosity_*columnHeight_; }
281 {
return permeability_*columnHeight_; }
293 {
return gasPlumeDist_; }
303 PermeabilityType permeability_;
305 Scalar columnHeight_;
306 Scalar mobility_[ModelTraits::numFluidPhases()];
308 Scalar gasPlumeDist_;
The isothermal base class.
Definition porousmediumflow/volumevariables.hh:28
const PrimaryVariables & priVars() const
Returns the vector of primary variables.
Definition porousmediumflow/volumevariables.hh:64
void update(const ElemSol &elemSol, const Problem &problem, const Element &element, const Scv &scv)
Updates all quantities for a given control volume.
Definition porousmediumflow/volumevariables.hh:52
Contains the quantities which are constant within a coarse-level finite volume in the two-phase VE mo...
Definition porousmediumflow/2pve/volumevariables.hh:48
const FluidState & fluidState() const
Returns the phase state for the control volume.
Definition porousmediumflow/2pve/volumevariables.hh:197
Scalar saturation(int phaseIdx) const
Returns the saturation of a given phase within the control volume in .
Definition porousmediumflow/2pve/volumevariables.hh:206
Scalar mobility(int phaseIdx) const
Returns the effective mobility of a given phase within the control volume in .
Definition porousmediumflow/2pve/volumevariables.hh:260
const PermeabilityType & permeability() const
Returns the column-average intrinsic permeability in .
Definition porousmediumflow/2pve/volumevariables.hh:272
void completeFluidStateCoarse(const ElemSol &elemSol, const Problem &problemCoarse, const Element &element, const Scv &scv, FluidState &fluidState, Scalar temperature, Scalar pcCoarse, Scalar gasPlumeDist)
Sets complete fluid state. This function is used for the coarse-level elements.
Definition porousmediumflow/2pve/volumevariables.hh:166
typename Traits::FluidState FluidState
Export type of fluid state.
Definition porousmediumflow/2pve/volumevariables.hh:76
Scalar porosity() const
Returns the dimensionless column-average porosity.
Definition porousmediumflow/2pve/volumevariables.hh:266
Scalar gasPlumeDist() const
Returns the gas plume distance within a coarse-level element.
Definition porousmediumflow/2pve/volumevariables.hh:292
typename ModelTraits::Indices Indices
Export the indices.
Definition porousmediumflow/2pve/volumevariables.hh:78
void update(const ElemSol &elemSol, const Problem &problem, const Element &element, const Scv &scv)
Updates all quantities for a given control volume, these volume variables refer to the coarse level o...
Definition porousmediumflow/2pve/volumevariables.hh:89
Scalar pressure(int phaseIdx) const
Returns the effective pressure of a given phase within the control volume in .
Definition porousmediumflow/2pve/volumevariables.hh:224
FluidState fluidState_
Definition porousmediumflow/2pve/volumevariables.hh:299
PermeabilityType permeabilityIntegral() const
Vertical integral of permeability [m^3].
Definition porousmediumflow/2pve/volumevariables.hh:280
Scalar capillaryPressure() const
Returns the capillary pressure within the control volume in .
Definition porousmediumflow/2pve/volumevariables.hh:231
int wettingPhase() const
Returns the wetting phase index.
Definition porousmediumflow/2pve/volumevariables.hh:286
typename Traits::FluidSystem FluidSystem
Export type of fluid system.
Definition porousmediumflow/2pve/volumevariables.hh:74
Scalar density(int phaseIdx) const
Returns the mass density of a given phase within the control volume in .
Definition porousmediumflow/2pve/volumevariables.hh:215
typename Traits::PrimaryVariables PrimaryVariables
Export the type used for the primary variables.
Definition porousmediumflow/2pve/volumevariables.hh:71
Scalar porosityIntegral() const
Vertical integral of porosity [m].
Definition porousmediumflow/2pve/volumevariables.hh:276
Scalar viscosity(int phaseIdx) const
Returns the dynamic viscosity of the fluid within the control volume in .
Definition porousmediumflow/2pve/volumevariables.hh:251
Scalar columnHeight() const
Height of the reconstructed column [m].
Definition porousmediumflow/2pve/volumevariables.hh:296
Scalar temperature() const
Returns temperature inside the sub-control volume in .
Definition porousmediumflow/2pve/volumevariables.hh:242
Defines all properties used in Dumux.
@ p0s1
first phase pressure and second phase saturation as primary variables
Definition formulation.hh:24
Base class for the model specific class which provides access to all volume averaged quantities.
Reconstructs quantities from the coarse to the fine level of the VE scheme.
The parameters of the Brooks-Corey material law.
Definition quantityreconstruction.hh:79
The gas plume distance of a column and its minimum over all previous time steps.
Definition quantityreconstruction.hh:35
The densities of the wetting and the nonwetting phase.
Definition quantityreconstruction.hh:46
The viscosities of the wetting and the nonwetting phase.
Definition quantityreconstruction.hh:57
Traits for isothermal VE flow, without solid-state or energy properties.
Definition porousmediumflow/2pve/volumevariables.hh:30
ModelTraits ModelTraits
Definition porousmediumflow/2pve/volumevariables.hh:35
PermeabilityType PermeabilityType
Definition porousmediumflow/2pve/volumevariables.hh:34
PrimaryVariables PrimaryVariables
Definition porousmediumflow/2pve/volumevariables.hh:31
FluidSystem FluidSystem
Definition porousmediumflow/2pve/volumevariables.hh:32
FluidState FluidState
Definition porousmediumflow/2pve/volumevariables.hh:33