volumevariables.hh 8.43 KB
Newer Older
1
2
3
4
5
6
7
// -*- 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    *
8
 *   the Free Software Foundation, either version 3 of the License, or       *
9
10
11
12
13
14
15
16
17
18
19
20
 *   (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 OnePModel
22
23
 * \brief Quantities required by the one-phase fully implicit model defined on a vertex.
 */
24

25
26
27
#ifndef DUMUX_1P_VOLUME_VARIABLES_HH
#define DUMUX_1P_VOLUME_VARIABLES_HH

Kilian Weishaupt's avatar
Kilian Weishaupt committed
28
#include <dumux/porousmediumflow/volumevariables.hh>
29
#include <dumux/porousmediumflow/nonisothermal/volumevariables.hh>
30
#include <dumux/material/fluidstates/immiscible.hh>
Timo Koch's avatar
Timo Koch committed
31
#include <dumux/material/solidstates/updatesolidvolumefractions.hh>
32

33
namespace Dumux {
34
35
36
37
38

/*!
 * \ingroup OnePModel
 * \brief Contains the quantities which are constant within a
 *        finite volume in the one-phase model.
39
40
 *
 * \tparam Traits Class encapsulating types to be used by the vol vars
41
 */
42
template<class Traits>
43
44
45
class OnePVolumeVariables
: public PorousMediumFlowVolumeVariables< Traits>
, public EnergyVolumeVariables<Traits, OnePVolumeVariables<Traits> >
46
{
47
    using ThisType = OnePVolumeVariables<Traits>;
48
49
    using ParentType = PorousMediumFlowVolumeVariables<Traits>;
    using EnergyVolVars = EnergyVolumeVariables<Traits, OnePVolumeVariables<Traits> >;
50

51
52
53
    using Scalar = typename Traits::PrimaryVariables::value_type;
    using Indices = typename Traits::ModelTraits::Indices;
    using PermeabilityType = typename Traits::PermeabilityType;
54
    static constexpr int numFluidComps = ParentType::numFluidComponents();
55
public:
56
    //! Export the underlying fluid system
57
    using FluidSystem = typename Traits::FluidSystem;
58
    //! Export the fluid state type
59
    using FluidState = typename Traits::FluidState;
60
    //! Export type of solid state
61
    using SolidState = typename Traits::SolidState;
62
    //! Export type of solid system
63
    using SolidSystem = typename Traits::SolidSystem;
64
65

    /*!
66
     * \brief Updates all quantities for a given control volume.
67
68
69
70
71
72
     *
     * \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
73
     */
74
    template<class ElemSol, class Problem, class Element, class Scv>
Dennis Gläser's avatar
Dennis Gläser committed
75
76
77
    void update(const ElemSol& elemSol,
                const Problem& problem,
                const Element& element,
78
                const Scv& scv)
79
    {
80
        ParentType::update(elemSol, problem, element, scv);
81

82
83
84
85
         // porosity
        completeFluidState(elemSol, problem, element, scv, fluidState_, solidState_);

        // porosity and permeability
Katharina Heck's avatar
Katharina Heck committed
86
        updateSolidVolumeFractions(elemSol, problem, element, scv, solidState_, numFluidComps);
87
        EnergyVolVars::updateSolidEnergyParams(elemSol, problem, element, scv, solidState_);
88
        permeability_ = problem.spatialParams().permeability(element, scv, elemSol);
89
        EnergyVolVars::updateEffectiveThermalConductivity();
90
    }
91
92

    /*!
93
     * \brief Sets complete fluid state
94
95
96
97
98
99
100
     *
     * \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
     * \param fluidState A container with the current (physical) state of the fluid
101
     * \param solidState A container with the current (physical) state of the solid
102
     */
103
    template<class ElemSol, class Problem, class Element, class Scv>
Dennis Gläser's avatar
Dennis Gläser committed
104
    void completeFluidState(const ElemSol& elemSol,
105
106
107
108
109
                            const Problem& problem,
                            const Element& element,
                            const Scv& scv,
                            FluidState& fluidState,
                            SolidState& solidState)
110
    {
111
        EnergyVolVars::updateTemperature(elemSol, problem, element, scv, fluidState, solidState);
112
113
        fluidState.setSaturation(/*phaseIdx=*/0, 1.);

114
        const auto& priVars = elemSol[scv.localDofIndex()];
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
        fluidState.setPressure(/*phaseIdx=*/0, priVars[Indices::pressureIdx]);

        // saturation in a single phase is always 1 and thus redundant
        // to set. But since we use the fluid state shared by the
        // immiscible multi-phase models, so we have to set it here...
        fluidState.setSaturation(/*phaseIdx=*/0, 1.0);

        typename FluidSystem::ParameterCache paramCache;
        paramCache.updatePhase(fluidState, /*phaseIdx=*/0);

        Scalar value = FluidSystem::density(fluidState, paramCache, /*phaseIdx=*/0);
        fluidState.setDensity(/*phaseIdx=*/0, value);

        value = FluidSystem::viscosity(fluidState, paramCache, /*phaseIdx=*/0);
        fluidState.setViscosity(/*phaseIdx=*/0, value);

        // compute and set the enthalpy
132
        value = EnergyVolVars::enthalpy(fluidState, paramCache, /*phaseIdx=*/0);
133
134
135
136
        fluidState.setEnthalpy(/*phaseIdx=*/0, value);
    }

    /*!
137
     * \brief Returns the temperature \f$\mathrm{[K]}\f$ inside the sub-control volume.
138
139
140
141
142
143
144
145
     *
     * Note that we assume thermodynamic equilibrium, i.e. the
     * temperatures of the rock matrix and of all fluid phases are
     * identical.
     */
    Scalar temperature() const
    { return fluidState_.temperature(); }

146
147
148
149
150
151
    /*!
     * \brief Returns the phase state for the control volume.
     */
    const SolidState &solidState() const
    { return solidState_; }

152
    /*!
153
     * \brief Returns the effective pressure \f$\mathrm{[Pa]}\f$ of a given phase within
154
155
156
157
158
     *        the control volume.
     */
    Scalar pressure(int phaseIdx = 0) const
    { return fluidState_.pressure(phaseIdx); }

159
    /*!
160
     * \brief Returns the saturation.
161
162
163
164
     */
    Scalar saturation(int phaseIdx = 0) const
    { return 1.0; }

165
    /*!
166
     * \brief Returns the mass density \f$\mathrm{[kg/m^3]}\f$ of a given phase within the
167
168
169
170
171
172
     *        control volume.
     */
    Scalar density(int phaseIdx = 0) const
    { return fluidState_.density(phaseIdx); }

    /*!
173
     * \brief Returns the dynamic viscosity \f$\mathrm{[Pa s]}\f$ of the fluid within the
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
     *        control volume.
     */
    Scalar viscosity(int phaseIdx = 0) const
    { return fluidState_.viscosity(phaseIdx); }

    /*!
     * \brief Returns the mobility \f$\mathrm{[1/(Pa s)]}\f$.
     *
     * This function enables the use of ImplicitDarcyFluxVariables
     * with the 1p fully implicit model, ALTHOUGH the term mobility is
     * usually not employed in the one phase context.
     *
     * \param phaseIdx The phase index
     */
    Scalar mobility(int phaseIdx = 0) const
    { return 1.0/fluidState_.viscosity(phaseIdx); }

    /*!
192
     * \brief Returns the average porosity \f$\mathrm{[-]}\f$ within the control volume.
193
194
     */
    Scalar porosity() const
Dennis Gläser's avatar
Dennis Gläser committed
195
    { return solidState_.porosity(); }
196

197
198
199
    /*!
     * \brief Returns the permeability within the control volume in \f$[m^2]\f$.
     */
200
    const PermeabilityType& permeability() const
201
202
    { return permeability_; }

203
    /*!
204
     * \brief Returns the fluid state of the control volume.
205
206
207
208
209
210
     */
    const FluidState &fluidState() const
    { return fluidState_; }

protected:
    FluidState fluidState_;
211
    SolidState solidState_;
212
    PermeabilityType permeability_;
213
214
};

215
} // end namespace Dumux
216
217

#endif