staggeredtestproblem.hh 9.68 KB
Newer Older
Kilian Weishaupt's avatar
Kilian Weishaupt committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// -*- 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
 *
 * \brief A test problem for the one-phase model:
 * water is flowing from bottom to top through and around a low permeable lens.
 */
#ifndef DUMUX_1PTEST_PROBLEM_HH
#define DUMUX_1PTEST_PROBLEM_HH

#include <dumux/implicit/staggered/properties.hh>
#include <dumux/freeflow/staggered/model.hh>
30
#include <dumux/implicit/problem.hh>
Kilian Weishaupt's avatar
Kilian Weishaupt committed
31
32
33
34
35
36
37
38
39
#include <dumux/material/components/simpleh2o.hh>
#include <dumux/material/fluidsystems/liquidphase.hh>

#include <dumux/linear/amgbackend.hh>


namespace Dumux
{
template <class TypeTag>
40
class StaggeredTestProblem;
Kilian Weishaupt's avatar
Kilian Weishaupt committed
41
42
43
44

namespace Capabilities
{
    template<class TypeTag>
45
    struct isStationary<StaggeredTestProblem<TypeTag>>
46
    { static const bool value = false; };
Kilian Weishaupt's avatar
Kilian Weishaupt committed
47
48
49
50
}

namespace Properties
{
51
NEW_TYPE_TAG(StaggeredTestProblem, INHERITS_FROM(StaggeredModel, NavierStokes));
Kilian Weishaupt's avatar
Kilian Weishaupt committed
52

53
SET_PROP(StaggeredTestProblem, Fluid)
Kilian Weishaupt's avatar
Kilian Weishaupt committed
54
55
56
57
{
private:
    typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
public:
58
    typedef FluidSystems::LiquidPhase<Scalar, Dumux::SimpleH2O<Scalar> > type;
Kilian Weishaupt's avatar
Kilian Weishaupt committed
59
60
61
};

// Set the grid type
62
SET_TYPE_PROP(StaggeredTestProblem, Grid, Dune::YaspGrid<2>);
Kilian Weishaupt's avatar
Kilian Weishaupt committed
63
64

// Set the problem property
65
SET_TYPE_PROP(StaggeredTestProblem, Problem, Dumux::StaggeredTestProblem<TypeTag> );
Kilian Weishaupt's avatar
Kilian Weishaupt committed
66
67

// Set the spatial parameters
68
// SET_TYPE_PROP(StaggeredTestProblem, SpatialParams, Dumux::OnePTestSpatialParams<TypeTag> );
Kilian Weishaupt's avatar
Kilian Weishaupt committed
69

70
SET_BOOL_PROP(StaggeredTestProblem, EnableGlobalFVGeometryCache, true);
Kilian Weishaupt's avatar
Kilian Weishaupt committed
71

72
73
74
SET_BOOL_PROP(StaggeredTestProblem, EnableGlobalFluxVariablesCache, true);
SET_BOOL_PROP(StaggeredTestProblem, EnableGlobalVolumeVariablesCache, true);

Kilian Weishaupt's avatar
Kilian Weishaupt committed
75
76

// Enable gravity
77
SET_BOOL_PROP(StaggeredTestProblem, ProblemEnableGravity, true);
Kilian Weishaupt's avatar
Kilian Weishaupt committed
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
}

/*!
 * \ingroup OnePModel
 * \ingroup ImplicitTestProblems
 * \brief  Test problem for the one-phase model:
 * water is flowing from bottom to top through and around a low permeable lens.
 *
 * The domain is box shaped. All sides are closed (Neumann 0 boundary)
 * except the top and bottom boundaries (Dirichlet), where water is
 * flowing from bottom to top.
 *
 * In the middle of the domain, a lens with low permeability (\f$K=10e-12\f$)
 * compared to the surrounding material (\f$ K=10e-10\f$) is defined.
 *
 * To run the simulation execute the following line in shell:
 * <tt>./test_box1p -parameterFile test_box1p.input</tt> or
 * <tt>./test_cc1p -parameterFile test_cc1p.input</tt>
 *
 * The same parameter file can be also used for 3d simulation but you need to change line
 * <tt>typedef Dune::YaspGrid<2> type;</tt> to
 * <tt>typedef Dune::YaspGrid<3> type;</tt> in the problem file
 * and use <tt>test_1p_3d.dgf</tt> in the parameter file.
 */
template <class TypeTag>
103
class StaggeredTestProblem : public NavierStokesProblem<TypeTag>
Kilian Weishaupt's avatar
Kilian Weishaupt committed
104
{
105
    typedef NavierStokesProblem<TypeTag> ParentType;
Kilian Weishaupt's avatar
Kilian Weishaupt committed
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134

    typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView;
    typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;

    // copy some indices for convenience
    typedef typename GET_PROP_TYPE(TypeTag, Indices) Indices;
    enum {
        // Grid and world dimension
        dim = GridView::dimension,
        dimWorld = GridView::dimensionworld
    };
    enum {
        // indices of the primary variables
        conti0EqIdx = Indices::conti0EqIdx,
        pressureIdx = Indices::pressureIdx
    };

    typedef typename GET_PROP_TYPE(TypeTag, PrimaryVariables) PrimaryVariables;
    typedef typename GET_PROP_TYPE(TypeTag, BoundaryTypes) BoundaryTypes;
    typedef typename GET_PROP_TYPE(TypeTag, TimeManager) TimeManager;

    typedef typename GridView::template Codim<0>::Entity Element;
    typedef typename GridView::Intersection Intersection;

    typedef typename GET_PROP_TYPE(TypeTag, FVElementGeometry) FVElementGeometry;
    typedef typename GET_PROP_TYPE(TypeTag, SubControlVolume) SubControlVolume;

    typedef Dune::FieldVector<Scalar, dimWorld> GlobalPosition;

135
136
137
    using CellCenterPrimaryVariables = typename GET_PROP_TYPE(TypeTag, CellCenterPrimaryVariables);
    using FacePrimaryVariables = typename GET_PROP_TYPE(TypeTag, FacePrimaryVariables);

Kilian Weishaupt's avatar
Kilian Weishaupt committed
138
public:
139
    StaggeredTestProblem(TimeManager &timeManager, const GridView &gridView)
Kilian Weishaupt's avatar
Kilian Weishaupt committed
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
171
172
173
174
175
176
    : ParentType(timeManager, gridView)
    {
        name_ = GET_RUNTIME_PARAM_FROM_GROUP(TypeTag,
                                             std::string,
                                             Problem,
                                             Name);
    }

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

    /*!
     * \brief The problem name.
     *
     * This is used as a prefix for files generated by the simulation.
     */
    std::string name() const
    {
        return name_;
    }

    /*!
     * \brief Return the temperature within the domain in [K].
     *
     * This problem assumes a temperature of 10 degrees Celsius.
     */
    Scalar temperature() const
    { return 273.15 + 10; } // 10C

    /*!
     * \brief Return the sources within the domain.
     *
     * \param values Stores the source values, acts as return value
     * \param globalPos The global position
     */
177
    CellCenterPrimaryVariables sourceAtPos(const GlobalPosition &globalPos) const
Kilian Weishaupt's avatar
Kilian Weishaupt committed
178
    {
179
        return CellCenterPrimaryVariables(0);
Kilian Weishaupt's avatar
Kilian Weishaupt committed
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
    }
    // \}
    /*!
     * \name Boundary conditions
     */
    // \{

    /*!
     * \brief Specifies which kind of boundary condition should be
     *        used for which equation on a given boundary control volume.
     *
     * \param values The boundary types for the conservation equations
     * \param globalPos The position of the center of the finite volume
     */
    BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
    {
        BoundaryTypes values;

        Scalar eps = 1.0e-6;
        if (globalPos[dimWorld-1] < eps || globalPos[dimWorld-1] > this->bBoxMax()[dimWorld-1] - eps)
            values.setAllDirichlet();
        else
            values.setAllNeumann();

        return values;
    }

    /*!
     * \brief Evaluate the boundary conditions for a dirichlet
     *        control volume.
     *
     * \param values The dirichlet values for the primary variables
     * \param globalPos The center of the finite volume which ought to be set.
     *
     * For this method, the \a values parameter stores primary variables.
     */
216
    CellCenterPrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
Kilian Weishaupt's avatar
Kilian Weishaupt committed
217
    {
218
        CellCenterPrimaryVariables values(0);
Kilian Weishaupt's avatar
Kilian Weishaupt committed
219
220
221
222
223
224
225
226
227
228
229
230
        values[pressureIdx] = 1.0e+5*(2.0 - globalPos[dimWorld-1]);
        return values;
    }

    /*!
     * \brief Evaluate the boundary conditions for a neumann
     *        boundary segment.
     *
     * For this method, the \a priVars parameter stores the mass flux
     * in normal direction of each component. Negative values mean
     * influx.
     */
231
    CellCenterPrimaryVariables neumannAtPos(const GlobalPosition& globalPos) const
Kilian Weishaupt's avatar
Kilian Weishaupt committed
232
    {
233
        return CellCenterPrimaryVariables(0);
Kilian Weishaupt's avatar
Kilian Weishaupt committed
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
    }

    // \}

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

    /*!
     * \brief Evaluate the initial value for a control volume.
     *
     * For this method, the \a priVars parameter stores primary
     * variables.
     */
249
    CellCenterPrimaryVariables initialCCValuesAtPos(const GlobalPosition &globalPos) const
Kilian Weishaupt's avatar
Kilian Weishaupt committed
250
    {
251
        CellCenterPrimaryVariables priVars(0);
Kilian Weishaupt's avatar
Kilian Weishaupt committed
252
253
254
255
        priVars[pressureIdx] = 1.0e+5;
        return priVars;
    }

256

257
    /*!
258
259
260
261
262
     * \brief Evaluate the initial value for a facet.
     *
     * \param globalPos The position of the center of the finite volume
     *            for which the initial values ought to be
     *            set (in global coordinates)
263
     * \param direction The direction index of the facets unit outer normal
264
     */
265
    GlobalPosition initialVelocityAtPos(const GlobalPosition &globalPos) const
266
    {
267
268
269
270
        GlobalPosition velocity;
        velocity[0] = 1.0;
        velocity[1] = 0.0;
        return velocity;
271
272
273

    }

274
275
276
277
278
279
280
281
282
     /*!
     * \brief Evaluate the boundary conditions for a dirichlet
     *        facet.
     *
     * \param globalPos The position of the center of the finite volume
     *            for which the dirichlet condition ought to be
     *            set in global coordinates
     * \param direction The direction index of the facets unit outer normal
     */
283
284
285
286
287
288
289
290
    GlobalPosition dirichletVelocityAtPos(const GlobalPosition &pos) const
    {
        GlobalPosition velocity;
        velocity[0] = 1.0;
        velocity[1] = 0.0;
        return velocity;
    }

Kilian Weishaupt's avatar
Kilian Weishaupt committed
291
292
293
294
295
296
297
298
    // \}

private:
    std::string name_;
};
} //end namespace

#endif