Line | Branch | Exec | Source |
---|---|---|---|
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 | // | ||
7 | /*! | ||
8 | * \file | ||
9 | * \ingroup BoxDFMModel | ||
10 | * \brief The sub control volume face class for the box discrete fracture model. | ||
11 | */ | ||
12 | |||
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 | |||
21 | #include <dumux/common/boundaryflag.hh> | ||
22 | #include <dumux/porousmediumflow/boxdfm/geometryhelper.hh> | ||
23 | #include <dumux/geometry/volume.hh> | ||
24 | |||
25 | namespace Dumux { | ||
26 | |||
27 | /*! | ||
28 | * \ingroup BoxDFMModel | ||
29 | * \brief Default traits class to be used for the sub-control volume faces | ||
30 | * for the box discrete fracture scheme | ||
31 | * | ||
32 | * \tparam GV the type of the grid view | ||
33 | * | ||
34 | * \note We define new traits for the box-dfm sub-control volume face | ||
35 | * as we use a different type of container for storing the scvf corners! | ||
36 | */ | ||
37 | template<class GridView> | ||
38 | struct BoxDfmDefaultScvfGeometryTraits | ||
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; | ||
46 | using GeometryTraits = BoxDfmMLGeometryTraits<Scalar>; | ||
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; | ||
50 | using BoundaryFlag = Dumux::BoundaryFlag<Grid>; | ||
51 | }; | ||
52 | |||
53 | /*! | ||
54 | * \ingroup BoxDFMModel | ||
55 | * \brief Class for a sub control volume face in the box discrete fracture method, i.e a | ||
56 | * part of the boundary of a sub control volume we compute fluxes on. | ||
57 | * \tparam GV the type of the grid view | ||
58 | * \tparam T the scvf geometry traits | ||
59 | */ | ||
60 | template<class GV, | ||
61 | class T = BoxDfmDefaultScvfGeometryTraits<GV> > | ||
62 | 24220574 | class BoxDfmSubControlVolumeFace | |
63 | { | ||
64 | using ThisType = BoxDfmSubControlVolumeFace<GV, T>; | ||
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 | |||
73 | public: | ||
74 | //! export the type used for global coordinates | ||
75 | using GlobalPosition = typename T::GlobalPosition; | ||
76 | //! State the traits public and thus export all types | ||
77 | using Traits = T; | ||
78 | |||
79 | //! The default constructor | ||
80 | 10067224 | BoxDfmSubControlVolumeFace() = default; | |
81 | |||
82 | //! Constructor for inner scvfs | ||
83 | template<class GeometryHelper, class Element> | ||
84 | 10173744 | BoxDfmSubControlVolumeFace(const GeometryHelper& geometryHelper, | |
85 | const Element& element, | ||
86 | const typename Element::Geometry& elemGeometry, | ||
87 | GridIndexType scvfIndex, | ||
88 | std::vector<LocalIndexType>&& scvIndices) | ||
89 | 10173744 | : center_(0.0) | |
90 | 10173744 | , scvfIndex_(scvfIndex) | |
91 |
1/2✓ Branch 1 taken 10173744 times.
✗ Branch 2 not taken.
|
10173744 | , scvIndices_(std::move(scvIndices)) |
92 | 10173744 | , boundary_(false) | |
93 | 10173744 | , isFractureScvf_(false) | |
94 |
1/2✓ Branch 1 taken 10173744 times.
✗ Branch 2 not taken.
|
10173744 | , boundaryFlag_{} |
95 | 10173744 | , facetIdx_(0) | |
96 |
1/2✓ Branch 1 taken 10173744 times.
✗ Branch 2 not taken.
|
10173744 | , indexInIntersection_(0) |
97 | { | ||
98 |
1/2✓ Branch 1 taken 10173744 times.
✗ Branch 2 not taken.
|
10173744 | const auto corners = geometryHelper.getScvfCorners(scvfIndex); |
99 |
1/2✓ Branch 1 taken 5792664 times.
✗ Branch 2 not taken.
|
10173744 | unitOuterNormal_ = geometryHelper.normal(corners, scvIndices_); |
100 | 20347488 | area_ = Dumux::convexPolytopeVolume<T::dim-1>( | |
101 | Dune::GeometryTypes::cube(T::dim-1), | ||
102 | 24495480 | [&](unsigned int i){ return corners[i]; }); | |
103 | |||
104 |
2/2✓ Branch 0 taken 28643472 times.
✓ Branch 1 taken 10173744 times.
|
38817216 | for (const auto& corner : corners) |
105 |
2/2✓ Branch 0 taken 73878912 times.
✓ Branch 1 taken 28643472 times.
|
102522384 | center_ += corner; |
106 | 10173744 | center_ /= corners.size(); | |
107 | 10173744 | } | |
108 | |||
109 | //! Constructor for boundary scvfs | ||
110 | template<class GeometryHelper, class Intersection> | ||
111 | 963468 | BoxDfmSubControlVolumeFace(const GeometryHelper& geometryHelper, | |
112 | const Intersection& intersection, | ||
113 | const typename Intersection::Geometry& isGeometry, | ||
114 | LocalIndexType indexInIntersection, | ||
115 | GridIndexType scvfIndex, | ||
116 | std::vector<LocalIndexType>&& scvIndices) | ||
117 | 1926936 | : center_(0.0) | |
118 | 963468 | , unitOuterNormal_(intersection.centerUnitOuterNormal()) | |
119 | 963468 | , scvfIndex_(scvfIndex) | |
120 |
1/2✓ Branch 1 taken 963468 times.
✗ Branch 2 not taken.
|
963468 | , scvIndices_(std::move(scvIndices)) |
121 | 963468 | , boundary_(true) | |
122 | 963468 | , isFractureScvf_(false) | |
123 |
1/2✓ Branch 1 taken 963468 times.
✗ Branch 2 not taken.
|
963468 | , boundaryFlag_{intersection} |
124 | 963468 | , facetIdx_(0) | |
125 | 963468 | , indexInIntersection_(0) | |
126 | { | ||
127 |
2/4✓ Branch 1 taken 963468 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 352604 times.
✗ Branch 5 not taken.
|
963468 | const auto corners = geometryHelper.getBoundaryScvfCorners(intersection.indexInInside(), indexInIntersection); |
128 | 1926936 | area_ = Dumux::convexPolytopeVolume<T::dim-1>( | |
129 | Dune::GeometryTypes::cube(T::dim-1), | ||
130 | 2699676 | [&](unsigned int i){ return corners[i]; }); | |
131 |
2/2✓ Branch 0 taken 3472416 times.
✓ Branch 1 taken 963468 times.
|
4435884 | for (const auto& corner : corners) |
132 |
2/2✓ Branch 0 taken 10035792 times.
✓ Branch 1 taken 3472416 times.
|
13508208 | center_ += corner; |
133 | 963468 | center_ /= corners.size(); | |
134 | 963468 | } | |
135 | |||
136 | //! Constructor for inner fracture scvfs | ||
137 | template<class GeometryHelper, class Intersection> | ||
138 | 406656 | BoxDfmSubControlVolumeFace(const GeometryHelper& geometryHelper, | |
139 | const Intersection& intersection, | ||
140 | const typename Intersection::Geometry& isGeometry, | ||
141 | LocalIndexType indexInIntersection, | ||
142 | GridIndexType scvfIndex, | ||
143 | std::vector<LocalIndexType>&& scvIndices, | ||
144 | bool boundary) | ||
145 | 406656 | : center_(0.0) | |
146 | 406656 | , scvfIndex_(scvfIndex) | |
147 |
1/2✓ Branch 1 taken 406656 times.
✗ Branch 2 not taken.
|
406656 | , scvIndices_(std::move(scvIndices)) |
148 | 406656 | , boundary_(boundary) | |
149 | 406656 | , isFractureScvf_(true) | |
150 |
2/4✓ Branch 1 taken 406656 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 406656 times.
✗ Branch 5 not taken.
|
406656 | , boundaryFlag_{intersection} |
151 | 406656 | , facetIdx_(intersection.indexInInside()) | |
152 |
2/4✓ Branch 1 taken 406656 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 167848 times.
✗ Branch 5 not taken.
|
574504 | , indexInIntersection_(indexInIntersection) |
153 | { | ||
154 |
1/2✓ Branch 1 taken 406656 times.
✗ Branch 2 not taken.
|
406656 | const auto corners = geometryHelper.getFractureScvfCorners(intersection.indexInInside(), indexInIntersection); |
155 | // The area here is given in meters. In order to | ||
156 | // get the right dimensions, the user has to provide | ||
157 | // the appropriate aperture in the problem (via an extrusion factor) | ||
158 | if (T::dim == 3) | ||
159 | 419760 | area_ = (corners[1]-corners[0]).two_norm(); | |
160 | else if (T::dim == 2) | ||
161 | 196776 | area_ = 1.0; | |
162 | |||
163 | // obtain the unit normal vector | ||
164 |
1/2✓ Branch 1 taken 406656 times.
✗ Branch 2 not taken.
|
406656 | unitOuterNormal_ = geometryHelper.fractureNormal(corners, intersection, indexInIntersection); |
165 | |||
166 | // compute the scvf center | ||
167 |
2/2✓ Branch 0 taken 616536 times.
✓ Branch 1 taken 406656 times.
|
1023192 | for (const auto& corner : corners) |
168 |
2/2✓ Branch 0 taken 1652832 times.
✓ Branch 1 taken 616536 times.
|
2269368 | center_ += corner; |
169 | 406656 | center_ /= corners.size(); | |
170 | 406656 | } | |
171 | |||
172 | //! The center of the sub control volume face | ||
173 | const GlobalPosition& center() const | ||
174 | ✗ | { return center_; } | |
175 | |||
176 | //! The integration point for flux evaluations in global coordinates | ||
177 | 10326420 | const GlobalPosition& ipGlobal() const | |
178 |
1/2✓ Branch 1 taken 5904540 times.
✗ Branch 2 not taken.
|
12649106 | { return center_; } |
179 | |||
180 | //! The area of the sub control volume face | ||
181 | 82482638 | Scalar area() const | |
182 | 82482638 | { return area_; } | |
183 | |||
184 | //! returns true if the sub control volume face is on the boundary | ||
185 | 248455464 | bool boundary() const | |
186 |
4/4✓ Branch 0 taken 40079976 times.
✓ Branch 1 taken 3987804 times.
✓ Branch 2 taken 40079976 times.
✓ Branch 3 taken 3987804 times.
|
88135560 | { return boundary_; } |
187 | |||
188 | //! returns the unit normal vector pointing outwards | ||
189 | const GlobalPosition& unitOuterNormal() const | ||
190 |
1/2✓ Branch 0 taken 80159952 times.
✗ Branch 1 not taken.
|
160319904 | { return unitOuterNormal_; } |
191 | |||
192 | //! The global index of this sub control volume face | ||
193 | 90486372 | GridIndexType index() const | |
194 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 80159952 times.
|
90486372 | { return scvfIndex_; } |
195 | |||
196 | //! Return if this is a fracture scvf | ||
197 | 20652840 | bool isOnFracture() const | |
198 |
4/4✓ Branch 0 taken 9964380 times.
✓ Branch 1 taken 362040 times.
✓ Branch 2 taken 9964380 times.
✓ Branch 3 taken 362040 times.
|
20652840 | { return isFractureScvf_; } |
199 | |||
200 | //! The element-local facet index for which a fracture scv was created | ||
201 | 724080 | LocalIndexType facetIndexInElement() const | |
202 | 724080 | { assert(isFractureScvf_); return facetIdx_; } | |
203 | |||
204 | //! The local edge index inside the intersection | ||
205 | LocalIndexType indexInIntersection() const | ||
206 | { assert(isFractureScvf_); return indexInIntersection_; } | ||
207 | |||
208 | //! Returns the boundary flag | ||
209 | typename BoundaryFlag::value_type boundaryFlag() const | ||
210 | { return boundaryFlag_.get(); } | ||
211 | |||
212 | //! index of the inside sub control volume | ||
213 | 208375488 | LocalIndexType insideScvIdx() const | |
214 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 80159952 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 80159952 times.
|
208375488 | { return scvIndices_[0]; } |
215 | |||
216 | //! Index of the i-th outside sub control volume or boundary scv index. | ||
217 | // Results in undefined behaviour if i >= numOutsideScvs() | ||
218 | 200399880 | LocalIndexType outsideScvIdx(int i = 0) const | |
219 | { | ||
220 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 80159952 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 80159952 times.
|
160319904 | assert(!boundary()); |
221 |
3/4✓ Branch 0 taken 38652800 times.
✓ Branch 1 taken 41507152 times.
✓ Branch 2 taken 80159952 times.
✗ Branch 3 not taken.
|
200399880 | return scvIndices_[1]; |
222 | } | ||
223 | |||
224 | //! The number of scvs on the outside of this face | ||
225 | std::size_t numOutsideScvs() const | ||
226 | { | ||
227 | return static_cast<std::size_t>(!boundary()); | ||
228 | } | ||
229 | |||
230 | private: | ||
231 | GlobalPosition center_; | ||
232 | GlobalPosition unitOuterNormal_; | ||
233 | Scalar area_; | ||
234 | GridIndexType scvfIndex_; | ||
235 | std::vector<LocalIndexType> scvIndices_; | ||
236 | bool boundary_; | ||
237 | bool isFractureScvf_; | ||
238 | BoundaryFlag boundaryFlag_; | ||
239 | LocalIndexType facetIdx_; | ||
240 | LocalIndexType indexInIntersection_; | ||
241 | }; | ||
242 | |||
243 | } // end namespace Dumux | ||
244 | |||
245 | #endif | ||
246 |