tutorialproblem_coupled.hh 9.63 KB
Newer Older
1
// $Id$
2
/*****************************************************************************
3
 *   Copyright (C) 2008-2009 by Melanie Darcis, Klaus Mosthaf                *
4
5
6
7
8
 *   Copyright (C) 2009 by Andreas Lauser                                    *
 *   Institute of Hydraulic Engineering                                      *
 *   University of Stuttgart, Germany                                        *
 *   email: <givenname>.<name>@iws.uni-stuttgart.de                          *
 *                                                                           *
9
 *   This program is free software: you can redistribute it and/or modify    *
10
 *   it under the terms of the GNU General Public License as published by    *
11
12
 *   the Free Software Foundation, either version 2 of the License, or       *
 *   (at your option) any later version.                                     *
13
 *                                                                           *
14
15
16
17
18
19
20
 *   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/>.   *
21
 *****************************************************************************/
Melanie Darcis's avatar
doc    
Melanie Darcis committed
22
23
24
25
26
/*!
 * \file
 *
 * \brief Tutorial problem for a fully coupled twophase box model.
 */
27
28
#ifndef DUMUX_TUTORIALPROBLEM_COUPLED_HH    // guardian macro /*@\label{tutorial-coupled:guardian1}@*/
#define DUMUX_TUTORIALPROBLEM_COUPLED_HH    // guardian macro /*@\label{tutorial-coupled:guardian2}@*/
29
30

// the numerical model
31
#include <dumux/boxmodels/2p/2pmodel.hh>
32

33
34
// the DUNE grid used
#include <dune/grid/sgrid.hh>
35

36
// spatialy dependent parameters
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "tutorialspatialparameters_coupled.hh"

