GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/dumux/discretization/cellcentered/gridvolumevariables.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 21 21 100.0%
Functions: 116 116 100.0%
Branches: 79 109 72.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-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 grid volume variables class for cell centered models
11 */
12 #ifndef DUMUX_DISCRETIZATION_CC_GRID_VOLUMEVARIABLES_HH
13 #define DUMUX_DISCRETIZATION_CC_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/cellcentered/elementsolution.hh>
23
24 namespace Dumux {
25
26 /*!
27 * \ingroup CCDiscretization
28 * \brief Base class for the grid volume variables
29 * \note This class has a cached version and a non-cached version
30 * \tparam Traits the traits class injecting the problem, volVar and elemVolVars type
31 * \tparam cachingEnabled if the cache is enabled
32 */
33 template<class Traits, bool cachingEnabled = false>
34 class CCGridVolumeVariables {};
35
36 //! specialization in case of storing the volume variables
37 template<class Traits>
38
4/7
✓ Branch 5 taken 567 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 567 times.
✗ Branch 9 not taken.
✓ Branch 3 taken 1293 times.
✗ Branch 4 not taken.
✓ Branch 2 taken 2400 times.
4994 class CCGridVolumeVariables<Traits, /*cachingEnabled*/true>
39 {
40 using ThisType = CCGridVolumeVariables<Traits, true>;
41
42 public:
43 //! export the problem type
44 using Problem = typename Traits::Problem;
45
46 //! export the volume variables type
47 using VolumeVariables = typename Traits::VolumeVariables;
48
49 //! make it possible to query if caching is enabled
50 static constexpr bool cachingEnabled = true;
51
52 //! export the type of the local view
53 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
54
55
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
159 CCGridVolumeVariables(const Problem& problem) : problemPtr_(&problem) {}
56
57 template<class GridGeometry, class SolutionVector>
58 18604 void update(const GridGeometry& gridGeometry, const SolutionVector& sol)
59 {
60 18604 volumeVariables_.resize(gridGeometry.numScv());
61 55053492 Dumux::parallelFor(gridGeometry.gridView().size(0), [&, &problem = problem()](const std::size_t eIdx)
62 {
63 42647465 const auto element = gridGeometry.element(eIdx);
64
2/4
✓ Branch 1 taken 2384062 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2384062 times.
✗ Branch 4 not taken.
87313443 const auto fvGeometry = localView(gridGeometry).bindElement(element);
65
6/6
✓ Branch 0 taken 19632663 times.
✓ Branch 1 taken 19632663 times.
✓ Branch 2 taken 21414802 times.
✓ Branch 3 taken 21414802 times.
✓ Branch 4 taken 1600000 times.
✓ Branch 5 taken 1600000 times.
85294930 for (const auto& scv : scvs(fvGeometry))
66 {
67
2/3
✓ Branch 1 taken 2950719 times.
✓ Branch 2 taken 111930 times.
✗ Branch 3 not taken.
42647465 const auto elemSol = elementSolution(element, sol, gridGeometry);
68
2/3
✓ Branch 1 taken 2950719 times.
✓ Branch 2 taken 111930 times.
✗ Branch 3 not taken.
43102546 volumeVariables_[scv.dofIndex()].update(elemSol, problem, element, scv);
69 }
70 2384062 });
71 18604 }
72
73 8155797040 const VolumeVariables& volVars(const std::size_t scvIdx) const
74 8155797040 { return volumeVariables_[scvIdx]; }
75
76 VolumeVariables& volVars(const std::size_t scvIdx)
77 { return volumeVariables_[scvIdx]; }
78
79 template<class SubControlVolume, typename std::enable_if_t<!std::is_integral<SubControlVolume>::value, int> = 0>
80 const VolumeVariables& volVars(const SubControlVolume& scv) const
81 { return volumeVariables_[scv.dofIndex()]; }
82
83 template<class SubControlVolume, typename std::enable_if_t<!std::is_integral<SubControlVolume>::value, int> = 0>
84 58172282 VolumeVariables& volVars(const SubControlVolume& scv)
85
4/7
✓ Branch 1 taken 2392180 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 295920 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2363892 times.
✗ Branch 8 not taken.
✓ Branch 3 taken 19968 times.
58172360 { return volumeVariables_[scv.dofIndex()]; }
86
87 // required for compatibility with the box method
88 const VolumeVariables& volVars(const std::size_t scvIdx, const std::size_t localIdx) const
89 { return volumeVariables_[scvIdx]; }
90
91 // required for compatibility with the box method
92 VolumeVariables& volVars(const std::size_t scvIdx, const std::size_t localIdx)
93 { return volumeVariables_[scvIdx]; }
94
95 //! The problem we are solving
96 70901878 const Problem& problem() const
97
39/46
✓ Branch 1 taken 4832 times.
✓ Branch 2 taken 349 times.
✓ Branch 5 taken 52396 times.
✓ Branch 6 taken 457504 times.
✓ Branch 9 taken 28743 times.
✓ Branch 10 taken 84069 times.
✓ Branch 12 taken 27993 times.
✓ Branch 13 taken 10844006 times.
✓ Branch 15 taken 1114923 times.
✓ Branch 16 taken 2611019 times.
✓ Branch 18 taken 3695537 times.
✓ Branch 19 taken 6320206 times.
✓ Branch 21 taken 1440827 times.
✓ Branch 22 taken 94573 times.
✓ Branch 24 taken 2055242 times.
✓ Branch 25 taken 957695 times.
✓ Branch 27 taken 14438 times.
✓ Branch 28 taken 3854 times.
✓ Branch 30 taken 301934 times.
✓ Branch 31 taken 2878 times.
✓ Branch 32 taken 15644 times.
✓ Branch 33 taken 17729 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 242406 times.
✓ Branch 36 taken 504 times.
✗ Branch 37 not taken.
✓ Branch 39 taken 1735 times.
✗ Branch 40 not taken.
✓ Branch 43 taken 1735 times.
✗ Branch 44 not taken.
✓ Branch 47 taken 8000 times.
✗ Branch 48 not taken.
✓ Branch 52 taken 101 times.
✗ Branch 53 not taken.
✓ Branch 4 taken 112431 times.
✓ Branch 7 taken 8035 times.
✓ Branch 8 taken 2207 times.
✓ Branch 11 taken 7998866 times.
✓ Branch 14 taken 20744125 times.
✓ Branch 3 taken 180004 times.
✓ Branch 17 taken 411553 times.
✓ Branch 20 taken 55226 times.
✓ Branch 23 taken 90 times.
✓ Branch 26 taken 22668 times.
✓ Branch 29 taken 21000 times.
✗ Branch 0 not taken.
70902059 { return *problemPtr_; }
98
99 private:
100 const Problem* problemPtr_;
101 std::vector<VolumeVariables> volumeVariables_;
102 };
103
104
105 //! Specialization when the current volume variables are not stored globally
106 template<class Traits>
107 class CCGridVolumeVariables<Traits, /*cachingEnabled*/false>
108 {
109 using ThisType = CCGridVolumeVariables<Traits, false>;
110
111 public:
112 //! export the problem type
113 using Problem = typename Traits::Problem;
114
115 //! export the volume variables type
116 using VolumeVariables = typename Traits::VolumeVariables;
117
118 //! make it possible to query if caching is enabled
119 static constexpr bool cachingEnabled = false;
120
121 //! export the type of the local view
122 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
123
124
4/8
✓ Branch 0 taken 242 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
286 CCGridVolumeVariables(const Problem& problem) : problemPtr_(&problem) {}
125
126 template<class GridGeometry, class SolutionVector>
127 void update(const GridGeometry& gridGeometry, const SolutionVector& sol) {}
128
129 //! The problem we are solving
130 46645308 const Problem& problem() const
131
15/23
✗ Branch 3 not taken.
✓ Branch 4 taken 149 times.
✓ Branch 7 taken 53 times.
✓ Branch 8 taken 9 times.
✓ Branch 10 taken 22 times.
✓ Branch 11 taken 10 times.
✓ Branch 13 taken 102 times.
✓ Branch 14 taken 1 times.
✓ Branch 16 taken 284 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 42 times.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 1 taken 129 times.
✓ Branch 2 taken 4 times.
✓ Branch 5 taken 1 times.
✓ Branch 9 taken 83 times.
✗ Branch 6 not taken.
✓ Branch 21 taken 1 times.
✓ Branch 12 taken 17 times.
✗ Branch 15 not taken.
✗ Branch 18 not taken.
51864997 { return *problemPtr_;}
132
133 private:
134 const Problem* problemPtr_;
135 };
136
137 } // end namespace Dumux
138
139 #endif
140