GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/discretization/staggered/subcontrolvolumeface.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 14 20 70.0%
Functions: 2 5 40.0%
Branches: 14 34 41.2%

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 StaggeredDiscretization
10 * \copydoc Dumux::StaggeredSubControlVolumeFace
11 */
12 #ifndef DUMUX_DISCRETIZATION_STAGGERED_SUBCONTROLVOLUMEFACE_HH
13 #define DUMUX_DISCRETIZATION_STAGGERED_SUBCONTROLVOLUMEFACE_HH
14
15 #include <utility>
16
17 #include <dune/geometry/axisalignedcubegeometry.hh>
18 #include <dune/common/fvector.hh>
19 #include <dune/geometry/type.hh>
20
21 #include <dumux/common/indextraits.hh>
22 #include <dumux/discretization/subcontrolvolumefacebase.hh>
23
24 #include <typeinfo>
25
26 namespace Dumux {
27
28 /*!
29 * \ingroup StaggeredDiscretization
30 * \brief Base class for a staggered grid geometry helper
31 */
32 template<class GridView>
33 class BaseStaggeredGeometryHelper
34 {
35 using Element = typename GridView::template Codim<0>::Entity;
36 using Intersection = typename GridView::Intersection;
37 static constexpr int codimIntersection = 1;
38
39 public:
40
41 BaseStaggeredGeometryHelper(const Element& element, const GridView& gridView)
42 : element_(element)
43 32 , gridView_(gridView)
44 { }
45
46 /*!
47 * \brief Updates the current face, i.e. sets the correct intersection
48 */
49 template<class IntersectionMapper>
50 void updateLocalFace(const IntersectionMapper& intersectionMapper, const Intersection& intersection)
51 {
52
4/4
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 6 times.
64 intersection_ = intersection;
53 }
54
55 /*!
56 * \brief Returns the global dofIdx of the intersection itself
57 */
58 32 int dofIndex() const
59 {
60 //TODO: use proper intersection mapper!
61
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 const auto inIdx = intersection_.indexInInside();
62
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 return gridView_.indexSet().subIndex(intersection_.inside(), inIdx, codimIntersection);
63 }
64
65 /*!
66 * \brief Returns the local index of the face (i.e. the intersection)
67 */
68 int localFaceIndex() const
69 {
70
4/4
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 6 times.
64 return intersection_.indexInInside();
71 }
72
73 private:
74 Intersection intersection_; //!< The intersection of interest
75 const Element element_; //!< The respective element
76 const GridView gridView_;
77 };
78
79
80 /*!
81 * \ingroup StaggeredDiscretization
82 * \brief Default traits class to be used for the sub-control volume faces
83 * for the staggered finite volume scheme
84 * \tparam GV the type of the grid view
85 */
86 template<class GridView>
87 struct StaggeredDefaultScvfGeometryTraits
88 {
89 using GridIndexType = typename IndexTraits<GridView>::GridIndex;
90 using LocalIndexType = typename IndexTraits<GridView>::LocalIndex;
91 using Scalar = typename GridView::ctype;
92 using Element = typename GridView::template Codim<0>::Entity;
93 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
94
95 static constexpr int dim = GridView::Grid::dimension;
96 static constexpr int dimWorld = GridView::Grid::dimensionworld;
97 using Geometry = Dune::AxisAlignedCubeGeometry<Scalar, dim-1, dimWorld>;
98 };
99
100 /*!
101 * \ingroup StaggeredDiscretization
102 * \brief Class for a sub control volume face in the staggered method, i.e a part of the boundary
103 * of a sub control volume we compute fluxes on.
104 */
105 template<class GV,
106 class T = StaggeredDefaultScvfGeometryTraits<GV> >
107
1/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 32 times.
✗ Branch 15 not taken.
64 class StaggeredSubControlVolumeFace
108 : public SubControlVolumeFaceBase<StaggeredSubControlVolumeFace<GV, T>, T>
109 {
110 using ThisType = StaggeredSubControlVolumeFace<GV, T>;
111 using ParentType = SubControlVolumeFaceBase<ThisType, T>;
112 using Geometry = typename T::Geometry;
113 using GridIndexType = typename T::GridIndexType;
114 using LocalIndexType = typename T::LocalIndexType;
115
116 using Scalar = typename T::Scalar;
117 static const int dim = Geometry::mydimension;
118 static const int dimworld = Geometry::coorddimension;
119
120 public:
121 using GlobalPosition = typename T::GlobalPosition;
122
123 //! state the traits public and thus export all types
124 using Traits = T;
125
126 // the default constructor
127 StaggeredSubControlVolumeFace() = default;
128
129 //! Constructor with intersection
130 template <class Intersection, class GeometryHelper>
131 32 StaggeredSubControlVolumeFace(const Intersection& is,
132 const typename Intersection::Geometry& isGeometry,
133 GridIndexType scvfIndex,
134 const std::vector<GridIndexType>& scvIndices,
135 const GeometryHelper& geometryHelper)
136 : ParentType()
137 , area_(isGeometry.volume())
138 , center_(isGeometry.center())
139 , unitOuterNormal_(is.centerUnitOuterNormal())
140 , scvfIndex_(scvfIndex)
141 , scvIndices_(scvIndices)
142
1/2
✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
128 , boundary_(is.boundary())
143 {
144 32 dofIdx_ = geometryHelper.dofIndex();
145 64 localFaceIdx_ = geometryHelper.localFaceIndex();
146 32 }
147
148 //! The center of the sub control volume face
149 const GlobalPosition& center() const
150 {
151 return center_;
152 }
153
154 //! The position of the dof living on the face
155 const GlobalPosition& dofPosition() const
156 {
157 return center_;
158 }
159
160 //! The integration point for flux evaluations in global coordinates
161 const GlobalPosition& ipGlobal() const
162 {
163 // Return center for now
164
1/2
✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
32 return center_;
165 }
166
167 //! The area of the sub control volume face
168 Scalar area() const
169 {
170 return area_;
171 }
172
173 //! Returns boolean if the sub control volume face is on the boundary
174 bool boundary() const
175 {
176 return boundary_;
177 }
178
179 //! The unit outer normal vector
180 const GlobalPosition& unitOuterNormal() const
181 {
182
1/2
✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
32 return unitOuterNormal_;
183 }
184
185 //! Index of the inside sub control volume
186 GridIndexType insideScvIdx() const
187 {
188 return scvIndices_[0];
189 }
190
191 //! Index of the outside sub control volume
192 GridIndexType outsideScvIdx() const
193 {
194 return scvIndices_[1];
195 }
196
197 //! The global index of this sub control volume face
198 GridIndexType index() const
199 {
200 return scvfIndex_;
201 }
202
203 //! The global index of the dof living on this face
204 GridIndexType dofIndex() const
205 {
206 return dofIdx_;
207 }
208
209 //! The local index of this sub control volume face
210 LocalIndexType localFaceIdx() const
211 {
212 return localFaceIdx_;
213 }
214
215 private:
216 Scalar area_;
217 GlobalPosition center_;
218 GlobalPosition unitOuterNormal_;
219 GridIndexType scvfIndex_;
220 std::vector<GridIndexType> scvIndices_;
221 bool boundary_;
222
223 GridIndexType dofIdx_;
224 LocalIndexType localFaceIdx_;
225 };
226
227 } // end namespace Dumux
228
229 #endif
230