problem.hh 5.79 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// -*- 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
21
22
 * \ingroup NavierStokesModel
 * \copydoc Dumux::NavierStokesProblem
23
24
25
26
 */
#ifndef DUMUX_NAVIERSTOKES_PROBLEM_HH
#define DUMUX_NAVIERSTOKES_PROBLEM_HH

27
#include <dumux/common/properties.hh>
28
#include <dumux/common/staggeredfvproblem.hh>
29
#include <dumux/discretization/methods.hh>
30
#include "model.hh"
31

32
namespace Dumux {
33
34

//! The implementation is specialized for the different discretizations
35
template<class TypeTag, DiscretizationMethod discMethod> struct NavierStokesParentProblemImpl;
36
37

template<class TypeTag>
38
struct NavierStokesParentProblemImpl<TypeTag, DiscretizationMethod::staggered>
39
40
41
42
43
44
45
46
{
    using type = StaggeredFVProblem<TypeTag>;
};

//! The actual NavierStokesParentProblem
template<class TypeTag>
using NavierStokesParentProblem =
      typename NavierStokesParentProblemImpl<TypeTag,
47
      GET_PROP_TYPE(TypeTag, FVGridGeometry)::discMethod>::type;
48

49
/*!
50
51
 * \ingroup NavierStokesModel
 * \brief Navier-Stokes problem base class.
52
53
 *
 * This implements gravity (if desired) and a function returning the temperature.
54
55
 * Includes a specialized method used only by the staggered grid discretization.
  *
56
57
 */
template<class TypeTag>
58
class NavierStokesProblem : public NavierStokesParentProblem<TypeTag>
59
{
60
    using ParentType = NavierStokesParentProblem<TypeTag>;
61
    using Implementation = typename GET_PROP_TYPE(TypeTag, Problem);
62

63
64
    using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry);
    using GridView = typename FVGridGeometry::GridView;
65
    using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
66

67
    using FVElementGeometry = typename FVGridGeometry::LocalView;
68
    using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
69
70
    using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector);
    using PrimaryVariables = typename GET_PROP_TYPE(TypeTag, PrimaryVariables);
71
    using Indices = typename GET_PROP_TYPE(TypeTag, ModelTraits)::Indices;
72
73

    enum {
74
75
        dim = GridView::dimension,
        dimWorld = GridView::dimensionworld
76
      };
77

78
    using GlobalPosition = Dune::FieldVector<Scalar, dimWorld>;
79
80

public:
81
82
83
84
85
86
87
88
    /*!
     * \brief The constructor
     * \param fvGridGeometry The finite volume grid geometry
     * \param paramGroup The parameter group in which to look for runtime parameters first (default is "")
     */
    NavierStokesProblem(std::shared_ptr<const FVGridGeometry> fvGridGeometry, const std::string& paramGroup = "")
    : ParentType(fvGridGeometry, paramGroup)
    , gravity_(0.0)
89
    {
90
        if (getParamFromGroup<bool>(paramGroup, "Problem.EnableGravity"))
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
            gravity_[dim-1]  = -9.81;
    }

    /*!
     * \brief Returns the temperature \f$\mathrm{[K]}\f$ at a given global position.
     *
     * This is not specific to the discretization. By default it just
     * calls temperature().
     *
     * \param globalPos The position in global coordinates where the temperature should be specified.
     */
    Scalar temperatureAtPos(const GlobalPosition &globalPos) const
    { return asImp_().temperature(); }

    /*!
     * \brief Returns the temperature within the domain.
     *
     * This method MUST be overwritten by the actual problem.
     */
    Scalar temperature() const
    { DUNE_THROW(Dune::NotImplemented, "temperature() method not implemented by the actual problem"); }

    /*!
     * \brief Returns the acceleration due to gravity.
     *
116
     * If the <tt>Problem.EnableGravity</tt> parameter is true, this means
117
118
119
120
121
     * \f$\boldsymbol{g} = ( 0,\dots,\ -9.81)^T \f$, else \f$\boldsymbol{g} = ( 0,\dots, 0)^T \f$
     */
    const GlobalPosition &gravity() const
    { return gravity_; }

122
    //! Applys the initial face solution (velocities on the faces). Specialization for staggered grid discretization.
123
124
    template <class G = FVGridGeometry>
    typename std::enable_if<G::discMethod == DiscretizationMethod::staggered, void>::type
Melanie Lipp's avatar
Melanie Lipp committed
125
    applyInitialFaceSolution(SolutionVector& sol,
126
127
128
                              const SubControlVolumeFace& scvf,
                              const PrimaryVariables& initSol) const
    {
129
        sol[FVGridGeometry::faceIdx()][scvf.dofIndex()][0] = initSol[Indices::velocity(scvf.directionIndex())];
130
131
    }

132
private:
133

134
135
136
137
138
139
140
141
142
143
144
    //! Returns the implementation of the problem (i.e. static polymorphism)
    Implementation &asImp_()
    { return *static_cast<Implementation *>(this); }

    //! \copydoc asImp_()
    const Implementation &asImp_() const
    { return *static_cast<const Implementation *>(this); }

    GlobalPosition gravity_;
};

145
} // end namespace Dumux
146
147

#endif