mpfalinteractionvolume3dadaptive.hh 11.6 KB
Newer Older
1
2
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
3
/*****************************************************************************
4
 *   See the file COPYING for full copying permissions.                      *
5
6
7
8
9
10
11
12
 *                                                                           *
 *   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          *
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the            *
14
15
16
17
18
 *   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/>.   *
 *****************************************************************************/
19

20
21
22
23
24
25
26
27
28
29
30
31
32
#ifndef DUMUX_FVMPFAL3DINTERACTIONVOLUME_ADAPTIVE_HH
#define DUMUX_FVMPFAL3DINTERACTIONVOLUME_ADAPTIVE_HH

/**
 * @file
 * @brief  Class including the information of an interaction volume of a MPFA 3D method that does not change with time
 * @author Markus Wolff
 */

#include "mpfalinteractionvolume3d.hh"

namespace Dumux
{
Markus Wolff's avatar
Markus Wolff committed
33
34
//! \cond \private
// Mapper for local interaction volume indices (see doc/docextra/3dmpfa).
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
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
class IndexTranslatorAdaptive: public IndexTranslator
{
public:
    enum
    {
        subVolumeTotalNum = 8,
        fluxFacesTotalNum = 12,
        fluxFacesNumOnSubVolume = 3,
        fluxEdgesTotalNum = 6,
        edgesNumOnFluxFace = 2
    };

    static int getOldElemIdxFromNewFaceIdxto0(int zeroFaceIdx, int elementIdx)
    {
        return oldElemIdxFromNewFaceIdxto0_[zeroFaceIdx][elementIdx];
    }

    static int getNewElemIdxFromOldFaceIdxto0(int zeroFaceIdx, int elementIdx)
    {
        return newElemIdxFromOldFaceIdxto0_[zeroFaceIdx][elementIdx];
    }

    static int getOldFaceIdxFromNewIdxto0(int zeroFaceIdx, int faceIdx)
    {
        return oldFaceIdxFromNewIdxto0_[zeroFaceIdx][faceIdx];
    }

    static int getNewFaceIdxFromOldIdxto0(int zeroFaceIdx, int faceIdx)
    {
        return newFaceIdxFromOldIdxto0_[zeroFaceIdx][faceIdx];
    }

    static int getOldEdgeIdxFromNewFaceIdxto0(int zeroFaceIdx, int edgeIdx)
    {
        return oldEdgeIdxFromNewFaceIdxto0_[zeroFaceIdx][edgeIdx];
    }

