2p2cproblem.hh 8.88 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// -*- 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
 *
22
 * \brief Tutorial problem for a fully coupled two phase-two component box model.
23
 */
24
25
#ifndef DUMUX_EXERCISE_FLUIDSYSTEM_B_PROBLEM_HH
#define DUMUX_EXERCISE_FLUIDSYSTEM_B_PROBLEM_HH
26
27
28
29

// The numerical model
#include <dumux/porousmediumflow/2p2c/model.hh>

30
// The box discretization
31
#include <dumux/discretization/box.hh>
32
33
34
35
36
37
38
39
40
41
42
43

// The base porous media box problem
#include <dumux/porousmediumflow/problem.hh>

// Spatially dependent parameters
#include "spatialparams.hh"

// The fluid system that is created in this exercise
#include "fluidsystems/h2omycompressiblecomponent.hh"

namespace Dumux{
// Forward declaration of the problem class
44
template <class TypeTag> class ExerciseFluidsystemProblemTwoPTwoC;
45
46
47

namespace Properties {
// Create a new type tag for the problem
48
49
50
51
// Create new type tags
namespace TTag {
struct ExerciseFluidsystemTwoPTwoCTypeTag { using InheritsFrom = std::tuple<BoxModel, TwoPTwoC>; };
} // end namespace TTag
52
53

// Set the "Problem" property
54
55
template<class TypeTag>
struct Problem<TypeTag, TTag::ExerciseFluidsystemTwoPTwoCTypeTag> { using type = ExerciseFluidsystemProblemTwoPTwoC<TypeTag>; };
56
57

// Set the spatial parameters
58
SET_TYPE_PROP(ExerciseFluidsystemTwoPTwoCTypeTag, SpatialParams,
59
60
              ExerciseFluidsystemSpatialParams<GetPropType<TypeTag, Properties::FVGridGeometry>,
                                         GetPropType<TypeTag, Properties::Scalar>>);
61
62
63

// Set grid and the grid creator to be used
#if HAVE_DUNE_ALUGRID
64
65
template<class TypeTag>
struct Grid<TypeTag, TTag::ExerciseFluidsystemTwoPTwoCTypeTag> { using type = Dune::ALUGrid</*dim=*/2, 2, Dune::cube, Dune::nonconforming>; };
66
#elif HAVE_UG
67
68
template<class TypeTag>
struct Grid<TypeTag, TTag::ExerciseFluidsystemTwoPTwoCTypeTag> { using type = Dune::UGGrid<2>; };
69
#else
70
71
template<class TypeTag>
struct Grid<TypeTag, TTag::ExerciseFluidsystemTwoPTwoCTypeTag> { using type = Dune::YaspGrid<2>; };
72
73
74
#endif // HAVE_DUNE_ALUGRID

