subcontrolvolumeface.hh 7.92 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
Dennis Gläser's avatar
Dennis Gläser committed
21
22
 * \ingroup CCMpfaDiscretization
 * \brief The sub control volume face
23
24
25
26
 */
#ifndef DUMUX_DISCRETIZATION_CC_MPFA_SUBCONTROLVOLUMEFACE_HH
#define DUMUX_DISCRETIZATION_CC_MPFA_SUBCONTROLVOLUMEFACE_HH

Timo Koch's avatar
Timo Koch committed
27
#include <vector>
28
#include <dune/common/version.hh>
Timo Koch's avatar
Timo Koch committed
29
#include <dune/geometry/type.hh>
30
#include "methods.hh"
31
32
33
34
35

namespace Dumux
{

/*!
Dennis Gläser's avatar
Dennis Gläser committed
36
 * \ingroup CCMpfaDiscretization
37
 * \brief Default implementation of the class for a sub-control volume face in mpfa methods.
38
 */
39
40
template<class ScvfGeometryTraits>
class CCMpfaDefaultSubControlVolumeFace
41
{
42
43
    using GridIndexType = typename ScvfGeometryTraits::GridIndexType;
    using Scalar = typename ScvfGeometryTraits::Scalar;
44
    using GlobalPosition = typename ScvfGeometryTraits::GlobalPosition;
45
    using CornerStorage = typename ScvfGeometryTraits::CornerStorage;
46
    using Geometry = typename ScvfGeometryTraits::Geometry;
47
48

public:
49
    //! state the traits public and thus export all types
50
    using Traits = ScvfGeometryTraits;
Dennis Gläser's avatar
Dennis Gläser committed
51

52
    /*!
53
     * \brief Constructor
54
     *
Dennis Gläser's avatar
Dennis Gläser committed
55
     * \param helper The helper class for mpfa schemes
56
57
58
     * \param corners The corners of the scv face
     * \param unitOuterNormal The unit outer normal vector of the scvf
     * \param vIdxGlobal The global vertex index the scvf is connected to
59
     * \param vIdxLocal The element-local vertex index the scvf is connected to
60
     * \param scvfIndex The global index of this scv face
61
62
     * \param insideScvIdx The inside scv index connected to this face
     * \param outsideScvIndices The outside scv indices connected to this face
63
64
65
     * \param q The parameterization of the quadrature point on the scvf for flux calculation
     * \param boundary Boolean to specify whether or not the scvf is on a boundary
     */
66
    template<class MpfaHelper>
Dennis Gläser's avatar
Dennis Gläser committed
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
    CCMpfaDefaultSubControlVolumeFace(const MpfaHelper& helper,
                                      CornerStorage&& corners,
                                      GlobalPosition&& unitOuterNormal,
                                      GridIndexType vIdxGlobal,
                                      unsigned int vIdxLocal,
                                      GridIndexType scvfIndex,
                                      GridIndexType insideScvIdx,
                                      const std::vector<GridIndexType>& outsideScvIndices,
                                      Scalar q,
                                      bool boundary)
    : boundary_(boundary)
    ,   vertexIndex_(vIdxGlobal)
    ,   scvfIndex_(scvfIndex)
    ,   insideScvIdx_(insideScvIdx)
    ,   outsideScvIndices_(outsideScvIndices)
    ,   vIdxInElement_(vIdxLocal)
    ,   corners_(std::move(corners))
    ,   center_(0.0)
    ,   unitOuterNormal_(std::move(unitOuterNormal))
    {
          // compute the center of the scvf
          for (const auto& corner : corners_)
              center_ += corner;
          center_ /= corners_.size();

          // use helper class to obtain area & integration point
          ipGlobal_ = helper.getScvfIntegrationPoint(corners_, q);
          area_ = helper.getScvfArea(corners_);
    }
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

    //! The area of the sub control volume face
    Scalar area() const { return area_; }

    //! returns bolean if the sub control volume face is on the domain boundary
    bool boundary() const { return boundary_; }

    //! The global index of this sub control volume face
    GridIndexType index() const { return scvfIndex_; }

    //! Returns the index of the vertex the scvf is connected to
    GridIndexType vertexIndex() const { return vertexIndex_; }

    //! Returns the element-local vertex index the scvf is connected to
    unsigned int vertexIndexInElement() const { return vIdxInElement_; }

    //! index of the inside sub control volume
    GridIndexType insideScvIdx() const { return insideScvIdx_; }

    //! The number of outside scvs connection via this scv face
    std::size_t numOutsideScvs() const { return outsideScvIndices_.size(); }

    //! index of the outside sub control volume or boundary scv index
    //! returns undefined behaviour if index exceeds numOutsideScvs
    GridIndexType outsideScvIdx(int i = 0) const { return outsideScvIndices_[i]; }

    //! returns the outside scv indices (can be more than one index for dim < dimWorld)
    const std::vector<GridIndexType>& outsideScvIndices() const { return outsideScvIndices_; }

    //! Returns the number of corners
    std::size_t corners() const { return corners_.size(); }

    //! Returns the corner for a given local index
    const GlobalPosition& corner(unsigned int localIdx) const
    {
        assert(localIdx < corners_.size() && "provided index exceeds the number of corners");
        return corners_[localIdx];
    }

    //! Returns the global position of the vertex the scvf is connected to
    const GlobalPosition& vertexCorner() const { return corners_.back(); }

    //! Returns the global position of the center of the element facet this scvf is embedded in
    const GlobalPosition& facetCorner() const { return corner(0); }

    //! The center of the sub control volume face
    const GlobalPosition& center() const { return center_; }

    //! The integration point for flux evaluations in global coordinates
    const GlobalPosition& ipGlobal() const { return ipGlobal_; }

    //! returns the unit outer normal vector (assumes non-curved geometries)
    const GlobalPosition& unitOuterNormal() const { return unitOuterNormal_; }

    //! The geometry of the sub control volume face
151
#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
152
    Geometry geometry() const { return Geometry(Dune::GeometryTypes::cube(Geometry::mydimension), corners_); }
153
154
155
#else
    Geometry geometry() const { return Geometry(Dune::GeometryType(Dune::GeometryType::cube, Geometry::mydimension), corners_); }
#endif
156
157
158
159
160
161
162
163
164
165
166
167
168
169

private:
    bool boundary_;
    GridIndexType vertexIndex_;
    GridIndexType scvfIndex_;
    GridIndexType insideScvIdx_;
    std::vector<GridIndexType> outsideScvIndices_;
    unsigned int vIdxInElement_;

    CornerStorage corners_;
    GlobalPosition center_;
    GlobalPosition ipGlobal_;
    GlobalPosition unitOuterNormal_;
    Scalar area_;
170
};
171

172
/*!
Dennis Gläser's avatar
Dennis Gläser committed
173
 * \ingroup CCMpfaDiscretization
174
175
176
177
178
179
180
181
182
183
 * \brief Class for a sub control volume face in mpfa methods, i.e a part of the boundary
 *        of a control volume we compute fluxes on. Per default, we use the default
 *        implementation of the mpfa scvf class. If a scheme requires a different implementation,
 *        provide a specialization for it.
 *
 * \param M the mpfa method used
 * \param GT the traits class for the geometry type
 */
template<MpfaMethods M, class GT>
using CCMpfaSubControlVolumeFace = CCMpfaDefaultSubControlVolumeFace< GT >;
184

185
} // end namespace Dumux
186

187
#endif