stokesvolumevariables.hh 8.01 KB
Newer Older
Andreas Lauser's avatar
Andreas Lauser committed
1
2
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
3
4
5
/*****************************************************************************
 *   Copyright (C) 2010 by Katherina Baber, Klaus Mosthaf                    *
 *   Copyright (C) 2008-2009 by Bernd Flemisch, Andreas Lauser               *
Andreas Lauser's avatar
Andreas Lauser committed
6
 *   Institute for Modelling Hydraulic and Environmental Systems             *
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 *   University of Stuttgart, Germany                                        *
 *   email: <givenname>.<name>@iws.uni-stuttgart.de                          *
 *                                                                           *
 *   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
 *
 * \brief Contains the quantities which are constant within a
Klaus Mosthaf's avatar
Klaus Mosthaf committed
27
 *        finite volume in the Stokes box model.
28
29
30
31
32
33
34
35
36
37
38
39
40
 */
#ifndef DUMUX_STOKES_VOLUME_VARIABLES_HH
#define DUMUX_STOKES_VOLUME_VARIABLES_HH

#include "stokesproperties.hh"
#include "dumux/boxmodels/common/boxvolumevariables.hh"

#include <dumux/material/fluidstates/immisciblefluidstate.hh>

namespace Dumux
{

/*!
41
 * \ingroup BoxStokesModel
42
43
 * \ingroup BoxVolumeVariables
 * \brief Contains the quantities which are are constant within a
Klaus Mosthaf's avatar
Klaus Mosthaf committed
44
 *        finite volume in the Stokes box model.
45
46
47
48
49
50
51
52
53
54
 */
template <class TypeTag>
class StokesVolumeVariables : public BoxVolumeVariables<TypeTag>
{
    typedef BoxVolumeVariables<TypeTag> ParentType;
    typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
    typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView;

    typedef typename GridView::template Codim<0>::Entity Element;
    typedef typename GET_PROP_TYPE(TypeTag, VolumeVariables) Implementation;
55
    typedef typename GET_PROP_TYPE(TypeTag, Indices) Indices;
56
57
58

    enum {
        dim = GridView::dimension,
59

60
61
62
63
        momentumXIdx = Indices::momentumXIdx,
        lastMomentumIdx = Indices::lastMomentumIdx,
        pressureIdx = Indices::pressureIdx
    };
64

65
    enum { phaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx) };
66
67
68
69
70
71
72

    typedef typename GET_PROP_TYPE(TypeTag, Problem) Problem;
    typedef typename GET_PROP_TYPE(TypeTag, FVElementGeometry) FVElementGeometry;
    typedef typename GET_PROP_TYPE(TypeTag, PrimaryVariables) PrimaryVariables;
    typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
    typedef typename GET_PROP_TYPE(TypeTag, FluidState) FluidState;

73
    typedef Dune::FieldVector<Scalar, dim> DimVector;
74
75
76

public:
    /*!
77
     * \copydoc BoxVolumeVariables::update()
78
     */
79
    void update(const PrimaryVariables &priVars,
80
81
                const Problem &problem,
                const Element &element,
82
83
84
                const FVElementGeometry &fvGeometry,
                const int scvIdx,
                const bool isOldSol)
85
    {
86
        ParentType::update(priVars,
87
88
                           problem,
                           element,
89
                           fvGeometry,
90
                           scvIdx,
91
92
                           isOldSol);

93
        completeFluidState(priVars, problem, element, fvGeometry, scvIdx, fluidState_, isOldSol);
94
95

        for (int dimIdx=momentumXIdx; dimIdx<=lastMomentumIdx; ++dimIdx)
96
            velocity_[dimIdx] = priVars[dimIdx];
97
98
    }

99
    /*!
100
101
     * \copydoc BoxModel::completeFluidState()
     * \param isOldSol Specifies whether this is the previous solution or the current one
102
     */
103
    static void completeFluidState(const PrimaryVariables& priVars,
104
105
                                   const Problem& problem,
                                   const Element& element,
106
107
                                   const FVElementGeometry& fvGeometry,
                                   const int scvIdx,
108
                                   FluidState& fluidState,
109
                                   const bool isOldSol = false)
110
    {
111
112
        Scalar temperature = Implementation::temperature_(priVars, problem,
                                                          element, fvGeometry, scvIdx);
113
        fluidState.setTemperature(temperature);
114
        fluidState.setPressure(phaseIdx, priVars[pressureIdx]);
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144

        // create NullParameterCache and do dummy update
        typename FluidSystem::ParameterCache paramCache;
        paramCache.updateAll(fluidState);

        fluidState.setDensity(phaseIdx,
                              FluidSystem::density(fluidState,
                                                   paramCache,
                                                   phaseIdx));
        fluidState.setViscosity(phaseIdx,
                                FluidSystem::viscosity(fluidState,
                                                       paramCache,
                                                       phaseIdx));

        // compute and set the enthalpy
        Scalar h = Implementation::enthalpy_(fluidState, paramCache, phaseIdx);
        fluidState.setEnthalpy(phaseIdx, h);

//        int globalVertIdx = problem.model().dofMapper().map(element, scvIdx, dim);
    }

