closedsystemtestproblem.hh 7.91 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
// -*- 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 A test problem for the staggered (Navier-) Stokes model
Kilian Weishaupt's avatar
Kilian Weishaupt committed
23
 */
24
25
#ifndef DUMUX_CLOSEDSYSTEM_TEST_PROBLEM_HH
#define DUMUX_CLOSEDSYSTEM_TEST_PROBLEM_HH
Kilian Weishaupt's avatar
Kilian Weishaupt committed
26

27
28
#include <dumux/freeflow/staggered/problem.hh>
#include <dumux/discretization/staggered/properties.hh>
Kilian Weishaupt's avatar
Kilian Weishaupt committed
29
30
#include <dumux/material/components/simpleh2o.hh>
#include <dumux/material/fluidsystems/liquidphase.hh>
31
32
#include <dumux/material/components/constant.hh>

33
34
35
#include <dumux/discretization/staggered/properties.hh>
#include <dumux/freeflow/staggered/properties.hh>

Kilian Weishaupt's avatar
Kilian Weishaupt committed
36
37
38
namespace Dumux
{
template <class TypeTag>
39
class ClosedSystemTestProblem;
Kilian Weishaupt's avatar
Kilian Weishaupt committed
40
41
42
43

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

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

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

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

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

66
SET_BOOL_PROP(ClosedSystemTestProblem, EnableFVGridGeometryCache, true);
Kilian Weishaupt's avatar
Kilian Weishaupt committed
67

68
69
SET_BOOL_PROP(ClosedSystemTestProblem, EnableGlobalFluxVariablesCache, true);
SET_BOOL_PROP(ClosedSystemTestProblem, EnableGlobalVolumeVariablesCache, true);
70

Kilian Weishaupt's avatar
Kilian Weishaupt committed
71
72
73
74
}

/*!
 * \brief  Test problem for the one-phase model:
75
   \todo doc me!
Kilian Weishaupt's avatar
Kilian Weishaupt committed
76
77
 */
template <class TypeTag>
78
class ClosedSystemTestProblem : public NavierStokesProblem<TypeTag>
Kilian Weishaupt's avatar
Kilian Weishaupt committed
79
{
80
    using ParentType = NavierStokesProblem<TypeTag>;
Kilian Weishaupt's avatar
Kilian Weishaupt committed
81

82
83
    using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
    using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
Kilian Weishaupt's avatar
Kilian Weishaupt committed
84
85

    // copy some indices for convenience
86
    using Indices = typename GET_PROP_TYPE(TypeTag, Indices);
Kilian Weishaupt's avatar
Kilian Weishaupt committed
87
88
89
90
91
92
    enum {
        // Grid and world dimension
        dim = GridView::dimension,
        dimWorld = GridView::dimensionworld
    };
    enum {
93
        massBalanceIdx = Indices::massBalanceIdx,
94
95
96
97
98
99
        momentumBalanceIdx = Indices::momentumBalanceIdx,
        momentumXBalanceIdx = Indices::momentumXBalanceIdx,
        momentumYBalanceIdx = Indices::momentumYBalanceIdx,
        pressureIdx = Indices::pressureIdx,
        velocityXIdx = Indices::velocityXIdx,
        velocityYIdx = Indices::velocityYIdx
Kilian Weishaupt's avatar
Kilian Weishaupt committed
100
101
    };

102
    using BoundaryTypes = typename GET_PROP_TYPE(TypeTag, BoundaryTypes);
Kilian Weishaupt's avatar
Kilian Weishaupt committed
103

104
105
    using Element = typename GridView::template Codim<0>::Entity;
    using Intersection = typename GridView::Intersection;
Kilian Weishaupt's avatar
Kilian Weishaupt committed
106

107
108
109
    using FVElementGeometry = typename GET_PROP_TYPE(TypeTag, FVElementGeometry);
    using SubControlVolume = typename GET_PROP_TYPE(TypeTag, SubControlVolume);
    using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry);
Kilian Weishaupt's avatar
Kilian Weishaupt committed
110

111
    using GlobalPosition = Dune::FieldVector<Scalar, dimWorld>;
Kilian Weishaupt's avatar
Kilian Weishaupt committed
112

113
114
115
    using CellCenterPrimaryVariables = typename GET_PROP_TYPE(TypeTag, CellCenterPrimaryVariables);
    using FacePrimaryVariables = typename GET_PROP_TYPE(TypeTag, FacePrimaryVariables);

