GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/discretization/box/subcontrolvolume.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 10 20 50.0%
Functions: 20 141 14.2%
Branches: 36 46 78.3%

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 the sub control volume for the box scheme
11 */
12 #ifndef DUMUX_DISCRETIZATION_BOX_SUBCONTROLVOLUME_HH
13 #define DUMUX_DISCRETIZATION_BOX_SUBCONTROLVOLUME_HH
14
15 #include <dune/geometry/type.hh>
16 #include <dune/geometry/multilineargeometry.hh>
17
18 #include <dumux/common/math.hh>
19 #include <dumux/common/indextraits.hh>
20 #include <dumux/geometry/volume.hh>
21 #include <dumux/geometry/center.hh>
22 #include <dumux/discretization/subcontrolvolumebase.hh>
23 #include <dumux/discretization/box/boxgeometryhelper.hh>
24
25 namespace Dumux {
26
27 /*!
28 * \ingroup BoxDiscretization
29 * \brief Default traits class to be used for the sub-control volumes
30 * for the box scheme
31 * \tparam GV the type of the grid view
32 */
33 template<class GridView>
34 struct BoxDefaultScvGeometryTraits
35 {
36 using Grid = typename GridView::Grid;
37
38 static const int dim = Grid::dimension;
39 static const int dimWorld = Grid::dimensionworld;
40
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, dimWorld, GeometryTraits>;
46 using CornerStorage = typename GeometryTraits::template CornerStorage<dim, dimWorld>::Type;
47 using GlobalPosition = typename Geometry::GlobalCoordinate;
48 };
49
50 /*!
51 * \ingroup BoxDiscretization
52 * \brief the sub control volume for the box scheme
53 * \tparam GV the type of the grid view
54 * \tparam T the scvf geometry traits
55 */
56 template<class GV,
57 class T = BoxDefaultScvGeometryTraits<GV> >
58 class BoxSubControlVolume
59 : public SubControlVolumeBase<BoxSubControlVolume<GV, T>, T>
60 {
61 using ThisType = BoxSubControlVolume<GV, T>;
62 using ParentType = SubControlVolumeBase<ThisType, T>;
63 using Geometry = typename T::Geometry;
64 using GridIndexType = typename T::GridIndexType;
65 using LocalIndexType = typename T::LocalIndexType;
66 using Scalar = typename T::Scalar;
67 static constexpr int dim = Geometry::mydimension;
68
69 public:
70 //! export the type used for global coordinates
71 using GlobalPosition = typename T::GlobalPosition;
72 //! state the traits public and thus export all types
73 using Traits = T;
74
75 //! The default constructor
76 54307137 BoxSubControlVolume() = default;
77
78 // the constructor in the box case
79 template<class Corners>
80 35926473 BoxSubControlVolume(const Corners& corners,
81 LocalIndexType scvIdx,
82 GridIndexType elementIndex,
83 GridIndexType dofIndex)
84 35926473 : dofPosition_(corners[0])
85 40767489 , center_(Dumux::center(corners))
86 , elementIndex_(elementIndex)
87 , localDofIdx_(scvIdx)
88 35926473 , dofIndex_(dofIndex)
89 {
90 // The corner list is defined such that the first entry is the vertex itself
91 40767489 volume_ = Dumux::convexPolytopeVolume<dim>(
92 Dune::GeometryTypes::cube(dim),
93 272008984 [&](unsigned int i){ return corners[i]; }
94 );
95 35486937 }
96
97 //! The center of the sub control volume
98 const GlobalPosition& center() const
99 {
100
18/25
✓ Branch 0 taken 711392 times.
✓ Branch 1 taken 49204740 times.
✓ Branch 2 taken 10933029 times.
✓ Branch 3 taken 12805076 times.
✓ Branch 4 taken 14216166 times.
✓ Branch 5 taken 1261591 times.
✓ Branch 6 taken 870071 times.
✓ Branch 7 taken 3640042 times.
✓ Branch 8 taken 5196895 times.
✓ Branch 9 taken 4011715 times.
✓ Branch 10 taken 6020348 times.
✓ Branch 11 taken 6303940 times.
✓ Branch 12 taken 5297178 times.
✓ Branch 13 taken 6058542 times.
✓ Branch 14 taken 615172 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 16567 times.
✓ Branch 17 taken 632033 times.
✓ Branch 18 taken 28800 times.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
648499790 return center_;
101 }
102
103 //! The volume of the sub control volume
104 Scalar volume() const
105 {
106 return volume_;
107 }
108
109 //! The element-local index of the dof this scv is embedded in
110 LocalIndexType localDofIndex() const
111 {
112 return localDofIdx_;
113 }
114
115 //! The element-local index of this scv.
116 //! For the standard box scheme this is the local dof index.
117 LocalIndexType indexInElement() const
118 {
119 return localDofIdx_;
120 }
121
122 //! The index of the dof this scv is embedded in
123 GridIndexType dofIndex() const
124 {
125 return dofIndex_;
126 }
127
128 // The position of the dof this scv is embedded in
129 const GlobalPosition& dofPosition() const
130 {
131
18/21
✓ Branch 0 taken 1007526 times.
✓ Branch 1 taken 751763 times.
✓ Branch 2 taken 1832940 times.
✓ Branch 3 taken 338879 times.
✓ Branch 4 taken 863332 times.
✓ Branch 5 taken 3608823 times.
✓ Branch 6 taken 564025 times.
✓ Branch 7 taken 3876663 times.
✓ Branch 8 taken 672573 times.
✓ Branch 9 taken 27554 times.
✓ Branch 10 taken 167586 times.
✓ Branch 11 taken 147382 times.
✓ Branch 12 taken 1444 times.
✓ Branch 13 taken 741604 times.
✓ Branch 14 taken 2174156 times.
✓ Branch 15 taken 2174164 times.
✓ Branch 16 taken 741604 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 21 taken 123600 times.
✗ Branch 22 not taken.
598019876 return dofPosition_;
132 }
133
134 //! The global index of the element this scv is embedded in
135 GridIndexType elementIndex() const
136 {
137 return elementIndex_;
138 }
139
140 private:
141 GlobalPosition dofPosition_;
142 GlobalPosition center_;
143 Scalar volume_;
144 GridIndexType elementIndex_;
145 LocalIndexType localDofIdx_;
146 GridIndexType dofIndex_;
147 };
148
149 } // end namespace Dumux
150
151 #endif
152