subcontrolvolumeface.hh 5.61 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
// -*- 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
 * \brief Class for an MPFA-O sub control volume face
 */
#ifndef DUMUX_DISCRETIZATION_CC_MPFA_SUBCONTROLVOLUMEFACE_HH
#define DUMUX_DISCRETIZATION_CC_MPFA_SUBCONTROLVOLUMEFACE_HH

#include <utility>
#include <dune/common/fvector.hh>
#include <dumux/discretization/subcontrolvolumefacebase.hh>

namespace Dumux
{

/*!
 * \ingroup Discretization
 * \brief Class for a sub control volume face in the box method, i.e a part of the boundary
 *        of a sub control volume we compute fluxes on. We simply use the base class here.
 */
template<class G, typename I>
class CCMpfaSubControlVolumeFace : public SubControlVolumeFaceBase<CCMpfaSubControlVolumeFace<G, I>, G, I>
{
    using ParentType = SubControlVolumeFaceBase<CCMpfaSubControlVolumeFace<G, I>, G, I>;
    using Geometry = G;
    using IndexType = I;

    using Scalar = typename Geometry::ctype;
    static const int dim = Geometry::mydimension;
    static const int dimworld = Geometry::coorddimension;

    using GlobalPosition = Dune::FieldVector<Scalar, dimworld>;
    using LocalPosition = Dune::FieldVector<Scalar, dim>;

public:
    template<class MpfaGeometryHelper>
    CCMpfaSubControlVolumeFace(const MpfaGeometryHelper& geomHelper,
                               std::vector<GlobalPosition>&& corners,
                               GlobalPosition&& unitOuterNormal,
                               IndexType vertexIndex,
                               IndexType scvfIndex,
                               std::array<IndexType, 2>&& scvIndices,
                               Scalar q,
61
                               bool boundary)
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
    : ParentType(),
      boundary_(boundary),
      vertexIndex_(vertexIndex),
      scvfIndex_(scvfIndex),
      scvIndices_(std::move(scvIndices)),
      corners_(std::move(corners)),
      center_(0.0),
      unitOuterNormal_(std::move(unitOuterNormal))
      {
            for (const auto& corner : corners_)
                center_ += corner;
            center_ /= corners_.size();
            ipGlobal_ = geomHelper.getScvfIntegrationPoint(corners_, q);
            area_ = geomHelper.getScvfArea(corners_);
      }

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

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

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

Dennis Gläser's avatar
Dennis Gläser committed
90
    //! returns bolean if the sub control volume face is on the domain boundary
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
    bool boundary() const
    { return boundary_; }

    GlobalPosition unitOuterNormal() const
    { return unitOuterNormal_; }

    //! index of the inside sub control volume for spatial param evaluation
    IndexType insideScvIdx() const
    { return scvIndices_[0]; }

    //! index of the outside sub control volume for spatial param evaluation
    IndexType outsideScvIdx() const
    { return scvIndices_[1]; }

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

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

    //! Returns the corner for a given local index
114
115
116
117
118
119
120
121
122
123
124
125
    GlobalPosition corner(unsigned int localIdx) const
    {
        assert(localIdx < corners_.size() && "provided index exceeds the number of corners");
        return corners_[localIdx];
    }

    //! The geometry of the sub control volume face
    const Geometry geometry() const
    { return Geometry(Dune::GeometryType(Dune::GeometryType::cube, dim), corners_); }

    //! Returns the global position of the vertex the scvf is connected to
    GlobalPosition vertexCorner() const
126
    { return corners_.back(); }
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

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

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

private:
    bool boundary_;
    IndexType vertexIndex_;
    IndexType scvfIndex_;
    std::array<IndexType, 2> scvIndices_;

    std::vector<GlobalPosition> corners_;
    GlobalPosition center_;
    GlobalPosition ipGlobal_;
    GlobalPosition unitOuterNormal_;
    Scalar area_;
};

} // end namespace

#endif