    /*!
     * \brief Returns the phase state for the control-volume.
     */
    const FluidState &fluidState() const
    { return fluidState_; }
    FluidState &fluidState()
    { return fluidState_; }

    /*!
Klaus Mosthaf's avatar
Klaus Mosthaf committed
145
146
     * \brief Returns the mass density \f$\mathrm{[kg/m^3]}\f$ of the fluid within the
     *        sub-control volume.
147
148
149
150
     */
    Scalar density() const
    { return fluidState_.density(phaseIdx); }

151
152
153
154
155
156
157
    /*!
     * \brief Returns the molar density \f$\mathrm{[mol/m^3]}\f$ of the fluid within the
     *        sub-control volume.
     */
    Scalar molarDensity() const
    { return fluidState_.density(phaseIdx) / fluidState_.averageMolarMass(phaseIdx); }

158
    /*!
Klaus Mosthaf's avatar
Klaus Mosthaf committed
159
160
     * \brief Returns the fluid pressure \f$\mathrm{[Pa]}\f$ within
     *        the sub-control volume.
161
162
163
164
165
     */
    Scalar pressure() const
    { return fluidState_.pressure(phaseIdx); }

    /*!
Klaus Mosthaf's avatar
Klaus Mosthaf committed
166
     * \brief Returns temperature\f$\mathrm{[T]}\f$ inside the sub-control volume.
167
168
169
170
171
     */
    Scalar temperature() const
    { return fluidState_.temperature(phaseIdx); }

    /*!
172
     * \brief Returns the viscosity \f$ \mathrm{[m^2/s]} \f$ of the fluid in
Klaus Mosthaf's avatar
Klaus Mosthaf committed
173
     *        the sub-control volume.
174
175
176
177
178
     */
    Scalar viscosity() const
    { return fluidState_.viscosity(phaseIdx); }

    /*!
Klaus Mosthaf's avatar
Klaus Mosthaf committed
179
     * \brief Returns the velocity vector in the sub-control volume.
180
     */
181
    const DimVector &velocity() const
182
183
184
185
186
187
188
189
190
191
192
    { return velocity_; }

protected:
    template<class ParameterCache>
    static Scalar enthalpy_(const FluidState& fluidState,
                            const ParameterCache& paramCache,
                            int phaseIdx)
    {
        return 0;
    }

193
    static Scalar temperature_(const PrimaryVariables &priVars,
194
195
                            const Problem& problem,
                            const Element &element,
196
197
                            const FVElementGeometry &fvGeometry,
                            const int scvIdx)
198
    {
199
        return problem.boxTemperature(element, fvGeometry, scvIdx);
200
201
    }

202
    DimVector velocity_;
203
204
205
206
207
208
209
210
211
212
213
214
    FluidState fluidState_;

private:
    Implementation &asImp()
    { return *static_cast<Implementation*>(this); }
    const Implementation &asImp() const
    { return *static_cast<const Implementation*>(this); }
};

}

#endif