GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/discretization/cellcentered/elementsolution.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 19 20 95.0%
Functions: 5 21 23.8%
Branches: 102 137 74.5%

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 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 112 CCElementSolution() = default;
39
40 //! Constructor with element, solution vector and grid geometry
41 template<class SolutionVector>
42 938118 CCElementSolution(const Element& element, const SolutionVector& sol,
43 const GridGeometry& gridGeometry)
44
46/60
✓ Branch 1 taken 2653395 times.
✓ Branch 2 taken 49144 times.
✓ Branch 3 taken 4916506 times.
✓ Branch 4 taken 2455785 times.
✓ Branch 5 taken 1616022 times.
✓ Branch 6 taken 26577412 times.
✓ Branch 7 taken 472640 times.
✓ Branch 8 taken 1235288 times.
✓ Branch 9 taken 1092573 times.
✓ Branch 10 taken 2373302 times.
✓ Branch 11 taken 1544784 times.
✓ Branch 12 taken 43098 times.
✓ Branch 13 taken 2381190 times.
✓ Branch 14 taken 3566204 times.
✓ Branch 15 taken 1208768 times.
✓ Branch 16 taken 2383005 times.
✓ Branch 17 taken 2747044 times.
✓ Branch 18 taken 10765 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 53679 times.
✓ Branch 21 taken 360 times.
✓ Branch 22 taken 3102 times.
✓ Branch 23 taken 1117555 times.
✓ Branch 24 taken 360 times.
✓ Branch 25 taken 1528143 times.
✓ Branch 26 taken 1170389 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 4069595 times.
✓ Branch 29 taken 105913 times.
✓ Branch 30 taken 52000 times.
✗ Branch 31 not taken.
✓ Branch 32 taken 168434 times.
✗ Branch 33 not taken.
✓ Branch 34 taken 19092 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 3045500 times.
✓ Branch 38 taken 48 times.
✓ Branch 39 taken 12172000 times.
✓ Branch 40 taken 3045500 times.
✗ Branch 41 not taken.
✓ Branch 42 taken 12172000 times.
✗ Branch 43 not taken.
✓ Branch 44 taken 100000 times.
✓ Branch 45 taken 21948 times.
✓ Branch 46 taken 517000 times.
✗ Branch 47 not taken.
✓ Branch 48 taken 21948 times.
✗ Branch 49 not taken.
✓ Branch 54 taken 528 times.
✓ Branch 55 taken 24056 times.
✗ Branch 56 not taken.
✓ Branch 57 taken 97376 times.
✓ Branch 58 taken 24056 times.
✗ Branch 59 not taken.
✓ Branch 60 taken 97376 times.
✗ Branch 61 not taken.
✓ Branch 62 taken 304 times.
✗ Branch 63 not taken.
✓ Branch 64 taken 1354 times.
✗ Branch 65 not taken.
239909840 : CCElementSolution(sol[gridGeometry.elementMapper().index(element)])
45 938118 {}
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
4/4
✓ Branch 0 taken 3979 times.
✓ Branch 1 taken 3979 times.
✓ Branch 2 taken 3979 times.
✓ Branch 3 taken 3979 times.
15916 for (const auto& scv : scvs(fvGeometry))
53 3979 priVars_ = elemVolVars[scv].priVars();
54 3979 }
55
56 //! Constructor with a primary variable object
57 1987080 CCElementSolution(PrimaryVariables&& priVars)
58 1987080 : priVars_(std::move(priVars)) {}
59
60 //! Constructor with a primary variable object
61 74180538 CCElementSolution(const PrimaryVariables& priVars)
62 241283147 : 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 const PrimaryVariables& operator [](IndexType i) const
79 {
80 assert(i == 0 && "Index exceeds valid range!");
81
5/10
✓ Branch 0 taken 3668493 times.
✓ Branch 1 taken 68129880 times.
✓ Branch 2 taken 2940 times.
✓ Branch 3 taken 792000 times.
✓ Branch 4 taken 80 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
176253972 return priVars_;
82 }
83
84 //! bracket operator access
85 template<typename IndexType>
86 PrimaryVariables& operator [](IndexType i)
87 {
88 assert(i == 0 && "Index exceeds valid range!");
89 69066810 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 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
45/60
✓ Branch 1 taken 2575740 times.
✓ Branch 2 taken 49144 times.
✓ Branch 3 taken 5361367 times.
✓ Branch 4 taken 2378130 times.
✓ Branch 5 taken 828582 times.
✓ Branch 6 taken 27364852 times.
✓ Branch 7 taken 1392 times.
✓ Branch 8 taken 3988476 times.
✓ Branch 9 taken 647712 times.
✓ Branch 10 taken 2373302 times.
✓ Branch 11 taken 3826724 times.
✓ Branch 12 taken 43098 times.
✓ Branch 13 taken 2381190 times.
✓ Branch 14 taken 1337343 times.
✓ Branch 15 taken 1208768 times.
✓ Branch 16 taken 2383005 times.
✓ Branch 17 taken 518183 times.
✓ Branch 18 taken 10765 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 106513 times.
✓ Branch 21 taken 360 times.
✓ Branch 22 taken 3102 times.
✓ Branch 23 taken 1170389 times.
✓ Branch 24 taken 360 times.
✓ Branch 25 taken 1528143 times.
✓ Branch 26 taken 1064476 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 4069595 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 52000 times.
✗ Branch 31 not taken.
✓ Branch 32 taken 168434 times.
✗ Branch 33 not taken.
✓ Branch 34 taken 19092 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 3045500 times.
✓ Branch 38 taken 48 times.
✓ Branch 39 taken 12172000 times.
✓ Branch 40 taken 3045500 times.
✗ Branch 41 not taken.
✓ Branch 42 taken 12172000 times.
✗ Branch 43 not taken.
✓ Branch 44 taken 100000 times.
✓ Branch 45 taken 21948 times.
✓ Branch 46 taken 517000 times.
✗ Branch 47 not taken.
✓ Branch 48 taken 21948 times.
✗ Branch 49 not taken.
✓ Branch 54 taken 528 times.
✓ Branch 55 taken 24056 times.
✗ Branch 56 not taken.
✓ Branch 57 taken 97376 times.
✓ Branch 58 taken 24056 times.
✗ Branch 59 not taken.
✓ Branch 60 taken 97376 times.
✗ Branch 61 not taken.
✓ Branch 62 taken 304 times.
✗ Branch 63 not taken.
✓ Branch 64 taken 1354 times.
✗ Branch 65 not taken.
239001212 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 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 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
2/3
✓ Branch 1 taken 813126 times.
✓ Branch 2 taken 520 times.
✗ Branch 3 not taken.
1987080 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 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 20311918 return CCElementSolution<FVElementGeometry, PrimaryVariables>(priVars);
152 }
153
154 } // end namespace Dumux
155
156 #endif
157