GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/discretization/cellcentered/mpfa/omethod/interactionvolumeindexset.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 47 54 87.0%
Functions: 18 52 34.6%
Branches: 59 108 54.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 CCMpfaDiscretization
10 * \brief Class for the index set within an interaction volume of the mpfa-o scheme.
11 */
12 #ifndef DUMUX_DISCRETIZATION_MPFA_O_INTERACTIONVOLUME_INDEXSET_HH
13 #define DUMUX_DISCRETIZATION_MPFA_O_INTERACTIONVOLUME_INDEXSET_HH
14
15 #include <dune/common/reservedvector.hh>
16
17 #include <dumux/discretization/cellcentered/mpfa/dualgridindexset.hh>
18
19 namespace Dumux {
20
21 /*!
22 * \ingroup CCMpfaDiscretization
23 * \brief The interaction volume index set class for the mpfa-o scheme.
24 *
25 * \tparam DualGridNodalIndexSet The type used for the nodal index set in the dual grid.
26 */
27 template< class DualGridNodalIndexSet >
28 class CCMpfaOInteractionVolumeIndexSet
29 {
30 public:
31 //! Export the type used for the nodal grid index sets
32 using NodalIndexSet = DualGridNodalIndexSet;
33
34 //! Export the types used for local/grid indices
35 using LocalIndexType = typename DualGridNodalIndexSet::LocalIndexType;
36 using GridIndexType = typename DualGridNodalIndexSet::GridIndexType;
37
38 //! Export the stencil types used
39 using NodalGridStencilType = typename DualGridNodalIndexSet::NodalGridStencilType;
40 using NodalLocalStencilType = typename DualGridNodalIndexSet::NodalLocalStencilType;
41 using NodalGridScvfStencilType = typename DualGridNodalIndexSet::NodalGridScvfStencilType;
42
43 //! Export the type used for the neighbor scv index sets of the scvfs
44 using ScvfNeighborLocalIndexSet = typename DualGridNodalIndexSet::ScvfNeighborLocalIndexSet;
45
46 //! The constructor
47 template< class FlipScvfIndexSet >
48 79024 CCMpfaOInteractionVolumeIndexSet(const NodalIndexSet& nodalIndexSet, const FlipScvfIndexSet& flipScvfIndexSet)
49
3/10
✓ Branch 1 taken 79024 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 79024 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 79024 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
237072 : nodalIndexSet_(nodalIndexSet)
50 {
51
1/2
✓ Branch 1 taken 79024 times.
✗ Branch 2 not taken.
79024 const auto numNodalScvfs = nodalIndexSet.numScvfs();
52
53 // kee track of which nodal scvfs have been handled already
54
1/2
✓ Branch 1 taken 79024 times.
✗ Branch 2 not taken.
79024 nodeToIvScvf_.resize(numNodalScvfs);
55
2/6
✓ Branch 1 taken 79024 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 79024 times.
✗ Branch 5 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
237072 std::vector<bool> isHandled(numNodalScvfs, false);
56
57 // go over faces in nodal index set, check if iv-local face has been
58 // inserted already for this scvf and if not, insert index mapping
59 79024 numFaces_ = 0;
60
2/2
✓ Branch 0 taken 630616 times.
✓ Branch 1 taken 79024 times.
709640 for (LocalIndexType i = 0; i < numNodalScvfs; ++i)
61 {
62 // check if the nodal scvf still has to be handled
63
6/6
✓ Branch 0 taken 323350 times.
✓ Branch 1 taken 307266 times.
✓ Branch 2 taken 323350 times.
✓ Branch 3 taken 307266 times.
✓ Branch 4 taken 323350 times.
✓ Branch 5 taken 307266 times.
1891848 if (isHandled[i])
64 323638 continue;
65
66 // for scvfs touching the boundary there are no "outside" scvfs
67
2/2
✓ Branch 1 taken 16372 times.
✓ Branch 2 taken 306978 times.
323350 if (nodalIndexSet.scvfIsOnBoundary(i))
68 {
69
6/13
✓ Branch 2 taken 2796 times.
✓ Branch 3 taken 13576 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2796 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 2796 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 2796 times.
✓ Branch 13 taken 2796 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
16372 scvfNeighborScvLocalIndices_.push_back({nodalIndexSet.insideScvLocalIndex(i)});
70
2/4
✓ Branch 1 taken 16372 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 16372 times.
✗ Branch 5 not taken.
32744 nodeToIvScvf_[i] = ivToNodeScvf_.size();
71
2/4
✓ Branch 1 taken 16372 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 16372 times.
✗ Branch 5 not taken.
32744 isHandled[i] = true;
72
1/2
✓ Branch 1 taken 16372 times.
✗ Branch 2 not taken.
16372 ivToNodeScvf_.push_back(i);
73 16372 numFaces_++;
74 16372 continue;
75 }
76
77 // insert a new iv-local face
78 306978 const auto curIvLocalScvfIdx = ivToNodeScvf_.size();
79 306978 nodeToIvScvf_[i] = curIvLocalScvfIdx;
80 613956 isHandled[i] = true;
81
82 // construct local index sets
83
1/2
✓ Branch 2 taken 53832 times.
✗ Branch 3 not taken.
306978 const auto& flipScvfIndices = flipScvfIndexSet[nodalIndexSet.gridScvfIndex(i)];
84
1/2
✓ Branch 1 taken 53832 times.
✗ Branch 2 not taken.
306978 const auto numFlipIndices = flipScvfIndices.size();
85
86
2/5
✓ Branch 0 taken 253146 times.
✓ Branch 1 taken 306978 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
613956 ScvfNeighborLocalIndexSet neighborsLocal;
87
1/2
✓ Branch 1 taken 53832 times.
✗ Branch 2 not taken.
306978 neighborsLocal.resize(numFlipIndices + 1);
88 306978 neighborsLocal[0] = nodalIndexSet.insideScvLocalIndex(i);
89
90 // mappings for all flip scvf
91
2/2
✓ Branch 0 taken 307266 times.
✓ Branch 1 taken 306978 times.
614244 for (unsigned int j = 0; j < numFlipIndices; ++j)
92 {
93 307266 const auto outsideScvfIdx = flipScvfIndices[j];
94
2/4
✓ Branch 0 taken 2044908 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2044908 times.
✗ Branch 3 not taken.
2044908 for (unsigned int nodeLocalIdx = 0; nodeLocalIdx < nodalIndexSet.numScvfs(); ++nodeLocalIdx)
95 {
96
2/2
✓ Branch 1 taken 307266 times.
✓ Branch 2 taken 1737642 times.
2044908 if (nodalIndexSet.gridScvfIndex(nodeLocalIdx) == outsideScvfIdx)
97 {
98 307266 neighborsLocal[j+1] = nodalIndexSet.insideScvLocalIndex(nodeLocalIdx);
99 307266 nodeToIvScvf_[nodeLocalIdx] = curIvLocalScvfIdx;
100 614532 isHandled[nodeLocalIdx] = true;
101 307266 break; // go to next outside scvf
102 }
103 }
104 }
105
106
1/2
✓ Branch 1 taken 306978 times.
✗ Branch 2 not taken.
306978 scvfNeighborScvLocalIndices_.push_back(neighborsLocal);
107
1/2
✓ Branch 1 taken 306978 times.
✗ Branch 2 not taken.
306978 ivToNodeScvf_.push_back(i);
108
1/2
✓ Branch 0 taken 53832 times.
✗ Branch 1 not taken.
306978 numFaces_++;
109 }
110 79024 }
111
112 //! returns the corresponding nodal index set
113 const NodalIndexSet& nodalIndexSet() const
114 { return nodalIndexSet_; }
115
116 //! returns the global scv indices connected to this dual grid node
117 const NodalGridStencilType& gridScvIndices() const
118 1265728 { return nodalIndexSet_.gridScvIndices(); }
119
120 //! returns the global scvf indices embedded in this interaction volume
121 const NodalGridScvfStencilType& gridScvfIndices() const
122
4/4
✓ Branch 0 taken 6370842 times.
✓ Branch 1 taken 59820846 times.
✓ Branch 2 taken 6370842 times.
✓ Branch 3 taken 59820846 times.
132387872 { return nodalIndexSet_.gridScvfIndices(); }
123
124 //! returns the number of faces in the interaction volume
125 std::size_t numFaces() const
126 { return numFaces_; }
127
128 //! returns the number of scvs in the interaction volume
129 std::size_t numScvs() const
130
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8491366 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8491366 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 34944 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 34944 times.
17052620 { return nodalIndexSet_.numScvs(); }
131
132 //! returns a grid scv idx for a given iv-local scv index
133 GridIndexType gridScvIndex(LocalIndexType ivLocalScvIdx) const
134 {
135 assert(ivLocalScvIdx < numScvs());
136 return gridScvIndices()[ivLocalScvIdx];
137 }
138
139 //! returns a grid scvf idx for a given iv-local scvf index
140 60814881 GridIndexType gridScvfIndex(LocalIndexType ivLocalScvfIdx) const
141 {
142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60814881 times.
60814881 assert(ivLocalScvfIdx < numFaces());
143 121629762 return nodalIndexSet_.gridScvfIndex( ivToNodeScvf_[ivLocalScvfIdx] );
144 }
145
146 //! returns the iv-local scvf idx of the i-th scvf embedded in a local scv
147 822915022 LocalIndexType localScvfIndex(LocalIndexType scvIdxLocal, unsigned int i) const
148 {
149
2/4
✗ Branch 1 not taken.
✓ Branch 2 taken 822915022 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 822915022 times.
822915022 assert(nodalIndexSet_.localScvfIndex(scvIdxLocal, i) < nodeToIvScvf_.size());
150 1645830044 return nodeToIvScvf_[ nodalIndexSet_.localScvfIndex(scvIdxLocal, i) ];
151 }
152
153 //! returns the local indices of the neighboring scvs of an scvf
154 const ScvfNeighborLocalIndexSet& neighboringLocalScvIndices(LocalIndexType ivLocalScvfIdx) const
155 {
156
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 39019258 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 178216 times.
39197474 assert(ivLocalScvfIdx < numFaces());
157
4/8
✓ Branch 1 taken 21470743 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 21470743 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 146664 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 146664 times.
✗ Branch 11 not taken.
78394948 return scvfNeighborScvLocalIndices_[ivLocalScvfIdx];
158 }
159
160 private:
161 using NI = NodalIndexSet;
162
163 std::size_t numFaces_;
164 const NI& nodalIndexSet_;
165 // Index maps from and to nodal index set. For the map to the
166 // nodal set we use the same storage type as we know the nodal
167 // has more faces, thus sufficient guaranteed here!
168 typename NI::Traits::template NodalScvfDataStorage< LocalIndexType > ivToNodeScvf_;
169 typename NI::Traits::template NodalScvfDataStorage< LocalIndexType > nodeToIvScvf_;
170 // maps to each scvf a list of neighbouring scv indices
171 // ordering: 0 - inside scv idx; 1..n - outside scv indices
172 typename NI::Traits::template NodalScvfDataStorage< ScvfNeighborLocalIndexSet > scvfNeighborScvLocalIndices_;
173 };
174
175 } // end namespace Dumux
176
177 #endif
178