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 620052 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 108124 times.
✓ Branch 5 taken 65897 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 34906 times.
✓ Branch 8 taken 56922 times.
✓ Branch 9 taken 101244 times.
✓ Branch 10 taken 2450925 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 13146634 times.
✓ Branch 18 taken 306391 times.
✓ Branch 19 taken 26749852 times.
✓ Branch 20 taken 524999 times.
✓ Branch 21 taken 26542042 times.
✓ Branch 22 taken 221676 times.
✓ Branch 23 taken 14035138 times.
✓ Branch 24 taken 6512820 times.
✓ Branch 25 taken 112 times.
✓ Branch 26 taken 10702825 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.
|
72192406 | 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 | 82106360 | BoxSubControlVolumeFace() = default; | |
80 | |||
81 | //! Constructor for inner scvfs | ||
82 | template<class Corners, class Element> | ||
83 | 27688086 | 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 | 27688086 | : center_(Dumux::center(corners)) | |
91 | , unitOuterNormal_(normal) | ||
92 | , scvfIndex_(scvfIndex) | ||
93 | 27688086 | , scvIndices_(std::move(scvIndices)) | |
94 | , boundary_(boundary) | ||
95 | 55376172 | , boundaryFlag_{} | |
96 | { | ||
97 | 27688086 | area_ = Dumux::convexPolytopeVolume<dim>( | |
98 | Dune::GeometryTypes::cube(dim), | ||
99 | 6064632 | [&](unsigned int i){ return corners[i]; } | |
100 | ); | ||
101 | 25031030 | } | |
102 | |||
103 | //! Constructor for boundary scvfs | ||
104 | template<class Corners, class Intersection> | ||
105 | 3023519 | 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 | 3023519 | : center_(Dumux::center(corners)) | |
114 | , unitOuterNormal_(normal) | ||
115 | , scvfIndex_(scvfIndex) | ||
116 | 3023519 | , scvIndices_(std::move(scvIndices)) | |
117 | , boundary_(boundary) | ||
118 |
4/8✓ Branch 0 taken 19927 times.
✓ Branch 1 taken 2553490 times.
✓ Branch 2 taken 19927 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2553490 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
6047038 | , boundaryFlag_{intersection} |
119 | { | ||
120 | 3023519 | area_ = Dumux::convexPolytopeVolume<dim>( | |
121 | Dune::GeometryTypes::cube(dim), | ||
122 | 965360 | [&](unsigned int i){ return corners[i]; } | |
123 | ); | ||
124 | 3023519 | } | |
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 8073600 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7436800 times.
|
498280483 | 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 112807 times.
✓ Branch 1 taken 11124417 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.
|
326979586 | 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 |
10/12✓ Branch 0 taken 226637352 times.
✓ Branch 1 taken 1010072 times.
✓ Branch 2 taken 146000070 times.
✓ Branch 3 taken 3030000 times.
✓ Branch 4 taken 267425912 times.
✓ Branch 5 taken 10000 times.
✓ Branch 6 taken 930000 times.
✓ Branch 7 taken 10000 times.
✓ Branch 8 taken 3804800 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1924800 times.
✗ Branch 11 not taken.
|
1782253394 | 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 46141856 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 603809774 times.
✓ Branch 4 taken 62103252 times.
✓ Branch 5 taken 762225614 times.
✓ Branch 6 taken 13299132 times.
✓ Branch 7 taken 259279744 times.
✓ Branch 8 taken 14101328 times.
✓ Branch 9 taken 283499582 times.
✓ Branch 10 taken 467582 times.
✓ Branch 11 taken 275465395 times.
✓ Branch 12 taken 220912 times.
✓ Branch 13 taken 13839550 times.
✓ Branch 14 taken 15849 times.
✓ Branch 15 taken 8082475 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 1883264 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.
|
2714088359 | 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 |
10/22✗ Branch 0 not taken.
✓ Branch 1 taken 46141856 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 108977726 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 571920806 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 776584720 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 258372868 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 283847596 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 275236712 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 13065120 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 5653200 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 1881600 times.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
|
2341682204 | assert(!boundary()); |
166 |
15/16✓ Branch 0 taken 22196128 times.
✓ Branch 1 taken 23945728 times.
✓ Branch 2 taken 307212971 times.
✓ Branch 3 taken 358700055 times.
✓ Branch 4 taken 431714038 times.
✓ Branch 5 taken 330565394 times.
✓ Branch 6 taken 156714484 times.
✓ Branch 7 taken 7149588 times.
✓ Branch 8 taken 270070349 times.
✓ Branch 9 taken 5761055 times.
✓ Branch 10 taken 298800 times.
✓ Branch 11 taken 1924800 times.
✓ Branch 12 taken 375 times.
✓ Branch 13 taken 985 times.
✓ Branch 14 taken 1360 times.
✗ Branch 15 not taken.
|
2638391412 | 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 |