GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/discretization/cvfe/elementboundarytypes.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 13 19 68.4%
Functions: 134 203 66.0%
Branches: 44 57 77.2%

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 Boundary types gathered on an element
11 */
12 #ifndef DUMUX_CVFE_ELEMENT_BOUNDARY_TYPES_HH
13 #define DUMUX_CVFE_ELEMENT_BOUNDARY_TYPES_HH
14
15 #include <cassert>
16 #include <vector>
17
18 #include <dumux/discretization/method.hh>
19
20 namespace Dumux {
21
22 /*!
23 * \ingroup CVFEDiscretization
24 * \brief This class stores an array of BoundaryTypes objects
25 */
26 template<class BTypes>
27
15/24
✓ Branch 0 taken 2273886 times.
✓ Branch 1 taken 2184756 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1097496 times.
✓ Branch 4 taken 1491267 times.
✓ Branch 5 taken 20800 times.
✓ Branch 6 taken 1087268 times.
✓ Branch 7 taken 20800 times.
✓ Branch 8 taken 232108 times.
✓ Branch 9 taken 161146 times.
✓ Branch 10 taken 6859 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 232108 times.
✓ Branch 13 taken 156861 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 156861 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 156861 times.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 156861 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
33253168 class CVFEElementBoundaryTypes
28 {
29 public:
30 using BoundaryTypes = BTypes;
31
32 /*!
33 * \brief Update the boundary types for all vertices of an element.
34 *
35 * \param problem The problem object which needs to be simulated
36 * \param element The DUNE Codim<0> entity for which the boundary
37 * types should be collected
38 * \param fvGeometry The element's finite volume geometry
39 */
40 template<class Problem, class FVElementGeometry>
41 19760558 void update(const Problem& problem,
42 const typename FVElementGeometry::Element& element,
43 const FVElementGeometry& fvGeometry)
44 {
45 39521116 bcTypes_.resize(fvGeometry.numScv());
46
47 19760558 hasDirichlet_ = false;
48 19760558 hasNeumann_ = false;
49
50
4/4
✓ Branch 0 taken 54734354 times.
✓ Branch 1 taken 15956060 times.
✓ Branch 2 taken 51441784 times.
✓ Branch 3 taken 14309775 times.
105311876 for (const auto& scv : scvs(fvGeometry))
51 {
52 65790760 const auto scvIdxLocal = scv.localDofIndex();
53
4/4
✓ Branch 0 taken 1672726 times.
✓ Branch 1 taken 11014484 times.
✓ Branch 2 taken 1672726 times.
✓ Branch 3 taken 11014484 times.
131581520 bcTypes_[scvIdxLocal].reset();
54
55
6/6
✓ Branch 0 taken 5025896 times.
✓ Branch 1 taken 49708458 times.
✓ Branch 2 taken 5025896 times.
✓ Branch 3 taken 49708458 times.
✓ Branch 4 taken 3847132 times.
✓ Branch 5 taken 35121060 times.
174452572 if (fvGeometry.gridGeometry().dofOnBoundary(scv.dofIndex()))
56 {
57
3/3
✓ Branch 0 taken 1687952 times.
✓ Branch 1 taken 2571871 times.
✓ Branch 2 taken 325551 times.
5601740 bcTypes_[scvIdxLocal] = problem.boundaryTypes(element, scv);
58
6/6
✓ Branch 0 taken 4604265 times.
✓ Branch 1 taken 421631 times.
✓ Branch 2 taken 572620 times.
✓ Branch 3 taken 4031645 times.
✓ Branch 4 taken 572620 times.
✓ Branch 5 taken 4031645 times.
5601740 hasDirichlet_ = hasDirichlet_ || bcTypes_[scvIdxLocal].hasDirichlet();
59
6/6
✓ Branch 0 taken 2853620 times.
✓ Branch 1 taken 2172276 times.
✓ Branch 2 taken 1785788 times.
✓ Branch 3 taken 1067832 times.
✓ Branch 4 taken 1785788 times.
✓ Branch 5 taken 1067832 times.
7537441 hasNeumann_ = hasNeumann_ || bcTypes_[scvIdxLocal].hasNeumann();
60 }
61 }
62 19760558 }
63
64 /*!
65 * \brief Returns whether the element has a vertex which contains
66 * a Dirichlet value.
67 */
68 bool hasDirichlet() const
69 { return hasDirichlet_; }
70
71 /*!
72 * \brief Returns whether the element potentially features a
73 * Neumann boundary segment.
74 */
75 bool hasNeumann() const
76 { return hasNeumann_; }
77
78 /*
79 * \brief Access operator
80 * \return BoundaryTypes
81 * \note yields undefined behaviour of the scv is not on the boundary
82 */
83 template<class FVElementGeometry>
84 const BoundaryTypes& get(const FVElementGeometry& fvGeometry, const typename FVElementGeometry::SubControlVolumeFace& scvf) const
85 {
86 assert(scvf.boundary());
87 const auto localDofIdx = fvGeometry.scv(scvf.insideScvIdx()).localDofIndex();
88 assert(localDofIdx < bcTypes_.size());
89 return bcTypes_[localDofIdx];
90 }
91
92 /*
93 * \brief Access operator
94 * \return BoundaryTypes
95 * \note yields undefined behaviour of the scv is not on the boundary
96 */
97 template<class FVElementGeometry>
98 const BoundaryTypes& get(const FVElementGeometry&, const typename FVElementGeometry::SubControlVolume& scv) const
99 {
100 const auto localDofIdx = scv.localDofIndex();
101 assert(localDofIdx < bcTypes_.size());
102 return bcTypes_[localDofIdx];
103 }
104
105 private:
106 std::vector<BoundaryTypes> bcTypes_;
107 bool hasDirichlet_ = false;
108 bool hasNeumann_ = false;
109 };
110
111 } // namespace Dumux
112
113 #endif
114