GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/dumux/discretization/cellcentered/elementsolution.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 25 25 100.0%
Functions: 5 5 100.0%
Branches: 85 113 75.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-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 CCDiscretization
10 * \brief The local element solution class for cell-centered methods
11 */
12 #ifndef DUMUX_CC_ELEMENT_SOLUTION_HH
13 #define DUMUX_CC_ELEMENT_SOLUTION_HH
14
15 #include <cassert>
16 #include <utility>
17 #include <type_traits>
18 #include <dumux/discretization/method.hh>
19
20 namespace Dumux {
21
22 /*!
23 * \ingroup CCDiscretization
24 * \brief The element solution vector
25 */
26 template<class FVElementGeometry, class PV>
27 class CCElementSolution
28 {
29 using GridGeometry = typename FVElementGeometry::GridGeometry;
30 using GridView = typename GridGeometry::GridView;
31 using Element = typename GridView::template Codim<0>::Entity;
32
33 public:
34 //! export the primary variables type
35 using PrimaryVariables = PV;
36
37 //! default constructor
38 56 CCElementSolution() = default;
39
40 //! Constructor with element, solution vector and grid geometry
41 template<class SolutionVector>
42 244776707 CCElementSolution(const Element& element, const SolutionVector& sol,
43 const GridGeometry& gridGeometry)
44
27/35
✓ Branch 1 taken 1130337 times.
✓ Branch 2 taken 5572171 times.
✓ Branch 6 taken 2288004 times.
✓ Branch 7 taken 9860 times.
✓ Branch 9 taken 64790 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 109015 times.
✓ Branch 13 taken 1233216 times.
✓ Branch 3 taken 202040 times.
✓ Branch 0 taken 508216 times.
✓ Branch 4 taken 2394967 times.
✓ Branch 5 taken 96653 times.
✓ Branch 8 taken 5073 times.
✓ Branch 14 taken 1837023 times.
✓ Branch 17 taken 62086 times.
✓ Branch 18 taken 183712 times.
✓ Branch 20 taken 550 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 12210500 times.
✗ Branch 24 not taken.
✓ Branch 15 taken 12 times.
✗ Branch 19 not taken.
✗ Branch 16 not taken.
✓ Branch 22 taken 3007048 times.
✓ Branch 27 taken 21948 times.
✗ Branch 28 not taken.
✓ Branch 31 taken 24584 times.
✓ Branch 32 taken 97376 times.
✓ Branch 26 taken 517000 times.
✗ Branch 33 not taken.
✓ Branch 35 taken 1354 times.
✗ Branch 36 not taken.
✓ Branch 11 taken 600 times.
✓ Branch 25 taken 100000 times.
✓ Branch 34 taken 304 times.
228612766 : CCElementSolution(sol[gridGeometry.elementMapper().index(element)])
45 935210 {}
46
47 //! Constructor with element, element volume variables and fv element geometry
48 template<class ElementVolumeVariables>
49 3979 CCElementSolution(const Element& element, const ElementVolumeVariables& elemVolVars,
50 const FVElementGeometry& fvGeometry)
51 3979 {
52
2/2
✓ Branch 0 taken 3979 times.
✓ Branch 1 taken 3979 times.
7958 for (const auto& scv : scvs(fvGeometry))
53 3979 priVars_ = elemVolVars[scv].priVars();
54 3979 }
55
56 //! Constructor with a primary variable object
57 2018901 CCElementSolution(PrimaryVariables&& priVars)
58 298178 : priVars_(std::move(priVars)) {}
59
60 //! Constructor with a primary variable object
61 265320977 CCElementSolution(const PrimaryVariables& priVars)
62 261330890 : priVars_(priVars) {}
63
64 //! extract the element solution from the solution vector using a mapper
65 template<class SolutionVector>
66 void update(const Element& element, const SolutionVector& sol,
67 const GridGeometry& gridGeometry)
68 {
69 priVars_ = sol[gridGeometry.elementMapper().index(element)];
70 }
71
72 //! return the size of the element solution
73 constexpr std::size_t size() const
74 { return 1; }
75
76 //! bracket operator const access
77 template<typename IndexType>
78 31894633 const PrimaryVariables& operator [](IndexType i) const
79 {
80 assert(i == 0 && "Index exceeds valid range!");
81
6/7
✓ Branch 1 taken 68078680 times.
✓ Branch 2 taken 3262 times.
✓ Branch 4 taken 80 times.
✓ Branch 5 taken 644 times.
✓ Branch 3 taken 3800 times.
✓ Branch 0 taken 3668493 times.
✗ Branch 6 not taken.
208670758 return priVars_;
82 }
83
84 //! bracket operator access
85 template<typename IndexType>
86 1923056 PrimaryVariables& operator [](IndexType i)
87 {
88 assert(i == 0 && "Index exceeds valid range!");
89
2/2
✓ Branch 0 taken 153832 times.
✓ Branch 1 taken 76916 times.
53678836 return priVars_;
90 }
91
92 private:
93 PrimaryVariables priVars_;
94 };
95
96 /*!
97 * \ingroup Discretization
98 * \brief Make an element solution for cell-centered schemes
99 */
100 template<class Element, class SolutionVector, class GridGeometry>
101
15/21
✓ Branch 2 taken 5516537 times.
✓ Branch 3 taken 589657 times.
✓ Branch 6 taken 3655765 times.
✓ Branch 7 taken 2363892 times.
✓ Branch 9 taken 1323240 times.
✓ Branch 10 taken 2378758 times.
✓ Branch 12 taken 1942936 times.
✗ Branch 13 not taken.
✓ Branch 4 taken 6696 times.
✓ Branch 1 taken 2613372 times.
✗ Branch 5 not taken.
✓ Branch 11 taken 1233216 times.
✓ Branch 17 taken 12210500 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 21948 times.
✗ Branch 20 not taken.
✓ Branch 26 taken 97376 times.
✗ Branch 27 not taken.
✓ Branch 16 taken 3007000 times.
✓ Branch 25 taken 24056 times.
✗ Branch 8 not taken.
244699052 auto elementSolution(const Element& element, const SolutionVector& sol, const GridGeometry& gg)
102 -> std::enable_if_t<GridGeometry::discMethod == DiscretizationMethods::cctpfa ||
103 GridGeometry::discMethod == DiscretizationMethods::ccmpfa,
104 CCElementSolution<typename GridGeometry::LocalView,
105 std::decay_t<decltype(std::declval<SolutionVector>()[0])>>
106 >
107 {
108 using PrimaryVariables = std::decay_t<decltype(std::declval<SolutionVector>()[0])>;
109
27/35
✓ Branch 2 taken 5572171 times.
✓ Branch 3 taken 2483980 times.
✓ Branch 8 taken 5073 times.
✓ Branch 9 taken 117624 times.
✓ Branch 13 taken 1233216 times.
✓ Branch 14 taken 1837023 times.
✓ Branch 17 taken 62086 times.
✓ Branch 18 taken 183712 times.
✓ Branch 20 taken 550 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 12210500 times.
✗ Branch 24 not taken.
✓ Branch 4 taken 2394967 times.
✓ Branch 6 taken 59143 times.
✓ Branch 7 taken 9860 times.
✗ Branch 10 not taken.
✓ Branch 0 taken 508216 times.
✓ Branch 1 taken 1052682 times.
✓ Branch 5 taken 96653 times.
✓ Branch 15 taken 12 times.
✗ Branch 19 not taken.
✗ Branch 16 not taken.
✓ Branch 22 taken 3007048 times.
✓ Branch 27 taken 21948 times.
✗ Branch 28 not taken.
✓ Branch 31 taken 24584 times.
✓ Branch 32 taken 97376 times.
✓ Branch 12 taken 3102 times.
✓ Branch 26 taken 517000 times.
✗ Branch 33 not taken.
✓ Branch 35 taken 1354 times.
✗ Branch 36 not taken.
✓ Branch 11 taken 600 times.
✓ Branch 25 taken 100000 times.
✓ Branch 34 taken 304 times.
229072180 return CCElementSolution<typename GridGeometry::LocalView, PrimaryVariables>(element, sol, gg);
110 }
111
112 /*!
113 * \ingroup Discretization
114 * \brief Make an element solution for cell-centered schemes
115 */
116 template<class Element, class ElementVolumeVariables, class FVElementGeometry>
117 3979 auto elementSolution(const Element& element, const ElementVolumeVariables& elemVolVars, const FVElementGeometry& gg)
118 -> std::enable_if_t<FVElementGeometry::GridGeometry::discMethod == DiscretizationMethods::cctpfa ||
119 FVElementGeometry::GridGeometry::discMethod == DiscretizationMethods::ccmpfa,
120 CCElementSolution<FVElementGeometry, typename ElementVolumeVariables::VolumeVariables::PrimaryVariables>>
121 {
122 using PrimaryVariables = typename ElementVolumeVariables::VolumeVariables::PrimaryVariables;
123 3979 return CCElementSolution<FVElementGeometry, PrimaryVariables>(element, elemVolVars, gg);
124 }
125
126 /*!
127 * \ingroup Discretization
128 * \brief Make an element solution for cell-centered schemes
129 * \note This is e.g. used to construct an element solution at Dirichlet boundaries
130 */
131 template<class FVElementGeometry, class PrimaryVariables>
132 2018901 auto elementSolution(PrimaryVariables&& priVars)
133 -> std::enable_if_t<FVElementGeometry::GridGeometry::discMethod == DiscretizationMethods::cctpfa ||
134 FVElementGeometry::GridGeometry::discMethod == DiscretizationMethods::ccmpfa,
135 CCElementSolution<FVElementGeometry, PrimaryVariables>>
136 {
137
4/9
✓ Branch 1 taken 1233480 times.
✓ Branch 2 taken 159854 times.
✓ Branch 4 taken 287644 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 183 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 3 not taken.
2018901 return CCElementSolution<FVElementGeometry, PrimaryVariables>(std::move(priVars));
138 }
139
140 /*!
141 * \ingroup Discretization
142 * \brief Make an element solution for cell-centered schemes
143 * \note This is e.g. used to construct an element solution at Dirichlet boundaries
144 */
145 template<class FVElementGeometry, class PrimaryVariables>
146 20570558 auto elementSolution(const PrimaryVariables& priVars)
147 -> std::enable_if_t<FVElementGeometry::GridGeometry::discMethod == DiscretizationMethods::cctpfa ||
148 FVElementGeometry::GridGeometry::discMethod == DiscretizationMethods::ccmpfa,
149 CCElementSolution<FVElementGeometry, PrimaryVariables>>
150 {
151
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3391 times.
20570558 return CCElementSolution<FVElementGeometry, PrimaryVariables>(priVars);
152 }
153
154 } // end namespace Dumux
155
156 #endif
157