version 3.11-dev
Loading...
Searching...
No Matches
porousmediumflow/2pve/volumevariables.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3//
4// SPDX-FileCopyrightText: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12
13#ifndef DUMUX_TWOPVE_VOLUMEVARIABLES_HH
14#define DUMUX_TWOPVE_VOLUMEVARIABLES_HH
15
16#include <type_traits>
17
18#include <dune/common/exceptions.hh>
19
24
25namespace Dumux {
26
28template<class PV, class FS, class FST, class PT, class MT>
30{
31 using PrimaryVariables = PV;
32 using FluidSystem = FS;
33 using FluidState = FST;
34 using PermeabilityType = PT;
35 using ModelTraits = MT;
36};
37
45template <class Traits>
48{
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;
59
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");
63
64 using GasPlumeDistances = TwoPVE::GasPlumeDistancesData<Scalar>;
65 using PhaseDensities = TwoPVE::PhaseDensitiesData<Scalar>;
66 using PhaseViscosities = TwoPVE::PhaseViscositiesData<Scalar>;
67 using BrooksCoreyParameters = TwoPVE::BrooksCoreyParametersData<Scalar>;
68
69public:
71 using PrimaryVariables = typename Traits::PrimaryVariables;
72
74 using FluidSystem = typename Traits::FluidSystem;
76 using FluidState = typename Traits::FluidState;
78 using Indices = typename ModelTraits::Indices;
79
88 template<class ElemSol, class Problem, class Element, class Scv>
89 void update(const ElemSol &elemSol,
90 const Problem &problem,
91 const Element &element,
92 const Scv& scv)
93 {
94 ParentType::update(elemSol, problem, element, scv);
95
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;
101
102 const auto& column = fineLevelView.columnMap().column(columnIdx);
103
104 // the wetting-phase pressure determines all coarse-level densities and viscosities
105 fluidState_.setDensity(phase0Idx, columnState.densityW);
106 fluidState_.setViscosity(phase0Idx, columnState.viscosityW);
107 fluidState_.setDensity(phase1Idx, columnState.densityNw);
108 fluidState_.setViscosity(phase1Idx, columnState.viscosityNw);
109
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_;
118
119 // column integrals of the fine-level permeability times the reconstructed fine-level mobilities
120 mobility_[phase0Idx] = 0.0;
121 mobility_[phase1Idx] = 0.0;
122 const auto& spatialParamsFine = problem.spatialParams().spatialParamsFine();
123 for (const auto& fineElement : column)
124 {
125 // relative height instead of absolute height is required for comparison with gas plume distance
126 const Scalar fineElementHeight = fineElement.geometry().center()[dim - 1] - fineLevelView.gridGeometry().bBoxMin()[dim - 1];
127
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,
133 fineElementHeight,
134 deltaZ,
135 BrooksCoreyParameters{columnState.brooksCoreyLambda,columnState.entryPressure});
136
137 const Scalar permeabilityFine = spatialParamsFine.permeabilityAtElement(fineElement);
138 mobility_[phase0Idx] += permeabilityFine * reconstructedMobilities[phase0Idx] * deltaZ;
139 mobility_[phase1Idx] += permeabilityFine * reconstructedMobilities[phase1Idx] * deltaZ;
140 }
141
142 completeFluidStateCoarse(elemSol, problem, element, scv, fluidState_, columnState.temperature, pcCoarse, columnState.gasPlumeDistance);
143
144 // permeability-weighted column average, the denominator is the column integral of the fine-level permeability
145 mobility_[phase0Idx] /= permeabilityIntegral;
146 mobility_[phase1Idx] /= permeabilityIntegral;
147
148 permeability_ = permeabilityIntegral/columnHeight_;
149 }
150
165 template<class ElemSol, class Problem, class Element, class Scv>
166 void completeFluidStateCoarse(const ElemSol& elemSol,
167 const Problem& problemCoarse,
168 const Element& element,
169 const Scv& scv,
171 Scalar temperature,
172 Scalar pcCoarse,
173 Scalar gasPlumeDist)
174 {
175 for (int phaseIdx = 0; phaseIdx < FluidSystem::numPhases; ++phaseIdx)
176 fluidState.setTemperature(phaseIdx, temperature);
177 const auto& priVars = elemSol[scv.localDofIndex()];
178
179 const auto wPhaseIdx = problemCoarse.spatialParams().template wettingPhase<FluidSystem>(element, scv, elemSol);
180 if (wPhaseIdx != phase0Idx)
181 DUNE_THROW(Dune::InvalidStateException, "The two-phase VE model requires the first phase to be the wetting phase");
182 fluidState.setWettingPhase(wPhaseIdx);
183
184 fluidState.setSaturation(phase1Idx, priVars[saturationIdx]);
185 fluidState.setSaturation(phase0Idx, 1.0 - priVars[saturationIdx]);
186
187 pc_ = pcCoarse;
188 fluidState.setPressure(phase0Idx, priVars[pressureIdx]);
189 fluidState.setPressure(phase1Idx, priVars[pressureIdx] + pc_);
190
191 gasPlumeDist_ = gasPlumeDist;
192 }
193
197 const FluidState &fluidState() const
198 { return fluidState_; }
199
206 Scalar saturation(int phaseIdx) const
207 { return fluidState_.saturation(phaseIdx); }
208
215 Scalar density(int phaseIdx) const
216 { return fluidState_.density(phaseIdx); }
217
224 Scalar pressure(int phaseIdx) const
225 { return fluidState_.pressure(phaseIdx); }
226
231 Scalar capillaryPressure() const
232 { return pc_; }
233
242 Scalar temperature() const
243 { return fluidState_.temperature(/*phaseIdx=*/0); }
244
251 Scalar viscosity(int phaseIdx) const
252 { return fluidState_.viscosity(phaseIdx); }
253
260 Scalar mobility(int phaseIdx) const
261 { return mobility_[phaseIdx]; }
262
266 Scalar porosity() const
267 { return porosity_; }
268
272 const PermeabilityType& permeability() const
273 { return permeability_; }
274
276 Scalar porosityIntegral() const
277 { return porosity_*columnHeight_; }
278
280 PermeabilityType permeabilityIntegral() const
281 { return permeability_*columnHeight_; }
282
286 int wettingPhase() const
287 { return fluidState_.wettingPhase(); }
288
292 Scalar gasPlumeDist() const
293 { return gasPlumeDist_; }
294
296 Scalar columnHeight() const { return columnHeight_; }
297
298protected:
300
301private:
302 Scalar pc_;
303 PermeabilityType permeability_;
304 Scalar porosity_;
305 Scalar columnHeight_;
306 Scalar mobility_[ModelTraits::numFluidPhases()];
307
308 Scalar gasPlumeDist_;
309};
310
311} // end namespace Dumux
312
313#endif
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.
Defines an enumeration for the formulations accepted by the two-phase model.
@ p0s1
first phase pressure and second phase saturation as primary variables
Definition formulation.hh:24
Definition adapt.hh:17
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
PermeabilityType PermeabilityType
Definition porousmediumflow/2pve/volumevariables.hh:34
PrimaryVariables PrimaryVariables
Definition porousmediumflow/2pve/volumevariables.hh:31