effectivediffusivityconstanttauproblem.hh 7.08 KB
Newer Older
Thomas Fetzer's avatar
[test]  
Thomas Fetzer 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
 *
Thomas Fetzer's avatar
Thomas Fetzer committed
22
 * \brief Test for the constant tau effective diffusivity model
Thomas Fetzer's avatar
[test]  
Thomas Fetzer committed
23
 */
Thomas Fetzer's avatar
Thomas Fetzer committed
24
25
#ifndef DUMUX_EFFECTIVE_DIFFUSIVITY_CONSTANT_TAU_PROBLEM_HH
#define DUMUX_EFFECTIVE_DIFFUSIVITY_CONSTANT_TAU_PROBLEM_HH
Thomas Fetzer's avatar
[test]  
Thomas Fetzer committed
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

#include <dune/grid/io/file/dgfparser/dgfyasp.hh>

#include <dumux/material/fluidsystems/h2on2fluidsystem.hh>

#include <dumux/implicit/2p2c/2p2cmodel.hh>
#include <dumux/implicit/common/implicitporousmediaproblem.hh>
#include <dumux/material/fluidmatrixinteractions/diffusivityconstanttau.hh>

#include "effectivediffusivityspatialparams.hh"

#define ISOTHERMAL 0

namespace Dumux
{
template <class TypeTag>
class EffectiveDiffusivityConstantTauProblem;

namespace Properties
{
NEW_TYPE_TAG(EffectiveDiffusivityConstantTauProblem, INHERITS_FROM(BoxModel, TwoPTwoCNI, EffectiveDiffusivitySpatialParams));
47

Thomas Fetzer's avatar
[test]  
Thomas Fetzer committed
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Set the grid type
SET_TYPE_PROP(EffectiveDiffusivityConstantTauProblem, Grid, Dune::YaspGrid<2>);

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

// Set the wetting phase
SET_TYPE_PROP(EffectiveDiffusivityConstantTauProblem, FluidSystem, Dumux::FluidSystems::H2ON2<typename GET_PROP_TYPE(TypeTag, Scalar), false>);

// Set thermal conductivity law
SET_TYPE_PROP(EffectiveDiffusivityConstantTauProblem, EffectiveDiffusivityModel,
              DiffusivityConstantTau<TypeTag, typename GET_PROP_TYPE(TypeTag, Scalar)>);
}


/*!
 * \ingroup MaterialTestProblems
 *
Thomas Fetzer's avatar
Thomas Fetzer committed
66
 * \brief Test for the constant tau effective diffusivity model
Thomas Fetzer's avatar
[test]  
Thomas Fetzer committed
67
68
 *
 * To run the test execute the following line in shell:
Thomas Fetzer's avatar
Thomas Fetzer committed
69
 * <tt>./test_effectivediffusivityconstanttau</tt>
Thomas Fetzer's avatar
[test]  
Thomas Fetzer committed
70
71
72
73
74
75
76
77
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
103
104
105
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
135
136
 *
 */
template <class TypeTag >
class EffectiveDiffusivityConstantTauProblem : public ImplicitPorousMediaProblem<TypeTag>
{
    typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
    typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView;
    typedef typename GridView::Grid Grid;

    typedef ImplicitPorousMediaProblem<TypeTag> ParentType;
    typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;

    // copy some indices for convenience
    typedef typename GET_PROP_TYPE(TypeTag, Indices) Indices;
    enum {
        pressureIdx = Indices::pressureIdx,
        switchIdx = Indices::switchIdx,
        temperatureIdx = Indices::temperatureIdx,

        // Phase State
        wPhaseOnly = Indices::wPhaseOnly,

        // Grid and world dimension
        dim = GridView::dimension,
        dimWorld = GridView::dimensionworld
    };

    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::template Codim<dim>::Entity Vertex;
    typedef typename GridView::Intersection Intersection;

    typedef typename GET_PROP_TYPE(TypeTag, FVElementGeometry) FVElementGeometry;

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

    //! property that defines whether mole or mass fractions are used
    static const bool useMoles = GET_PROP_VALUE(TypeTag, UseMoles);

public:
    /*!
     * \brief The constructor.
     *
     * \param timeManager The time manager
     * \param gridView The grid view
     */
    EffectiveDiffusivityConstantTauProblem(TimeManager &timeManager, const GridView &gridView)
        : ParentType(timeManager, gridView)
    {
        FluidSystem::init();
        this->spatialParams().plotMaterialLaw();
    }

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

    /*!
     * \brief The problem name.
     *
     * This is used as a prefix for files generated by the simulation.
     */
    const std::string name() const
137
    { return "test_effectivediffusivity_ct"; }
Thomas Fetzer's avatar
[test]  
Thomas Fetzer committed
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155


    //! \copydoc Dumux::ImplicitProblem::sourceAtPos()
    void sourceAtPos(PrimaryVariables &values,
                     const GlobalPosition &globalPos) const
    {
        values = 0;
    }

    // \}

    /*!
     * \name Boundary conditions
     */
    // \{


    //! \copydoc Dumux::ImplicitProblem::boundaryTypesAtPos()
156
    void boundaryTypesAtPos(BoundaryTypes &values,
Thomas Fetzer's avatar
[test]  
Thomas Fetzer committed
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
                            const GlobalPosition &globalPos) const
    {
        values.setAllDirichlet();
    }


    //! \copydoc Dumux::ImplicitProblem::dirichletAtPos()
    void dirichletAtPos(PrimaryVariables &values, const GlobalPosition &globalPos) const
    {
        initial_(values, globalPos);
    }


    //! \copydoc Dumux::ImplicitProblem::neumann()
    void neumann(PrimaryVariables &values,
                 const Element &element,
                 const FVElementGeometry &fvGeometry,
                 const Intersection &intersection,
                 const int scvIdx,
                 const int boundaryFaceIdx) const
    {
        values = 0;
    }

    // \}

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


    //! \copydoc Dumux::ImplicitProblem::initialAtPos()
    void initialAtPos(PrimaryVariables &values, const GlobalPosition &globalPos) const
    {
        initial_(values, globalPos);
    }


Thomas Fetzer's avatar
Thomas Fetzer committed
196
    //! \copydoc Dumux::InjectionProblem::initialPhasePresence()
Thomas Fetzer's avatar
[test]  
Thomas Fetzer committed
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
    int initialPhasePresence(const Vertex &vertex,
                             int &vIdxGlobal,
                             const GlobalPosition &globalPos) const
    {
        return wPhaseOnly;
    }

private:
    // internal method for the initial condition (reused for the
    // dirichlet conditions!)
    void initial_(PrimaryVariables &values,
                  const GlobalPosition &globalPos) const
    {
        Scalar densityW = 1000.0;
        values[pressureIdx] = 1e5 + globalPos[1]*densityW*9.81;
        values[switchIdx] = 0.0;
        values[temperatureIdx] = 283.0 + globalPos[1]*0.03;
    }
};
} //end namespace

#endif