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 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 |
12/28✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7776 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10824 times.
✓ Branch 6 taken 320 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 17152 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 56922 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✓ Branch 18 taken 256 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 256 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 13824 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 13824 times.
✗ Branch 25 not taken.
✓ Branch 26 taken 51492 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 51492 times.
|
50908820 | 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 | 16863325 | BoxSubControlVolumeFace() = default; | |
80 | |||
81 | //! Constructor for inner scvfs | ||
82 | template<class Corners, class Element> | ||
83 | 28218281 | 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 | 28218281 | : center_(Dumux::center(corners)) | |
91 | 28218281 | , unitOuterNormal_(normal) | |
92 | 28218281 | , scvfIndex_(scvfIndex) | |
93 | 28218281 | , scvIndices_(std::move(scvIndices)) | |
94 | 28218281 | , boundary_(boundary) | |
95 | 28218281 | , boundaryFlag_{} | |
96 | { | ||
97 | 53604620 | area_ = Dumux::convexPolytopeVolume<dim>( | |
98 | Dune::GeometryTypes::cube(dim), | ||
99 | 54451276 | [&](unsigned int i){ return corners[i]; } | |
100 | ); | ||
101 | 25550955 | } | |
102 | |||
103 | //! Constructor for boundary scvfs | ||
104 | template<class Corners, class Intersection> | ||
105 | 3071015 | 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 | 3071015 | : center_(Dumux::center(corners)) | |
114 | 3071015 | , unitOuterNormal_(normal) | |
115 | 3071015 | , scvfIndex_(scvfIndex) | |
116 |
2/3✓ Branch 0 taken 19927 times.
✓ Branch 1 taken 2600488 times.
✗ Branch 2 not taken.
|
3071015 | , scvIndices_(std::move(scvIndices)) |
117 | 3071015 | , boundary_(boundary) | |
118 |
2/3✓ Branch 0 taken 19927 times.
✓ Branch 1 taken 2600488 times.
✗ Branch 2 not taken.
|
3071015 | , boundaryFlag_{intersection} |
119 | { | ||
120 | 6074319 | area_ = Dumux::convexPolytopeVolume<dim>( | |
121 | Dune::GeometryTypes::cube(dim), | ||
122 | 6176869 | [&](unsigned int i){ return corners[i]; } | |
123 | ); | ||
124 | 3071015 | } | |
125 | |||
126 | //! The center of the sub control volume face | ||
127 | const GlobalPosition& center() const | ||
128 | { | ||
129 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 7234448 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3539200 times.
|
491577603 | return center_; |
130 | } | ||
131 | |||
132 | //! The integration point for flux evaluations in global coordinates | ||
133 | 34942812 | const GlobalPosition& ipGlobal() const | |
134 | { | ||
135 |
10/12✓ Branch 0 taken 469194 times.
✓ Branch 1 taken 22430730 times.
✓ Branch 2 taken 26277 times.
✓ Branch 3 taken 81275 times.
✓ Branch 4 taken 485006 times.
✓ Branch 5 taken 512 times.
✓ Branch 6 taken 2048 times.
✓ Branch 7 taken 10432 times.
✓ Branch 8 taken 5430 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 15350 times.
✗ Branch 11 not taken.
|
330002379 | return center_; |
136 | } | ||
137 | |||
138 | //! The area of the sub control volume face | ||
139 | 1211096792 | Scalar area() const | |
140 | { | ||
141 |
0/2✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
594691350 | return area_; |
142 | } | ||
143 | |||
144 | //! returns true if the sub control volume face is on the boundary | ||
145 | 3053247812 | bool boundary() const | |
146 | { | ||
147 |
18/18✓ Branch 0 taken 67933126 times.
✓ Branch 1 taken 9197620 times.
✓ Branch 2 taken 310541028 times.
✓ Branch 3 taken 35780005 times.
✓ Branch 4 taken 244050934 times.
✓ Branch 5 taken 28391699 times.
✓ Branch 6 taken 734540 times.
✓ Branch 7 taken 48984 times.
✓ Branch 8 taken 1001332 times.
✓ Branch 9 taken 86304 times.
✓ Branch 10 taken 5430 times.
✓ Branch 11 taken 10824 times.
✓ Branch 12 taken 64 times.
✓ Branch 13 taken 112 times.
✓ Branch 14 taken 3072 times.
✓ Branch 15 taken 7104 times.
✓ Branch 16 taken 5430 times.
✓ Branch 17 taken 10824 times.
|
697808432 | return boundary_; |
148 | } | ||
149 | |||
150 | 29659784 | const GlobalPosition& unitOuterNormal() const | |
151 | { | ||
152 |
7/8✓ Branch 0 taken 382172037 times.
✓ Branch 1 taken 89833457 times.
✓ Branch 2 taken 275608727 times.
✓ Branch 3 taken 102697655 times.
✓ Branch 4 taken 268729033 times.
✓ Branch 5 taken 565487 times.
✓ Branch 6 taken 2128000 times.
✗ Branch 7 not taken.
|
2103216020 | return unitOuterNormal_; |
153 | } | ||
154 | |||
155 | //! index of the inside sub control volume | ||
156 | 2748547385 | LocalIndexType insideScvIdx() const | |
157 | { | ||
158 |
15/18✗ Branch 0 not taken.
✓ Branch 1 taken 47654764 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 609836202 times.
✓ Branch 4 taken 62139252 times.
✓ Branch 5 taken 764976334 times.
✓ Branch 6 taken 13335132 times.
✓ Branch 7 taken 260120704 times.
✓ Branch 8 taken 14122770 times.
✓ Branch 9 taken 285598212 times.
✓ Branch 10 taken 530050 times.
✓ Branch 11 taken 275656245 times.
✓ Branch 12 taken 220912 times.
✓ Branch 13 taken 13820350 times.
✓ Branch 14 taken 15849 times.
✓ Branch 15 taken 8061675 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 2083200 times.
|
2745983511 | 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 | 2667021868 | LocalIndexType outsideScvIdx(int i = 0) const | |
164 | { | ||
165 |
10/20✗ Branch 0 not taken.
✓ Branch 1 taken 47654764 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 110526074 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 576614886 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 779507240 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 260115608 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 285189744 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 275089544 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 13035920 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 5622400 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 2083200 times.
|
2386546568 | assert(!boundary()); |
166 |
14/16✓ Branch 0 taken 22575966 times.
✓ Branch 1 taken 25078798 times.
✓ Branch 2 taken 310200581 times.
✓ Branch 3 taken 361774873 times.
✓ Branch 4 taken 432679943 times.
✓ Branch 5 taken 340761809 times.
✓ Branch 6 taken 159441812 times.
✓ Branch 7 taken 3427860 times.
✓ Branch 8 taken 273322109 times.
✓ Branch 9 taken 74655 times.
✓ Branch 10 taken 2382000 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2128375 times.
✓ Branch 13 taken 985 times.
✓ Branch 14 taken 1360 times.
✗ Branch 15 not taken.
|
2672644268 | 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 1 taken 72 times.
✗ Branch 2 not taken.
|
72 | return static_cast<std::size_t>(!boundary()); |
173 | } | ||
174 | |||
175 | //! The local index of this sub control volume face | ||
176 | 1117944008 | GridIndexType index() const | |
177 | { | ||
178 |
10/16✓ Branch 2 taken 12892444 times.
✓ Branch 3 taken 803522 times.
✓ Branch 6 taken 3130900 times.
✓ Branch 7 taken 3072 times.
✓ Branch 9 taken 10860 times.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 32 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 2048 times.
✓ Branch 1 taken 37114409 times.
✓ Branch 4 taken 456688436 times.
✓ Branch 5 taken 1244980 times.
✗ Branch 0 not taken.
|
1117946968 | return scvfIndex_; |
179 | } | ||
180 | |||
181 | //! Return the boundary flag | ||
182 | 3446322 | typename BoundaryFlag::value_type boundaryFlag() const | |
183 | { | ||
184 |
3/4✓ Branch 0 taken 231456 times.
✓ Branch 1 taken 2823318 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2016 times.
|
3446322 | 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 |