volumevariables.hh 7.28 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
 *   See the file COPYING for full copying permissions.                      *
 *                                                                           *
 *   This program is free software: you can redistribute it and/or modify    *
 *   it under the terms of the GNU General Public License as published by    *
 *   the Free Software Foundation, either version 2 of the License, or       *
 *   (at your option) any later version.                                     *
 *                                                                           *
 *   This program is distributed in the hope that it will be useful,         *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of          *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the            *
 *   GNU General Public License for more details.                            *
 *                                                                           *
 *   You should have received a copy of the GNU General Public License       *
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.   *
 *****************************************************************************/
/*!
 * \file
21
 * \ingroup TracerModel
22
23
24
25
26
 * \brief Quantities required by the tracer model in a control volume
 */
#ifndef DUMUX_TRACER_VOLUME_VARIABLES_HH
#define DUMUX_TRACER_VOLUME_VARIABLES_HH

Timo Koch's avatar
Timo Koch committed
27
28
#include <dune/common/fvector.hh>

Sina Ackermann's avatar
Sina Ackermann committed
29
#include <dumux/common/properties.hh>
30
#include <dumux/porousmediumflow/volumevariables.hh>
31

32
namespace Dumux {
33
34
35
36
37
38
39

/*!
 * \ingroup TracerModel
 * \brief Contains the quantities which are constant within a
 *        finite volume for the tracer model.
 */
template <class TypeTag>
40
class TracerVolumeVariables : public PorousMediumFlowVolumeVariables<TypeTag>
41
{
42
    using ParentType = PorousMediumFlowVolumeVariables<TypeTag>;
43
44
45
46
47

    using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
    using Problem = typename GET_PROP_TYPE(TypeTag, Problem);
    using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
    using Implementation = typename GET_PROP_TYPE(TypeTag, VolumeVariables);
48
    using FVElementGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry)::LocalView;
49
    using SubControlVolume = typename FVElementGeometry::SubControlVolume;
50
51
52
    using PrimaryVariables = typename GET_PROP_TYPE(TypeTag, PrimaryVariables);
    using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem);

53
54
55
    static constexpr bool useMoles = GET_PROP_VALUE(TypeTag, UseMoles);
    static constexpr int dimWorld = GridView::dimensionworld;
    static constexpr int numComponents = GET_PROP_VALUE(TypeTag, NumComponents);
56
57
58
59
60
61
62

    using GlobalPosition = Dune::FieldVector<Scalar,dimWorld>;
    using Element = typename GridView::template Codim<0>::Entity;

public:

    /*!
63
64
65
66
67
68
69
     * \brief Update all quantities for a given control volume
     *
     * \param elemSol A vector containing all primary variables connected to the element
     * \param problem The object specifying the problem which ought to
     *                be simulated
     * \param element An element which contains part of the control volume
     * \param scv The sub-control volume
70
     */
71
72
    template<class ElementSolution>
    void update(const ElementSolution &elemSol,
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
                const Problem &problem,
                const Element &element,
                const SubControlVolume &scv)
    {
        // update parent type sets primary variables
        ParentType::update(elemSol, problem, element, scv);

        porosity_ = problem.spatialParams().porosity(element, scv, elemSol);
        dispersivity_ = problem.spatialParams().dispersivity(element, scv, elemSol);

        // the spatial params special to the tracer model
        fluidDensity_ = problem.spatialParams().fluidDensity(element, scv);
        fluidMolarMass_ = problem.spatialParams().fluidMolarMass(element, scv);

        for (int compIdx = 0; compIdx < numComponents; ++compIdx)
        {
89
            moleOrMassFraction_[compIdx] = this->priVars()[compIdx];
90
            diffCoeff_[compIdx] = FluidSystem::binaryDiffusionCoefficient(compIdx, problem, element, scv);
91
92
93
94
95
96
97
        }
    }

    /*!
     * \brief Return density \f$\mathrm{[kg/m^3]}\f$ the of the fluid phase.
     *
     * We always forward to the fluid state with the phaseIdx property (see class description).
98
99
     *
     * \param pIdx TODO docme!
100
101
102
103
104
105
106
107
108
     */
    Scalar density(int pIdx = 0) const
    { return fluidDensity_; }

    /*!
     * \brief Return the saturation
     *
     * This method is here for compatibility reasons with other models. The saturation
     * is always 1.0 in a one-phasic context.
109
110
     *
     * \param pIdx TODO docme!
111
112
113
114
115
116
117
118
119
     */
    Scalar saturation(int pIdx = 0) const
    { return 1.0; }

    /*!
     * \brief Return the mobility
     *
     * This method is here for compatibility reasons with other models. The mobility is always 1
     * for one-phasic models where the velocity field is given
120
121
     *
     * \param pIdx TODO docme!
122
123
124
125
126
127
     */
    Scalar mobility(int pIdx = 0) const
    { return 1.0; }

    /*!
     * \brief Return molar density \f$\mathrm{[mol/m^3]}\f$ the of the fluid phase.
128
129
     *
     * \param pIdx TODO docme!
130
131
132
133
134
135
     */
    Scalar molarDensity(int pIdx = 0) const
    { return fluidDensity_/fluidMolarMass_; }

    /*!
     * \brief Return mole fraction \f$\mathrm{[mol/mol]}\f$ of a component in the phase.
136
137
     *
     * \param pIdx TODO docme!
138
139
140
     * \param compIdx The index of the component
     */
    Scalar moleFraction(int pIdx, int compIdx) const
141
    { return useMoles ? moleOrMassFraction_[compIdx] : moleOrMassFraction_[compIdx]/FluidSystem::molarMass(compIdx)*fluidMolarMass_; }
142
143
144

    /*!
     * \brief Return mass fraction \f$\mathrm{[kg/kg]}\f$ of a component in the phase.
145
146
     *
     * \param pIdx TODO docme!
147
148
149
     * \param compIdx The index of the component
     */
    Scalar massFraction(int pIdx, int compIdx) const
150
    { return useMoles ? moleOrMassFraction_[compIdx]*FluidSystem::molarMass(compIdx)/fluidMolarMass_ : moleOrMassFraction_[compIdx]; }
151
152
153

    /*!
     * \brief Return concentration \f$\mathrm{[mol/m^3]}\f$  of a component in the phase.
154
155
     *
     * \param pIdx TODO docme!
156
157
158
159
160
161
162
     * \param compIdx The index of the component
     */
    Scalar molarity(int pIdx, int compIdx) const
    { return moleFraction(pIdx, compIdx)*molarDensity(); }

    /*!
     * \brief Return the binary diffusion coefficient \f$\mathrm{[m^2/s]}\f$ in the fluid.
163
164
165
     *
     * \param pIdx TODO docme!
     * \param compIdx The index of the component
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
     */
    Scalar diffusionCoefficient(int pIdx, int compIdx) const
    { return diffCoeff_[compIdx]; }

    /*!
     * \brief Returns the dispersivity of the fluid's streamlines.
     */
    const GlobalPosition &dispersivity() const
    { return dispersivity_; }

    /*!
     * \brief Return the average porosity \f$\mathrm{[-]}\f$ within the control volume.
     */
    Scalar porosity() const
    { return porosity_; }

protected:
183
    Scalar porosity_;    // Effective porosity within the control volume
184
185
186
    Scalar fluidDensity_, fluidMolarMass_;
    GlobalPosition dispersivity_;
    std::array<Scalar, numComponents> diffCoeff_;
187
    std::array<Scalar, numComponents> moleOrMassFraction_;
188
189
190
191
192
};

} // end namespace Dumux

#endif