GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/discretization/cellcentered/connectivitymap.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 24 26 92.3%
Functions: 58 99 58.6%
Branches: 85 147 57.8%

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 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
9/16
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 36 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 8 times.
✓ Branch 9 taken 13 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 4 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
880 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 7155183 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 638 void update(const GridGeometry& gridGeometry)
67 {
68
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 48 times.
638 map_.clear();
69 1282 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 652 Dune::ReservedVector<std::pair<GridIndexType, DataJ>, maxElemStencilSize> dataJForI;
73
1/4
✓ Branch 1 taken 248 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
737 auto fvGeometry = localView(gridGeometry);
74
18/21
✓ Branch 1 taken 248 times.
✓ Branch 2 taken 1636063 times.
✓ Branch 3 taken 104 times.
✓ Branch 4 taken 141483 times.
✓ Branch 5 taken 110 times.
✓ Branch 6 taken 312145 times.
✓ Branch 7 taken 2117 times.
✓ Branch 8 taken 20661 times.
✓ Branch 9 taken 23 times.
✓ Branch 10 taken 77 times.
✓ Branch 11 taken 22837 times.
✓ Branch 12 taken 233009 times.
✓ Branch 13 taken 77 times.
✓ Branch 14 taken 253670 times.
✓ Branch 15 taken 77 times.
✓ Branch 17 taken 233009 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 233009 times.
✗ Branch 21 not taken.
✓ Branch 25 taken 14 times.
✗ Branch 26 not taken.
6546096 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
5/6
✓ Branch 0 taken 1734 times.
✓ Branch 1 taken 257863 times.
✓ Branch 2 taken 1734 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 257862 times.
✗ Branch 5 not taken.
7028716 const auto globalJ = gridGeometry.elementMapper().index(element);
78
2/3
✓ Branch 0 taken 1734 times.
✓ Branch 1 taken 574206 times.
✗ Branch 2 not taken.
3514358 fvGeometry.bindElement(element);
79
80 // obtain the data of J in elements I
81 3514358 dataJForI.clear();
82
83 // loop over sub control faces
84
4/4
✓ Branch 0 taken 10848199 times.
✓ Branch 1 taken 2179229 times.
✓ Branch 2 taken 10848199 times.
✓ Branch 3 taken 2179229 times.
25342637 for (auto&& scvf : scvfs(fvGeometry))
85 {
86
2/6
✓ Branch 1 taken 84010 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 41364 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
18453371 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
4/4
✓ Branch 0 taken 23001379 times.
✓ Branch 1 taken 10848199 times.
✓ Branch 2 taken 2924748 times.
✓ Branch 3 taken 714626 times.
92666856 for (auto globalI : stencil)
90 {
91
2/2
✓ Branch 0 taken 12153180 times.
✓ Branch 1 taken 10848199 times.
38143443 if (globalI == globalJ)
92 continue;
93
94
6/6
✓ Branch 0 taken 1416818 times.
✓ Branch 1 taken 10736362 times.
✓ Branch 2 taken 1416818 times.
✓ Branch 3 taken 10736362 times.
✓ Branch 4 taken 1416818 times.
✓ Branch 5 taken 10736362 times.
59906916 auto it = std::find_if(dataJForI.begin(), dataJForI.end(),
95 [globalI](const auto& pair) { return pair.first == globalI; });
96
97
4/4
✓ Branch 0 taken 1416818 times.
✓ Branch 1 taken 10736362 times.
✓ Branch 2 taken 1416818 times.
✓ Branch 3 taken 10736362 times.
39937944 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 10736362 times.
17969420 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
2/6
✓ Branch 1 taken 709326 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 709326 times.
✗ Branch 5 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
18951184 dataJForI.push_back(std::make_pair(globalI, DataJ({globalJ, {scvf.index()}, {}})));
107 }
108 }
109 }
110
111
2/2
✓ Branch 0 taken 10736362 times.
✓ Branch 1 taken 2179229 times.
28512494 for (auto&& pair : dataJForI)
112
2/4
✓ Branch 1 taken 2671786 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2671786 times.
✗ Branch 5 not taken.
35938840 map_[pair.first].emplace_back(std::move(pair.second));
113 }
114 638 }
115
116 const std::vector<DataJ>& operator[] (const GridIndexType globalI) const
117
18/18
✓ Branch 0 taken 11359180 times.
✓ Branch 1 taken 3667751 times.
✓ Branch 2 taken 15371250 times.
✓ Branch 3 taken 4698272 times.
✓ Branch 4 taken 5680774 times.
✓ Branch 5 taken 1339560 times.
✓ Branch 6 taken 59234078 times.
✓ Branch 7 taken 10517063 times.
✓ Branch 8 taken 61179716 times.
✓ Branch 9 taken 10743996 times.
✓ Branch 10 taken 5478776 times.
✓ Branch 11 taken 1017870 times.
✓ Branch 12 taken 1864434 times.
✓ Branch 13 taken 481898 times.
✓ Branch 16 taken 20892 times.
✓ Branch 17 taken 5781 times.
✓ Branch 18 taken 20892 times.
✓ Branch 19 taken 5781 times.
983497800 { return map_[globalI]; }
118
119 private:
120 Map map_;
121 };
122
123 } // end namespace Dumux
124
125 #endif
126