GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/discretization/facecentered/staggered/subcontrolvolume.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 9 27 33.3%
Functions: 7 75 9.3%
Branches: 22 24 91.7%

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 FaceCenteredStaggeredDiscretization
10 * \copydoc Dumux::FaceCenteredStaggeredSubControlVolume
11 */
12 #ifndef DUMUX_DISCRETIZATION_FACECENTERED_STAGGERED_SUBCONTROLVOLUME_HH
13 #define DUMUX_DISCRETIZATION_FACECENTERED_STAGGERED_SUBCONTROLVOLUME_HH
14
15 #include <array>
16 #include <utility>
17
18 #include <dune/geometry/type.hh>
19 #include <dune/geometry/axisalignedcubegeometry.hh>
20
21 #include <dumux/common/indextraits.hh>
22
23 namespace Dumux {
24
25 /*!
26 * \ingroup FaceCenteredStaggeredDiscretization
27 * \brief Default traits class to be used for the sub-control volumes
28 * for the face-centered staggered scheme
29 * \tparam GV the type of the grid view
30 */
31 template<class GridView>
32 struct FaceCenteredDefaultScvGeometryTraits
33 {
34 using GridIndexType = typename IndexTraits<GridView>::GridIndex;
35 using LocalIndexType = typename IndexTraits<GridView>::LocalIndex;
36 using Scalar = typename GridView::ctype;
37 using Element = typename GridView::template Codim<0>::Entity;
38 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
39
40 static constexpr int dim = GridView::Grid::dimension;
41 static constexpr int dimWorld = GridView::Grid::dimensionworld;
42 using CornerStorage = std::array<GlobalPosition, (1<<(dim))>;
43 using Geometry = Dune::AxisAlignedCubeGeometry<Scalar, dim, dimWorld>;
44 };
45
46 /*!
47 * \ingroup FaceCenteredStaggeredDiscretization
48 * \brief Face centered staggered sub control volume
49 */
50 template<class GridView, class T = FaceCenteredDefaultScvGeometryTraits<GridView>>
51 class FaceCenteredStaggeredSubControlVolume
52 {
53 using Geometry = typename T::Geometry;
54 using CornerStorage = typename T::CornerStorage;
55 using Element = typename T::Element;
56 using GlobalPosition = typename T::GlobalPosition;
57 using Scalar = typename T::Scalar;
58 using GridIndexType = typename T::GridIndexType;
59 using SmallLocalIndexType = typename IndexTraits<GridView>::SmallLocalIndex;
60
61 using ElementGeometry = typename Element::Geometry;
62 using IntersectionGeometry = typename GridView::Intersection::Geometry;
63
64
65 public:
66 //! state the traits public and thus export all types
67 using Traits = T;
68
69 57395688 FaceCenteredStaggeredSubControlVolume() = default;
70
71 9582748 FaceCenteredStaggeredSubControlVolume(const ElementGeometry& elementGeometry,
72 const IntersectionGeometry& intersectionGeometry,
73 const GridIndexType globalIndex,
74 const SmallLocalIndexType indexInElement,
75 const GridIndexType dofIdx,
76 const SmallLocalIndexType dofAxis,
77 const GridIndexType eIdx,
78 const bool boundary)
79
8/8
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 32 times.
✓ Branch 3 taken 32 times.
✓ Branch 4 taken 32 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 32 times.
✓ Branch 7 taken 32 times.
36501000 : center_(0.5*(intersectionGeometry.center() + elementGeometry.center()))
80 , dofPosition_(intersectionGeometry.center())
81 19159904 , volume_(elementGeometry.volume()*0.5)
82 , globalIndex_(globalIndex)
83 , indexInElement_(indexInElement)
84 , dofIdx_(dofIdx)
85 , dofAxis_(dofAxis)
86 , eIdx_(eIdx)
87
4/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 468 times.
✓ Branch 3 taken 32 times.
18244908 , boundary_(boundary)
88 {
89
2/2
✓ Branch 0 taken 4791374 times.
✓ Branch 1 taken 4791374 times.
9582748 directionSign_ = (indexInElement % 2) ? 1.0 : -1.0;
90 9582684 }
91
92 //! The center of the sub control volume
93 const GlobalPosition& center() const
94
2/4
✗ Branch 1 not taken.
✓ Branch 2 taken 1376760 times.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
76948096 { return center_; }
95
96 //! The position of the degree of freedom
97 const GlobalPosition& dofPosition() const
98
6/6
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 16022 times.
✓ Branch 2 taken 5150 times.
✓ Branch 3 taken 50750 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 189 times.
975855795 { return dofPosition_; }
99
100 Scalar volume() const
101 { return volume_; }
102
103 GridIndexType dofIndex() const
104 { return dofIdx_; }
105
106 GridIndexType index() const
107 { return globalIndex_; }
108
109 GridIndexType elementIndex() const
110 { return eIdx_; }
111
112 SmallLocalIndexType indexInElement() const
113 { return indexInElement_; }
114
115 SmallLocalIndexType localDofIndex() const
116 { return indexInElement_; }
117
118 SmallLocalIndexType dofAxis() const
119 { return dofAxis_; }
120
121 std::int_least8_t directionSign() const
122 { return directionSign_; }
123
124 bool boundary() const
125 { return boundary_; }
126
127 private:
128 GlobalPosition center_;
129 GlobalPosition dofPosition_;
130 Scalar volume_;
131 GridIndexType globalIndex_;
132 SmallLocalIndexType indexInElement_;
133 GridIndexType dofIdx_;
134 SmallLocalIndexType dofAxis_;
135 std::int_least8_t directionSign_;
136 GridIndexType eIdx_;
137 bool boundary_;
138 };
139
140 } // end namespace Dumux
141
142 #endif
143