GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/discretization/staggered/gridfacevariables.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 13 15 86.7%
Functions: 56 111 50.5%
Branches: 46 55 83.6%

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 1268 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 300 StaggeredGridFaceVariables(const Problem& problem) : problemPtr_(&problem) {}
71
72 //! Update all face variables
73 template<class GridGeometry, class SolutionVector>
74 5750 void update(const GridGeometry& gridGeometry, const SolutionVector& sol)
75 {
76 11404 faceVariables_.resize(gridGeometry.numScvf());
77
1/2
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
5750 auto fvGeometry = localView(gridGeometry);
78
5/9
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 1782818 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1248 times.
✗ Branch 7 not taken.
✓ Branch 10 taken 1200 times.
✗ Branch 11 not taken.
3570724 for (auto&& element : elements(gridGeometry.gridView()))
79 {
80
1/2
✓ Branch 1 taken 1200 times.
✗ Branch 2 not taken.
1779564 fvGeometry.bindElement(element);
81
82
4/4
✓ Branch 0 taken 7113456 times.
✓ Branch 1 taken 1778364 times.
✓ Branch 2 taken 7113456 times.
✓ Branch 3 taken 1778364 times.
10677384 for (auto&& scvf : scvfs(fvGeometry))
83 {
84
1/2
✓ Branch 1 taken 4800 times.
✗ Branch 2 not taken.
14236512 const auto faceSol = StaggeredFaceSolution(scvf, sol, gridGeometry);
85 14236512 faceVariables_[scvf.index()].update(faceSol, problem(), element, fvGeometry, scvf);
86 }
87 }
88 5750 }
89
90 const FaceVariables& faceVars(const std::size_t facetIdx) const
91
34/36
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 112029673 times.
✓ Branch 2 taken 14544905 times.
✓ Branch 3 taken 160158722 times.
✓ Branch 4 taken 38692817 times.
✓ Branch 5 taken 85048054 times.
✓ Branch 6 taken 148240454 times.
✓ Branch 7 taken 61199941 times.
✓ Branch 8 taken 192629677 times.
✓ Branch 9 taken 49788271 times.
✓ Branch 10 taken 96144257 times.
✓ Branch 11 taken 114250203 times.
✓ Branch 12 taken 33813601 times.
✓ Branch 13 taken 130823166 times.
✓ Branch 14 taken 11178212 times.
✓ Branch 15 taken 157746176 times.
✓ Branch 16 taken 5025600 times.
✓ Branch 17 taken 162475814 times.
✓ Branch 18 taken 29305243 times.
✓ Branch 19 taken 127325475 times.
✓ Branch 20 taken 31599193 times.
✓ Branch 21 taken 120806119 times.
✓ Branch 22 taken 69260790 times.
✓ Branch 23 taken 71457078 times.
✓ Branch 24 taken 94748564 times.
✓ Branch 25 taken 41725222 times.
✓ Branch 26 taken 100474198 times.
✓ Branch 27 taken 10504846 times.
✓ Branch 28 taken 109025470 times.
✓ Branch 29 taken 2 times.
✓ Branch 30 taken 66551486 times.
✓ Branch 31 taken 2 times.
✓ Branch 32 taken 41005970 times.
✗ Branch 33 not taken.
✓ Branch 34 taken 10787488 times.
✗ Branch 35 not taken.
3333945802 { return faceVariables_[facetIdx]; }
92
93 FaceVariables& faceVars(const std::size_t facetIdx)
94 96523728 { 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