GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/dumux/discretization/cvfe/gridvolumevariables.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 23 23 100.0%
Functions: 67 67 100.0%
Branches: 94 128 73.4%

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 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
2/3
✓ Branch 3 taken 2245 times.
✗ Branch 4 not taken.
✓ Branch 2 taken 550 times.
2866 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
2/4
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
71 CVFEGridVolumeVariables(const Problem& problem) : problemPtr_(&problem) {}
64
65 template<class GridGeometry, class SolutionVector>
66 10464 void update(const GridGeometry& gridGeometry, const SolutionVector& sol)
67 {
68 10464 volumeVariables_.resize(gridGeometry.gridView().size(0));
69 3215368 Dumux::parallelFor(gridGeometry.gridView().size(0), [&, &problem = problem()](const std::size_t eIdx)
70 {
71 8055390 const auto element = gridGeometry.element(eIdx);
72
4/8
✓ Branch 1 taken 3474173 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2869873 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 31200 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 31200 times.
✗ Branch 10 not taken.
11560763 const auto fvGeometry = localView(gridGeometry).bindElement(element);
73
74 // get the element solution
75
1/2
✓ Branch 1 taken 3474173 times.
✗ Branch 2 not taken.
8055390 auto elemSol = elementSolution(element, sol, gridGeometry);
76
77 // update the volvars of the element
78
2/4
✓ Branch 1 taken 3474173 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 31200 times.
✗ Branch 5 not taken.
8055390 volumeVariables_[eIdx].resize(fvGeometry.numScv());
79
4/4
✓ Branch 0 taken 26789463 times.
✓ Branch 1 taken 7398400 times.
✓ Branch 2 taken 2267960 times.
✓ Branch 3 taken 656990 times.
37112813 for (const auto& scv : scvs(fvGeometry))
80
1/2
✓ Branch 1 taken 9894354 times.
✗ Branch 2 not taken.
29151023 volumeVariables_[eIdx][scv.indexInElement()].update(elemSol, problem, element, scv);
81 3505373 });
82 10464 }
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 111935139 VolumeVariables& volVars(const SubControlVolume& scv)
90
4/9
✓ Branch 3 taken 3337 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 34 times.
✗ Branch 8 not taken.
✓ Branch 1 taken 124800 times.
✗ Branch 2 not taken.
✓ Branch 6 taken 1868572 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
111935139 { return volumeVariables_[scv.elementIndex()][scv.indexInElement()]; }
91
92 4818616102 const VolumeVariables& volVars(const std::size_t eIdx, const std::size_t scvIdx) const
93
24/26
✓ Branch 0 taken 5019673 times.
✓ Branch 1 taken 51348955 times.
✓ Branch 2 taken 28473432 times.
✓ Branch 3 taken 23568836 times.
✓ Branch 4 taken 39136646 times.
✓ Branch 5 taken 296610438 times.
✓ Branch 6 taken 213917383 times.
✓ Branch 7 taken 246085617 times.
✓ Branch 8 taken 162462180 times.
✓ Branch 9 taken 150815129 times.
✓ Branch 10 taken 453511677 times.
✓ Branch 11 taken 156242238 times.
✓ Branch 12 taken 33306084 times.
✓ Branch 13 taken 93233896 times.
✓ Branch 14 taken 73542800 times.
✓ Branch 15 taken 14419534 times.
✓ Branch 16 taken 274422724 times.
✓ Branch 17 taken 9259214 times.
✓ Branch 18 taken 72038 times.
✓ Branch 19 taken 64499144 times.
✓ Branch 20 taken 10120 times.
✓ Branch 21 taken 20800 times.
✓ Branch 22 taken 534408 times.
✗ Branch 23 not taken.
✓ Branch 27 taken 40 times.
✗ Branch 28 not taken.
4189898602 { 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 212285 const Problem& problem() const
99
7/12
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 7 times.
✓ Branch 4 taken 26 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 10 times.
✓ Branch 8 taken 3 times.
✓ Branch 10 taken 16 times.
✗ Branch 11 not taken.
✗ Branch 3 not taken.
✗ Branch 9 not taken.
✓ Branch 13 taken 5 times.
✗ Branch 14 not taken.
212285 { 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
5/8
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
190 CVFEGridVolumeVariables(const Problem& problem) : problemPtr_(&problem) {}
127
128 template<class GridGeometry, class SolutionVector>
129 2 void update(const GridGeometry& gridGeometry, const SolutionVector& sol) {}
130
131 67690008 const Problem& problem() const
132
38/46
✓ Branch 1 taken 91 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 529 times.
✓ Branch 5 taken 21 times.
✓ Branch 9 taken 13 times.
✓ Branch 10 taken 42340 times.
✓ Branch 12 taken 6 times.
✓ Branch 13 taken 46203 times.
✓ Branch 17 taken 10 times.
✓ Branch 18 taken 1 times.
✓ Branch 20 taken 8 times.
✓ Branch 21 taken 2 times.
✓ Branch 26 taken 4 times.
✓ Branch 27 taken 2 times.
✓ Branch 29 taken 4 times.
✓ Branch 30 taken 1 times.
✓ Branch 32 taken 3 times.
✗ Branch 33 not taken.
✓ Branch 36 taken 1 times.
✓ Branch 37 taken 1 times.
✓ Branch 39 taken 1 times.
✓ Branch 40 taken 1 times.
✓ Branch 42 taken 1 times.
✓ Branch 43 taken 1 times.
✓ Branch 7 taken 5175 times.
✓ Branch 8 taken 16 times.
✓ Branch 6 taken 449 times.
✓ Branch 11 taken 41 times.
✓ Branch 14 taken 24 times.
✓ Branch 15 taken 1 times.
✓ Branch 19 taken 8 times.
✓ Branch 22 taken 6 times.
✓ Branch 23 taken 5 times.
✓ Branch 25 taken 6 times.
✓ Branch 28 taken 2 times.
✓ Branch 16 taken 7 times.
✗ Branch 38 not taken.
✗ Branch 41 not taken.
✗ Branch 44 not taken.
✓ Branch 47 taken 4368 times.
✗ Branch 48 not taken.
✓ Branch 51 taken 2014 times.
✗ Branch 52 not taken.
✓ Branch 24 taken 2 times.
✓ Branch 3 taken 6 times.
✗ Branch 31 not taken.
68446005 { return *problemPtr_;}
133
134 private:
135 const Problem* problemPtr_;
136 };
137
138 } // end namespace Dumux
139
140 #endif
141