version 3.11-dev
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-FileCopyrightText: 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
24
25namespace Dumux {
26
37template<class GridView>
39{
40 using Grid = typename GridView::Grid;
41 static constexpr int dim = Grid::dimension;
42 static constexpr int dimWorld = Grid::dimensionworld;
43 using GridIndexType = typename Grid::LeafGridView::IndexSet::IndexType;
44 using LocalIndexType = unsigned int;
45 using Scalar = typename Grid::ctype;
47 using Geometry = Dune::MultiLinearGeometry<Scalar, dim-1, dimWorld, GeometryTraits>;
48 using CornerStorage = typename GeometryTraits::template CornerStorage<dim-1, dimWorld>::Type;
49 using GlobalPosition = typename CornerStorage::value_type;
51};
52
60template<class GV,
63{
65 using GridIndexType = typename T::GridIndexType;
66 using LocalIndexType = typename T::LocalIndexType;
67 using Scalar = typename T::Scalar;
68 using Geometry = typename T::Geometry;
69 using BoundaryFlag = typename T::BoundaryFlag;
70
71 static_assert(T::dim == 2 || T::dim == 3, "Box-Dfm sub-control volume face only implemented in 2d or 3d");
72
73public:
75 using GlobalPosition = typename T::GlobalPosition;
77 using Traits = T;
78
81
83 template<class GeometryHelper, class Element>
84 BoxDfmSubControlVolumeFace(const GeometryHelper& geometryHelper,
85 const Element& element,
86 GridIndexType scvfIndex,
87 std::array<LocalIndexType, 2>&& scvIndices)
88 : center_(0.0)
89 , scvfIndex_(scvfIndex)
90 , scvIndices_(std::move(scvIndices))
91 , boundary_(false)
92 , isFractureScvf_(false)
93 , boundaryFlag_{}
94 , facetIdx_(0)
95 , indexInIntersection_(0)
96 {
97 const auto corners = geometryHelper.getScvfCorners(scvfIndex);
98 unitOuterNormal_ = geometryHelper.normal(corners, scvIndices_);
99 area_ = Dumux::convexPolytopeVolume<T::dim-1>(
100 Dune::GeometryTypes::cube(T::dim-1),
101 [&](unsigned int i){ return corners[i]; });
102
103 for (const auto& corner : corners)
104 center_ += corner;
105 center_ /= corners.size();
106 }
107
109 template<class GeometryHelper, class Intersection>
110 BoxDfmSubControlVolumeFace(const GeometryHelper& geometryHelper,
111 const Intersection& intersection,
112 LocalIndexType indexInIntersection,
113 GridIndexType scvfIndex,
114 std::array<LocalIndexType, 2>&& scvIndices)
115 : center_(0.0)
116 , unitOuterNormal_(intersection.centerUnitOuterNormal())
117 , scvfIndex_(scvfIndex)
118 , scvIndices_(std::move(scvIndices))
119 , boundary_(true)
120 , isFractureScvf_(false)
121 , boundaryFlag_{intersection}
122 , facetIdx_(0)
123 , indexInIntersection_(0)
124 {
125 const auto corners = geometryHelper.getBoundaryScvfCorners(intersection.indexInInside(), indexInIntersection);
126 area_ = Dumux::convexPolytopeVolume<T::dim-1>(
127 Dune::GeometryTypes::cube(T::dim-1),
128 [&](unsigned int i){ return corners[i]; });
129 for (const auto& corner : corners)
130 center_ += corner;
131 center_ /= corners.size();
132 }
133
135 template<class GeometryHelper, class Intersection>
136 BoxDfmSubControlVolumeFace(const GeometryHelper& geometryHelper,
137 const Intersection& intersection,
138 LocalIndexType indexInIntersection,
139 GridIndexType scvfIndex,
140 std::array<LocalIndexType, 2>&& scvIndices,
141 bool boundary)
142 : center_(0.0)
143 , scvfIndex_(scvfIndex)
144 , scvIndices_(std::move(scvIndices))
145 , boundary_(boundary)
146 , isFractureScvf_(true)
147 , boundaryFlag_{intersection}
148 , facetIdx_(intersection.indexInInside())
149 , indexInIntersection_(indexInIntersection)
150 {
151 const auto corners = geometryHelper.getFractureScvfCorners(intersection.indexInInside(), indexInIntersection);
152 // The area here is given in meters. In order to
153 // get the right dimensions, the user has to provide
154 // the appropriate aperture in the problem (via an extrusion factor)
155 if (T::dim == 3)
156 area_ = (corners[1]-corners[0]).two_norm();
157 else if (T::dim == 2)
158 area_ = 1.0;
159
160 // obtain the unit normal vector
161 unitOuterNormal_ = geometryHelper.fractureNormal(corners, intersection, indexInIntersection);
162
163 // compute the scvf center
164 for (const auto& corner : corners)
165 center_ += corner;
166 center_ /= corners.size();
167 }
168
170 const GlobalPosition& center() const
171 { return center_; }
172
175 { return center_; }
176
178 Scalar area() const
179 { return area_; }
180
182 bool boundary() const
183 { return boundary_; }
184
187 { return unitOuterNormal_; }
188
190 GridIndexType index() const
191 { return scvfIndex_; }
192
194 bool isOnFracture() const
195 { return isFractureScvf_; }
196
198 LocalIndexType facetIndexInElement() const
199 { assert(isFractureScvf_); return facetIdx_; }
200
202 LocalIndexType indexInIntersection() const
203 { assert(isFractureScvf_); return indexInIntersection_; }
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
227private:
228 GlobalPosition center_;
229 GlobalPosition unitOuterNormal_;
230 Scalar area_;
231 GridIndexType scvfIndex_;
232 std::array<LocalIndexType, 2> scvIndices_;
233 bool boundary_;
234 bool isFractureScvf_;
235 BoundaryFlag boundaryFlag_;
236 LocalIndexType facetIdx_;
237 LocalIndexType indexInIntersection_;
238};
239
240} // end namespace Dumux
241
242#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:58
std::size_t value_type
Definition: boundaryflag.hh:28
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:63
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:186
BoundaryFlag::value_type boundaryFlag() const
Returns the boundary flag.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:206
LocalIndexType indexInIntersection() const
The local edge index inside the intersection.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:202
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:174
const GlobalPosition & center() const
The center of the sub control volume face.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:170
BoxDfmSubControlVolumeFace(const GeometryHelper &geometryHelper, const Element &element, GridIndexType scvfIndex, std::array< LocalIndexType, 2 > &&scvIndices)
Constructor for inner scvfs.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:84
LocalIndexType facetIndexInElement() const
The element-local facet index for which a fracture scv was created.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:198
BoxDfmSubControlVolumeFace()=default
The default constructor.
bool isOnFracture() const
Return if this is a fracture scvf.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:194
bool boundary() const
returns true if the sub control volume face is on the boundary
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:182
BoxDfmSubControlVolumeFace(const GeometryHelper &geometryHelper, const Intersection &intersection, LocalIndexType indexInIntersection, GridIndexType scvfIndex, std::array< LocalIndexType, 2 > &&scvIndices, bool boundary)
Constructor for inner fracture scvfs.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:136
T Traits
State the traits public and thus export all types.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:77
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
typename T::GlobalPosition GlobalPosition
export the type used for global coordinates
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:75
GridIndexType index() const
The global index of this sub control volume face.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:190
BoxDfmSubControlVolumeFace(const GeometryHelper &geometryHelper, const Intersection &intersection, LocalIndexType indexInIntersection, GridIndexType scvfIndex, std::array< LocalIndexType, 2 > &&scvIndices)
Constructor for boundary scvfs.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:110
Scalar area() const
The area of the sub control volume face.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:178
auto convexPolytopeVolume(Dune::GeometryType type, const CornerF &c)
Compute the volume of several common geometry types.
Definition: volume.hh:41
Definition: adapt.hh:17
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:39
static constexpr int dim
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:41
Dune::MultiLinearGeometry< Scalar, dim-1, dimWorld, GeometryTraits > Geometry
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:47
typename Grid::LeafGridView::IndexSet::IndexType GridIndexType
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:43
typename GeometryTraits::template CornerStorage< dim-1, dimWorld >::Type CornerStorage
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:48
static constexpr int dimWorld
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:42
typename CornerStorage::value_type GlobalPosition
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:49
typename Grid::ctype Scalar
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:45
typename GridView::Grid Grid
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:40
unsigned int LocalIndexType
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:44
Definition: porousmediumflow/boxdfm/geometryhelper.hh:26
Compute the volume of several common geometry types.