GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/discretization/cvfe/elementboundarytypes.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 13 19 68.4%
Functions: 133 202 65.8%
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 2327686 times.
✓ Branch 1 taken 2184756 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1097496 times.
✓ Branch 4 taken 1549163 times.
✓ Branch 5 taken 20800 times.
✓ Branch 6 taken 1087268 times.
✓ Branch 7 taken 20800 times.
✓ Branch 8 taken 261056 times.
✓ Branch 9 taken 161146 times.
✓ Branch 10 taken 6859 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 261056 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.
33615554 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 20057543 void update(const Problem& problem,
42 const typename FVElementGeometry::Element& element,
43 const FVElementGeometry& fvGeometry)
44 {
45 40115086 bcTypes_.resize(fvGeometry.numScv());
46
47 20057543 hasDirichlet_ = false;
48 20057543 hasNeumann_ = false;
49
50
4/4
✓ Branch 0 taken 55328934 times.
✓ Branch 1 taken 16137253 times.
✓ Branch 2 taken 52036364 times.
✓ Branch 3 taken 14490968 times.
106905698 for (const auto& scv : scvs(fvGeometry))
51 {
52 66790612 const auto scvIdxLocal = scv.localDofIndex();
53
4/4
✓ Branch 0 taken 1676820 times.
✓ Branch 1 taken 11184078 times.
✓ Branch 2 taken 1676820 times.
✓ Branch 3 taken 11184078 times.
133581224 bcTypes_[scvIdxLocal].reset();
54
55
6/6
✓ Branch 0 taken 5034136 times.
✓ Branch 1 taken 50294798 times.
✓ Branch 2 taken 5034136 times.
✓ Branch 3 taken 50294798 times.
✓ Branch 4 taken 3855372 times.
✓ Branch 5 taken 35707400 times.
177452128 if (fvGeometry.gridGeometry().dofOnBoundary(scv.dofIndex()))
56 {
57
3/3
✓ Branch 0 taken 1693511 times.
✓ Branch 1 taken 2572409 times.
✓ Branch 2 taken 327694 times.
5618168 bcTypes_[scvIdxLocal] = problem.boundaryTypes(element, scv);
58
6/6
✓ Branch 0 taken 4610239 times.
✓ Branch 1 taken 423897 times.
✓ Branch 2 taken 577442 times.
✓ Branch 3 taken 4032797 times.
✓ Branch 4 taken 577442 times.
✓ Branch 5 taken 4032797 times.
5618168 hasDirichlet_ = hasDirichlet_ || bcTypes_[scvIdxLocal].hasDirichlet();
59
6/6
✓ Branch 0 taken 2862061 times.
✓ Branch 1 taken 2172075 times.
✓ Branch 2 taken 1787401 times.
✓ Branch 3 taken 1074660 times.
✓ Branch 4 taken 1787401 times.
✓ Branch 5 taken 1074660 times.
7558380 hasNeumann_ = hasNeumann_ || bcTypes_[scvIdxLocal].hasNeumann();
60 }
61 }
62 20057543 }
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