namespace Dumux
{

// forward declaration of the problem class
template <class TypeTag>
class TutorialProblemCoupled;

namespace Properties
{
// create a new type tag for the problem
NEW_TYPE_TAG(TutorialProblemCoupled, INHERITS_FROM(BoxTwoP)); /*@\label{tutorial-coupled:create-type-tag}@*/

// Set the "Problem" property
SET_PROP(TutorialProblemCoupled, Problem) /*@\label{tutorial-coupled:set-problem}@*/
53
{ typedef Dumux::TutorialProblemCoupled<TypeTag> type;};
54
55
56
57
58
59
60
61

// Set the grid
SET_PROP(TutorialProblemCoupled, Grid) /*@\label{tutorial-coupled:set-grid}@*/
{
    typedef Dune::SGrid<2,2> type;
    static type *create() /*@\label{tutorial-coupled:create-grid-method}@*/
    {
        typedef typename type::ctype ctype;
62
63
64
        Dune::FieldVector<int, 2> cellRes;  // vector holding resolution of the grid
        Dune::FieldVector<ctype, 2> lowerLeft(0.0); // Coordinate of lower left corner of the grid
        Dune::FieldVector<ctype, 2> upperRight; // Coordinate of upper right corner of the grid
65
66
        cellRes[0] = 100;
        cellRes[1] = 1;
67
68
69
70
71
72
73
74
        upperRight[0] = 300;
        upperRight[1] = 60;
        return new Dune::SGrid<2,2>(cellRes,
                                    lowerLeft,
                                    upperRight);
    }
};

75
76
// Set the wetting phase
SET_PROP(TutorialProblemCoupled, WettingPhase) /*@\label{tutorial-coupled:2p-system-start}@*/
77
{
78
79
private: typedef typename GET_PROP_TYPE(TypeTag, PTAG(Scalar)) Scalar;
public: typedef Dumux::LiquidPhase<Scalar, Dumux::H2O<Scalar> > type; /*@\label{tutorial-coupled:wettingPhase}@*/
80
81
};

82
83
84
// Set the non-wetting phase
SET_PROP(TutorialProblemCoupled, NonwettingPhase)
{
85
86
private: typedef typename GET_PROP_TYPE(TypeTag, PTAG(Scalar)) Scalar;
public: typedef Dumux::LiquidPhase<Scalar, Dumux::Oil<Scalar> > type; /*@\label{tutorial-coupled:nonwettingPhase}@*/
87
88
89
}; /*@\label{tutorial-coupled:2p-system-end}@*/


90
91
// Set the spatial parameters
SET_PROP(TutorialProblemCoupled, SpatialParameters) /*@\label{tutorial-coupled:set-spatialparameters}@*/
92
{ typedef Dumux::TutorialSpatialParametersCoupled<TypeTag> type; };
93
94
95
96
97

// Disable gravity
SET_BOOL_PROP(TutorialProblemCoupled, EnableGravity, false); /*@\label{tutorial-coupled:gravity}@*/
}

Melanie Darcis's avatar
doc    
Melanie Darcis committed
98
99
100
101
102
103
/*!
* \ingroup TwoPBoxModel
*
* \brief Tutorial problem for a fully coupled twophase box model.
*/

104
// Definition of the actual problem
105
template <class TypeTag>
106
class TutorialProblemCoupled : public TwoPProblem<TypeTag> /*@\label{tutorial-coupled:def-problem}@*/
107
{
108
    typedef TwoPProblem<TypeTag> ParentType;
109
    typedef typename GET_PROP_TYPE(TypeTag, PTAG(Scalar)) Scalar;
110
    typedef typename GET_PROP_TYPE(TypeTag, PTAG(GridView)) GridView;
111

112
113
    // Grid dimension
    enum { dim = GridView::dimension };
114

115
    // Types from DUNE-Grid
116
117
118
    typedef typename GridView::template Codim<0>::Entity Element;
    typedef typename GridView::template Codim<dim>::Entity Vertex;
    typedef typename GridView::Intersection Intersection;
119
    typedef Dune::FieldVector<Scalar, dim> GlobalPosition;
120

121
122
123
    // Dumux specific types
    typedef typename GET_PROP_TYPE(TypeTag, PTAG(TimeManager)) TimeManager;
    typedef typename GET_PROP_TYPE(TypeTag, PTAG(TwoPIndices)) Indices;
124
    typedef typename GET_PROP_TYPE(TypeTag, PTAG(PrimaryVariables)) PrimaryVariables;
125
    typedef typename GET_PROP_TYPE(TypeTag, PTAG(BoundaryTypes)) BoundaryTypes;
126
    typedef typename GET_PROP_TYPE(TypeTag, PTAG(FVElementGeometry)) FVElementGeometry;
127

128
public:
129
130
131
    TutorialProblemCoupled(TimeManager &timeManager,
                           const GridView &gridView)
        : ParentType(timeManager, gridView)
132
133
134
    {
    }

135
    // Specifies the problem name. This is used as a prefix for files
136
    // generated by the simulation.
137
138
    const char *name() const
    { return "tutorial_coupled"; }
139

Melanie Darcis's avatar
doc    
Melanie Darcis committed
140
141
142
143
144
145
146
147
148
149
    //!  Returns true if a restart file should be written.
    /* The default behaviour is to write no restart file.
     */
    bool shouldWriteRestartFile() const /*@\label{tutorial-coupled:restart}@*/
    {
        return false;
    }

    //! Returns true if the current solution should be written to disk (i.e. as a VTK file)
    /*! The default behaviour is to write out the solution for
150
     *  every time step. Else, the user has to change the divisor in this function.
Melanie Darcis's avatar
doc    
Melanie Darcis committed
151
152
153
154
155
156
157
     */
    bool shouldWriteOutput() const /*@\label{tutorial-coupled:output}@*/
    {
        return this->timeManager().timeStepIndex() > 0 &&
        (this->timeManager().timeStepIndex() % 1 == 0);
    }

158
159
    // Return the temperature within a finite volume. We use constant
    // 10 degrees Celsius.
160
    Scalar temperature(const Element &element,
161
                       const FVElementGeometry &fvElemGeom,
162
                       int scvIdx) const
163
164
165
    { return 283.15; };

    // Specifies which kind of boundary condition should be used for
166
167
    // which equation for a finite volume on the boundary.
    void boundaryTypes(BoundaryTypes &BCtypes, const Vertex &vertex) const
168
    {
169
        const GlobalPosition &pos = vertex.geometry().center();
170
171
        Scalar right = this->bboxMax()[0];

172
173
        if (pos[0] < eps_) // Dirichlet conditions on left boundary
           BCtypes.setAllDirichlet();
174
        else // neuman for the remaining boundaries
175
           BCtypes.setAllNeumann();
176
177
178

    }

179
180
    // Evaluate the Dirichlet boundary conditions for a finite volume
    // on the grid boundary. Here, the 'values' parameter stores
181
    // primary variables.
182
    void dirichlet(PrimaryVariables &values, const Vertex &vertex) const
183
    {
184
185
        const GlobalPosition &pos = vertex.geometry().center();

186
187
188
189
        values[Indices::pwIdx] = 200.0e3; // 200 kPa = 2 bar
        values[Indices::SnIdx] = 0.0; // 0 % oil saturation on left boundary
    }

190
191
192
    // Evaluate the boundary conditions for a Neumann boundary
    // segment. Here, the 'values' parameter stores the mass flux in
    // normal direction of each phase. Negative values mean influx.
193
    void neumann(PrimaryVariables &values,
194
195
196
197
198
                 const Element &element,
                 const FVElementGeometry &fvElemGeom,
                 const Intersection &isIt,
                 int scvIdx,
                 int boundaryFaceIdx) const
199
200
201
202
    {
        const GlobalPosition &pos =
            fvElemGeom.boundaryFace[boundaryFaceIdx].ipGlobal;
        Scalar right = this->bboxMax()[0];
Melanie Darcis's avatar
doc    
Melanie Darcis committed
203
        // extraction of oil on the right boundary for approx. 1.e6 seconds
204
205
        if (pos[0] > right - eps_) {
            // oil outflux of 30 g/(m * s) on the right boundary.
206
            values[Indices::contiWEqIdx] = 0;
207
            values[Indices::contiNEqIdx] = 3e-2;
208
        } else {
209
            // no-flow on the remaining Neumann-boundaries.
210
211
212
213
214
215
216
            values[Indices::contiWEqIdx] = 0;
            values[Indices::contiNEqIdx] = 0;
        }
    }

    // Evaluate the initial value for a control volume. For this
    // method, the 'values' parameter stores primary variables.
217
    void initial(PrimaryVariables &values,
218
                 const Element &element,
219
                 const FVElementGeometry &fvElemGeom,
220
                 int scvIdx) const
221
222
223
224
225
226
    {
        values[Indices::pwIdx] = 200.0e3; // 200 kPa = 2 bar
        values[Indices::SnIdx] = 1.0;
    }

    // Evaluate the source term for all phases within a given
227
228
229
    // sub-control-volume. In this case, the 'values' parameter stores
    // the rate mass generated or annihilate per volume unit. Positive
    // values mean that mass is created.
230
    void source(PrimaryVariables &values,
231
                const Element &element,
232
                const FVElementGeometry &fvElemGeom,
233
                int scvIdx) const
234
235
236
237
238
239
    {
        values[Indices::contiWEqIdx] = 0.0;
        values[Indices::contiNEqIdx]= 0.0;
    }

private:
240
    // small epsilon value
241
242
243
244
245
    static const Scalar eps_ = 3e-6;
};
}

#endif