3.4
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
multidomain/facet/box/subcontrolvolumeface.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3/*****************************************************************************
4 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
26#ifndef DUMUX_FACETCOUPLING_BOX_SUBCONTROLVOLUMEFACE_HH
27#define DUMUX_FACETCOUPLING_BOX_SUBCONTROLVOLUMEFACE_HH
28
29#include <utility>
30
31#include <dune/geometry/type.hh>
32#include <dune/geometry/multilineargeometry.hh>
33
38
39namespace Dumux {
40
49template<class GV, class T = BoxDefaultScvfGeometryTraits<GV> >
51: public SubControlVolumeFaceBase<BoxFacetCouplingSubControlVolumeFace<GV, T>, T>
52{
55 using GridIndexType = typename T::GridIndexType;
56 using LocalIndexType = typename T::LocalIndexType;
57 using Scalar = typename T::Scalar;
58 using CornerStorage = typename T::CornerStorage;
59 using Geometry = typename T::Geometry;
60 using BoundaryFlag = typename T::BoundaryFlag;
61
62public:
64 using GlobalPosition = typename T::GlobalPosition;
66 using Traits = T;
67
70
72 template<class GeometryHelper, class Element>
73 BoxFacetCouplingSubControlVolumeFace(const GeometryHelper& geometryHelper,
74 const Element& element,
75 const typename Element::Geometry& elemGeometry,
76 unsigned int scvfIndex,
77 std::vector<LocalIndexType>&& scvIndices)
78 : corners_(geometryHelper.getScvfCorners(scvfIndex))
79 , center_(0.0)
80 , unitOuterNormal_(geometryHelper.normal(corners_, scvIndices))
81 , area_(geometryHelper.scvfArea(corners_))
82 , scvfIndex_(scvfIndex)
83 , scvIndices_(std::move(scvIndices))
84 , facetIndex_(/*undefined*/)
85 , indexInFacet_(/*undefined*/)
86 , boundary_(false)
87 , interiorBoundary_(false)
88 , boundaryFlag_{}
89 {
90 for (const auto& corner : corners_)
91 center_ += corner;
92 center_ /= corners_.size();
93 }
94
96 template<class GeometryHelper, class Intersection>
97 BoxFacetCouplingSubControlVolumeFace(const GeometryHelper& geometryHelper,
98 const Intersection& intersection,
99 const typename Intersection::Geometry& isGeometry,
100 LocalIndexType indexInIntersection,
101 GridIndexType scvfIndex,
102 std::vector<LocalIndexType>&& scvIndices,
103 bool boundary,
104 bool interiorBoundary)
105 : corners_(geometryHelper.getBoundaryScvfCorners(intersection, isGeometry, indexInIntersection))
106 , center_(0.0)
107 , unitOuterNormal_(intersection.centerUnitOuterNormal())
108 , area_(geometryHelper.scvfArea(corners_))
109 , scvfIndex_(scvfIndex)
110 , scvIndices_(std::move(scvIndices))
111 , facetIndex_(intersection.indexInInside())
112 , indexInFacet_(indexInIntersection)
113 , boundary_(boundary)
114 , interiorBoundary_(interiorBoundary)
115 , boundaryFlag_{intersection}
116 {
117 for (const auto& corner : corners_)
118 center_ += corner;
119 center_ /= corners_.size();
120 }
121
123 const GlobalPosition& center() const
124 { return center_; }
125
128 { return center_; }
129
131 Scalar area() const
132 { return area_; }
133
135 bool boundary() const
136 { return boundary_; }
137
139 bool interiorBoundary() const
140 { return interiorBoundary_; }
141
145 { return unitOuterNormal_; }
146
148 LocalIndexType insideScvIdx() const
149 { return scvIndices_[0]; }
150
152 GridIndexType index() const
153 { return scvfIndex_; }
154
156 // Results in undefined behaviour if i >= numOutsideScvs()
157 LocalIndexType outsideScvIdx(int i = 0) const
158 {
159 assert(!boundary() && !interiorBoundary());
160 return scvIndices_[1];
161 }
162
164 std::size_t numOutsideScvs() const
165 {
166 return static_cast<std::size_t>(!(boundary() || interiorBoundary()));
167 }
168
171 LocalIndexType facetIndexInElement() const
172 {
173 assert(interiorBoundary_ || boundary_);
174 return facetIndex_;
175 }
176
179 LocalIndexType indexInElementFacet() const
180 {
181 assert(interiorBoundary_ || boundary_);
182 return indexInFacet_;
183 }
184
186 Geometry geometry() const
187 { return Geometry(Dune::GeometryTypes::cube(Geometry::mydimension), corners_); }
188
191 { return boundaryFlag_.get(); }
192
194 const GlobalPosition& corner(unsigned int localIdx) const
195 {
196 assert(localIdx < corners_.size() && "provided index exceeds the number of corners");
197 return corners_[localIdx];
198 }
199
200private:
201 // geometrical information
202 CornerStorage corners_;
203 GlobalPosition center_;
204 GlobalPosition unitOuterNormal_;
205 Scalar area_;
206
207 // indices
208 GridIndexType scvfIndex_;
209 std::vector<LocalIndexType> scvIndices_;
210
211 // indices valid for domain/interior boundary scvfs
212 LocalIndexType facetIndex_;
213 LocalIndexType indexInFacet_;
214
215 // boundary information
216 bool boundary_;
217 bool interiorBoundary_;
218 BoundaryFlag boundaryFlag_;
219};
220
221} // end namespace Dumux
222
223#endif
Boundary flag to store e.g. in sub control volume faces.
Helper class constructing the dual grid finite volume geometries for the box discretizazion method.
Base class for a sub control volume face.
Vector normal(const Vector &v)
Create a vector normal to the given one (v is expected to be non-zero)
Definition: normal.hh:36
Definition: adapt.hh:29
std::size_t value_type
Definition: boundaryflag.hh:51
Definition: boundaryflag.hh:68
Class for a sub control volume face in the box method, i.e a part of the boundary of a sub control vo...
Definition: discretization/box/subcontrolvolumeface.hh:93
Base class for a sub control volume face, i.e a part of the boundary of a sub control volume we compu...
Definition: subcontrolvolumefacebase.hh:41
Class for a sub control volume face in the box method, i.e a part of the boundary of a sub control vo...
Definition: multidomain/facet/box/subcontrolvolumeface.hh:52
bool boundary() const
returns true if the sub control volume face is on the boundary
Definition: multidomain/facet/box/subcontrolvolumeface.hh:135
LocalIndexType facetIndexInElement() const
Definition: multidomain/facet/box/subcontrolvolumeface.hh:171
Geometry geometry() const
The geometry of the sub control volume face.
Definition: multidomain/facet/box/subcontrolvolumeface.hh:186
LocalIndexType insideScvIdx() const
index of the inside sub control volume
Definition: multidomain/facet/box/subcontrolvolumeface.hh:148
GridIndexType index() const
The element-local index of this sub control volume face.
Definition: multidomain/facet/box/subcontrolvolumeface.hh:152
T Traits
state the traits public and thus export all types
Definition: multidomain/facet/box/subcontrolvolumeface.hh:66
Scalar area() const
The area of the sub control volume face.
Definition: multidomain/facet/box/subcontrolvolumeface.hh:131
BoxFacetCouplingSubControlVolumeFace(const GeometryHelper &geometryHelper, const Element &element, const typename Element::Geometry &elemGeometry, unsigned int scvfIndex, std::vector< LocalIndexType > &&scvIndices)
Constructor for inner scvfs.
Definition: multidomain/facet/box/subcontrolvolumeface.hh:73
typename T::GlobalPosition GlobalPosition
export the type used for global coordinates
Definition: multidomain/facet/box/subcontrolvolumeface.hh:64
BoxFacetCouplingSubControlVolumeFace()=default
The default constructor.
const GlobalPosition & center() const
The center of the sub control volume face.
Definition: multidomain/facet/box/subcontrolvolumeface.hh:123
const GlobalPosition & ipGlobal() const
The integration point for flux evaluations in global coordinates.
Definition: multidomain/facet/box/subcontrolvolumeface.hh:127
const GlobalPosition & corner(unsigned int localIdx) const
returns the position of a corner of the face
Definition: multidomain/facet/box/subcontrolvolumeface.hh:194
BoxFacetCouplingSubControlVolumeFace(const GeometryHelper &geometryHelper, const Intersection &intersection, const typename Intersection::Geometry &isGeometry, LocalIndexType indexInIntersection, GridIndexType scvfIndex, std::vector< LocalIndexType > &&scvIndices, bool boundary, bool interiorBoundary)
Constructor for domain or interior boundary scvfs.
Definition: multidomain/facet/box/subcontrolvolumeface.hh:97
bool interiorBoundary() const
returns true if the sub control volume face is on an interior boundary
Definition: multidomain/facet/box/subcontrolvolumeface.hh:139
std::size_t numOutsideScvs() const
The number of scvs on the outside of this face.
Definition: multidomain/facet/box/subcontrolvolumeface.hh:164
LocalIndexType indexInElementFacet() const
Definition: multidomain/facet/box/subcontrolvolumeface.hh:179
const GlobalPosition & unitOuterNormal() const
Definition: multidomain/facet/box/subcontrolvolumeface.hh:144
BoundaryFlag::value_type boundaryFlag() const
Return the boundary flag.
Definition: multidomain/facet/box/subcontrolvolumeface.hh:190
LocalIndexType outsideScvIdx(int i=0) const
Index of the i-th outside sub control volume or boundary scv index.
Definition: multidomain/facet/box/subcontrolvolumeface.hh:157
Base class for a sub control volume face.