version 3.8
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 : corners_(geometryHelper.getScvfCorners(scvfIndex))
66 , center_(0.0)
67 , unitOuterNormal_(geometryHelper.normal(corners_, scvIndices))
68 , area_(Dumux::convexPolytopeVolume<T::dim-1>(
69 Dune::GeometryTypes::cube(T::dim-1),
70 [&](unsigned int i){ return corners_[i]; })
71 )
72 , scvfIndex_(scvfIndex)
73 , scvIndices_(std::move(scvIndices))
74 , facetIndex_(/*undefined*/)
75 , indexInFacet_(/*undefined*/)
76 , boundary_(false)
77 , interiorBoundary_(false)
78 , boundaryFlag_{}
79 {
80 for (const auto& corner : corners_)
81 center_ += corner;
82 center_ /= corners_.size();
83 }
84
86 template<class GeometryHelper, class Intersection>
87 BoxFacetCouplingSubControlVolumeFace(const GeometryHelper& geometryHelper,
88 const Intersection& intersection,
89 const typename Intersection::Geometry& isGeometry,
90 LocalIndexType indexInIntersection,
91 GridIndexType scvfIndex,
92 std::vector<LocalIndexType>&& scvIndices,
93 bool boundary,
95 : corners_(geometryHelper.getBoundaryScvfCorners(intersection.indexInInside(), indexInIntersection))
96 , center_(0.0)
97 , unitOuterNormal_(intersection.centerUnitOuterNormal())
98 , area_(Dumux::convexPolytopeVolume<T::dim-1>(
99 Dune::GeometryTypes::cube(T::dim-1),
100 [&](unsigned int i){ return corners_[i]; })
101 )
102 , scvfIndex_(scvfIndex)
103 , scvIndices_(std::move(scvIndices))
104 , facetIndex_(intersection.indexInInside())
105 , indexInFacet_(indexInIntersection)
106 , boundary_(boundary)
107 , interiorBoundary_(interiorBoundary)
108 , boundaryFlag_{intersection}
109 {
110 for (const auto& corner : corners_)
111 center_ += corner;
112 center_ /= corners_.size();
113 }
114
116 const GlobalPosition& center() const
117 { return center_; }
118
121 { return center_; }
122
124 Scalar area() const
125 { return area_; }
126
128 bool boundary() const
129 { return boundary_; }
130
132 bool interiorBoundary() const
133 { return interiorBoundary_; }
134
138 { return unitOuterNormal_; }
139
141 LocalIndexType insideScvIdx() const
142 { return scvIndices_[0]; }
143
145 GridIndexType index() const
146 { return scvfIndex_; }
147
149 // Results in undefined behaviour if i >= numOutsideScvs()
150 LocalIndexType outsideScvIdx(int i = 0) const
151 {
152 assert(!boundary() && !interiorBoundary());
153 return scvIndices_[1];
154 }
155
157 std::size_t numOutsideScvs() const
158 {
159 return static_cast<std::size_t>(!(boundary() || interiorBoundary()));
160 }
161
164 LocalIndexType facetIndexInElement() const
165 {
166 assert(interiorBoundary_ || boundary_);
167 return facetIndex_;
168 }
169
172 LocalIndexType indexInElementFacet() const
173 {
174 assert(interiorBoundary_ || boundary_);
175 return indexInFacet_;
176 }
177
179 [[deprecated("Will be removed after 3.7. Use fvGeometry.geometry(scvf).")]]
180 Geometry geometry() const
181 { return Geometry(Dune::GeometryTypes::cube(Geometry::mydimension), corners_); }
182
185 { return boundaryFlag_.get(); }
186
187private:
188 // geometrical information
189 CornerStorage corners_;
190 GlobalPosition center_;
191 GlobalPosition unitOuterNormal_;
192 Scalar area_;
193
194 // indices
195 GridIndexType scvfIndex_;
196 std::vector<LocalIndexType> scvIndices_;
197
198 // indices valid for domain/interior boundary scvfs
199 LocalIndexType facetIndex_;
200 LocalIndexType indexInFacet_;
201
202 // boundary information
203 bool boundary_;
204 bool interiorBoundary_;
205 BoundaryFlag boundaryFlag_;
206};
207
208} // end namespace Dumux
209
210#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:128
LocalIndexType facetIndexInElement() const
Definition: multidomain/facet/box/subcontrolvolumeface.hh:164
Geometry geometry() const
The geometry of the sub control volume face.
Definition: multidomain/facet/box/subcontrolvolumeface.hh:180
LocalIndexType insideScvIdx() const
index of the inside sub control volume
Definition: multidomain/facet/box/subcontrolvolumeface.hh:141
GridIndexType index() const
The element-local index of this sub control volume face.
Definition: multidomain/facet/box/subcontrolvolumeface.hh:145
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:124
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:116
const GlobalPosition & ipGlobal() const
The integration point for flux evaluations in global coordinates.
Definition: multidomain/facet/box/subcontrolvolumeface.hh:120
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:87
bool interiorBoundary() const
returns true if the sub control volume face is on an interior boundary
Definition: multidomain/facet/box/subcontrolvolumeface.hh:132
std::size_t numOutsideScvs() const
The number of scvs on the outside of this face.
Definition: multidomain/facet/box/subcontrolvolumeface.hh:157
LocalIndexType indexInElementFacet() const
Definition: multidomain/facet/box/subcontrolvolumeface.hh:172
const GlobalPosition & unitOuterNormal() const
Definition: multidomain/facet/box/subcontrolvolumeface.hh:137
BoundaryFlag::value_type boundaryFlag() const
Return the boundary flag.
Definition: multidomain/facet/box/subcontrolvolumeface.hh:184
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:150
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.
Vector normal(const Vector &v)
Create a vector normal to the given one (v is expected to be non-zero)
Definition: normal.hh:26
auto convexPolytopeVolume(Dune::GeometryType type, const CornerF &c)
Compute the volume of several common geometry types.
Definition: volume.hh:41
Definition: adapt.hh:17
Definition: common/pdesolver.hh:24
Base class for a sub control volume face.
Compute the volume of several common geometry types.