3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
porousmediumflow/tracer/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 *****************************************************************************/
24#ifndef DUMUX_TRACER_VOLUME_VARIABLES_HH
25#define DUMUX_TRACER_VOLUME_VARIABLES_HH
26
27#include <type_traits>
28#include <array>
29#include <dune/common/std/type_traits.hh>
30
33
34namespace Dumux {
35
36namespace Detail {
37// helper structs and functions detecting if the user-defined spatial params class
38// has user-specified functions saturation() for multi-phase tracer.
39template <typename T, typename ...Ts>
40using SaturationDetector = decltype(std::declval<T>().spatialParams().saturation(std::declval<Ts>()...));
41
42template<class T, typename ...Args>
43static constexpr bool hasSaturation()
44{ return Dune::Std::is_detected<SaturationDetector, T, Args...>::value; }
45
46} // end namespace Detail
47
53template <class Traits>
56{
58 using Scalar = typename Traits::PrimaryVariables::value_type;
59 static constexpr bool useMoles = Traits::ModelTraits::useMoles();
60
61public:
63 using FluidSystem = typename Traits::FluidSystem;
64 using SolidState = typename Traits::SolidState;
65
75 template<class ElemSol, class Problem, class Element, class Scv>
76 void update(const ElemSol &elemSol,
77 const Problem &problem,
78 const Element &element,
79 const Scv &scv)
80 {
81 // update parent type sets primary variables
82 ParentType::update(elemSol, problem, element, scv);
83
85 // dispersivity_ = problem.spatialParams().dispersivity(element, scv, elemSol);
86
87 // the spatial params special to the tracer model
88 fluidDensity_ = problem.spatialParams().fluidDensity(element, scv);
89 fluidMolarMass_ = problem.spatialParams().fluidMolarMass(element, scv);
90 fluidSaturation_ = saturation_(problem, element, scv);
91
92 for (int compIdx = 0; compIdx < ParentType::numFluidComponents(); ++compIdx)
93 {
94 moleOrMassFraction_[compIdx] = this->priVars()[compIdx];
95 diffCoeff_[compIdx] = FluidSystem::binaryDiffusionCoefficient(compIdx, problem, element, scv);
96 }
97 }
98
106 Scalar density(int phaseIdx = 0) const
107 { return fluidDensity_; }
108
114 Scalar averageMolarMass(int phaseIdx = 0) const
115 { return fluidMolarMass_; }
116
120 const SolidState &solidState() const
121 { return solidState_; }
122
133 Scalar saturation(int phaseIdx = 0) const
134 { return fluidSaturation_ ; }
135
144 Scalar mobility(int phaseIdx = 0) const
145 { return 1.0; }
146
152 Scalar molarDensity(int phaseIdx = 0) const
154
161 Scalar moleFraction(int phaseIdx, int compIdx) const
162 { return useMoles ? moleOrMassFraction_[compIdx] : moleOrMassFraction_[compIdx]/FluidSystem::molarMass(compIdx)*fluidMolarMass_; }
163
170 Scalar massFraction(int phaseIdx, int compIdx) const
171 { return useMoles ? moleOrMassFraction_[compIdx]*FluidSystem::molarMass(compIdx)/fluidMolarMass_ : moleOrMassFraction_[compIdx]; }
172
179 Scalar molarity(int phaseIdx, int compIdx) const
180 { return moleFraction(phaseIdx, compIdx)*molarDensity(); }
181
188 Scalar diffusionCoefficient(int phaseIdx, int compIdx) const
189 { return diffCoeff_[compIdx]; }
190
191 // /*!
192 // * \brief Returns the dispersivity of the fluid's streamlines.
193 // * \todo implement me
194 // */
195 // const DispersivityType &dispersivity() const
196 // { return dispersivity_; }
197
201 Scalar porosity() const
202 { return solidState_.porosity(); }
203
204protected:
207 Scalar fluidSaturation_ = 1.0;
216 template<class Problem, class Element, class Scv,
217 std::enable_if_t<Detail::hasSaturation<Problem, Element, Scv>(), int> = 0>
218 Scalar saturation_(const Problem& problem,
219 const Element& element,
220 const Scv& scv)
221 { return problem.spatialParams().saturation(element, scv); }
222
231 template<class Problem, class Element, class Scv,
232 std::enable_if_t<!Detail::hasSaturation<Problem, Element, Scv>(), int> = 0>
233 Scalar saturation_(const Problem& problem,
234 const Element &element,
235 const Scv &scv)
236 { return 1.0; }
237
238 // DispersivityType dispersivity_;
241};
242
243} // end namespace Dumux
244
245#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
decltype(std::declval< T >().spatialParams().saturation(std::declval< Ts >()...)) SaturationDetector
Definition: porousmediumflow/tracer/volumevariables.hh:40
static constexpr bool hasSaturation()
Definition: porousmediumflow/tracer/volumevariables.hh:43
Contains the quantities which are constant within a finite volume for the tracer model.
Definition: porousmediumflow/tracer/volumevariables.hh:56
Scalar averageMolarMass(int phaseIdx=0) const
Returns the average molar mass of the fluid phase.
Definition: porousmediumflow/tracer/volumevariables.hh:114
Scalar diffusionCoefficient(int phaseIdx, int compIdx) const
Returns the binary diffusion coefficient in the fluid.
Definition: porousmediumflow/tracer/volumevariables.hh:188
typename Traits::FluidSystem FluidSystem
Export fluid system type.
Definition: porousmediumflow/tracer/volumevariables.hh:63
Scalar moleFraction(int phaseIdx, int compIdx) const
Returns the mole fraction of a component in the phase.
Definition: porousmediumflow/tracer/volumevariables.hh:161
Scalar massFraction(int phaseIdx, int compIdx) const
Returns the mass fraction of a component in the phase.
Definition: porousmediumflow/tracer/volumevariables.hh:170
Scalar molarDensity(int phaseIdx=0) const
Returns the molar density the of the fluid phase.
Definition: porousmediumflow/tracer/volumevariables.hh:152
typename Traits::SolidState SolidState
Definition: porousmediumflow/tracer/volumevariables.hh:64
Scalar fluidDensity_
Definition: porousmediumflow/tracer/volumevariables.hh:206
SolidState solidState_
Definition: porousmediumflow/tracer/volumevariables.hh:205
Scalar density(int phaseIdx=0) const
Returns the density the of the fluid phase.
Definition: porousmediumflow/tracer/volumevariables.hh:106
const SolidState & solidState() const
Returns the phase state for the control volume.
Definition: porousmediumflow/tracer/volumevariables.hh:120
Scalar mobility(int phaseIdx=0) const
Returns the mobility.
Definition: porousmediumflow/tracer/volumevariables.hh:144
Scalar saturation(int phaseIdx=0) const
Returns the saturation.
Definition: porousmediumflow/tracer/volumevariables.hh:133
void update(const ElemSol &elemSol, const Problem &problem, const Element &element, const Scv &scv)
Updates all quantities for a given control volume.
Definition: porousmediumflow/tracer/volumevariables.hh:76
Scalar porosity() const
Definition: porousmediumflow/tracer/volumevariables.hh:201
std::array< Scalar, ParentType::numFluidComponents()> diffCoeff_
Definition: porousmediumflow/tracer/volumevariables.hh:239
Scalar saturation_(const Problem &problem, const Element &element, const Scv &scv)
Gets the saturation in an scv.
Definition: porousmediumflow/tracer/volumevariables.hh:218
Scalar fluidSaturation_
Definition: porousmediumflow/tracer/volumevariables.hh:207
Scalar fluidMolarMass_
Definition: porousmediumflow/tracer/volumevariables.hh:206
Scalar molarity(int phaseIdx, int compIdx) const
Returns the concentration of a component in the phase.
Definition: porousmediumflow/tracer/volumevariables.hh:179
std::array< Scalar, ParentType::numFluidComponents()> moleOrMassFraction_
Definition: porousmediumflow/tracer/volumevariables.hh:240
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.