version 3.8
porousmediumflow/boxdfm/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//
13#ifndef DUMUX_POROUSMEDIUMFLOW_BOXDFM_SUBCONTROLVOLUMEFACE_HH
14#define DUMUX_POROUSMEDIUMFLOW_BOXDFM_SUBCONTROLVOLUMEFACE_HH
15
16#include <utility>
17
18#include <dune/geometry/type.hh>
19#include <dune/geometry/multilineargeometry.hh>
20
25
26namespace Dumux {
27
38template<class GridView>
40{
41 using Grid = typename GridView::Grid;
42 static constexpr int dim = Grid::dimension;
43 static constexpr int dimWorld = Grid::dimensionworld;
44 using GridIndexType = typename Grid::LeafGridView::IndexSet::IndexType;
45 using LocalIndexType = unsigned int;
46 using Scalar = typename Grid::ctype;
48 using Geometry = Dune::MultiLinearGeometry<Scalar, dim-1, dimWorld, GeometryTraits>;
49 using CornerStorage = typename GeometryTraits::template CornerStorage<dim-1, dimWorld>::Type;
50 using GlobalPosition = typename CornerStorage::value_type;
52};
53
61template<class GV,
64: public SubControlVolumeFaceBase<BoxDfmSubControlVolumeFace<GV, T>, T>
65{
68 using GridIndexType = typename T::GridIndexType;
69 using LocalIndexType = typename T::LocalIndexType;
70 using Scalar = typename T::Scalar;
71 using GlobalPosition = typename T::GlobalPosition;
72 using CornerStorage = typename T::CornerStorage;
73 using Geometry = typename T::Geometry;
74 using BoundaryFlag = typename T::BoundaryFlag;
75
76 static_assert(T::dim == 2 || T::dim == 3, "Box-Dfm sub-control volume face only implemented in 2d or 3d");
77
78public:
80 using Traits = T;
81
84
86 template<class GeometryHelper, class Element>
87 BoxDfmSubControlVolumeFace(const GeometryHelper& geometryHelper,
88 const Element& element,
89 const typename Element::Geometry& elemGeometry,
90 GridIndexType scvfIndex,
91 std::vector<LocalIndexType>&& scvIndices)
92 : corners_(geometryHelper.getScvfCorners(scvfIndex))
93 , center_(0.0)
94 , unitOuterNormal_(geometryHelper.normal(corners_, scvIndices))
95 , area_(Dumux::convexPolytopeVolume<T::dim-1>(
96 Dune::GeometryTypes::cube(T::dim-1),
97 [&](unsigned int i){ return corners_[i]; })
98 )
99 , scvfIndex_(scvfIndex)
100 , scvIndices_(std::move(scvIndices))
101 , boundary_(false)
102 , isFractureScvf_(false)
103 , boundaryFlag_{}
104 , facetIdx_(0)
105 {
106 for (const auto& corner : corners_)
107 center_ += corner;
108 center_ /= corners_.size();
109 }
110
112 template<class GeometryHelper, class Intersection>
113 BoxDfmSubControlVolumeFace(const GeometryHelper& geometryHelper,
114 const Intersection& intersection,
115 const typename Intersection::Geometry& isGeometry,
116 LocalIndexType indexInIntersection,
117 GridIndexType scvfIndex,
118 std::vector<LocalIndexType>&& scvIndices)
119 : corners_(geometryHelper.getBoundaryScvfCorners(intersection.indexInInside(), indexInIntersection))
120 , center_(0.0)
121 , unitOuterNormal_(intersection.centerUnitOuterNormal())
122 , area_(Dumux::convexPolytopeVolume<T::dim-1>(
123 Dune::GeometryTypes::cube(T::dim-1),
124 [&](unsigned int i){ return corners_[i]; })
125 )
126 , scvfIndex_(scvfIndex)
127 , scvIndices_(std::move(scvIndices))
128 , boundary_(true)
129 , isFractureScvf_(false)
130 , boundaryFlag_{intersection}
131 , facetIdx_(0)
132 {
133 for (const auto& corner : corners_)
134 center_ += corner;
135 center_ /= corners_.size();
136 }
137
139 template<class GeometryHelper, class Intersection>
140 BoxDfmSubControlVolumeFace(const GeometryHelper& geometryHelper,
141 const Intersection& intersection,
142 const typename Intersection::Geometry& isGeometry,
143 LocalIndexType indexInIntersection,
144 GridIndexType scvfIndex,
145 std::vector<LocalIndexType>&& scvIndices,
146 bool boundary)
147 : corners_(geometryHelper.getFractureScvfCorners(intersection.indexInInside(), indexInIntersection))
148 , center_(0.0)
149 , scvfIndex_(scvfIndex)
150 , scvIndices_(std::move(scvIndices))
151 , boundary_(boundary)
152 , isFractureScvf_(true)
153 , boundaryFlag_{intersection}
154 , facetIdx_(intersection.indexInInside())
155 {
156 // The area here is given in meters. In order to
157 // get the right dimensions, the user has to provide
158 // the appropriate aperture in the problem (via an extrusion factor)
159 if (T::dim == 3)
160 area_ = (corners_[1]-corners_[0]).two_norm();
161 else if (T::dim == 2)
162 area_ = 1.0;
163
164 // obtain the unit normal vector
165 unitOuterNormal_ = geometryHelper.fractureNormal(corners_, intersection, indexInIntersection);
166
167 // compute the scvf center
168 for (const auto& corner : corners_)
169 center_ += corner;
170 center_ /= corners_.size();
171 }
172
174 const GlobalPosition& center() const
175 { return center_; }
176
178 const GlobalPosition& ipGlobal() const
179 { return center_; }
180
182 Scalar area() const
183 { return area_; }
184
186 bool boundary() const
187 { return boundary_; }
188
190 const GlobalPosition& unitOuterNormal() const
191 { return unitOuterNormal_; }
192
194 GridIndexType index() const
195 { return scvfIndex_; }
196
198 bool isOnFracture() const
199 { return isFractureScvf_; }
200
202 LocalIndexType facetIndexInElement() const
203 { assert(isFractureScvf_); return facetIdx_; }
204
207 { return boundaryFlag_.get(); }
208
210 LocalIndexType insideScvIdx() const
211 { return scvIndices_[0]; }
212
214 // Results in undefined behaviour if i >= numOutsideScvs()
215 LocalIndexType outsideScvIdx(int i = 0) const
216 {
217 assert(!boundary());
218 return scvIndices_[1];
219 }
220
222 std::size_t numOutsideScvs() const
223 {
224 return static_cast<std::size_t>(!boundary());
225 }
226
228 [[deprecated("Will be removed after 3.7. Use fvGeometry.geometry(scvf).")]]
229 Geometry geometry() const
230 {
231 if (isFractureScvf_)
232 DUNE_THROW(Dune::InvalidStateException, "The geometry object cannot be defined for fracture scvs "
233 "because the number of known corners is insufficient. "
234 "You can do this manually by extract the corners from this scv "
235 "and extrude them by the corresponding aperture. ");
236
237 return Geometry(Dune::GeometryTypes::cube(Geometry::mydimension), corners_);
238 }
239
240private:
241 CornerStorage corners_;
242 GlobalPosition center_;
243 GlobalPosition unitOuterNormal_;
244 Scalar area_;
245 GridIndexType scvfIndex_;
246 std::vector<LocalIndexType> scvIndices_;
247 bool boundary_;
248 bool isFractureScvf_;
249 BoundaryFlag boundaryFlag_;
250 LocalIndexType facetIdx_;
251};
252
253} // end namespace Dumux
254
255#endif
Boundary flag to store e.g. in sub control volume faces.
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 discrete fracture method, i.e a part of the boundary o...
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:65
BoxDfmSubControlVolumeFace(const GeometryHelper &geometryHelper, const Intersection &intersection, const typename Intersection::Geometry &isGeometry, LocalIndexType indexInIntersection, GridIndexType scvfIndex, std::vector< LocalIndexType > &&scvIndices, bool boundary)
Constructor for inner fracture scvfs.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:140
std::size_t numOutsideScvs() const
The number of scvs on the outside of this face.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:222
const GlobalPosition & unitOuterNormal() const
returns the unit normal vector pointing outwards
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:190
BoxDfmSubControlVolumeFace(const GeometryHelper &geometryHelper, const Intersection &intersection, const typename Intersection::Geometry &isGeometry, LocalIndexType indexInIntersection, GridIndexType scvfIndex, std::vector< LocalIndexType > &&scvIndices)
Constructor for boundary scvfs.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:113
BoundaryFlag::value_type boundaryFlag() const
Returns the boundary flag.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:206
LocalIndexType insideScvIdx() const
index of the inside sub control volume
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:210
const GlobalPosition & ipGlobal() const
The integration point for flux evaluations in global coordinates.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:178
const GlobalPosition & center() const
The center of the sub control volume face.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:174
LocalIndexType facetIndexInElement() const
The element-local facet index for which a fracture scv was created.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:202
BoxDfmSubControlVolumeFace()=default
The default constructor.
bool isOnFracture() const
Return if this is a fracture scvf.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:198
bool boundary() const
returns true if the sub control volume face is on the boundary
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:186
BoxDfmSubControlVolumeFace(const GeometryHelper &geometryHelper, const Element &element, const typename Element::Geometry &elemGeometry, GridIndexType scvfIndex, std::vector< LocalIndexType > &&scvIndices)
Constructor for inner scvfs.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:87
T Traits
State the traits public and thus export all types.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:80
LocalIndexType outsideScvIdx(int i=0) const
Index of the i-th outside sub control volume or boundary scv index.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:215
Geometry geometry() const
The geometry of the sub control volume face.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:229
GridIndexType index() const
The global index of this sub control volume face.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:194
Scalar area() const
The area of the sub control volume face.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:182
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
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
Helper class constructing the dual grid finite volume geometries for the box discrete fracture model.
Default traits class to be used for the sub-control volume faces for the box discrete fracture scheme...
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:40
static constexpr int dim
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:42
Dune::MultiLinearGeometry< Scalar, dim-1, dimWorld, GeometryTraits > Geometry
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:48
typename Grid::LeafGridView::IndexSet::IndexType GridIndexType
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:44
typename GeometryTraits::template CornerStorage< dim-1, dimWorld >::Type CornerStorage
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:49
static constexpr int dimWorld
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:43
typename CornerStorage::value_type GlobalPosition
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:50
typename Grid::ctype Scalar
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:46
typename GridView::Grid Grid
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:41
unsigned int LocalIndexType
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:45
Definition: porousmediumflow/boxdfm/geometryhelper.hh:26
Base class for a sub control volume face.
Compute the volume of several common geometry types.