channeltestproblem.hh 8.84 KB
Newer Older
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
// -*- 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 Channel flow test for the staggered grid (Navier-)Stokes model
 */
#ifndef DUMUX_CHANNEL_TEST_PROBLEM_HH
#define DUMUX_CHANNEL_TEST_PROBLEM_HH

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

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

36
37
38
39
40
41
42
43
44
45
46
47
48
49
namespace Dumux
{
template <class TypeTag>
class ChannelTestProblem;

namespace Capabilities
{
    template<class TypeTag>
    struct isStationary<ChannelTestProblem<TypeTag>>
    { static const bool value = false; };
}

namespace Properties
{
50
#if !NONISOTHERMAL
51
NEW_TYPE_TAG(ChannelTestProblem, INHERITS_FROM(StaggeredModel, NavierStokes));
52
53
54
#else
NEW_TYPE_TAG(ChannelTestProblem, INHERITS_FROM(StaggeredModel, NavierStokesNI));
#endif
55
56
57
58

SET_PROP(ChannelTestProblem, Fluid)
{
private:
59
    using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
60
public:
61
62
63
#if NONISOTHERMAL
    using type = FluidSystems::LiquidPhase<Scalar, Dumux::SimpleH2O<Scalar> > ;
#else
64
    using type = FluidSystems::LiquidPhase<Scalar, Dumux::Components::Constant<1, Scalar> > ;
65
#endif
66
67
68
69
70
71
72
73
};

// Set the grid type
SET_TYPE_PROP(ChannelTestProblem, Grid, Dune::YaspGrid<2>);

// Set the problem property
SET_TYPE_PROP(ChannelTestProblem, Problem, Dumux::ChannelTestProblem<TypeTag> );

74
SET_BOOL_PROP(ChannelTestProblem, EnableFVGridGeometryCache, true);
75
76
77
78
79
80
81
82
83
84
85
86
87

SET_BOOL_PROP(ChannelTestProblem, EnableGlobalFluxVariablesCache, true);
SET_BOOL_PROP(ChannelTestProblem, EnableGlobalVolumeVariablesCache, true);


#if ENABLE_NAVIERSTOKES
SET_BOOL_PROP(ChannelTestProblem, EnableInertiaTerms, true);
#else
SET_BOOL_PROP(ChannelTestProblem, EnableInertiaTerms, false);
#endif
}

/*!
88
 * \brief  Test problem for the one-phase (Navier-) Stokes problem in a channel:
89
   \todo doc me!
90
91
92
93
 */
template <class TypeTag>
class ChannelTestProblem : public NavierStokesProblem<TypeTag>
{
94
95
96
97
    using ParentType = NavierStokesProblem<TypeTag>;

    using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
    using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
98
99
100


    // copy some indices for convenience
101
    using Indices = typename GET_PROP_TYPE(TypeTag, Indices);
102
103
104
105
106
107
108
    enum {
        // Grid and world dimension
        dim = GridView::dimension,
        dimWorld = GridView::dimensionworld
    };
    enum {
        massBalanceIdx = Indices::massBalanceIdx,
109
110
111
112
        momentumBalanceIdx = Indices::momentumBalanceIdx,
        momentumXBalanceIdx = Indices::momentumXBalanceIdx,
        momentumYBalanceIdx = Indices::momentumYBalanceIdx,
        pressureIdx = Indices::pressureIdx,
113
114
115
116
#if NONISOTHERMAL
        temperatureIdx = Indices::temperatureIdx,
        energyBalanceIdx = Indices::energyBalanceIdx,
#endif
117
118
        velocityXIdx = Indices::velocityXIdx,
        velocityYIdx = Indices::velocityYIdx
119
120
    };

121
    using BoundaryTypes = typename GET_PROP_TYPE(TypeTag, BoundaryTypes);
122

123
    using Element = typename GridView::template Codim<0>::Entity;
124

125
    using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry);
126
127
    using FVElementGeometry = typename GET_PROP_TYPE(TypeTag, FVElementGeometry);
    using SubControlVolume = typename GET_PROP_TYPE(TypeTag, SubControlVolume);
128

129
    using GlobalPosition = Dune::FieldVector<Scalar, dimWorld>;
130
131
132
133