    static int getNewEdgeIdxFromOldFaceIdxto0(int zeroFaceIdx, int edgeIdx)
    {
        return newEdgeIdxFromOldFaceIdxto0_[zeroFaceIdx][edgeIdx];
    }


private:
    static const int oldElemIdxFromNewFaceIdxto0_[fluxFacesTotalNum][subVolumeTotalNum];
    static const int newElemIdxFromOldFaceIdxto0_[fluxFacesTotalNum][subVolumeTotalNum];
    static const int oldFaceIdxFromNewIdxto0_[fluxFacesTotalNum][fluxFacesTotalNum];
    static const int newFaceIdxFromOldIdxto0_[fluxFacesTotalNum][fluxFacesTotalNum];
    static const int oldEdgeIdxFromNewFaceIdxto0_[fluxFacesTotalNum][fluxEdgesTotalNum];
    static const int newEdgeIdxFromOldFaceIdxto0_[fluxFacesTotalNum][fluxEdgesTotalNum];
};

const int IndexTranslatorAdaptive::oldElemIdxFromNewFaceIdxto0_[fluxFacesTotalNum][subVolumeTotalNum] =
{
        {0, 1, 2, 3, 4, 5, 6, 7},
        {1, 3, 0, 2, 5, 7, 4, 6},
        {3, 2, 1, 0, 7, 6, 5, 4},
        {2, 0, 3, 1, 6, 4, 7, 5},
        {5, 4, 7, 6, 1, 0, 3, 2},
        {7, 5, 6, 4, 3, 1, 2, 0},
        {6, 7, 4, 5, 2, 3, 0, 1},
        {4, 6, 5, 7, 0, 2, 1, 3},
        {0, 4, 1, 5, 2, 6, 3, 7},
        {1, 5, 3, 7, 0, 4, 2, 6},
        {3, 7, 2, 6, 1, 5, 0, 4},
        {2, 6, 0, 4, 3, 7, 1, 5}
};

const int IndexTranslatorAdaptive::newElemIdxFromOldFaceIdxto0_[fluxFacesTotalNum][subVolumeTotalNum] =
{
    {0, 1, 2, 3, 4, 5, 6, 7},
    {2, 0, 3, 1, 6, 4, 7, 5},
    {3, 2, 1, 0, 7, 6, 5, 4},
    {1, 3, 0, 2, 5, 7, 4, 6},
    {5, 4, 7, 6, 1, 0, 3, 2},
    {7, 5, 6, 4, 3, 1, 2, 0},
    {6, 7, 4, 5, 2, 3, 0, 1},
    {4, 6, 5, 7, 0, 2, 1, 3},
    {0, 2, 4, 6, 1, 3, 5, 7},
    {4, 0, 6, 2, 5, 1, 7, 3},
    {6, 4, 2, 0, 7, 5, 3, 1},
    {2, 6, 0, 4, 3, 7, 1, 5}
};

const int IndexTranslatorAdaptive::oldFaceIdxFromNewIdxto0_[fluxFacesTotalNum][fluxFacesTotalNum] =
{
        {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11},
        {1, 2, 3, 0, 5, 6, 7, 4, 9, 10, 11, 8},
        {2, 3, 0, 1, 6, 7, 4, 5, 10, 11, 8, 9},
        {3, 0, 1, 2, 7, 4, 5, 6, 11, 8, 9, 10},
        {4, 7, 6, 5, 0, 3, 2, 1, 9, 8, 11, 10},
        {5, 4, 7, 6, 1, 0, 3, 2, 10, 9, 8, 11},
        {6, 5, 4, 7, 2, 1, 0, 3, 11, 10, 9, 8},
        {7, 6, 5, 4, 3, 2, 1, 0, 8, 11, 10, 9},
        {8, 4, 9, 0, 11, 6, 10, 2, 3, 7, 5, 1},
        {9, 5, 10, 1, 8, 7, 11, 3, 0, 4, 6, 2},
        {10, 6, 11, 2, 9, 4, 8, 0, 1, 5, 7, 3},
        {11, 7, 8, 3, 10, 5, 9, 1, 2, 6, 4, 0}
};

const int IndexTranslatorAdaptive::newFaceIdxFromOldIdxto0_[fluxFacesTotalNum][fluxFacesTotalNum] =
{
    {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11},
    {3, 0, 1, 2, 7, 4, 5, 6, 11, 8, 9, 10},
    {2, 3, 0, 1, 6, 7, 4, 5, 10, 11, 8, 9},
    {1, 2, 3, 0, 5, 6, 7, 4, 9, 10, 11, 8},
    {4, 7, 6, 5, 0, 3, 2, 1, 9, 8, 11, 10},
    {5, 4, 7, 6, 1, 0, 3, 2, 10, 9, 8, 11},
    {6, 5, 4, 7, 2, 1, 0, 3, 11, 10, 9, 8},
    {7, 6, 5, 4, 3, 2, 1, 0, 8, 11, 10, 9},
    {3, 11, 7, 8, 1, 10, 5, 9, 0, 2, 6, 4},
    {8, 3, 11, 7, 9, 1, 10, 5, 4, 0, 2, 6},
    {7, 8, 3, 11, 5, 9, 1, 10, 6, 4, 0, 2},
    {11, 7, 8, 3, 10, 5, 9, 1, 2, 6, 4, 0}
};

const int IndexTranslatorAdaptive::oldEdgeIdxFromNewFaceIdxto0_[fluxFacesTotalNum][fluxEdgesTotalNum] =
{
        {0, 1, 2, 3, 4, 5},
        {0, 1, 3, 4, 5, 2},
        {0, 1, 4, 5, 2, 3},
        {0, 1, 5, 2, 3, 4},
        {1, 0, 2, 5, 4, 3},
        {1, 0, 3, 2, 5, 4},
        {1, 0, 4, 3, 2, 5},
        {1, 0, 5, 4, 3, 2},
        {2, 4, 5, 1, 3, 0},
        {3, 5, 2, 1, 4, 0},
        {4, 2, 3, 1, 5, 0},
        {5, 3, 4, 1, 2, 0}
};

const int IndexTranslatorAdaptive::newEdgeIdxFromOldFaceIdxto0_[fluxFacesTotalNum][fluxEdgesTotalNum] =
{
    {0, 1, 2, 3, 4, 5},
    {0, 1, 5, 2, 3, 4},
    {0, 1, 4, 5, 2, 3},
    {0, 1, 3, 4, 5, 2},
    {1, 0, 2, 5, 4, 3},
    {1, 0, 3, 2, 5, 4},
    {1, 0, 4, 3, 2, 5},
    {1, 0, 5, 4, 3, 2},
    {5, 3, 0, 4, 1, 2},
    {5, 3, 2, 0, 4, 1},
    {5, 3, 1, 2, 0, 4},
    {5, 3, 4, 1, 2, 0}
};
Markus Wolff's avatar
Markus Wolff committed
182
//! \endcond
183

184
//! \ingroup IMPET mpfa
Markus Wolff's avatar
Markus Wolff committed
185
186
187
188
189
/*! \brief Class including the information of a 3d interaction volume of an adaptive MPFA L-method that does not change with time.
 *
 * Includes information needed to calculate the transmissibility matrices of an L-interaction-volume.
 *
 */
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
template<class TypeTag>
class FvMpfaL3dInteractionVolumeAdaptive:public FvMpfaL3dInteractionVolume<TypeTag>
{
private:
    typedef FvMpfaL3dInteractionVolume<TypeTag> ParentType;
    typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
    typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView;
    typedef typename GET_PROP_TYPE(TypeTag, Problem) Problem;

