version 3.9
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// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
14#ifndef DUMUX_FACETCOUPLING_BOX_SUBCONTROLVOLUMEFACE_HH
15#define DUMUX_FACETCOUPLING_BOX_SUBCONTROLVOLUMEFACE_HH
16
17#include <utility>
18
19#include <dune/geometry/type.hh>
20#include <dune/geometry/multilineargeometry.hh>
21
27
28namespace Dumux {
29
38template<class GV, class T = BoxDefaultScvfGeometryTraits<GV> >
40: public SubControlVolumeFaceBase<BoxFacetCouplingSubControlVolumeFace<GV, T>, T>
41{
42 using GridIndexType = typename T::GridIndexType;
43 using LocalIndexType = typename T::LocalIndexType;
44 using Scalar = typename T::Scalar;
45 using CornerStorage = typename T::CornerStorage;
46 using Geometry = typename T::Geometry;
47 using BoundaryFlag = typename T::BoundaryFlag;
48
49public:
51 using GlobalPosition = typename T::GlobalPosition;
53 using Traits = T;
54
57
59 template<class GeometryHelper, class Element>
60 BoxFacetCouplingSubControlVolumeFace(const GeometryHelper& geometryHelper,
61 const Element& element,
62 const typename Element::Geometry& elemGeometry,
63 unsigned int scvfIndex,
64 std::vector<LocalIndexType>&& scvIndices)
65 : center_(0.0)
66 , scvfIndex_(scvfIndex)
67 , scvIndices_(std::move(scvIndices))
68 , facetIndex_(/*undefined*/)
69 , indexInFacet_(/*undefined*/)
70 , boundary_(false)
71 , interiorBoundary_(false)
72 , boundaryFlag_{}
73 {
74 const auto corners = geometryHelper.getScvfCorners(scvfIndex);
75 unitOuterNormal_ = geometryHelper.normal(corners, scvIndices_);
76 area_ = Dumux::convexPolytopeVolume<T::dim-1>(
77 Dune::GeometryTypes::cube(T::dim-1),
78 [&](unsigned int i){ return corners[i]; });
79 for (const auto& corner : corners)
80 center_ += corner;
81 center_ /= corners.size();
82 }
83
85 template<class GeometryHelper, class Intersection>
86 BoxFacetCouplingSubControlVolumeFace(const GeometryHelper& geometryHelper,
87 const Intersection& intersection,
88 const typename Intersection::Geometry& isGeometry,
89 LocalIndexType indexInIntersection,
90 GridIndexType scvfIndex,
91 std::vector<LocalIndexType>&& scvIndices,
92 bool boundary,
94 : center_(0.0)
95 , unitOuterNormal_(intersection.centerUnitOuterNormal())
96 , scvfIndex_(scvfIndex)
97 , scvIndices_(std::move(scvIndices))
98 , facetIndex_(intersection.indexInInside())
99 , indexInFacet_(indexInIntersection)
100 , boundary_(boundary)
101 , interiorBoundary_(interiorBoundary)
102 , boundaryFlag_{intersection}
103 {
104 auto corners = geometryHelper.getBoundaryScvfCorners(intersection.indexInInside(), indexInIntersection);
105 area_ = Dumux::convexPolytopeVolume<T::dim-1>(
106 Dune::GeometryTypes::cube(T::dim-1),
107 [&](unsigned int i){ return corners[i]; });
108 for (const auto& corner : corners)
109 center_ += corner;
110 center_ /= corners.size();
111 }
112
114 const GlobalPosition& center() const
115 { return center_; }
116
119 { return center_; }
120
122 Scalar area() const
123 { return area_; }
124
126 bool boundary() const
127 { return boundary_; }
128
130 bool interiorBoundary() const
131 { return interiorBoundary_; }
132
136 { return unitOuterNormal_; }
137
139 LocalIndexType insideScvIdx() const
140 { return scvIndices_[0]; }
141
143 GridIndexType index() const
144 { return scvfIndex_; }
145
147 // Results in undefined behaviour if i >= numOutsideScvs()
148 LocalIndexType outsideScvIdx(int i = 0) const
149 {
150 assert(!boundary() && !interiorBoundary());
151 return scvIndices_[1];
152 }
153
155 std::size_t numOutsideScvs() const
156 {
157 return static_cast<std::size_t>(!(boundary() || interiorBoundary()));
158 }
159
162 LocalIndexType facetIndexInElement() const
163 {
164 assert(interiorBoundary_ || boundary_);
165 return facetIndex_;
166 }
167
170 LocalIndexType indexInElementFacet() const
171 {
172 assert(interiorBoundary_ || boundary_);
173 return indexInFacet_;
174 }
175
178 { return boundaryFlag_.get(); }
179
180private:
181 // geometrical information
182 GlobalPosition center_;
183 GlobalPosition unitOuterNormal_;
184 Scalar area_;
185
186 // indices
187 GridIndexType scvfIndex_;
188 std::vector<LocalIndexType> scvIndices_;
189
190 // indices valid for domain/interior boundary scvfs
191 LocalIndexType facetIndex_;
192 LocalIndexType indexInFacet_;
193
194 // boundary information
195 bool boundary_;
196 bool interiorBoundary_;
197 BoundaryFlag boundaryFlag_;
198};
199
200} // end namespace Dumux
201
202#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.
Boundary flag to store e.g. in sub control volume faces.
Definition: boundaryflag.hh:55
std::size_t value_type
Definition: boundaryflag.hh:39
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:41
bool boundary() const
returns true if the sub control volume face is on the boundary
Definition: multidomain/facet/box/subcontrolvolumeface.hh:126
LocalIndexType facetIndexInElement() const
Definition: multidomain/facet/box/subcontrolvolumeface.hh:162
LocalIndexType insideScvIdx() const
index of the inside sub control volume
Definition: multidomain/facet/box/subcontrolvolumeface.hh:139
GridIndexType index() const
The element-local index of this sub control volume face.
Definition: multidomain/facet/box/subcontrolvolumeface.hh:143
T Traits
state the traits public and thus export all types
Definition: multidomain/facet/box/subcontrolvolumeface.hh:53
Scalar area() const
The area of the sub control volume face.
Definition: multidomain/facet/box/subcontrolvolumeface.hh:122
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:60
typename T::GlobalPosition GlobalPosition
export the type used for global coordinates
Definition: multidomain/facet/box/subcontrolvolumeface.hh:51
BoxFacetCouplingSubControlVolumeFace()=default
The default constructor.
const GlobalPosition & center() const
The center of the sub control volume face.
Definition: multidomain/facet/box/subcontrolvolumeface.hh:114
const GlobalPosition & ipGlobal() const
The integration point for flux evaluations in global coordinates.
Definition: multidomain/facet/box/subcontrolvolumeface.hh:118
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:86
bool interiorBoundary() const
returns true if the sub control volume face is on an interior boundary
Definition: multidomain/facet/box/subcontrolvolumeface.hh:130
std::size_t numOutsideScvs() const
The number of scvs on the outside of this face.
Definition: multidomain/facet/box/subcontrolvolumeface.hh:155
LocalIndexType indexInElementFacet() const
Definition: multidomain/facet/box/subcontrolvolumeface.hh:170
const GlobalPosition & unitOuterNormal() const
Definition: multidomain/facet/box/subcontrolvolumeface.hh:135
BoundaryFlag::value_type boundaryFlag() const
Return the boundary flag.
Definition: multidomain/facet/box/subcontrolvolumeface.hh:177
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:148
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:29
Base class for a sub control volume face.
auto convexPolytopeVolume(Dune::GeometryType type, const CornerF &c)
Compute the volume of several common geometry types.
Definition: volume.hh:41
Definition: adapt.hh:17
Base class for a sub control volume face.
Compute the volume of several common geometry types.