116
117
    using BoundaryValues = typename GET_PROP_TYPE(TypeTag, BoundaryValues);
    using InitialValues = typename GET_PROP_TYPE(TypeTag, BoundaryValues);
118
    using SourceValues = typename GET_PROP_TYPE(TypeTag, BoundaryValues);
119
120
121
122
123
    using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector);

    using DofTypeIndices = typename GET_PROP(TypeTag, DofTypeIndices);
    typename DofTypeIndices::CellCenterIdx cellCenterIdx;
    typename DofTypeIndices::FaceIdx faceIdx;
124

Kilian Weishaupt's avatar
Kilian Weishaupt committed
125
public:
126
127
    ClosedSystemTestProblem(std::shared_ptr<const FVGridGeometry> fvGridGeometry)
    : ParentType(fvGridGeometry), eps_(1e-6)
Kilian Weishaupt's avatar
Kilian Weishaupt committed
128
    {
129
        lidVelocity_ = getParam<Scalar>("Problem.LidVelocity");
130
131

        using CellArray = std::array<unsigned int, dimWorld>;
132
133
        const CellArray numCells = getParam<CellArray>("Grid.Cells");
        cellSizeX_ = this->fvGridGeometry().bBoxMax()[0] / numCells[0];
Kilian Weishaupt's avatar
Kilian Weishaupt committed
134
135
136
137
138
139
140
141
    }

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


142
    bool shouldWriteRestartFile() const
143
144
145
146
    {
        return false;
    }

Kilian Weishaupt's avatar
Kilian Weishaupt committed
147
148
149
150
151
152
153
154
155
156
157
158
159
160
    /*!
     * \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
     */
161
    SourceValues sourceAtPos(const GlobalPosition &globalPos) const
Kilian Weishaupt's avatar
Kilian Weishaupt committed
162
    {
163
        return SourceValues(0.0);
Kilian Weishaupt's avatar
Kilian Weishaupt committed
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
    }
    // \}
    /*!
     * \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;

182
183
184
185
        // set Dirichlet values for the velocity everywhere
        values.setDirichlet(momentumBalanceIdx);

        // set a fixed pressure in one cell
186
        if (isLowerLeftCell_(globalPos))
187
            values.setDirichletCell(massBalanceIdx);
188
189
        else
            values.setNeumann(massBalanceIdx);
Kilian Weishaupt's avatar
Kilian Weishaupt committed
190
191
192
193

        return values;
    }

194
195
    /*!
     * \brief Return dirichlet boundary values at a given position
Kilian Weishaupt's avatar
Kilian Weishaupt committed
196
     *
197
     * \param globalPos The global position
Kilian Weishaupt's avatar
Kilian Weishaupt committed
198
     */
199
    BoundaryValues dirichletAtPos(const GlobalPosition &globalPos) const
Kilian Weishaupt's avatar
Kilian Weishaupt committed
200
    {
201
        BoundaryValues values;
202
203
204
        values[pressureIdx] = 1.1e+5;
        values[velocityXIdx] = 0.0;
        values[velocityYIdx] = 0.0;
205

206
        if(globalPos[1] > this->fvGridGeometry().bBoxMax()[1] - eps_)
207
            values[velocityXIdx] = lidVelocity_;
208

Kilian Weishaupt's avatar
Kilian Weishaupt committed
209
210
211
212
213
214
        return values;
    }

    /*!
     * \brief Evaluate the initial value for a control volume.
     *
215
     * \param globalPos The global position
Kilian Weishaupt's avatar
Kilian Weishaupt committed
216
     */
217
    InitialValues initialAtPos(const GlobalPosition &globalPos) const
218
    {
219
        InitialValues values;
220
221
222
        values[pressureIdx] = 1.0e+5;
        values[velocityXIdx] = 0.0;
        values[velocityYIdx] = 0.0;
223

224
        return values;
225
226
    }

Kilian Weishaupt's avatar
Kilian Weishaupt committed
227
228
229
    // \}

private:
230

231
    bool isLowerLeftCell_(const GlobalPosition& globalPos) const
232
233
234
235
236
    {
        return globalPos[0] < (0.5*cellSizeX_ + eps_) && globalPos[1] < eps_;
    }


237
238
    Scalar eps_;
    Scalar lidVelocity_;
239
    Scalar cellSizeX_;
Kilian Weishaupt's avatar
Kilian Weishaupt committed
240
241
242
243
};
} //end namespace

#endif