 // The fluid system property
75
76
template<class TypeTag>
struct FluidSystem<TypeTag, TTag::ExerciseFluidsystemTwoPTwoCTypeTag>
77
78
{
private:
79
    using Scalar = GetPropType<TypeTag, Properties::Scalar>;
80
81
82
83
84
85
86
87
88
public:
    using type = FluidSystems::H2OMyCompressibleComponent<Scalar>;
};

}

/*!
 * \ingroup TwoPBoxModel
 *
89
 * \brief  Tutorial problem for a fully coupled two phase-two component box model.
90
91
 */
template <class TypeTag>
92
class ExerciseFluidsystemProblemTwoPTwoC : public PorousMediumFlowProblem<TypeTag>
93
94
{
    using ParentType = PorousMediumFlowProblem<TypeTag>;
95
96
    using GridView = GetPropType<TypeTag, Properties::GridView>;
    using Scalar = GetPropType<TypeTag, Properties::Scalar>;
97
98
99
100
101
102
103
104
105

    // Grid dimension
    enum { dim = GridView::dimension,
           dimWorld = GridView::dimensionworld
    };
    using Element = typename GridView::template Codim<0>::Entity;
    using GlobalPosition = typename Element::Geometry::GlobalCoordinate;

    // Dumux specific types
106
107
108
109
110
111
    using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
    using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
    using BoundaryTypes = GetPropType<TypeTag, Properties::BoundaryTypes>;
    using FVGridGeometry = GetPropType<TypeTag, Properties::FVGridGeometry>;
    using FVElementGeometry = typename GetPropType<TypeTag, Properties::FVGridGeometry>::LocalView;
    using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
112
113

public:
114
    ExerciseFluidsystemProblemTwoPTwoC(std::shared_ptr<const FVGridGeometry> fvGridGeometry)
115
116
117
118
    : ParentType(fvGridGeometry)
        , eps_(3e-6)
    {
#if !(HAVE_DUNE_ALUGRID || HAVE_UG)
119
        std::cout << "If you want to use simplices instead of cubes, install and use dune-ALUGrid or UGGrid." << std::endl;
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#endif // !(HAVE_DUNE_ALUGRID || HAVE_UG)

        // initialize the fluid system
        FluidSystem::init();

        // set the depth of the bottom of the reservoir
        depthBOR_ = this->fvGridGeometry().bBoxMax()[dimWorld-1];
    }

    /*!
     * \name Problem parameters
     */
    // \{

    /*!
     * \brief Returns the temperature \f$ K \f$
     */
    Scalar temperature() const
    { return 283.15; }

     /*!
     * \name Boundary conditions
     */
    // \{

    /*!
     * \brief Specifies which kind of boundary condition should be
     *        used for which equation on a given boundary segment.
     *
     * \param globalPos The position for which the bc type should be evaluated
     */
    BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
    {
         BoundaryTypes bcTypes;

        if (globalPos[0] < eps_ || globalPos[0] > this->fvGridGeometry().bBoxMax()[0] - eps_)
           bcTypes.setAllDirichlet();
        else
            bcTypes.setAllNeumann();

        return bcTypes;
    }

    /*!
     * \brief Evaluates the boundary conditions for a Dirichlet
     *        boundary segment
     *
     * \param globalPos The global position
     */
    PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
    {
171
172
        // use initial as Dirichlet conditions
        return initialAtPos(globalPos);
173
174
175
176
177
178
179
180
181
182
183
184
    }

    /*!
     * \brief Evaluate the boundary conditions for a neumann
     *        boundary segment.
     *
     * \param globalPos The position of the integration point of the boundary segment.
     */
    PrimaryVariables neumannAtPos(const GlobalPosition &globalPos) const
    {
        // initialize values to zero, i.e. no-flow Neumann boundary conditions
        PrimaryVariables values(0.0);
185

186
        Scalar up = this->fvGridGeometry().bBoxMax()[dimWorld-1];
187
188
189
        // extraction of oil (30 g/m/s) on a segment of the upper boundary
        if (globalPos[dimWorld-1] > up - eps_ && globalPos[0] > 20 && globalPos[0] < 40)
        {
190
191
192
            // we solve for the mole balance, so we have to divide by the molar mass
            values[Indices::conti0EqIdx + FluidSystem::H2OIdx] = 0;
            values[Indices::conti0EqIdx + FluidSystem::NAPLIdx] = -3e-2/FluidSystem::MyCompressibleComponent::molarMass();
193
194
195
        }
        else
        {
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
            // no-flow on the remaining Neumann-boundaries.
            values[Indices::conti0EqIdx + FluidSystem::H2OIdx] = 0;
            values[Indices::conti0EqIdx + FluidSystem::NAPLIdx] = 0;
        }

        return values;
    }

    // \}

    /*!
     * \name Volume terms
     */
    // \{

    /*!
     * \brief Evaluate the initial value for a control volume.
     * \param globalPos The position for which the initial condition should be evaluated
     *
     * For this method, the \a values parameter stores primary
     * variables.
     */
    PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const

    {
        PrimaryVariables values(0.0);
222
223
224
225

        // tell the primary variables the phase state, i.e. which phase/phases
        // is/are present, because this changes the meaning of the primary variable
        // value at the index Indices::switchIdx
226
227
        values.setState(Indices::firstPhaseOnly);

228
        // use hydrostatic pressure distribution with 2 bar at the top and zero saturation
229
230
231
232
233
234
235
236
237
238
239
240
241
242
        values[Indices::pressureIdx] = 200.0e3 + 9.81*1000*(depthBOR_ - globalPos[dimWorld-1]); // 200 kPa = 2 bar
        values[Indices::switchIdx] = 0.0;

        return values;
    }

    // \}

    /*!
     * \brief Returns the source term
     * \param globalPos The global position
     */
    PrimaryVariables sourceAtPos(const GlobalPosition &globalPos) const
    {
243
        // we do not define any sources
244
245
246
247
248
249
        PrimaryVariables values(0.0);
        return values;
    }


private:
250
251
    Scalar eps_; //! small epsilon value
    Scalar depthBOR_; //! depth at the bottom of the reservoir
252
};
253
254

} // end namespace Dumux
255
256

#endif