    enum
    {
        dim = GridView::dimension, 
        dimWorld = GridView::dimensionworld,
    };

    typedef typename GridView::template Codim<0>::EntityPointer ElementPointer;

    typedef typename GET_PROP_TYPE(TypeTag, BoundaryTypes) BoundaryTypes;
208
209
    typedef typename GET_PROP(TypeTag, SolutionTypes) SolutionTypes;
    typedef typename SolutionTypes::PrimaryVariables PrimaryVariables;
210
211
212
213
214
215
216
217
218
219

    typedef Dune::FieldVector<Scalar, dim> DimVector;
    typedef Dune::FieldVector<DimVector, dim> FieldVectorVector;
    typedef Dune::FieldVector<DimVector, 2> FieldVectorVector2;
    typedef Dune::FieldVector<FieldVectorVector2, dim> FieldVectorVectorVector;
    typedef Dune::FieldVector<int, dim> IndexVector;
    typedef std::vector<BoundaryTypes> BCTypeVector;
    typedef std::vector<PrimaryVariables> BCVector;

public:
Markus Wolff's avatar
Markus Wolff committed
220
221

    //! \cond \private
222
223
224
225
226
227
228
    enum FaceTypes
    {
        inside = 1,
        boundary = 0,
        outside = -1,
    };

Markus Wolff's avatar
Markus Wolff committed
229
    //!\copydoc
230
231
232
233
234
235
    enum
    {
        subVolumeTotalNum = IndexTranslatorAdaptive::subVolumeTotalNum,
        fluxFacesTotalNum = IndexTranslatorAdaptive::fluxFacesTotalNum,
        fluxEdgesTotalNum = IndexTranslatorAdaptive::fluxEdgesTotalNum
    };
Markus Wolff's avatar
Markus Wolff committed
236
    //! \endcond
237

Markus Wolff's avatar
Markus Wolff committed
238
    //! The different hanging node interaction volume types (see dissertation M. Wolff, http://elib.uni-stuttgart.de/opus/volltexte/2013/8661/)
239
240
    enum HangingNodeTypes
    {
Markus Wolff's avatar
Markus Wolff committed
241
242
243
244
245
246
        noHangingNode = -1,//!< regular interaction volume
        twoSmallCells = 0,//!< hanging-node interaction volume of type 5 or 7
        fourSmallCellsFace = 1,//!<  hanging-node interaction volume of type 1
        fourSmallCellsEdge = 2,//!<  hanging-node interaction volume of type 3
        fourSmallCellsDiag = 3,//!<  hanging-node interaction volume of type 4
        sixSmallCells = 4//!<  hanging-node interaction volume of type 2 or 6
247
248
    };

Markus Wolff's avatar
Markus Wolff committed
249
    //! Constructs a FvMpfaL3dInteractionVolumeAdaptive object
250
251
252
253
254
255
    /**
     */
    FvMpfaL3dInteractionVolumeAdaptive() :
        hangingNodeType_(noHangingNode)
    {}

256
    //!\copydoc FvMpfaL3dInteractionVolume::reset()
257
258
259
260
261
262
    void reset()
    {
        hangingNodeType_ = noHangingNode;
        existingLevel_.clear();
    }

263
    //!\copydoc FvMpfaL3dInteractionVolume::setSubVolumeElement()
264
265
266
267
268
    void setSubVolumeElement(ElementPointer pointer, int subVolumeIdx)
    {
            ParentType::setSubVolumeElement(pointer, subVolumeIdx);
            existingLevel_.insert(pointer.level());
    }
Markus Wolff's avatar
Markus Wolff committed
269
270
271
272
273

