GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/dumux/discretization/cellcentered/mpfa/omethod/interactionvolumeindexset.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 55 56 98.2%
Functions: 18 18 100.0%
Branches: 54 77 70.1%

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 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
1/2
✓ Branch 1 taken 79024 times.
✗ Branch 2 not taken.
79024 : nodalIndexSet_(nodalIndexSet)
50 {
51 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
1/2
✓ Branch 1 taken 79024 times.
✗ Branch 2 not taken.
79024 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
2/2
✓ Branch 0 taken 307266 times.
✓ Branch 1 taken 323350 times.
630616 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
3/5
✓ Branch 2 taken 2796 times.
✓ Branch 3 taken 13576 times.
✓ Branch 6 taken 2796 times.
✗ Branch 7 not taken.
✗ Branch 4 not taken.
19168 scvfNeighborScvLocalIndices_.push_back({nodalIndexSet.insideScvLocalIndex(i)});
70
1/2
✓ Branch 1 taken 16372 times.
✗ Branch 2 not taken.
16372 nodeToIvScvf_[i] = ivToNodeScvf_.size();
71
1/2
✓ Branch 1 taken 16372 times.
✗ Branch 2 not taken.
16372 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 306978 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 306978 const auto numFlipIndices = flipScvfIndices.size();
85
86
2/2
✓ Branch 0 taken 253146 times.
✓ Branch 1 taken 253146 times.
560124 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
1/2
✓ Branch 0 taken 2044908 times.
✗ Branch 1 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 307266 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 306978 numFaces_++;
109 }
110 79024 }
111
112 //! returns the corresponding nodal index set
113 990870054 const NodalIndexSet& nodalIndexSet() const
114
10/11
✓ Branch 0 taken 522040756 times.
✓ Branch 1 taken 16949706 times.
✓ Branch 2 taken 24548778 times.
✓ Branch 3 taken 16302510 times.
✓ Branch 4 taken 111062338 times.
✓ Branch 5 taken 46516870 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1367347 times.
✓ Branch 10 taken 31091712 times.
✓ Branch 11 taken 1899784 times.
✓ Branch 6 taken 572794 times.
990870054 { return nodalIndexSet_; }
115
116 //! returns the global scv indices connected to this dual grid node
117 632864 const NodalGridStencilType& gridScvIndices() const
118 632864 { return nodalIndexSet_.gridScvIndices(); }
119
120 //! returns the global scvf indices embedded in this interaction volume
121 66233368 const NodalGridScvfStencilType& gridScvfIndices() const
122
2/2
✓ Branch 0 taken 6410274 times.
✓ Branch 1 taken 59820846 times.
66233368 { return nodalIndexSet_.gridScvfIndices(); }
123
124 //! returns the number of faces in the interaction volume
125 163277814 std::size_t numFaces() const
126
8/9
✓ Branch 1 taken 26751660 times.
✓ Branch 2 taken 3997952 times.
✓ Branch 3 taken 22111823 times.
✓ Branch 4 taken 3997952 times.
✓ Branch 6 taken 146664 times.
✓ Branch 7 taken 24336 times.
✓ Branch 8 taken 146664 times.
✓ Branch 9 taken 24336 times.
✗ Branch 0 not taken.
61223675 { return numFaces_; }
127
128 //! returns the number of scvs in the interaction volume
129 8709390 std::size_t numScvs() const
130
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8674446 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34944 times.
8709390 { 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 62156313 GridIndexType gridScvfIndex(LocalIndexType ivLocalScvfIdx) const
141 {
142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62156313 times.
62156313 assert(ivLocalScvfIdx < numFaces());
143 62156313 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 824807758 LocalIndexType localScvfIndex(LocalIndexType scvIdxLocal, unsigned int i) const
148 {
149
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 824807758 times.
824807758 assert(nodalIndexSet_.localScvfIndex(scvIdxLocal, i) < nodeToIvScvf_.size());
150 824807758 return nodeToIvScvf_[ nodalIndexSet_.localScvfIndex(scvIdxLocal, i) ];
151 }
152
153 //! returns the local indices of the neighboring scvs of an scvf
154 39897826 const ScvfNeighborLocalIndexSet& neighboringLocalScvIndices(LocalIndexType ivLocalScvfIdx) const
155 {
156
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 39719610 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 178216 times.
39897826 assert(ivLocalScvfIdx < numFaces());
157
2/4
✓ Branch 1 taken 22111823 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 146664 times.
✗ Branch 5 not taken.
39897826 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