problem.hh 16 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
 * \ingroup RANSNCTests
22
 * \brief Flat plate test for the multi-component staggered grid Reynolds-averaged Navier-Stokes model
23
24
25
26
 */
#ifndef DUMUX_RANS_NC_TEST_PROBLEM_HH
#define DUMUX_RANS_NC_TEST_PROBLEM_HH

27
28
#include <dune/grid/yaspgrid.hh>

29
#include <dumux/discretization/staggered/freeflow/properties.hh>
30
#include <dumux/material/fluidsystems/1padapter.hh>
31
#include <dumux/material/fluidsystems/h2oair.hh>
32
#include <dumux/freeflow/turbulenceproperties.hh>
33

34
35
36
#if LOWREKEPSILON
#include <dumux/freeflow/compositional/lowrekepsilonncmodel.hh>
#include <dumux/freeflow/rans/twoeq/lowrekepsilon/problem.hh>
37
38
39
#elif KEPSILON
#include <dumux/freeflow/compositional/kepsilonncmodel.hh>
#include <dumux/freeflow/rans/twoeq/kepsilon/problem.hh>
40
41
42
#elif KOMEGA
#include <dumux/freeflow/compositional/komegancmodel.hh>
#include <dumux/freeflow/rans/twoeq/komega/problem.hh>
43
44
45
#elif ONEEQ
#include <dumux/freeflow/compositional/oneeqncmodel.hh>
#include <dumux/freeflow/rans/oneeq/problem.hh>
46
47
#else
#include <dumux/freeflow/compositional/zeroeqncmodel.hh>
48
#include <dumux/freeflow/rans/zeroeq/problem.hh>
49
#endif
50
51
52
53

