GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/discretization/staggered/freeflow/connectivitymap.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 45 57 78.9%
Functions: 18 50 36.0%
Branches: 30 177 16.9%

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 StaggeredDiscretization
10 * \copydoc Dumux::StaggeredFreeFlowConnectivityMap
11 */
12 #ifndef DUMUX_STAGGERED_FREEFLOW_CONNECTIVITY_MAP_HH
13 #define DUMUX_STAGGERED_FREEFLOW_CONNECTIVITY_MAP_HH
14
15 #include <vector>
16 #include <dumux/common/indextraits.hh>
17
18 namespace Dumux {
19
20 /*!
21 * \ingroup StaggeredDiscretization
22 * \brief Stores the dof indices corresponding to the neighboring cell centers and faces
23 * that contribute to the derivative calculation. Specialization for the staggered free flow model.
24 */
25 template<class GridGeometry>
26
5/10
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 51 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 51 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 51 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 51 times.
255 class StaggeredFreeFlowConnectivityMap
27 {
28 using GridView = typename GridGeometry::GridView;
29 using FVElementGeometry = typename GridGeometry::LocalView;
30 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
31
32 using Element = typename GridView::template Codim<0>::Entity;
33 using GridIndexType = typename IndexTraits<GridView>::GridIndex;
34
35 using CellCenterIdxType = typename GridGeometry::DofTypeIndices::CellCenterIdx;
36 using FaceIdxType = typename GridGeometry::DofTypeIndices::FaceIdx;
37
38 using SmallLocalIndex = typename IndexTraits<GridView>::SmallLocalIndex;
39
40 using Stencil = std::vector<GridIndexType>;
41 using Map = std::vector<Stencil>;
42
43 static constexpr SmallLocalIndex upwindSchemeOrder = GridGeometry::upwindSchemeOrder;
44 static constexpr bool useHigherOrder = upwindSchemeOrder > 1;
45
46 public:
47
48 //! Update the map and prepare the stencils
49 51 void update(const GridGeometry& gridGeometry)
50 {
51 102 const auto numDofsCC = gridGeometry.gridView().size(0);
52 102 const auto numDofsFace = gridGeometry.gridView().size(1);
53 51 const auto numBoundaryFacets = gridGeometry.numBoundaryScvf();
54
55 // reinitialize maps
56 102 cellCenterToCellCenterMap_ = Map(numDofsCC);
57 102 cellCenterToFaceMap_ = Map(numDofsCC);
58 102 faceToCellCenterMap_ = Map(2*numDofsFace - numBoundaryFacets);
59
0/2
✗ Branch 5 not taken.
✗ Branch 6 not taken.
102 faceToFaceMap_ = Map(2*numDofsFace - numBoundaryFacets);
60
61 // restrict the FvGeometry locally
62
0/2
✗ Branch 1 not taken.
✗ Branch 2 not taken.
51 auto fvGeometry = localView(gridGeometry);
63
1/9
✗ Branch 1 not taken.
✓ Branch 2 taken 89568 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
179136 for(auto&& element: elements(gridGeometry.gridView()))
64 {
65 // bind the FvGeometry to the element
66
0/2
✗ Branch 1 not taken.
✗ Branch 2 not taken.
89517 fvGeometry.bindElement(element);
67
68 // loop over sub control faces
69
4/4
✓ Branch 0 taken 358318 times.
✓ Branch 1 taken 89517 times.
✓ Branch 2 taken 358318 times.
✓ Branch 3 taken 89517 times.
537352 for (auto&& scvf : scvfs(fvGeometry))
70 {
71 // handle the cell center dof stencils first
72 716636 const auto dofIdxCellCenter = gridGeometry.elementMapper().index(element);
73
74 // the stencil for cell center dofs w.r.t. to other cell center dofs,
75 // includes all neighboring element indices
76
2/2
✓ Branch 0 taken 352402 times.
✓ Branch 1 taken 5916 times.
358318 if (!scvf.boundary())
77
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.
1057206 cellCenterToCellCenterMap_[dofIdxCellCenter].push_back(scvf.outsideScvIdx());
78
79 // the stencil for cell center dofs w.r.t. face dofs, includes the face dof indices of the current element
80
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.
1074954 cellCenterToFaceMap_[dofIdxCellCenter].push_back(scvf.dofIndex());
81
82 // handle the face dof stencils
83 358318 const auto scvfIdx = scvf.index();
84
0/4
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
716636 computeFaceToCellCenterStencil_(faceToCellCenterMap_[scvfIdx], fvGeometry, scvf);
85
0/4
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
716636 computeFaceToFaceStencil_(faceToFaceMap_[scvfIdx], fvGeometry, scvf);
86 }
87 }
88 51 }
89
90 //! Returns the stencil of a cell center dof w.r.t. other cell center dofs
91 const Stencil& operator() (CellCenterIdxType, CellCenterIdxType, const GridIndexType globalI) const
92 {
93
0/96
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ 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 not taken.
✗ Branch 56 not taken.
✗ Branch 57 not taken.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
✗ Branch 64 not taken.
✗ Branch 65 not taken.
✗ Branch 66 not taken.
✗ Branch 67 not taken.
✗ Branch 68 not taken.
✗ Branch 69 not taken.
✗ Branch 70 not taken.
✗ Branch 71 not taken.
✗ Branch 72 not taken.
✗ Branch 73 not taken.
✗ Branch 74 not taken.
✗ Branch 75 not taken.
✗ Branch 76 not taken.
✗ Branch 77 not taken.
✗ Branch 78 not taken.
✗ Branch 79 not taken.
✗ Branch 80 not taken.
✗ Branch 81 not taken.
✗ Branch 82 not taken.
✗ Branch 83 not taken.
✗ Branch 84 not taken.
✗ Branch 85 not taken.
✗ Branch 86 not taken.
✗ Branch 87 not taken.
✗ Branch 88 not taken.
✗ Branch 89 not taken.
✗ Branch 90 not taken.
✗ Branch 91 not taken.
✗ Branch 92 not taken.
✗ Branch 93 not taken.
✗ Branch 94 not taken.
✗ Branch 95 not taken.
2889672 return cellCenterToCellCenterMap_[globalI];
94 }
95
96 //! Returns the stencil of a cell center dof w.r.t. face dofs
97 const Stencil& operator() (CellCenterIdxType, FaceIdxType, const GridIndexType globalI) const
98 {
99 178784 return cellCenterToFaceMap_[globalI];
100 }
101
102 //! Returns the stencil of a face dof w.r.t. cell center dofs
103 const Stencil& operator() (FaceIdxType, CellCenterIdxType, const GridIndexType globalI) const
104 {
105 10843552 return faceToCellCenterMap_[globalI];
106 }
107
108 //! Returns the stencil of a face dof w.r.t. other face dofs
109 const Stencil& operator() (FaceIdxType, FaceIdxType, const GridIndexType globalI) const
110 {
111
2/4
✓ Branch 1 taken 12502432 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 12502432 times.
✗ Branch 5 not taken.
36563552 return faceToFaceMap_[globalI];
112 }
113
114 private:
115
116 /*
117 * \brief Computes the stencil for face dofs w.r.t to cell center dofs.
118 * Basically, these are the dof indices of the elements adjacent to the face and those of
119 * the elements adjacent to the faces parallel to the own face.
120 */
121 358318 void computeFaceToCellCenterStencil_(Stencil& stencil,
122 const FVElementGeometry& fvGeometry,
123 const SubControlVolumeFace& scvf)
124 {
125 358318 const auto eIdx = scvf.insideScvIdx();
126 358318 stencil.push_back(eIdx);
127
128
2/2
✓ Branch 0 taken 718136 times.
✓ Branch 1 taken 358318 times.
2151408 for (const auto& data : scvf.pairData())
129 {
130
2/2
✓ Branch 0 taken 706004 times.
✓ Branch 1 taken 12132 times.
718136 auto& lateralFace = fvGeometry.scvf(eIdx, data.localLateralFaceIdx);
131
2/2
✓ Branch 0 taken 706004 times.
✓ Branch 1 taken 12132 times.
718136 if (!lateralFace.boundary())
132 {
133 706004 const auto firstParallelElementDofIdx = lateralFace.outsideScvIdx();
134 706004 stencil.push_back(firstParallelElementDofIdx);
135 }
136 }
137 358318 }
138
139 /*
140 * \brief Computes the stencil for face dofs w.r.t to face dofs.
141 * For a full description of the stencil, please see the document under dumux/doc/docextra/staggered
142 */
143 358318 void computeFaceToFaceStencil_(Stencil& stencil,
144 const FVElementGeometry& fvGeometry,
145 const SubControlVolumeFace& scvf)
146 {
147 358318 stencil.push_back(scvf.axisData().oppositeDof);
148 358318 addHigherOrderInAxisDofs_(scvf, stencil, std::integral_constant<bool, useHigherOrder>{});
149
150
2/2
✓ Branch 0 taken 718136 times.
✓ Branch 1 taken 358318 times.
2151408 for (const auto& data : scvf.pairData())
151 {
152 // add normal dofs
153 718136 stencil.push_back(data.lateralPair.first);
154
2/2
✓ Branch 0 taken 706004 times.
✓ Branch 1 taken 12132 times.
718136 if (!scvf.boundary())
155 706004 stencil.push_back(data.lateralPair.second);
156
157 // add parallel dofs
158
2/2
✓ Branch 0 taken 757136 times.
✓ Branch 1 taken 718136 times.
1475272 for (SmallLocalIndex i = 0; i < upwindSchemeOrder; i++)
159 {
160
4/4
✓ Branch 0 taken 84532 times.
✓ Branch 1 taken 672604 times.
✓ Branch 2 taken 84532 times.
✓ Branch 3 taken 672604 times.
1514272 if (data.hasParallelNeighbor[i])
161 1484408 stencil.push_back(data.parallelDofs[i]);
162 }
163 }
164 358318 }
165
166 void addHigherOrderInAxisDofs_(const SubControlVolumeFace& scvf, Stencil& stencil, std::false_type) {}
167
168 void addHigherOrderInAxisDofs_(const SubControlVolumeFace& scvf, Stencil& stencil, std::true_type)
169 {
170 for (SmallLocalIndex i = 0; i < upwindSchemeOrder - 1; i++)
171 {
172 if (scvf.hasBackwardNeighbor(i))
173 stencil.push_back(scvf.axisData().inAxisBackwardDofs[i]);
174
175 if (scvf.hasForwardNeighbor(i))
176 stencil.push_back(scvf.axisData().inAxisForwardDofs[i]);
177 }
178 }
179
180 Map cellCenterToCellCenterMap_;
181 Map cellCenterToFaceMap_;
182 Map faceToCellCenterMap_;
183 Map faceToFaceMap_;
184 };
185
186 } // end namespace Dumux
187
188 #endif
189