volumevariables.hh 6.89 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

27
#include <dumux/porousmediumflow/volumevariables.hh>
Timo Koch's avatar
Timo Koch committed
28
#include <dumux/material/solidstates/updatesolidvolumefractions.hh>
29

30
namespace Dumux {
31
32
33
34
35
36

/*!
 * \ingroup TracerModel
 * \brief Contains the quantities which are constant within a
 *        finite volume for the tracer model.
 */
37
38
template <class Traits>
class TracerVolumeVariables
39
: public PorousMediumFlowVolumeVariables<Traits>
40
{
41
    using ParentType = PorousMediumFlowVolumeVariables<Traits>;
42
43
    using Scalar = typename Traits::PrimaryVariables::value_type;
    static constexpr bool useMoles = Traits::ModelTraits::useMoles();
44
45

public:
46
47
    //! export fluid system type
    using FluidSystem = typename Traits::FluidSystem;
48
    using SolidState = typename Traits::SolidState;
49
50

    /*!
51
52
53
54
55
56
57
     * \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
58
     */
59
60
    template<class ElemSol, class Problem, class Element, class Scv>
    void update(const ElemSol &elemSol,
61
62
                const Problem &problem,
                const Element &element,
63
                const Scv &scv)
64
65
66
67
    {
        // update parent type sets primary variables
        ParentType::update(elemSol, problem, element, scv);

68
        updateSolidVolumeFractions(elemSol, problem, element, scv, solidState_, ParentType::numComponents());
69
        // dispersivity_ = problem.spatialParams().dispersivity(element, scv, elemSol);
70
71
72
73
74

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

75
        for (int compIdx = 0; compIdx < ParentType::numComponents(); ++compIdx)
76
        {
77
            moleOrMassFraction_[compIdx] = this->priVars()[compIdx];
78
            diffCoeff_[compIdx] = FluidSystem::binaryDiffusionCoefficient(compIdx, problem, element, scv);
79
80
81
82
83
84
85
        }
    }

    /*!
     * \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).
86
87
     *
     * \param pIdx TODO docme!
88
89
90
91
     */
    Scalar density(int pIdx = 0) const
    { return fluidDensity_; }

92
93
94
95
96
97
    /*!
     * \brief Returns the phase state for the control volume.
     */
    const SolidState &solidState() const
    { return solidState_; }

98
99
100
101
102
    /*!
     * \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.
103
104
     *
     * \param pIdx TODO docme!
105
106
107
108
109
110
111
112
113
     */
    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
114
115
     *
     * \param pIdx TODO docme!
116
117
118
119
120
121
     */
    Scalar mobility(int pIdx = 0) const
    { return 1.0; }

    /*!
     * \brief Return molar density \f$\mathrm{[mol/m^3]}\f$ the of the fluid phase.
122
123
     *
     * \param pIdx TODO docme!
124
125
126
127
128
129
     */
    Scalar molarDensity(int pIdx = 0) const
    { return fluidDensity_/fluidMolarMass_; }

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

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

    /*!
     * \brief Return concentration \f$\mathrm{[mol/m^3]}\f$  of a component in the phase.
148
149
     *
     * \param pIdx TODO docme!
150
151
152
153
154
155
156
     * \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.
157
158
159
     *
     * \param pIdx TODO docme!
     * \param compIdx The index of the component
160
161
162
163
     */
    Scalar diffusionCoefficient(int pIdx, int compIdx) const
    { return diffCoeff_[compIdx]; }

164
165
166
167
168
169
    // /*!
    //  * \brief Returns the dispersivity of the fluid's streamlines.
    //  * \todo implement me
    //  */
    // const DispersivityType &dispersivity() const
    // { return dispersivity_; }
170
171
172
173
174

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

protected:
178
    SolidState solidState_;
179
    Scalar fluidDensity_, fluidMolarMass_;
180
    // DispersivityType dispersivity_;
181
182
    std::array<Scalar, ParentType::numComponents()> diffCoeff_;
    std::array<Scalar, ParentType::numComponents()> moleOrMassFraction_;
183
184
185
186
187
};

} // end namespace Dumux

#endif