namespace Dumux
{
template <class TypeTag>
54
class FlatPlateNCTestProblem;
55
56
57
58

namespace Properties
{

59
60
// Create new type tags
namespace TTag {
61
#if NONISOTHERMAL
62
  #if LOWREKEPSILON
63
  struct FlatPlateNCTest { using InheritsFrom = std::tuple<LowReKEpsilonNCNI, StaggeredFreeFlowModel>; };
64
  #elif KEPSILON
65
  struct FlatPlateNCTest { using InheritsFrom = std::tuple<KEpsilonNCNI, StaggeredFreeFlowModel>; };
66
  #elif KOMEGA
67
  struct FlatPlateNCTest { using InheritsFrom = std::tuple<KOmegaNCNI, StaggeredFreeFlowModel>; };
68
  #elif ONEEQ
69
  struct FlatPlateNCTest { using InheritsFrom = std::tuple<OneEqNCNI, StaggeredFreeFlowModel>; };
70
  #else
71
  struct FlatPlateNCTest { using InheritsFrom = std::tuple<ZeroEqNCNI, StaggeredFreeFlowModel>; };
72
  #endif
73
#else
74
  #if LOWREKEPSILON
75
  struct FlatPlateNCTest { using InheritsFrom = std::tuple<LowReKEpsilonNC, StaggeredFreeFlowModel>; };
76
  #elif KEPSILON
77
  struct FlatPlateNCTest { using InheritsFrom = std::tuple<KEpsilonNC, StaggeredFreeFlowModel>; };
78
  #elif KOMEGA
79
  struct FlatPlateNCTest { using InheritsFrom = std::tuple<KOmegaNC, StaggeredFreeFlowModel>; };
80
  #elif ONEEQ
81
  struct FlatPlateNCTest { using InheritsFrom = std::tuple<OneEqNC, StaggeredFreeFlowModel>; };
82
  #else
83
  struct FlatPlateNCTest { using InheritsFrom = std::tuple<ZeroEqNC, StaggeredFreeFlowModel>; };
84
  #endif
85
#endif
86
} // end namespace TTag
87

88
// The fluid system
89
SET_PROP(FlatPlateNCTest, FluidSystem)
90
{
91
  using H2OAir = FluidSystems::H2OAir<GetPropType<TypeTag, Properties::Scalar>>;
92
93
94
  static constexpr auto phaseIdx = H2OAir::gasPhaseIdx; // simulate the air phase
  using type = FluidSystems::OnePAdapter<H2OAir, phaseIdx>;
};
95

96
// replace the main component balance eq with a total balance eq
97
98
template<class TypeTag>
struct ReplaceCompEqIdx<TypeTag, TTag::FlatPlateNCTest> { static constexpr int value = 0; };
99
100

// Set the grid type
101
102
103
template<class TypeTag>
struct Grid<TypeTag, TTag::FlatPlateNCTest>
{ using type = Dune::YaspGrid<2, Dune::TensorProductCoordinates<GetPropType<TypeTag, Properties::Scalar>, 2> >; };
104
105

// Set the problem property
106
107
template<class TypeTag>
struct Problem<TypeTag, TTag::FlatPlateNCTest> { using type = Dumux::FlatPlateNCTestProblem<TypeTag> ; };
108

109
110
template<class TypeTag>
struct EnableFVGridGeometryCache<TypeTag, TTag::FlatPlateNCTest> { static constexpr bool value = true; };
111

112
113
114
115
template<class TypeTag>
struct EnableGridFluxVariablesCache<TypeTag, TTag::FlatPlateNCTest> { static constexpr bool value = true; };
template<class TypeTag>
struct EnableGridVolumeVariablesCache<TypeTag, TTag::FlatPlateNCTest> { static constexpr bool value = true; };
116
117

// Enable gravity
118
119
template<class TypeTag>
struct UseMoles<TypeTag, TTag::FlatPlateNCTest> { static constexpr bool value = true; };
120
} // end namespace Properties
121
122
123
124

/*!
 * \ingroup RANSNCTests
 * \brief  Test problem for the one-phase model.
125
 *
126
 * Dry air is entering from the left side and flows above a 1-D a flat plate.
127
128
129
 * In the middle of the inlet, water vapor is injected, which spreads by turbulent diffusion.
 * For the nonisothermal model the bottom has a constant temperature
 * which is \f$ \unit[30]{K} \f$ higher than the initial and inlet temperature.
130
131
 */
template <class TypeTag>
132
#if LOWREKEPSILON
133
class FlatPlateNCTestProblem : public LowReKEpsilonProblem<TypeTag>
134
135
{
    using ParentType = LowReKEpsilonProblem<TypeTag>;
136
137
138
139
#elif KEPSILON
class FlatPlateNCTestProblem : public KEpsilonProblem<TypeTag>
{
    using ParentType = KEpsilonProblem<TypeTag>;
140
141
142
143
#elif KOMEGA
class FlatPlateNCTestProblem : public KOmegaProblem<TypeTag>
{
    using ParentType = KOmegaProblem<TypeTag>;
144
145
146
147
#elif ONEEQ
class FlatPlateNCTestProblem : public OneEqProblem<TypeTag>
{
    using ParentType = OneEqProblem<TypeTag>;
148
#else
149
class FlatPlateNCTestProblem : public ZeroEqProblem<TypeTag>
150
{
151
    using ParentType = ZeroEqProblem<TypeTag>;
152
#endif
153

154
155
156
157
158
159
160
161
    using BoundaryTypes = GetPropType<TypeTag, Properties::BoundaryTypes>;
    using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
    using FluidState = GetPropType<TypeTag, Properties::FluidState>;
    using FVGridGeometry = GetPropType<TypeTag, Properties::FVGridGeometry>;
    using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
    using NumEqVector = GetPropType<TypeTag, Properties::NumEqVector>;
    using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
    using Scalar = GetPropType<TypeTag, Properties::Scalar>;
162

163
164
    using Element = typename FVGridGeometry::GridView::template Codim<0>::Entity;
    using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
165
    using FVElementGeometry = typename GetPropType<TypeTag, Properties::FVGridGeometry>::LocalView;
166
167
    using SubControlVolume = typename FVElementGeometry::SubControlVolume;
    using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
168
169
170

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

171
    static constexpr auto dimWorld = GetPropType<TypeTag, Properties::GridView>::dimensionworld;
172
173
    static constexpr auto transportEqIdx = Indices::conti0EqIdx + 1;
    static constexpr auto transportCompIdx = Indices::conti0EqIdx + 1;
174

175
public:
176
    FlatPlateNCTestProblem(std::shared_ptr<const FVGridGeometry> fvGridGeometry)
177
178
179
    : ParentType(fvGridGeometry), eps_(1e-6)
    {
        inletVelocity_ = getParam<Scalar>("Problem.InletVelocity");
180

181
        FluidSystem::init();
182
183
        Dumux::TurbulenceProperties<Scalar, dimWorld, true> turbulenceProperties;
        FluidState fluidState;
184
        const auto phaseIdx = 0;
185
186
187
188
189
190
        fluidState.setPressure(phaseIdx, 1e5);
        fluidState.setTemperature(temperature());
        fluidState.setMassFraction(phaseIdx, phaseIdx, 1.0);
        Scalar density = FluidSystem::density(fluidState, phaseIdx);
        Scalar kinematicViscosity = FluidSystem::viscosity(fluidState, phaseIdx) / density;
        Scalar diameter = this->fvGridGeometry().bBoxMax()[1] - this->fvGridGeometry().bBoxMin()[1];
191
        viscosityTilde_ = 1e-3 * turbulenceProperties.viscosityTilde(inletVelocity_, diameter, kinematicViscosity);
192
        turbulentKineticEnergy_ = turbulenceProperties.turbulentKineticEnergy(inletVelocity_, diameter, kinematicViscosity);
193
194
195
#if KOMEGA
        dissipation_ = turbulenceProperties.dissipationRate(inletVelocity_, diameter, kinematicViscosity);
#else
196
197
        dissipation_ = turbulenceProperties.dissipation(inletVelocity_, diameter, kinematicViscosity);
#endif
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
    }

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

    bool shouldWriteRestartFile() const
    {
        return false;
    }

   /*!
     * \brief Return the temperature within the domain in [K].
     *
213
     * The isothermal problem assumes a temperature of 10 degrees Celsius.
214
215
216
217
218
219
220
221
222
223
224
225
226
     */
    Scalar temperature() const
    { return 273.15 + 10; } // 10C

   /*!
     * \brief Return the sources within the domain.
     *
     * \param globalPos The global position
     */
    NumEqVector sourceAtPos(const GlobalPosition &globalPos) const
    {
        return NumEqVector(0.0);
    }
227

228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
    // \}
   /*!
     * \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;

244
        if(isInlet_(globalPos))
245
        {
246
247
248
249
            values.setDirichlet(Indices::velocityXIdx);
            values.setDirichlet(Indices::velocityYIdx);
            values.setDirichlet(transportCompIdx);

250
#if NONISOTHERMAL
251
252
253
            values.setDirichlet(Indices::temperatureIdx);
#endif

254
#if KEPSILON || KOMEGA || LOWREKEPSILON
255
256
            values.setDirichlet(Indices::turbulentKineticEnergyIdx);
            values.setDirichlet(Indices::dissipationIdx);
257
258
259
#endif
#if ONEEQ
            values.setDirichlet(Indices::viscosityTildeIdx);
260
261
#endif
        }
262
        else if(isOutlet_(globalPos))
263
        {
264
            values.setDirichlet(Indices::pressureIdx);
265
            values.setOutflow(transportEqIdx);
266

267
#if NONISOTHERMAL
268
            values.setOutflow(Indices::energyEqIdx);
269
#endif
270

271
#if KEPSILON || KOMEGA || LOWREKEPSILON
272
273
            values.setOutflow(Indices::turbulentKineticEnergyEqIdx);
            values.setOutflow(Indices::dissipationEqIdx);
274
275
276
#endif
#if ONEEQ
            values.setOutflow(Indices::viscosityTildeIdx);
277
278
#endif
        }
279
        else if(isOnWallAtPos(globalPos))
280
        {
281
282
283
284
            values.setDirichlet(Indices::velocityXIdx);
            values.setDirichlet(Indices::velocityYIdx);
            values.setNeumann(transportEqIdx);

285
#if NONISOTHERMAL
286
287
288
            values.setDirichlet(Indices::temperatureIdx);
#endif

289
#if KEPSILON || LOWREKEPSILON
290
291
            values.setDirichlet(Indices::turbulentKineticEnergyEqIdx);
            values.setDirichlet(Indices::dissipationEqIdx);
292
293
#elif KOMEGA
            values.setDirichlet(Indices::turbulentKineticEnergyEqIdx);
294
295
296
#endif
#if ONEEQ
            values.setDirichlet(Indices::viscosityTildeIdx);
297
298
#endif
        }
299
300
301
302
        else
        {
            values.setAllSymmetry();
        }
303
304
305
306

        return values;
    }

307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
#if KOMEGA
    /*!
     * \brief Returns whether a fixed Dirichlet value shall be used at a given cell.
     *
     * \param element The finite element
     * \param fvGeometry The finite-volume geometry
     * \param scv The sub control volume
     */
    template<class Element, class FVElementGeometry, class SubControlVolume>
    bool isDirichletCell(const Element& element,
                         const FVElementGeometry& fvGeometry,
                         const SubControlVolume& scv,
                         int pvIdx) const
    {
        // set a fixed dissipation (omega) for all cells at the wall
        for (const auto& scvf : scvfs(fvGeometry))
            if (isOnWallAtPos(scvf.center()) && pvIdx == Indices::dissipationIdx)
                return true;

        return false;
    }
#endif

330
331
    /*!
     * \brief Evaluate the boundary conditions for a dirichlet values at the boundary.
332
     *
333
334
335
     * \param element The finite element
     * \param scvf the sub control volume face
     * \note used for cell-centered discretization schemes
336
     */
337
    PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const
338
    {
339
        const auto globalPos = scvf.ipGlobal();
340
341
        PrimaryVariables values = initialAtPos(globalPos);

342
        if (time() > 10.0)
343
        {
344
            if (isInlet_(globalPos)
345
346
347
348
349
                && globalPos[1] > 0.4 * this->fvGridGeometry().bBoxMax()[1]
                && globalPos[1] < 0.6 * this->fvGridGeometry().bBoxMax()[1])
            {
                values[transportCompIdx] = 1e-3;
            }
350
#if NONISOTHERMAL
351
            if (isOnWallAtPos(globalPos))
352
            {
353
                values[Indices::temperatureIdx] += 30.;
354
            }
355
#endif
356
        }
357
358
359
360

        return values;
    }

361
362
363
364
365
366
367
368
369
370
371
372
373
     /*!
      * \brief Evaluate the boundary conditions for fixed values at cell centers
      *
      * \param element The finite element
      * \param scv the sub control volume
      * \note used for cell-centered discretization schemes
      */
    PrimaryVariables dirichlet(const Element &element, const SubControlVolume &scv) const
    {
        const auto globalPos = scv.center();
        PrimaryVariables values(initialAtPos(globalPos));
#if KOMEGA
        using std::pow;
374
375
376
        unsigned int elementIdx = this->fvGridGeometry().elementMapper().index(element);
        const auto wallDistance = ParentType::wallDistance_[elementIdx];
        values[Indices::dissipationEqIdx] = 6.0 * ParentType::kinematicViscosity_[elementIdx]
377
378
379
380
381
                                            / (ParentType::betaOmega() * pow(wallDistance, 2));
#endif
        return values;
    }

382
383
384
385
386
387
388
389
390
391
392
393
394
395
    // \}

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

   /*!
     * \brief Evaluate the initial value for a control volume.
     *
     * \param globalPos The global position
     */
    PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
    {
396
        PrimaryVariables values(0.0);
397
        values[Indices::pressureIdx] = 1.0e+5;
398
399
        values[transportCompIdx] = 0.0;
#if NONISOTHERMAL
400
        values[Indices::temperatureIdx] = temperature();
401
402
#endif

403
        // block velocity profile
404
        values[Indices::velocityXIdx] = 0.0;
405
        if (!isOnWallAtPos(globalPos))
406
407
            values[Indices::velocityXIdx] =  inletVelocity_;
        values[Indices::velocityYIdx] = 0.0;
408

409
#if KEPSILON || KOMEGA || LOWREKEPSILON
410
411
        values[Indices::turbulentKineticEnergyEqIdx] = turbulentKineticEnergy_;
        values[Indices::dissipationEqIdx] = dissipation_;
412
        if (isOnWallAtPos(globalPos))
413
414
415
416
417
418
        {
            values[Indices::turbulentKineticEnergyEqIdx] = 0.0;
            values[Indices::dissipationEqIdx] = 0.0;
        }
#endif

419
420
#if ONEEQ
        values[Indices::viscosityTildeIdx] = viscosityTilde_;
421
        if (isOnWallAtPos(globalPos))
422
423
424
425
426
        {
            values[Indices::viscosityTildeIdx] = 0.0;
        }
#endif

427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
        return values;
    }

    // \}

    void setTimeLoop(TimeLoopPtr timeLoop)
    {
        timeLoop_ = timeLoop;
    }

    Scalar time() const
    {
        return timeLoop_->time();
    }

442
    bool isOnWallAtPos(const GlobalPosition& globalPos) const
443
    {
444
445
446
        return globalPos[1] < eps_;
    }

447
448
private:

449
450

    bool isInlet_(const GlobalPosition& globalPos) const
451
452
453
454
    {
        return globalPos[0] < eps_;
    }

455
    bool isOutlet_(const GlobalPosition& globalPos) const
456
457
458
459
460
461
    {
        return globalPos[0] > this->fvGridGeometry().bBoxMax()[0] - eps_;
    }

    const Scalar eps_;
    Scalar inletVelocity_;
462
    Scalar viscosityTilde_;
463
464
    Scalar turbulentKineticEnergy_;
    Scalar dissipation_;
465
466
467
468
469
    TimeLoopPtr timeLoop_;
};
} //end namespace

#endif