GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/discretization/staggered/gridfacevariables.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 13 15 86.7%
Functions: 32 111 28.8%
Branches: 39 55 70.9%

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 StaggeredDiscretization
10 * \copydoc Dumux::StaggeredGridFaceVariables
11 */
12 #ifndef DUMUX_DISCRETIZATION_STAGGERED_GRID_FACEVARIABLES_HH
13 #define DUMUX_DISCRETIZATION_STAGGERED_GRID_FACEVARIABLES_HH
14
15 // make the local view function available whenever we use this class
16 #include <dumux/discretization/localview.hh>
17 #include <dumux/discretization/staggered/elementfacevariables.hh>
18 #include <dumux/discretization/staggered/facesolution.hh>
19
20 namespace Dumux {
21
22 /*!
23 * \ingroup StaggeredDiscretization
24 * \brief Traits class to be used for the StaggeredGridFaceVariables.
25 *
26 * \tparam P The problem type
27 * \tparam FV The face variables type
28 */
29 template<class P, class FV>
30 struct StaggeredDefaultGridFaceVariablesTraits
31 {
32 template<class GridFaceVariables, bool enableCache>
33 using LocalView = StaggeredElementFaceVariables<GridFaceVariables, enableCache>;
34
35 using FaceVariables = FV;
36 using Problem = P;
37 };
38
39 /*!
40 * \ingroup StaggeredDiscretization
41 * \brief Face variables cache class for staggered models
42 */
43 template<class Problem,
44 class FaceVariables,
45 bool cachingEnabled = false,
46 class Traits = StaggeredDefaultGridFaceVariablesTraits<Problem, FaceVariables> >
47 class StaggeredGridFaceVariables;
48
49 /*!
50 * \ingroup StaggeredDiscretization
51 * \brief Face variables cache class for staggered models.
52 Specialization in case of storing the face variables.
53 */
54 template<class P, class FV, class Traits>
55 1260 class StaggeredGridFaceVariables<P, FV, /*cachingEnabled*/true, Traits>
56 {
57 using ThisType = StaggeredGridFaceVariables<P, FV, /*cachingEnabled*/true, Traits>;
58 using Problem = typename Traits::Problem;
59
60 public:
61 //! make it possible to query if caching is enabled
62 static constexpr bool cachingEnabled = true;
63
64 //! export the type of the local view
65 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
66
67 //! export the type of the face variables
68 using FaceVariables = typename Traits::FaceVariables;
69
70 200 StaggeredGridFaceVariables(const Problem& problem) : problemPtr_(&problem) {}
71
72 //! Update all face variables
73 template<class GridGeometry, class SolutionVector>
74 5619 void update(const GridGeometry& gridGeometry, const SolutionVector& sol)
75 {
76 11238 faceVariables_.resize(gridGeometry.numScvf());
77
0/2
✗ Branch 1 not taken.
✗ Branch 2 not taken.
5619 auto fvGeometry = localView(gridGeometry);
78
1/9
✗ Branch 1 not taken.
✓ Branch 2 taken 1775783 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
3551566 for (auto&& element : elements(gridGeometry.gridView()))
79 {
80
0/2
✗ Branch 1 not taken.
✗ Branch 2 not taken.
1770164 fvGeometry.bindElement(element);
81
82
4/4
✓ Branch 0 taken 7080656 times.
✓ Branch 1 taken 1770164 times.
✓ Branch 2 taken 7080656 times.
✓ Branch 3 taken 1770164 times.
10620984 for (auto&& scvf : scvfs(fvGeometry))
83 {
84
0/2
✗ Branch 1 not taken.
✗ Branch 2 not taken.
14161312 const auto faceSol = StaggeredFaceSolution(scvf, sol, gridGeometry);
85 14161312 faceVariables_[scvf.index()].update(faceSol, problem(), element, fvGeometry, scvf);
86 }
87 }
88 5619 }
89
90 const FaceVariables& faceVars(const std::size_t facetIdx) const
91
34/36
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 110921424 times.
✓ Branch 2 taken 14544904 times.
✓ Branch 3 taken 159050473 times.
✓ Branch 4 taken 38692816 times.
✓ Branch 5 taken 82831555 times.
✓ Branch 6 taken 148240453 times.
✓ Branch 7 taken 58983442 times.
✓ Branch 8 taken 192629677 times.
✓ Branch 9 taken 49788271 times.
✓ Branch 10 taken 94488207 times.
✓ Branch 11 taken 114209178 times.
✓ Branch 12 taken 32157551 times.
✓ Branch 13 taken 130782141 times.
✓ Branch 14 taken 11178211 times.
✓ Branch 15 taken 156637927 times.
✓ Branch 16 taken 5025599 times.
✓ Branch 17 taken 161367565 times.
✓ Branch 18 taken 29305242 times.
✓ Branch 19 taken 126217226 times.
✓ Branch 20 taken 31599192 times.
✓ Branch 21 taken 119697870 times.
✓ Branch 22 taken 69239890 times.
✓ Branch 23 taken 70621178 times.
✓ Branch 24 taken 94727664 times.
✓ Branch 25 taken 40889322 times.
✓ Branch 26 taken 99617398 times.
✓ Branch 27 taken 10504846 times.
✓ Branch 28 taken 108168670 times.
✓ Branch 29 taken 2 times.
✓ Branch 30 taken 65694686 times.
✓ Branch 31 taken 2 times.
✓ Branch 32 taken 40149170 times.
✗ Branch 33 not taken.
✓ Branch 34 taken 10787488 times.
✗ Branch 35 not taken.
3308991922 { return faceVariables_[facetIdx]; }
92
93 FaceVariables& faceVars(const std::size_t facetIdx)
94 96175728 { return faceVariables_[facetIdx]; }
95
96 const Problem& problem() const
97 { return *problemPtr_; }
98
99 private:
100 const Problem* problemPtr_;
101 std::vector<FaceVariables> faceVariables_;
102 };
103
104 /*!
105 * \ingroup StaggeredDiscretization
106 * \brief Face variables cache class for staggered models.
107 Specialization in case of not storing the face variables.
108 */
109 template<class P, class FV, class Traits>
110 class StaggeredGridFaceVariables<P, FV, /*cachingEnabled*/false, Traits>
111 {
112 using ThisType = StaggeredGridFaceVariables<P, FV, /*cachingEnabled*/false, Traits>;
113 using Problem = typename Traits::Problem;
114
115 public:
116 //! make it possible to query if caching is enabled
117 static constexpr bool cachingEnabled = false;
118
119 //! export the type of the local view
120 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
121
122 //! export the type of the face variables
123 using FaceVariables = typename Traits::FaceVariables;
124
125 StaggeredGridFaceVariables(const Problem& problem) : problemPtr_(&problem) {}
126
127 //! Do nothing here.
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