GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/discretization/facecentered/staggered/connectivitymap.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 42 42 100.0%
Functions: 11 12 91.7%
Branches: 86 131 65.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 FaceCenteredStaggeredDiscretization
10 * \copydoc Dumux::FaceCenteredStaggeredConnectivityMap
11 */
12 #ifndef DUMUX_DISCRETIZATION_FACECENTERED_STAGGERED_CONNECTIVITY_MAP_HH
13 #define DUMUX_DISCRETIZATION_FACECENTERED_STAGGERED_CONNECTIVITY_MAP_HH
14
15 #include <algorithm>
16 #include <vector>
17 #include <dune/grid/common/partitionset.hh>
18 #include <dune/grid/common/gridenums.hh>
19 #include <dumux/common/indextraits.hh>
20
21 namespace Dumux {
22
23 /*!
24 * \ingroup FaceCenteredStaggeredDiscretization
25 * \brief Stores the dof indices corresponding to the neighboring scvs
26 * that contribute to the derivative calculation.
27 */
28 template<class GridGeometry>
29
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 54 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
124 class FaceCenteredStaggeredConnectivityMap
30 {
31 using GridView = typename GridGeometry::GridView;
32 using GridIndexType = typename IndexTraits<GridView>::GridIndex;
33 using Stencil = std::vector<GridIndexType>;
34 using Map = std::vector<Stencil>;
35
36 public:
37
38 //! Update the map and prepare the stencils
39 62 void update(const GridGeometry& gridGeometry)
40 {
41 62 map_.clear();
42 120 map_.resize(gridGeometry.numScv());
43
44 62 auto fvGeometry = localView(gridGeometry);
45
11/14
✓ Branch 2 taken 330728 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 109 times.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3536 times.
✓ Branch 9 taken 6 times.
✓ Branch 10 taken 3536 times.
✓ Branch 11 taken 6 times.
✓ Branch 13 taken 3536 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 3536 times.
✗ Branch 17 not taken.
665010 for (const auto& element : elements(gridGeometry.gridView()))
46 {
47
2/2
✓ Branch 1 taken 1265 times.
✓ Branch 2 taken 332943 times.
334208 if (element.partitionType() == Dune::InteriorEntity)
48 1101 continue;
49
50
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 164 times.
✗ Branch 3 not taken.
164 assert(element.partitionType() == Dune::OverlapEntity);
51
52 // restrict the FvGeometry locally and bind to the element
53
0/2
✗ Branch 1 not taken.
✗ Branch 2 not taken.
164 fvGeometry.bind(element);
54 // loop over sub control faces
55
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1976 times.
✓ Branch 2 taken 164 times.
✓ Branch 3 taken 1976 times.
✓ Branch 4 taken 164 times.
2140 for (const auto& scvf : scvfs(fvGeometry))
56 {
57
5/6
✓ Branch 0 taken 664 times.
✓ Branch 1 taken 1312 times.
✓ Branch 2 taken 656 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 656 times.
✗ Branch 5 not taken.
1976 if (scvf.isFrontal() && !scvf.boundary() && !scvf.processorBoundary())
58 {
59
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 656 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 656 times.
1312 const auto& ownScv = fvGeometry.scv(scvf.insideScvIdx());
60
0/2
✗ Branch 1 not taken.
✗ Branch 2 not taken.
656 const auto& facet = element.template subEntity <1> (ownScv.indexInElement());
61
4/4
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 496 times.
✓ Branch 2 taken 160 times.
✓ Branch 3 taken 496 times.
1312 if (facet.partitionType() == Dune::BorderEntity)
62
0/6
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
480 map_[ownScv.index()].push_back(scvf.outsideScvIdx());
63 }
64 }
65 }
66
67
11/14
✓ Branch 2 taken 330564 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 109 times.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3536 times.
✓ Branch 9 taken 6 times.
✓ Branch 10 taken 3536 times.
✓ Branch 11 taken 6 times.
✓ Branch 13 taken 3536 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 3536 times.
✗ Branch 17 not taken.
664682 for (const auto& element : elements(gridGeometry.gridView(), Dune::Partitions::interior))
68 {
69
1/2
✓ Branch 1 taken 3536 times.
✗ Branch 2 not taken.
334044 fvGeometry.bind(element);
70
71 // loop over sub control faces
72
5/5
✓ Branch 0 taken 36622 times.
✓ Branch 1 taken 4006002 times.
✓ Branch 2 taken 331026 times.
✓ Branch 3 taken 4002984 times.
✓ Branch 4 taken 331026 times.
4376668 for (const auto& scvf : scvfs(fvGeometry))
73 {
74
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4039606 times.
4039606 assert(!scvf.processorBoundary());
75
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4002984 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4002984 times.
8079212 const auto& ownScv = fvGeometry.scv(scvf.insideScvIdx());
76 4039606 const auto ownDofIndex = ownScv.dofIndex();
77 4039606 const auto ownScvIndex = ownScv.index();
78
79
2/2
✓ Branch 0 taken 1352598 times.
✓ Branch 1 taken 2687008 times.
4039606 if (scvf.isFrontal())
80 {
81
2/2
✓ Branch 0 taken 1337976 times.
✓ Branch 1 taken 14622 times.
1352598 if (!scvf.boundary()) // opposite dof
82
3/6
✓ Branch 1 taken 14144 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 14144 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 14144 times.
✗ Branch 8 not taken.
4013928 map_[ownScvIndex].push_back(scvf.outsideScvIdx());
83 else
84 {
85 // treat frontal faces on boundaries
86
5/5
✓ Branch 0 taken 1624 times.
✓ Branch 1 taken 59490 times.
✓ Branch 2 taken 14216 times.
✓ Branch 3 taken 59084 times.
✓ Branch 4 taken 14216 times.
75330 for (const auto& scv : scvs(fvGeometry))
87 {
88 60708 const auto otherDofIndex = scv.dofIndex();
89
2/2
✓ Branch 0 taken 46086 times.
✓ Branch 1 taken 14622 times.
60708 if (ownDofIndex != otherDofIndex)
90
2/4
✓ Branch 1 taken 1536 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1536 times.
✗ Branch 5 not taken.
92172 map_[scv.index()].push_back(ownScvIndex);
91 }
92 }
93 }
94 else // lateral face
95 {
96 // the parallel DOF scv
97 // outsideScv insideScv
98 // ###y######|s|#####x####
99 // |c|
100 // |v|
101 // |f|
102
2/2
✓ Branch 0 taken 2655544 times.
✓ Branch 1 taken 31464 times.
2687008 if (!scvf.boundary())
103
3/6
✓ Branch 1 taken 27264 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 27264 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 27264 times.
✗ Branch 8 not taken.
7966632 map_[ownScvIndex].push_back(scvf.outsideScvIdx());
104
105
106 // the normal DOF scv
107 //
108 // outsideScv
109 //
110 // |s|orthogonalScvf
111 // |c|
112 // |v| insideScv
113 // |f|
114 2687008 const auto& orthogonalScvf = fvGeometry.lateralOrthogonalScvf(scvf);
115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2687008 times.
2687008 assert(orthogonalScvf.isLateral());
116
3/6
✓ Branch 1 taken 28288 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 28288 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 28288 times.
✗ Branch 8 not taken.
8061024 map_[ownScvIndex].push_back(orthogonalScvf.insideScvIdx());
117
2/2
✓ Branch 0 taken 2655544 times.
✓ Branch 1 taken 31464 times.
2687008 if (!orthogonalScvf.boundary())
118
3/6
✓ Branch 1 taken 27264 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 27264 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 27264 times.
✗ Branch 8 not taken.
7966632 map_[ownScvIndex].push_back(orthogonalScvf.outsideScvIdx());
119 }
120 }
121 }
122
123 // make stencils unique
124
4/4
✓ Branch 0 taken 1338632 times.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 1338632 times.
✓ Branch 3 taken 62 times.
2677450 for (auto& stencil : map_)
125 {
126 4015896 std::sort(stencil.begin(), stencil.end());
127 6693160 stencil.erase(std::unique(stencil.begin(), stencil.end()), stencil.end());
128 }
129 62 }
130
131 const Stencil& operator[] (const GridIndexType globalI) const
132 18148656 { return map_[globalI]; }
133
134 private:
135 Map map_;
136 };
137
138 } // end namespace Dumux
139
140 #endif
141