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-FileCopyrightInfo: 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 BoxDiscretization | ||
10 | * \brief Base class for a sub control volume face | ||
11 | */ | ||
12 | #ifndef DUMUX_DISCRETIZATION_BOX_SUBCONTROLVOLUMEFACE_HH | ||
13 | #define DUMUX_DISCRETIZATION_BOX_SUBCONTROLVOLUMEFACE_HH | ||
14 | |||
15 | #include <utility> | ||
16 | |||
17 | #include <dune/geometry/type.hh> | ||
18 | #include <dune/geometry/multilineargeometry.hh> | ||
19 | |||
20 | #include <dumux/common/boundaryflag.hh> | ||
21 | #include <dumux/common/indextraits.hh> | ||
22 | #include <dumux/geometry/volume.hh> | ||
23 | #include <dumux/geometry/center.hh> | ||
24 | #include <dumux/discretization/subcontrolvolumefacebase.hh> | ||
25 | #include <dumux/discretization/box/boxgeometryhelper.hh> | ||
26 | |||
27 | namespace Dumux { | ||
28 | |||
29 | /*! | ||
30 | * \ingroup BoxDiscretization | ||
31 | * \brief Default traits class to be used for the sub-control volume faces | ||
32 | * for the box scheme | ||
33 | * \tparam GV the type of the grid view | ||
34 | */ | ||
35 | template<class GridView> | ||
36 | struct BoxDefaultScvfGeometryTraits | ||
37 | { | ||
38 | using Grid = typename GridView::Grid; | ||
39 | static constexpr int dim = Grid::dimension; | ||
40 | static constexpr int dimWorld = Grid::dimensionworld; | ||
41 | using GridIndexType = typename IndexTraits<GridView>::GridIndex; | ||
42 | using LocalIndexType = typename IndexTraits<GridView>::LocalIndex; | ||
43 | using Scalar = typename Grid::ctype; | ||
44 | using GeometryTraits = BoxMLGeometryTraits<Scalar>; | ||
45 | using Geometry = Dune::MultiLinearGeometry<Scalar, dim-1, dimWorld, GeometryTraits>; | ||
46 | using CornerStorage = typename GeometryTraits::template CornerStorage<dim-1, dimWorld>::Type; | ||
47 | using GlobalPosition = typename Geometry::GlobalCoordinate; | ||
48 | using BoundaryFlag = Dumux::BoundaryFlag<Grid>; | ||
49 | }; | ||
50 | |||
51 | /*! | ||
52 | * \ingroup BoxDiscretization | ||
53 | * \brief Class for a sub control volume face in the box method, i.e a part of the boundary | ||
54 | * of a sub control volume we compute fluxes on. We simply use the base class here. | ||
55 | * \tparam GV the type of the grid view | ||
56 | * \tparam T the scvf geometry traits | ||
57 | */ | ||
58 | template<class GV, | ||
59 | class T = BoxDefaultScvfGeometryTraits<GV> > | ||
60 |
33/60✓ Branch 0 taken 708260 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 108124 times.
✓ Branch 5 taken 72665 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 34906 times.
✓ Branch 8 taken 56922 times.
✓ Branch 9 taken 103290 times.
✓ Branch 10 taken 2444785 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 21306 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 429872 times.
✓ Branch 16 taken 73214 times.
✓ Branch 17 taken 13236226 times.
✓ Branch 18 taken 393235 times.
✓ Branch 19 taken 26840866 times.
✓ Branch 20 taken 611843 times.
✓ Branch 21 taken 26633056 times.
✓ Branch 22 taken 308520 times.
✓ Branch 23 taken 14036560 times.
✓ Branch 24 taken 6559148 times.
✓ Branch 25 taken 112 times.
✓ Branch 26 taken 10692693 times.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 20 times.
✗ Branch 32 not taken.
✓ Branch 33 taken 7796 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 82308 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 82308 times.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✓ Branch 41 taken 10824 times.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 47 not taken.
✓ Branch 48 taken 256 times.
✗ Branch 49 not taken.
✓ Branch 50 taken 256 times.
✗ Branch 51 not taken.
✓ Branch 52 taken 256 times.
✗ Branch 53 not taken.
✓ Branch 54 taken 13824 times.
✗ Branch 55 not taken.
✓ Branch 56 taken 13824 times.
✗ Branch 57 not taken.
✓ Branch 58 taken 51492 times.
✗ Branch 59 not taken.
✓ Branch 60 taken 51492 times.
|
72627094 | class BoxSubControlVolumeFace |
61 | : public SubControlVolumeFaceBase<BoxSubControlVolumeFace<GV, T>, T> | ||
62 | { | ||
63 | using ThisType = BoxSubControlVolumeFace<GV, T>; | ||
64 | using ParentType = SubControlVolumeFaceBase<ThisType, 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 | static constexpr int dim = Geometry::mydimension; | ||
71 | |||
72 | public: | ||
73 | //! export the type used for global coordinates | ||
74 | using GlobalPosition = typename T::GlobalPosition; | ||
75 | //! state the traits public and thus export all types | ||
76 | using Traits = T; | ||
77 | |||
78 | //! The default constructor | ||
79 | 82717080 | BoxSubControlVolumeFace() = default; | |
80 | |||
81 | //! Constructor for inner scvfs | ||
82 | template<class Corners, class Element> | ||
83 | 27865944 | BoxSubControlVolumeFace(const Corners& corners, | |
84 | const GlobalPosition& normal, | ||
85 | const Element& element, | ||
86 | const typename Element::Geometry& elemGeometry, | ||
87 | GridIndexType scvfIndex, | ||
88 | std::vector<LocalIndexType>&& scvIndices, | ||
89 | bool boundary = false) | ||
90 | 27865944 | : center_(Dumux::center(corners)) | |
91 | , unitOuterNormal_(normal) | ||
92 | , scvfIndex_(scvfIndex) | ||
93 | 27865944 | , scvIndices_(std::move(scvIndices)) | |
94 | , boundary_(boundary) | ||
95 | 55731888 | , boundaryFlag_{} | |
96 | { | ||
97 | 27865944 | area_ = Dumux::convexPolytopeVolume<dim>( | |
98 | Dune::GeometryTypes::cube(dim), | ||
99 | 6064632 | [&](unsigned int i){ return corners[i]; } | |
100 | ); | ||
101 | 25198618 | } | |
102 | |||
103 | //! Constructor for boundary scvfs | ||
104 | template<class Corners, class Intersection> | ||
105 | 3029357 | BoxSubControlVolumeFace(const Corners& corners, | |
106 | const GlobalPosition& normal, | ||
107 | const Intersection& intersection, | ||
108 | const typename Intersection::Geometry& isGeometry, | ||
109 | LocalIndexType indexInIntersection, | ||
110 | GridIndexType scvfIndex, | ||
111 | std::vector<LocalIndexType>&& scvIndices, | ||
112 | bool boundary = false) | ||
113 | 3029357 | : center_(Dumux::center(corners)) | |
114 | , unitOuterNormal_(normal) | ||
115 | , scvfIndex_(scvfIndex) | ||
116 | 3029357 | , scvIndices_(std::move(scvIndices)) | |
117 | , boundary_(boundary) | ||
118 |
4/8✓ Branch 0 taken 19927 times.
✓ Branch 1 taken 2556304 times.
✓ Branch 2 taken 19927 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2556304 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
6058714 | , boundaryFlag_{intersection} |
119 | { | ||
120 | 3029357 | area_ = Dumux::convexPolytopeVolume<dim>( | |
121 | Dune::GeometryTypes::cube(dim), | ||
122 | 965360 | [&](unsigned int i){ return corners[i]; } | |
123 | ); | ||
124 | 3029357 | } | |
125 | |||
126 | //! The center of the sub control volume face | ||
127 | const GlobalPosition& center() const | ||
128 | { | ||
129 | 499639243 | return center_; | |
130 | } | ||
131 | |||
132 | //! The integration point for flux evaluations in global coordinates | ||
133 | const GlobalPosition& ipGlobal() const | ||
134 | { | ||
135 |
13/24✓ Branch 0 taken 120347 times.
✓ Branch 1 taken 12632793 times.
✓ Branch 2 taken 120562 times.
✓ Branch 3 taken 394983 times.
✓ Branch 4 taken 482446 times.
✓ Branch 5 taken 10350 times.
✓ Branch 6 taken 20270 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2560 times.
✓ Branch 9 taken 10432 times.
✓ Branch 10 taken 2048 times.
✓ Branch 11 taken 512 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 5430 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 5430 times.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
58369864 | return center_; |
136 | } | ||
137 | |||
138 | //! The area of the sub control volume face | ||
139 | ✗ | Scalar area() const | |
140 | { | ||
141 | ✗ | return area_; | |
142 | } | ||
143 | |||
144 | //! returns true if the sub control volume face is on the boundary | ||
145 | ✗ | bool boundary() const | |
146 | { | ||
147 | ✗ | return boundary_; | |
148 | } | ||
149 | |||
150 | const GlobalPosition& unitOuterNormal() const | ||
151 | { | ||
152 |
8/10✓ Branch 0 taken 226462852 times.
✓ Branch 1 taken 5738472 times.
✓ Branch 2 taken 142814870 times.
✓ Branch 3 taken 6162400 times.
✓ Branch 4 taken 264156312 times.
✓ Branch 5 taken 940000 times.
✓ Branch 6 taken 3814800 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1924800 times.
✗ Branch 9 not taken.
|
1789399462 | return unitOuterNormal_; |
153 | } | ||
154 | |||
155 | //! index of the inside sub control volume | ||
156 | LocalIndexType insideScvIdx() const | ||
157 | { | ||
158 |
21/30✗ Branch 0 not taken.
✓ Branch 1 taken 47588524 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 607085162 times.
✓ Branch 4 taken 62139252 times.
✓ Branch 5 taken 765475734 times.
✓ Branch 6 taken 13335132 times.
✓ Branch 7 taken 259349804 times.
✓ Branch 8 taken 14154868 times.
✓ Branch 9 taken 282337702 times.
✓ Branch 10 taken 504108 times.
✓ Branch 11 taken 275617399 times.
✓ Branch 12 taken 221362 times.
✓ Branch 13 taken 10164380 times.
✓ Branch 14 taken 5849 times.
✓ Branch 15 taken 2439275 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 1664 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 1664 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 1664 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 1664 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 1664 times.
✗ Branch 26 not taken.
✓ Branch 27 taken 1664 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 1664 times.
|
2711949475 | return scvIndices_[0]; |
159 | } | ||
160 | |||
161 | //! Index of the i-th outside sub control volume or boundary scv index. | ||
162 | // Results in undefined behaviour if i >= numOutsideScvs() | ||
163 | ✗ | LocalIndexType outsideScvIdx(int i = 0) const | |
164 | { | ||
165 |
8/18✗ Branch 0 not taken.
✓ Branch 1 taken 47588524 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 110459834 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 573755846 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 779870840 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 258489488 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 282666876 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 275403672 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 9384640 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
|
2337619720 | assert(!boundary()); |
166 |
14/16✓ Branch 0 taken 22550551 times.
✓ Branch 1 taken 25037973 times.
✓ Branch 2 taken 309250253 times.
✓ Branch 3 taken 359974161 times.
✓ Branch 4 taken 432842266 times.
✓ Branch 5 taken 332640086 times.
✓ Branch 6 taken 161186546 times.
✓ Branch 7 taken 3437426 times.
✓ Branch 8 taken 275828989 times.
✓ Branch 9 taken 74655 times.
✓ Branch 10 taken 2223600 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 375 times.
✓ Branch 13 taken 985 times.
✓ Branch 14 taken 1360 times.
✗ Branch 15 not taken.
|
2636168536 | return scvIndices_[1]; |
167 | } | ||
168 | |||
169 | //! The number of scvs on the outside of this face | ||
170 | std::size_t numOutsideScvs() const | ||
171 | { | ||
172 |
1/2✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
|
24 | return static_cast<std::size_t>(!boundary()); |
173 | } | ||
174 | |||
175 | //! The local index of this sub control volume face | ||
176 | ✗ | GridIndexType index() const | |
177 | { | ||
178 | ✗ | return scvfIndex_; | |
179 | } | ||
180 | |||
181 | //! Return the boundary flag | ||
182 | typename BoundaryFlag::value_type boundaryFlag() const | ||
183 | { | ||
184 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 4464 times.
✗ Branch 2 not taken.
|
1586568 | return boundaryFlag_.get(); |
185 | } | ||
186 | |||
187 | private: | ||
188 | GlobalPosition center_; | ||
189 | GlobalPosition unitOuterNormal_; | ||
190 | Scalar area_; | ||
191 | GridIndexType scvfIndex_; | ||
192 | std::vector<LocalIndexType> scvIndices_; | ||
193 | bool boundary_; | ||
194 | BoundaryFlag boundaryFlag_; | ||
195 | }; | ||
196 | |||
197 | } // end namespace Dumux | ||
198 | |||
199 | #endif | ||
200 |