GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/dumux/discretization/cvfe/elementboundarytypes.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 19 19 100.0%
Functions: 200 202 99.0%
Branches: 45 63 71.4%

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 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
9/16
✓ Branch 0 taken 2287531 times.
✓ Branch 1 taken 926114 times.
✓ Branch 2 taken 160545 times.
✓ Branch 3 taken 926719 times.
✓ Branch 4 taken 509516 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 156861 times.
✓ Branch 7 taken 6859 times.
✓ Branch 8 taken 261128 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 261056 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
20571327 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 20349949 void update(const Problem& problem,
42 const typename FVElementGeometry::Element& element,
43 const FVElementGeometry& fvGeometry)
44 {
45 20349949 bcTypes_.resize(fvGeometry.numScv());
46
47 20349949 hasDirichlet_ = false;
48 20349949 hasNeumann_ = false;
49
50
4/4
✓ Branch 0 taken 45042586 times.
✓ Branch 1 taken 23276662 times.
✓ Branch 2 taken 12860920 times.
✓ Branch 3 taken 4337091 times.
88038307 for (const auto& scv : scvs(fvGeometry))
51 {
52 67688358 const auto scvIdxLocal = scv.localDofIndex();
53
2/2
✓ Branch 0 taken 5246426 times.
✓ Branch 1 taken 50980254 times.
114094900 bcTypes_[scvIdxLocal].reset();
54
55
2/2
✓ Branch 0 taken 5246426 times.
✓ Branch 1 taken 50980254 times.
67688358 if (fvGeometry.gridGeometry().dofOnBoundary(scv.dofIndex()))
56 {
57
3/3
✓ Branch 0 taken 3938211 times.
✓ Branch 1 taken 396351 times.
✓ Branch 2 taken 11556 times.
5830458 bcTypes_[scvIdxLocal] = problem.boundaryTypes(element, scv);
58
4/4
✓ Branch 0 taken 4819741 times.
✓ Branch 1 taken 426685 times.
✓ Branch 2 taken 575744 times.
✓ Branch 3 taken 4243997 times.
5830458 hasDirichlet_ = hasDirichlet_ || bcTypes_[scvIdxLocal].hasDirichlet();
59
4/4
✓ Branch 0 taken 2998124 times.
✓ Branch 1 taken 2248302 times.
✓ Branch 2 taken 1924485 times.
✓ Branch 3 taken 1073639 times.
10247032 hasNeumann_ = hasNeumann_ || bcTypes_[scvIdxLocal].hasNeumann();
60 }
61 }
62 20349949 }
63
64 /*!
65 * \brief Returns whether the element has a vertex which contains
66 * a Dirichlet value.
67 */
68 36109832 bool hasDirichlet() const
69
15/24
✓ Branch 0 taken 801556 times.
✓ Branch 1 taken 22146084 times.
✓ Branch 2 taken 599864 times.
✓ Branch 3 taken 9632539 times.
✓ Branch 4 taken 10046 times.
✓ Branch 5 taken 794504 times.
✓ Branch 6 taken 34888 times.
✓ Branch 7 taken 537715 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 261056 times.
✓ Branch 10 taken 13760 times.
✓ Branch 11 taken 255744 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 50016 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 964352 times.
✓ Branch 16 taken 2480 times.
✓ Branch 17 taken 5228 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
36109832 { 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
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41086063 times.
43684540 const BoundaryTypes& get(const FVElementGeometry&, const typename FVElementGeometry::SubControlVolume& scv) const
99 {
100 43684540 const auto localDofIdx = scv.localDofIndex();
101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41086063 times.
43684540 assert(localDofIdx < bcTypes_.size());
102 43684540 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