GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/dumux/discretization/cellcentered/connectivitymap.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 27 28 96.4%
Functions: 60 61 98.4%
Branches: 97 158 61.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 CCDiscretization
10 * \brief Stores the face indices corresponding to the neighbors of an element
11 * that contribute to the derivative calculation. This is used for
12 * finite-volume schemes with symmetric sparsity pattern in the global matrix.
13 */
14 #ifndef DUMUX_CC_CONNECTIVITY_MAP_HH
15 #define DUMUX_CC_CONNECTIVITY_MAP_HH
16
17 #include <vector>
18 #include <utility>
19 #include <algorithm>
20
21 #include <dune/common/exceptions.hh>
22 #include <dune/common/reservedvector.hh>
23
24 #include <dumux/common/indextraits.hh>
25 #include <dumux/discretization/fluxstencil.hh>
26
27 namespace Dumux {
28
29 /*!
30 * \ingroup CCDiscretization
31 * \brief A simple version of the connectivity map for cellcentered schemes.
32 * This implementation works for schemes in which for a given cell I only
33 * those cells J have to be prepared in whose stencil the cell I appears.
34 * This means that for the flux calculations in the cells J (in order to compute
35 * the derivatives with respect to cell I), we do not need data on any additional cells J
36 * to compute these fluxes. The same holds for scvfs in the cells J, i.e. we need only those
37 * scvfs in the cells J in which the cell I is in the stencil.
38 */
39 template<class GridGeometry>
40
4/11
✗ Branch 0 not taken.
✓ Branch 1 taken 380 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 86 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 7 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 5 not taken.
✗ Branch 8 not taken.
481 class CCSimpleConnectivityMap
41 {
42 using FVElementGeometry = typename GridGeometry::LocalView;
43 using GridView = typename GridGeometry::GridView;
44 using GridIndexType = typename IndexTraits<GridView>::GridIndex;
45 using FluxStencil = Dumux::FluxStencil<FVElementGeometry>;
46 static constexpr int maxElemStencilSize = GridGeometry::maxElementStencilSize;
47
48 4127550 struct DataJ
49 {
50 GridIndexType globalJ;
51 typename FluxStencil::ScvfStencilIForJ scvfsJ;
52 // A list of additional scvfs is needed for compatibility
53 // reasons with more complex connectivity maps (see mpfa)
54 typename FluxStencil::ScvfStencilIForJ additionalScvfs;
55 };
56
57 using Map = std::vector<std::vector<DataJ>>;
58
59 public:
60
61 /*!
62 * \brief Initialize the ConnectivityMap object.
63 *
64 * \param gridGeometry The grid's finite volume geometry.
65 */
66 684 void update(const GridGeometry& gridGeometry)
67 {
68
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 481 times.
684 map_.clear();
69 684 map_.resize(gridGeometry.gridView().size(0));
70
71 // container to store for each element J the elements I which have J in their flux stencil
72
2/3
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 47 times.
✗ Branch 3 not taken.
684 Dune::ReservedVector<std::pair<GridIndexType, DataJ>, maxElemStencilSize> dataJForI;
73 684 auto fvGeometry = localView(gridGeometry);
74
13/15
✓ Branch 2 taken 1619723 times.
✓ Branch 3 taken 70620 times.
✓ Branch 1 taken 274 times.
✓ Branch 4 taken 385709 times.
✓ Branch 5 taken 7 times.
✓ Branch 7 taken 131810 times.
✓ Branch 8 taken 5 times.
✓ Branch 10 taken 233809 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 233809 times.
✓ Branch 13 taken 85 times.
✓ Branch 16 taken 14 times.
✗ Branch 17 not taken.
✓ Branch 6 taken 155342 times.
✓ Branch 9 taken 2176 times.
11119398 for (const auto& element : elements(gridGeometry.gridView()))
75 {
76 // We are looking for the elements I, for which this element J is in the flux stencil
77
4/6
✓ Branch 1 taken 259463 times.
✓ Branch 2 taken 370243 times.
✓ Branch 4 taken 215926 times.
✗ Branch 5 not taken.
✗ Branch 3 not taken.
✓ Branch 0 taken 1734 times.
3868028 const auto globalJ = gridGeometry.elementMapper().index(element);
78
1/2
✓ Branch 1 taken 41520 times.
✗ Branch 2 not taken.
3868028 fvGeometry.bindElement(element);
79
80 // obtain the data of J in elements I
81 3868028 dataJForI.clear();
82
83 // loop over sub control faces
84
3/3
✓ Branch 1 taken 2424735 times.
✓ Branch 2 taken 29264 times.
✓ Branch 0 taken 11534001 times.
23460951 for (auto&& scvf : scvfs(fvGeometry))
85 {
86
1/2
✓ Branch 1 taken 84010 times.
✗ Branch 2 not taken.
19592923 const auto& stencil = FluxStencil::stencil(element, fvGeometry, scvf);
87
88 // insert our index in the neighbor stencils of the elements in the flux stencil
89
2/2
✓ Branch 0 taken 24500457 times.
✓ Branch 1 taken 11617411 times.
60500444 for (auto globalI : stencil)
90 {
91
2/2
✓ Branch 0 taken 11617411 times.
✓ Branch 1 taken 12883046 times.
40907521 if (globalI == globalJ)
92 19592923 continue;
93
94
2/2
✓ Branch 0 taken 1416818 times.
✓ Branch 1 taken 11466228 times.
21314598 auto it = std::find_if(dataJForI.begin(), dataJForI.end(),
95
43/56
✓ Branch 0 taken 169833 times.
✓ Branch 1 taken 1284142 times.
✓ Branch 2 taken 183228 times.
✓ Branch 3 taken 1100914 times.
✓ Branch 4 taken 208964 times.
✓ Branch 5 taken 891950 times.
✓ Branch 6 taken 134238 times.
✓ Branch 7 taken 757712 times.
✓ Branch 8 taken 1143665 times.
✓ Branch 9 taken 24416 times.
✓ Branch 10 taken 2337152 times.
✓ Branch 11 taken 24283 times.
✓ Branch 12 taken 89122 times.
✓ Branch 13 taken 3532080 times.
✓ Branch 14 taken 91252 times.
✓ Branch 15 taken 2394268 times.
✓ Branch 16 taken 98590 times.
✓ Branch 17 taken 2295678 times.
✓ Branch 18 taken 110583 times.
✓ Branch 19 taken 2185095 times.
✓ Branch 20 taken 60615 times.
✓ Branch 21 taken 2124480 times.
✓ Branch 22 taken 1233115 times.
✓ Branch 23 taken 22925 times.
✓ Branch 24 taken 2429016 times.
✓ Branch 25 taken 7440 times.
✓ Branch 26 taken 38993 times.
✓ Branch 27 taken 4428266 times.
✓ Branch 28 taken 37671 times.
✓ Branch 29 taken 1323831 times.
✓ Branch 30 taken 36997 times.
✓ Branch 31 taken 1286834 times.
✓ Branch 32 taken 37202 times.
✓ Branch 33 taken 1249632 times.
✓ Branch 34 taken 36356 times.
✓ Branch 35 taken 1213276 times.
✓ Branch 36 taken 21476 times.
✓ Branch 37 taken 684 times.
✓ Branch 38 taken 44280 times.
✓ Branch 39 taken 1434 times.
✓ Branch 40 taken 1992 times.
✓ Branch 41 taken 66087 times.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 49 not taken.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 54 not taken.
✓ Branch 55 taken 8 times.
20747431 [globalI](const auto& pair) { return pair.first == globalI; });
96
97
2/2
✓ Branch 0 taken 1416818 times.
✓ Branch 1 taken 11466228 times.
21314598 if (it != dataJForI.end())
98
1/2
✓ Branch 1 taken 1416818 times.
✗ Branch 2 not taken.
1999552 it->second.scvfsJ.push_back(scvf.index());
99 else
100 {
101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11466228 times.
19315046 if (dataJForI.size() > maxElemStencilSize - 1)
102 DUNE_THROW(Dune::InvalidStateException, "Maximum admissible stencil size (" << maxElemStencilSize-1
103 << ") is surpassed (" << dataJForI.size() << "). "
104 << "Please adjust the GridGeometry traits accordingly!");
105
106
1/2
✓ Branch 1 taken 709326 times.
✗ Branch 2 not taken.
21079310 dataJForI.push_back(std::make_pair(globalI, DataJ({globalJ, {scvf.index()}, {}})));
107 }
108 }
109 }
110
111
2/2
✓ Branch 0 taken 11466228 times.
✓ Branch 1 taken 2370589 times.
23183074 for (auto&& pair : dataJForI)
112
1/2
✓ Branch 1 taken 3345744 times.
✗ Branch 2 not taken.
19315046 map_[pair.first].emplace_back(std::move(pair.second));
113 }
114 686 }
115
116 497660831 const std::vector<DataJ>& operator[] (const GridIndexType globalI) const
117
10/10
✓ Branch 0 taken 4132052 times.
✓ Branch 1 taken 10147861 times.
✓ Branch 2 taken 63487777 times.
✓ Branch 3 taken 11468891 times.
✓ Branch 4 taken 4147826 times.
✓ Branch 6 taken 1463128 times.
✓ Branch 7 taken 122602 times.
✓ Branch 5 taken 4424152 times.
✓ Branch 8 taken 20892 times.
✓ Branch 9 taken 5781 times.
497664287 { return map_[globalI]; }
118
119 private:
120 Map map_;
121 };
122
123 } // end namespace Dumux
124
125 #endif
126