3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
porousmediumflow/1pnc/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 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
26#ifndef DUMUX_1PNC_VOLUME_VARIABLES_HH
27#define DUMUX_1PNC_VOLUME_VARIABLES_HH
28
29#include <dune/common/fvector.hh>
30
34
35namespace Dumux {
36
46template <class Traits>
49, public EnergyVolumeVariables<Traits, OnePNCVolumeVariables<Traits> >
50{
53 using Scalar = typename Traits::PrimaryVariables::value_type;
54 using PermeabilityType = typename Traits::PermeabilityType;
55 using Idx = typename Traits::ModelTraits::Indices;
56 static constexpr int numFluidComps = ParentType::numFluidComponents();
57
58 enum
59 {
60 // pressure primary variable index
61 pressureIdx = Idx::pressureIdx
62 };
63
64public:
66 using FluidState = typename Traits::FluidState;
68 using FluidSystem = typename Traits::FluidSystem;
72 using SolidState = typename Traits::SolidState;
74 using SolidSystem = typename Traits::SolidSystem;
75
77 static constexpr bool useMoles() { return Traits::ModelTraits::useMoles(); }
78
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 completeFluidState(elemSol, problem, element, scv, fluidState_, solidState_);
97
98 // calculate the remaining quantities
99 updateSolidVolumeFractions(elemSol, problem, element, scv, solidState_, numFluidComps);
100 EnergyVolVars::updateSolidEnergyParams(elemSol, problem, element, scv, solidState_);
101 permeability_ = problem.spatialParams().permeability(element, scv, elemSol);
102
103 // Second instance of a parameter cache.
104 // Could be avoided if diffusion coefficients also
105 // became part of the fluid state.
106 typename FluidSystem::ParameterCache paramCache;
107
108 paramCache.updatePhase(fluidState_, 0);
109
110 for (unsigned int compIIdx = 0; compIIdx < numFluidComps; ++compIIdx)
111 {
112 for (unsigned int compJIdx = 0; compJIdx < numFluidComps; ++compJIdx)
113 {
114 if(compIIdx != compJIdx)
115 diffCoeff_[compIIdx][compJIdx] = FluidSystem::binaryDiffusionCoefficient(fluidState_,
116 paramCache,
117 0,
118 compIIdx,
119 compJIdx);
120 }
121 }
122 }
123
135 template<class ElemSol, class Problem, class Element, class Scv>
136 void completeFluidState(const ElemSol &elemSol,
137 const Problem& problem,
138 const Element& element,
139 const Scv &scv,
142 {
143 EnergyVolVars::updateTemperature(elemSol, problem, element, scv, fluidState, solidState);
144 fluidState.setSaturation(0, 1.0);
145
146 const auto& priVars = elemSol[scv.localDofIndex()];
147 fluidState.setPressure(0, priVars[pressureIdx]);
148
149 // Set fluid state mole fractions
150 if (useMoles())
151 {
152 Scalar sumMoleFracNotMainComp = 0;
153 for (int compIdx = 1; compIdx < numFluidComps; ++compIdx)
154 {
155 fluidState.setMoleFraction(0, compIdx, priVars[compIdx]);
156 sumMoleFracNotMainComp += priVars[compIdx];
157 }
158 fluidState.setMoleFraction(0, 0, 1.0 - sumMoleFracNotMainComp);
159 }
160 else
161 {
162 // for mass fractions we only have to set numComponents-1 mass fractions
163 // the fluid state will internally compute the remaining mass fraction
164 for (int compIdx = 1; compIdx < numFluidComps; ++compIdx)
165 fluidState.setMassFraction(0, compIdx, priVars[compIdx]);
166 }
167
168 typename FluidSystem::ParameterCache paramCache;
169 paramCache.updateAll(fluidState);
170
171 Scalar rho = FluidSystem::density(fluidState, paramCache, 0);
172 Scalar rhoMolar = FluidSystem::molarDensity(fluidState, paramCache, 0);
173 Scalar mu = FluidSystem::viscosity(fluidState, paramCache, 0);
174
175 fluidState.setDensity(0, rho);
176 fluidState.setMolarDensity(0, rhoMolar);
177 fluidState.setViscosity(0, mu);
178
179 // compute and set the enthalpy
180 Scalar h = EnergyVolVars::enthalpy(fluidState, paramCache, 0);
181 fluidState.setEnthalpy(0, h);
182 }
183
188 const FluidState &fluidState() const
189 { return fluidState_; }
190
194 const SolidState &solidState() const
195 { return solidState_; }
196
202 Scalar averageMolarMass(int phaseIdx = 0) const
203 { return fluidState_.averageMolarMass(0); }
204
211 Scalar density(int phaseIdx = 0) const
212 {
213 return fluidState_.density(0);
214 }
215
222 Scalar molarDensity(int phaseIdx = 0) const
223 {
224 return fluidState_.molarDensity(0);
225 }
226
233 Scalar saturation(int phaseIdx = 0) const
234 { return 1.0; }
235
245 Scalar moleFraction(int phaseIdx, int compIdx) const
246 {
247 // make sure this is only called with admissible indices
248 assert(compIdx < numFluidComps);
249 return fluidState_.moleFraction(0, compIdx);
250 }
251
261 Scalar massFraction(int phaseIdx, int compIdx) const
262 {
263 // make sure this is only called with admissible indices
264 assert(compIdx < numFluidComps);
265 return fluidState_.massFraction(0, compIdx);
266 }
267
277 Scalar pressure(int phaseIdx = 0) const
278 {
279 return fluidState_.pressure(0);
280 }
281
289 Scalar temperature() const
290 { return fluidState_.temperature(); }
291
301 Scalar mobility(int phaseIdx = 0) const
302 {
303 return 1.0/fluidState_.viscosity(0);
304 }
305
313 Scalar viscosity(int phaseIdx = 0) const
314 {
315 return fluidState_.viscosity(0);
316 }
317
321 Scalar porosity() const
322 { return solidState_.porosity(); }
323
327 Scalar diffusionCoefficient(int phaseIdx, int compIdx) const
328 {
329 assert(compIdx < numFluidComps);
330 return diffCoeff_[phaseIdx][compIdx];
331 }
332
338 Scalar molarity(int compIdx) const // [moles/m^3]
339 {
340 assert(compIdx < numFluidComps);
341 return fluidState_.molarity(0, compIdx);
342 }
343
349 Scalar massFraction(int compIdx) const
350 {
351 assert(compIdx < numFluidComps);
352 return fluidState_.massFraction(0, compIdx);
353 }
354
358 const PermeabilityType& permeability() const
359 { return permeability_; }
360
361protected:
364
365private:
366 PermeabilityType permeability_;
367 std::array<std::array<Scalar, numFluidComps>, numFluidComps> diffCoeff_;
368};
369
370} // end namespace Dumux
371
372#endif
Update the solid volume fractions (inert and reacitve) and set them in the solidstate.
void updateSolidVolumeFractions(const ElemSol &elemSol, const Problem &problem, const Element &element, const Scv &scv, SolidState &solidState, const int solidVolFracOffset)
update the solid volume fractions (inert and reacitve) and set them in the solidstate
Definition: updatesolidvolumefractions.hh:36
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
Property tag Indices
Definition: porousmediumflow/sequential/properties.hh:59
std::string viscosity(int phaseIdx) noexcept
I/O name of viscosity for multiphase systems.
Definition: name.hh:74
std::string molarDensity(int phaseIdx) noexcept
I/O name of molar density for multiphase systems.
Definition: name.hh:83
std::string density(int phaseIdx) noexcept
I/O name of density for multiphase systems.
Definition: name.hh:65
Contains the quantities which are are constant within a finite volume in the one-phase,...
Definition: porousmediumflow/1pnc/volumevariables.hh:50
Scalar saturation(int phaseIdx=0) const
Returns the saturation.
Definition: porousmediumflow/1pnc/volumevariables.hh:233
FluidState fluidState_
Definition: porousmediumflow/1pnc/volumevariables.hh:362
Scalar massFraction(int phaseIdx, int compIdx) const
Returns the mass fraction of a component in the phase.
Definition: porousmediumflow/1pnc/volumevariables.hh:261
void update(const ElemSol &elemSol, const Problem &problem, const Element &element, const Scv &scv)
Updates all quantities for a given control volume.
Definition: porousmediumflow/1pnc/volumevariables.hh:89
Scalar viscosity(int phaseIdx=0) const
Returns the dynamic viscosity of the fluid within the control volume.
Definition: porousmediumflow/1pnc/volumevariables.hh:313
SolidState solidState_
Definition: porousmediumflow/1pnc/volumevariables.hh:363
Scalar diffusionCoefficient(int phaseIdx, int compIdx) const
Returns the binary diffusion coefficient in the fluid.
Definition: porousmediumflow/1pnc/volumevariables.hh:327
static constexpr bool useMoles()
Returns whether moles or masses are balanced.
Definition: porousmediumflow/1pnc/volumevariables.hh:77
Scalar density(int phaseIdx=0) const
Returns density the of the fluid phase.
Definition: porousmediumflow/1pnc/volumevariables.hh:211
Scalar mobility(int phaseIdx=0) const
Returns the mobility .
Definition: porousmediumflow/1pnc/volumevariables.hh:301
Scalar massFraction(int compIdx) const
Returns the mass fraction of a component in the phase.
Definition: porousmediumflow/1pnc/volumevariables.hh:349
typename Traits::ModelTraits::Indices Indices
Export indices.
Definition: porousmediumflow/1pnc/volumevariables.hh:70
Scalar molarDensity(int phaseIdx=0) const
Returns molar density the of the fluid phase.
Definition: porousmediumflow/1pnc/volumevariables.hh:222
Scalar porosity() const
Returns the average porosity within the control volume.
Definition: porousmediumflow/1pnc/volumevariables.hh:321
typename Traits::SolidSystem SolidSystem
Export type of solid system.
Definition: porousmediumflow/1pnc/volumevariables.hh:74
Scalar pressure(int phaseIdx=0) const
Returns the effective pressure of a given phase within the control volume.
Definition: porousmediumflow/1pnc/volumevariables.hh:277
const PermeabilityType & permeability() const
Returns the permeability within the control volume in .
Definition: porousmediumflow/1pnc/volumevariables.hh:358
Scalar molarity(int compIdx) const
Returns the molarity of a component in the phase.
Definition: porousmediumflow/1pnc/volumevariables.hh:338
Scalar averageMolarMass(int phaseIdx=0) const
Returns the average molar mass of the fluid phase.
Definition: porousmediumflow/1pnc/volumevariables.hh:202
Scalar moleFraction(int phaseIdx, int compIdx) const
Returns the mole fraction of a component in the phase.
Definition: porousmediumflow/1pnc/volumevariables.hh:245
typename Traits::FluidState FluidState
Export fluid state type.
Definition: porousmediumflow/1pnc/volumevariables.hh:66
const SolidState & solidState() const
Returns the phase state for the control volume.
Definition: porousmediumflow/1pnc/volumevariables.hh:194
typename Traits::FluidSystem FluidSystem
Export fluid system type.
Definition: porousmediumflow/1pnc/volumevariables.hh:68
const FluidState & fluidState() const
Returns the fluid configuration at the given primary variables.
Definition: porousmediumflow/1pnc/volumevariables.hh:188
typename Traits::SolidState SolidState
Export type of solid state.
Definition: porousmediumflow/1pnc/volumevariables.hh:72
Scalar temperature() const
Returns the temperature inside the sub-control volume.
Definition: porousmediumflow/1pnc/volumevariables.hh:289
void completeFluidState(const ElemSol &elemSol, const Problem &problem, const Element &element, const Scv &scv, FluidState &fluidState, SolidState &solidState)
Sets complete fluid state.
Definition: porousmediumflow/1pnc/volumevariables.hh:136
Definition: porousmediumflow/nonisothermal/volumevariables.hh:75
The isothermal base class.
Definition: porousmediumflow/volumevariables.hh:40
static constexpr int numFluidComponents()
Return number of components considered by the model.
Definition: porousmediumflow/volumevariables.hh:52
const PrimaryVariables & priVars() const
Returns the vector of primary variables.
Definition: porousmediumflow/volumevariables.hh:76
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:64
Base class for the model specific class which provides access to all volume averaged quantities.
Base class for the model specific class which provides access to all volume averaged quantities.