    //! Store the type of hanging-node-interaction volume
    /*!
     * \param hNType the type of hanging-node-interaction volume of type Dumux::FvMpfaL3dInteractionVolumeAdaptive<TypeTag>::HangingNodeTypes
     */
274
275
276
277
278
    void setHangingNodeType(int hNType)
    {
        hangingNodeType_ = hNType;
    }

Markus Wolff's avatar
Markus Wolff committed
279
280
281
282
    //! Check if elements in the interaction volume are of the same grid level
    /*!
     * \return <tt>true</tt> if all elements are on the same grid level
     */
283
284
285
286
287
288
289
290
291
292
    bool sameLevel()
    {
        if (!isHangingNodeVolume())
            return existingLevel_.size() < 2;
        else
        {
            return existingLevel_.size() < 3;
        }
    }

Markus Wolff's avatar
Markus Wolff committed
293
294
295
296
297
298
    //! Check if an element of a certain grid level is stored
    /*!
     * \param level the dune grid level
     *
     * \return <tt>true</tt> if an element of a certain grid level is stored
     */
299
300
301
302
303
    bool hasLevel(int level)
    {
        return  existingLevel_.find(level) != existingLevel_.end();
    }

Markus Wolff's avatar
Markus Wolff committed
304
305
306
307
    //! Check whether the interaction volume is a hanging-node volume
    /*!
     * \return <tt>true</tt> if the interaction volume is a hanging-node volume
     */
308
309
310
311
312
    bool isHangingNodeVolume()
    {
        return hangingNodeType_ != noHangingNode;
    }

Markus Wolff's avatar
Markus Wolff committed
313
    //! The type of the interaction volume as type of Dumux::FvMpfaL3dInteractionVolumeAdaptive<TypeTag>::HangingNodeTypes
314
315
316
317
318
    int getHangingNodeType()
    {
        return hangingNodeType_;
    }

319
    //!\copydoc FvMpfaL3dInteractionVolume::printInteractionVolumeInfo()
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
    void printInteractionVolumeInfo()
    {
        ParentType::printInteractionVolumeInfo();

            if (isHangingNodeVolume())
                std::cout<<"hanging node type: "<<hangingNodeType_<<"\n";
    }

//    void printInteractionVolumeInfoToFile(std::ofstream& dataFile)
//    {
//        ParentType::printInteractionVolumeInfoToFile(dataFile);
//
//            if (isHangingNodeVolume())
//                dataFile<<"hanging node type: "<<hangingNodeType_<<"\n";
//    }

private:
    int hangingNodeType_;
    std::set<int> existingLevel_;
};
}
#endif