GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/discretization/cvfe/gridvolumevariables.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 14 20 70.0%
Functions: 63 296 21.3%
Branches: 114 184 62.0%

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 CVFEDiscretization
10 * \brief The grid volume variables class for control-volume finite element methods
11 */
12 #ifndef DUMUX_DISCRETIZATION_CVFE_GRID_VOLUMEVARIABLES_HH
13 #define DUMUX_DISCRETIZATION_CVFE_GRID_VOLUMEVARIABLES_HH
14
15 #include <vector>
16 #include <type_traits>
17
18 #include <dumux/parallel/parallel_for.hh>
19
20 // make the local view function available whenever we use this class
21 #include <dumux/discretization/localview.hh>
22 #include <dumux/discretization/cvfe/elementvolumevariables.hh>
23 #include <dumux/discretization/cvfe/elementsolution.hh>
24
25 namespace Dumux {
26
27 template<class P, class VV>
28 struct CVFEDefaultGridVolumeVariablesTraits
29 {
30 using Problem = P;
31 using VolumeVariables = VV;
32
33 template<class GridVolumeVariables, bool cachingEnabled>
34 using LocalView = CVFEElementVolumeVariables<GridVolumeVariables, cachingEnabled>;
35 };
36
37 /*!
38 * \ingroup CVFEDiscretization
39 * \brief Base class for the grid volume variables
40 */
41 template<class Traits, bool enableCaching>
42 class CVFEGridVolumeVariables;
43
44 // specialization in case of storing the volume variables
45 template<class Traits>
46
3/5
✓ Branch 2 taken 550 times.
✓ Branch 3 taken 621 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1524 times.
✗ Branch 6 not taken.
2764 class CVFEGridVolumeVariables<Traits, /*cachingEnabled*/true>
47 {
48 using ThisType = CVFEGridVolumeVariables<Traits, true>;
49
50 public:
51 //! export the problem type
52 using Problem = typename Traits::Problem;
53
54 //! export the volume variables type
55 using VolumeVariables = typename Traits::VolumeVariables;
56
57 //! make it possible to query if caching is enabled
58 static constexpr bool cachingEnabled = true;
59
60 //! export the type of the local view
61 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
62
63 CVFEGridVolumeVariables(const Problem& problem) : problemPtr_(&problem) {}
64
65 template<class GridGeometry, class SolutionVector>
66 10174 void update(const GridGeometry& gridGeometry, const SolutionVector& sol)
67 {
68 20348 volumeVariables_.resize(gridGeometry.gridView().size(0));
69 14559010 Dumux::parallelFor(gridGeometry.gridView().size(0), [&, &problem = problem()](const std::size_t eIdx)
70 {
71 9852485 const auto element = gridGeometry.element(eIdx);
72
8/20
✓ Branch 1 taken 2926118 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2926118 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2321818 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2321818 times.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 15 taken 31200 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 31200 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 31200 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 31200 times.
✗ Branch 23 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
23266588 const auto fvGeometry = localView(gridGeometry).bindElement(element);
73
74 // get the element solution
75
1/2
✓ Branch 1 taken 2926118 times.
✗ Branch 2 not taken.
7499467 auto elemSol = elementSolution(element, sol, gridGeometry);
76
77 // update the volvars of the element
78
6/12
✓ Branch 1 taken 2926118 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2926118 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2926118 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 31200 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 31200 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 31200 times.
✗ Branch 17 not taken.
22498401 volumeVariables_[eIdx].resize(fvGeometry.numScv());
79
8/8
✓ Branch 0 taken 25106282 times.
✓ Branch 1 taken 6842477 times.
✓ Branch 2 taken 25106282 times.
✓ Branch 3 taken 6842477 times.
✓ Branch 4 taken 2267960 times.
✓ Branch 5 taken 656990 times.
✓ Branch 6 taken 2267960 times.
✓ Branch 7 taken 656990 times.
49959132 for (const auto& scv : scvs(fvGeometry))
80
3/6
✓ Branch 1 taken 9894354 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 9894354 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 9894354 times.
✗ Branch 8 not taken.
87308922 volumeVariables_[eIdx][scv.indexInElement()].update(elemSol, problem, element, scv);
81 });
82 10174 }
83
84 template<class SubControlVolume, typename std::enable_if_t<!std::is_integral<SubControlVolume>::value, int> = 0>
85 const VolumeVariables& volVars(const SubControlVolume& scv) const
86 { return volumeVariables_[scv.elementIndex()][scv.indexInElement()]; }
87
88 template<class SubControlVolume, typename std::enable_if_t<!std::is_integral<SubControlVolume>::value, int> = 0>
89 VolumeVariables& volVars(const SubControlVolume& scv)
90
8/22
✓ Branch 1 taken 124800 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 124800 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 127605 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 2805 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 2839 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1868606 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1868606 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1868572 times.
✗ Branch 23 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
310516674 { return volumeVariables_[scv.elementIndex()][scv.indexInElement()]; }
91
92 const VolumeVariables& volVars(const std::size_t eIdx, const std::size_t scvIdx) const
93
73/77
✓ Branch 0 taken 5019673 times.
✓ Branch 1 taken 51348955 times.
✓ Branch 2 taken 5019673 times.
✓ Branch 3 taken 51348955 times.
✓ Branch 4 taken 5019673 times.
✓ Branch 5 taken 51348955 times.
✓ Branch 6 taken 26524651 times.
✓ Branch 7 taken 29843977 times.
✓ Branch 8 taken 26524651 times.
✓ Branch 9 taken 29843977 times.
✓ Branch 10 taken 41099208 times.
✓ Branch 11 taken 290129396 times.
✓ Branch 12 taken 41099208 times.
✓ Branch 13 taken 290129396 times.
✓ Branch 14 taken 66475608 times.
✓ Branch 15 taken 290129396 times.
✓ Branch 16 taken 205934884 times.
✓ Branch 17 taken 150670120 times.
✓ Branch 18 taken 205934884 times.
✓ Branch 19 taken 150674908 times.
✓ Branch 20 taken 208007938 times.
✓ Branch 21 taken 244155010 times.
✓ Branch 22 taken 208007938 times.
✓ Branch 23 taken 244150222 times.
✓ Branch 24 taken 182636326 times.
✓ Branch 25 taken 244150222 times.
✓ Branch 26 taken 173954406 times.
✓ Branch 27 taken 101380110 times.
✓ Branch 28 taken 190872006 times.
✓ Branch 29 taken 101380110 times.
✓ Branch 30 taken 449829812 times.
✓ Branch 31 taken 49841724 times.
✓ Branch 32 taken 449829812 times.
✓ Branch 33 taken 49841724 times.
✓ Branch 34 taken 432912212 times.
✓ Branch 35 taken 58300524 times.
✓ Branch 36 taken 33093092 times.
✓ Branch 37 taken 92133408 times.
✓ Branch 38 taken 33093092 times.
✓ Branch 39 taken 92153408 times.
✓ Branch 40 taken 89548852 times.
✓ Branch 41 taken 92153408 times.
✓ Branch 42 taken 89548892 times.
✓ Branch 43 taken 9115280 times.
✓ Branch 44 taken 89548852 times.
✓ Branch 45 taken 9129878 times.
✓ Branch 46 taken 63491042 times.
✓ Branch 47 taken 6639508 times.
✓ Branch 48 taken 63491082 times.
✓ Branch 49 taken 6639508 times.
✓ Branch 50 taken 247140082 times.
✓ Branch 51 taken 13270950 times.
✓ Branch 52 taken 247080720 times.
✓ Branch 53 taken 6666000 times.
✓ Branch 54 taken 249636640 times.
✓ Branch 55 taken 6656000 times.
✓ Branch 56 taken 2565920 times.
✓ Branch 57 taken 63431680 times.
✓ Branch 58 taken 2565920 times.
✓ Branch 59 taken 63431680 times.
✓ Branch 60 taken 636480 times.
✓ Branch 61 taken 63431680 times.
✓ Branch 62 taken 636480 times.
✗ Branch 63 not taken.
✓ Branch 64 taken 636480 times.
✓ Branch 65 taken 20800 times.
✓ Branch 66 taken 40560 times.
✓ Branch 67 taken 20800 times.
✓ Branch 68 taken 40560 times.
✓ Branch 69 taken 20800 times.
✓ Branch 70 taken 40560 times.
✓ Branch 83 taken 40 times.
✗ Branch 84 not taken.
✓ Branch 86 taken 40 times.
✗ Branch 87 not taken.
✓ Branch 89 taken 40 times.
✗ Branch 90 not taken.
12592908573 { return volumeVariables_[eIdx][scvIdx]; }
94
95 VolumeVariables& volVars(const std::size_t eIdx, const std::size_t scvIdx)
96 { return volumeVariables_[eIdx][scvIdx]; }
97
98 const Problem& problem() const
99 { return *problemPtr_; }
100
101 private:
102 const Problem* problemPtr_;
103 std::vector<std::vector<VolumeVariables>> volumeVariables_;
104 };
105
106
107 // Specialization when the current volume variables are not stored
108 template<class Traits>
109 class CVFEGridVolumeVariables<Traits, /*cachingEnabled*/false>
110 {
111 using ThisType = CVFEGridVolumeVariables<Traits, false>;
112
113 public:
114 //! export the problem type
115 using Problem = typename Traits::Problem;
116
117 //! export the volume variables type
118 using VolumeVariables = typename Traits::VolumeVariables;
119
120 //! make it possible to query if caching is enabled
121 static constexpr bool cachingEnabled = false;
122
123 //! export the type of the local view
124 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
125
126
4/16
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ 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 not taken.
✗ Branch 15 not taken.
16 CVFEGridVolumeVariables(const Problem& problem) : problemPtr_(&problem) {}
127
128 template<class GridGeometry, class SolutionVector>
129 void update(const GridGeometry& gridGeometry, const SolutionVector& sol) {}
130
131 const Problem& problem() const
132 { return *problemPtr_;}
133
134 private:
135 const Problem* problemPtr_;
136 };
137
138 } // end namespace Dumux
139
140 #endif
141