    using CellCenterPrimaryVariables = typename GET_PROP_TYPE(TypeTag, CellCenterPrimaryVariables);
    using FacePrimaryVariables = typename GET_PROP_TYPE(TypeTag, FacePrimaryVariables);

134
135
    using BoundaryValues = typename GET_PROP_TYPE(TypeTag, BoundaryValues);
    using InitialValues = typename GET_PROP_TYPE(TypeTag, BoundaryValues);
136
    using SourceValues = typename GET_PROP_TYPE(TypeTag, BoundaryValues);
137

138
139
    using TimeLoopPtr = std::shared_ptr<CheckPointTimeLoop<Scalar>>;

140
public:
141
142
    ChannelTestProblem(std::shared_ptr<const FVGridGeometry> fvGridGeometry)
    : ParentType(fvGridGeometry), eps_(1e-6)
143
    {
144
        inletVelocity_ = getParam<Scalar>("Problem.InletVelocity");
145
146
147
148
149
150
151
    }

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

152

153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
    bool shouldWriteRestartFile() const
    {
        return false;
    }

    /*!
     * \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 globalPos The global position
     */
171
    SourceValues sourceAtPos(const GlobalPosition &globalPos) const
172
    {
173
        return SourceValues(0.0);
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
    }
    // \}
    /*!
     * \name Boundary conditions
     */
    // \{

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

        // set Dirichlet values for the velocity everywhere
        values.setDirichlet(momentumBalanceIdx);

194
195
196
197
198
199
200
#if NONISOTHERMAL
        if(isInlet(globalPos))
            values.setDirichlet(energyBalanceIdx);
        else
            values.setOutflow(energyBalanceIdx);
#endif

201
202
203
204
205
206
207
        // set a fixed pressure in one cell
        if (isOutlet(globalPos))
        {
            values.setDirichlet(massBalanceIdx);
            values.setOutflow(momentumBalanceIdx);
        }
        else
208
            values.setOutflow(massBalanceIdx);
209
210
211
212
213
214
215
216
217
218

        return values;
    }

    /*!
     * \brief Evaluate the boundary conditions for a dirichlet
     *        control volume.
     *
     * \param globalPos The center of the finite volume which ought to be set.
     */
219
    BoundaryValues dirichletAtPos(const GlobalPosition &globalPos) const
220
    {
221
        BoundaryValues values = initialAtPos(globalPos);
222
223
224

        if(isInlet(globalPos))
        {
225
            values[velocityXIdx] = inletVelocity_;
226
227
#if NONISOTHERMAL
        // give the system some time so that the pressure can equilibrate, then start the injection of the hot liquid
228
        if(time() >= 200.0)
229
230
            values[temperatureIdx] = 293.15;
#endif
231
232
        }

233
234
235
236
237
238
239
240
241
242
243
244
245
        return values;
    }

    // \}

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

    /*!
     * \brief Evaluate the initial value for a control volume.
     *
246
     * \param globalPos The global position
247
     */
248
    InitialValues initialAtPos(const GlobalPosition &globalPos) const
249
    {
250
        InitialValues values;
251
252
253
        values[pressureIdx] = 1.1e+5;
        values[velocityXIdx] = 0.0;
        values[velocityYIdx] = 0.0;
254

255
256
257
258
#if NONISOTHERMAL
        values[temperatureIdx] = 283.15;
#endif

259
        return values;
260
261
262
    }

    // \}
263
264
265
266
267
268
269
270
271
272
273
    void setTimeLoop(TimeLoopPtr timeLoop)
    {
        timeLoop_ = timeLoop;
        if(inletVelocity_ > eps_)
            timeLoop_->setCheckPoint({200.0, 210.0});
    }

    Scalar time() const
    {
        return timeLoop_->time();
    }
274
275
276
277
278
279
280
281
282
283

private:

    bool isInlet(const GlobalPosition& globalPos) const
    {
        return globalPos[0] < eps_;
    }

    bool isOutlet(const GlobalPosition& globalPos) const
    {
284
        return globalPos[0] > this->fvGridGeometry().bBoxMax()[0] - eps_;
285
286
287
288
    }

    bool isWall(const GlobalPosition& globalPos) const
    {
289
        return globalPos[0] > eps_ || globalPos[0] < this->fvGridGeometry().bBoxMax()[0] - eps_;
290
291
292
293
    }

    Scalar eps_;
    Scalar inletVelocity_;
294
    TimeLoopPtr timeLoop_;
295
296
297
298
};
} //end namespace

#endif