GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/multidomain/dualnetwork/couplingmapper.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 146 157 93.0%
Functions: 5 10 50.0%
Branches: 297 544 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 DualNetworkCoupling
10 * \ingroup PoreNetworkModels
11 * \copydoc Dumux::PoreNetwork::DualNetworkCouplingMapper
12 */
13
14 #ifndef DUMUX_DUAL_NETWORK_COUPLINGMAPPER_HH
15 #define DUMUX_DUAL_NETWORK_COUPLINGMAPPER_HH
16
17 #include <type_traits>
18 #include <unordered_map>
19 #include <algorithm>
20 #include <vector>
21 #include <iostream>
22 #include <cassert>
23
24 #include <dune/common/iteratorrange.hh>
25 #include <dune/common/iteratorfacades.hh>
26
27 #include <dune/common/exceptions.hh>
28 #include <dumux/common/entitymap.hh>
29
30 namespace Dumux::PoreNetwork {
31
32 /*!
33 * \ingroup DualNetworkCoupling
34 * \ingroup PoreNetworkModels
35 * \brief Coupling mapper for Stokes and Darcy domains with equal dimension.
36 */
37
38 template<class Scalar>
39 class DualNetworkCouplingMapper
40 {
41
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3594 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3594 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3594 times.
10782 struct HostGridConnectionInfo
42 {
43 std::size_t hostGridElementIndex;
44 std::size_t voidVertexHostIdx;
45 std::size_t solidVertexHostIdx;
46 Scalar connectionArea;
47 Scalar connectionLength;
48 std::vector<std::size_t> voidElementHostIdx;
49 std::vector<std::size_t> solidElementHostIdx;
50 std::vector<std::size_t> coupledVoidVertexHostIdx;
51 std::vector<std::size_t> coupledSolidVertexHostIdx;
52 std::size_t connectionGlobalId;
53 };
54
55
2/8
✗ 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 taken 3415 times.
✓ Branch 7 taken 179 times.
14197 struct SubGridConnectionInfo
56 {
57 std::size_t id; // the global id of the connections
58 std::size_t solidVertexIdx; // the directly coupled solid vertex
59 std::size_t voidVertexIdx; // the directly coupled void vertex
60 std::size_t someSolidElementIdx; // index of one the solid elements adjacent to the solid vertex
61 std::size_t someVoidElementIdx; // index of one the void elements adjacent to the solid vertex
62 std::vector<std::size_t> convectionVoidElementIdx; // all void elements adjacent to the own void vertex coupled to the same solid vertex
63 Scalar connectionArea;
64 Scalar connectionLength;
65 };
66
67 template<class Vector>
68 class ConnectionIterator : public Dune::ForwardIteratorFacade<ConnectionIterator<Vector>, const SubGridConnectionInfo>
69 {
70 using ThisType = ConnectionIterator<Vector>;
71 using Iterator = typename Vector::const_iterator;
72 public:
73 ConnectionIterator(const Iterator& it, const std::vector<SubGridConnectionInfo>& info)
74 : it_(it), InfoPtr_(&info) {}
75
76 ConnectionIterator() : it_(Iterator()), InfoPtr_(nullptr) {}
77
78 //! dereferencing yields a subcontrol volume
79 191017059 const SubGridConnectionInfo& dereference() const
80
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 191017059 times.
191017059 { return InfoPtr_->at(*it_); }
81 // { return (*InfoPtr_)[*it_]; }
82
83 bool equals(const ThisType& other) const
84
42/52
✗ 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 taken 338742 times.
✓ Branch 9 taken 39258 times.
✓ Branch 10 taken 338742 times.
✓ Branch 11 taken 39258 times.
✓ Branch 12 taken 338742 times.
✓ Branch 13 taken 39258 times.
✓ Branch 14 taken 338742 times.
✓ Branch 15 taken 39258 times.
✓ Branch 16 taken 182830 times.
✓ Branch 17 taken 20140 times.
✓ Branch 18 taken 182830 times.
✓ Branch 19 taken 20140 times.
✓ Branch 20 taken 182830 times.
✓ Branch 21 taken 20140 times.
✓ Branch 22 taken 182830 times.
✓ Branch 23 taken 20140 times.
✓ Branch 24 taken 177395633 times.
✗ Branch 25 not taken.
✓ Branch 26 taken 177395633 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 8280803 times.
✓ Branch 29 taken 815961 times.
✓ Branch 30 taken 8280803 times.
✓ Branch 31 taken 815961 times.
✓ Branch 32 taken 75276 times.
✓ Branch 33 taken 8724 times.
✓ Branch 34 taken 75276 times.
✓ Branch 35 taken 8724 times.
✓ Branch 36 taken 4651288 times.
✓ Branch 37 taken 431017 times.
✓ Branch 38 taken 4651288 times.
✓ Branch 39 taken 431017 times.
✓ Branch 40 taken 36566 times.
✓ Branch 41 taken 4028 times.
✓ Branch 42 taken 36566 times.
✓ Branch 43 taken 4028 times.
✓ Branch 44 taken 37638 times.
✓ Branch 45 taken 4362 times.
✓ Branch 46 taken 37638 times.
✓ Branch 47 taken 4362 times.
✓ Branch 48 taken 18283 times.
✓ Branch 49 taken 2014 times.
✓ Branch 50 taken 18283 times.
✓ Branch 51 taken 2014 times.
385847066 { return it_ == other.it_; }
85
86 void increment()
87 319179914 { ++it_; }
88
89 private:
90 Iterator it_;
91 const std::vector<SubGridConnectionInfo>* InfoPtr_;
92 };
93
94 public:
95 using Stencil = std::vector<std::size_t>;
96
97 template<class HostGridView, class HostGridData, class VoidGridGeometry, class SolidGridGeometry>
98 1 DualNetworkCouplingMapper(const HostGridView& hostGridView,
99 const HostGridData& hostGridData,
100 const VoidGridGeometry& voidGridGeometry,
101 const SolidGridGeometry& solidGridGeometry)
102 12 {
103
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 fillVertexMap_(hostGridView, voidGridGeometry, voidHostToSubVertexIdxMap_);
104
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 fillVertexMap_(hostGridView, solidGridGeometry, solidHostToSubVertexIdxMap_);
105
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 fillElementMap_(hostGridView, voidGridGeometry, voidHostToSubElementIdxMap_);
106
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 fillElementMap_(hostGridView, solidGridGeometry, solidHostToSubElementIdxMap_);
107
108
1/2
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
2 isCoupledVoidDof_.resize(voidGridGeometry.gridView().size(1), false);
109
1/2
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
2 isCoupledSolidDof_.resize(solidGridGeometry.gridView().size(1), false);
110
111
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 const auto connectionInfo = getConnectionInfo_(hostGridView, hostGridData);
112
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 connectionInfo_.resize(connectionInfo.size());
113
4/4
✓ Branch 0 taken 3594 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 3594 times.
✓ Branch 3 taken 1 times.
7191 for (const auto& info : connectionInfo)
114 {
115 3594 auto voidHostToSubVertexIdx = [&](const auto hostIdx)
116 { return voidHostToSubVertexIdxMap_.at(hostIdx); };
117
118 3594 auto solidHostToSubVertexIdx = [&](const auto hostIdx)
119 { return solidHostToSubVertexIdxMap_.at(hostIdx); };
120
121
1/2
✓ Branch 1 taken 3594 times.
✗ Branch 2 not taken.
3594 const auto directlyCoupledVoidDofIdx = voidHostToSubVertexIdx(info.voidVertexHostIdx);
122
1/2
✓ Branch 1 taken 3594 times.
✗ Branch 2 not taken.
3594 const auto directlyCoupledSolidDofIdx = solidHostToSubVertexIdx(info.solidVertexHostIdx);
123
124
1/4
✓ Branch 1 taken 3594 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
7188 auto coupledVoidElementIdxSub = info.voidElementHostIdx;
125
2/6
✓ Branch 1 taken 3594 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3594 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
7188 auto coupledSolidElementIdxSub = info.solidElementHostIdx;
126
127 // convert hostgrid indices to subgrid indices
128 14376 std::transform(coupledVoidElementIdxSub.begin(), coupledVoidElementIdxSub.end(),
129
1/2
✓ Branch 2 taken 18283 times.
✗ Branch 3 not taken.
18283 coupledVoidElementIdxSub.begin(), [&](const auto eIdx){ return voidHostToSubElementIdxMap_.at(eIdx); });
130 14376 std::transform(coupledSolidElementIdxSub.begin(), coupledSolidElementIdxSub.end(),
131
1/2
✓ Branch 2 taken 37638 times.
✗ Branch 3 not taken.
37638 coupledSolidElementIdxSub.begin(), [&](const auto eIdx){ return solidHostToSubElementIdxMap_.at(eIdx); });
132
133 // initialize an empty vector - will be filled later in a second loop
134
3/8
✓ Branch 1 taken 3594 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 3594 times.
✓ Branch 5 taken 3594 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
7188 auto convectionVoidElementIdx = std::vector<std::size_t>();
135
136
2/4
✓ Branch 1 taken 3594 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3594 times.
✗ Branch 5 not taken.
3594 voidToSolidConnectionIds_[directlyCoupledVoidDofIdx].emplace_back(info.connectionGlobalId);
137
2/4
✓ Branch 1 taken 3594 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3594 times.
✗ Branch 5 not taken.
3594 solidToVoidConnectionIds_[directlyCoupledSolidDofIdx].emplace_back(info.connectionGlobalId);
138
139
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 3594 times.
3594 connectionInfo_[info.connectionGlobalId] = SubGridConnectionInfo{info.connectionGlobalId,
140 directlyCoupledSolidDofIdx,
141 directlyCoupledVoidDofIdx,
142 3594 coupledSolidElementIdxSub[0],
143
1/2
✓ Branch 1 taken 3594 times.
✗ Branch 2 not taken.
3594 coupledVoidElementIdxSub[0],
144 convectionVoidElementIdx,
145 3594 info.connectionArea,
146 3594 info.connectionLength};
147
148
1/2
✓ Branch 1 taken 3594 times.
✗ Branch 2 not taken.
3594 hostGridElementIndexToGlobalId_[info.hostGridElementIndex] = info.connectionGlobalId;
149
150 7188 isCoupledVoidDof_[directlyCoupledVoidDofIdx] = true;
151 7188 isCoupledSolidDof_[directlyCoupledSolidDofIdx] = true;
152
153
4/4
✓ Branch 0 taken 18283 times.
✓ Branch 1 taken 3594 times.
✓ Branch 2 taken 18283 times.
✓ Branch 3 taken 3594 times.
29065 for (const auto eIdxVoidHost : info.voidElementHostIdx)
154 {
155
1/2
✓ Branch 1 taken 18283 times.
✗ Branch 2 not taken.
18283 const auto eIdxSubVoid = voidHostToSubElementIdxMap_.at(eIdxVoidHost);
156
2/4
✓ Branch 1 taken 18283 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 18283 times.
✗ Branch 5 not taken.
18283 voidToSolidStencils_[eIdxSubVoid].push_back(directlyCoupledSolidDofIdx);
157 }
158
159
4/4
✓ Branch 0 taken 37638 times.
✓ Branch 1 taken 3594 times.
✓ Branch 2 taken 37638 times.
✓ Branch 3 taken 3594 times.
48420 for (const auto eIdxSolidHost : info.solidElementHostIdx)
160 {
161
1/2
✓ Branch 1 taken 37638 times.
✗ Branch 2 not taken.
37638 const auto eIdxSubSolid = solidHostToSubElementIdxMap_.at(eIdxSolidHost);
162
2/4
✓ Branch 1 taken 37638 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 37638 times.
✗ Branch 5 not taken.
37638 solidToVoidStencils_[eIdxSubSolid].push_back(directlyCoupledVoidDofIdx);
163 }
164 }
165
166
2/2
✓ Branch 0 taken 1007 times.
✓ Branch 1 taken 1 times.
1010 for (auto& stencil : voidToSolidStencils_)
167 1007 removeDuplicates_(stencil.second);
168
2/2
✓ Branch 0 taken 2184 times.
✓ Branch 1 taken 1 times.
2187 for (auto& stencil : solidToVoidStencils_)
169 2184 removeDuplicates_(stencil.second);
170
171 // second loop: find void element coupling for convective transport
172 1 auto voidFVGeometry = localView(voidGridGeometry);
173
7/10
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1007 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 1007 times.
✓ Branch 9 taken 1 times.
✓ Branch 11 taken 1007 times.
✗ Branch 12 not taken.
2016 for (const auto& voidElement : elements(voidGridGeometry.gridView()))
174 {
175
1/2
✓ Branch 1 taken 1007 times.
✗ Branch 2 not taken.
1007 voidFVGeometry.bindElement(voidElement);
176 std::array<std::size_t, 2> dofIndex;
177
1/2
✓ Branch 1 taken 1007 times.
✗ Branch 2 not taken.
1007 std::array<std::vector<std::size_t>, 2> coupledSolidVertexIdx;
178
2/2
✓ Branch 0 taken 2014 times.
✓ Branch 1 taken 1007 times.
3021 for (const auto& scv : scvs(voidFVGeometry))
179 4028 dofIndex[scv.indexInElement()] = scv.dofIndex();
180
181 // check if both void pores couple to the same solid pore
182
8/16
✓ Branch 0 taken 1007 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1007 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1007 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1007 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1007 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1007 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1007 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1007 times.
✗ Branch 15 not taken.
4028 if (isCoupledVoidDof_[dofIndex[0]] && isCoupledVoidDof_[dofIndex[1]])
183 {
184
6/8
✓ Branch 1 taken 1007 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1007 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1007 times.
✓ Branch 7 taken 8961 times.
✓ Branch 8 taken 1007 times.
✓ Branch 9 taken 8961 times.
10975 for (auto& conn0 : voidToSolidConnectionIds_[dofIndex[0]])
185 {
186
7/10
✓ Branch 1 taken 8961 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8961 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 8961 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 81330 times.
✓ Branch 10 taken 8961 times.
✓ Branch 11 taken 81330 times.
✓ Branch 12 taken 8961 times.
108213 for (auto& conn1 : voidToSolidConnectionIds_[dofIndex[1]])
187 {
188 81330 const auto globalId0 = conn0;
189 81330 const auto globalId1 = conn1;
190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81330 times.
81330 assert(globalId0 != globalId1);
191
192
6/6
✓ Branch 0 taken 3788 times.
✓ Branch 1 taken 77542 times.
✓ Branch 2 taken 3788 times.
✓ Branch 3 taken 77542 times.
✓ Branch 4 taken 3788 times.
✓ Branch 5 taken 77542 times.
243990 if (connectionInfo_[globalId0].solidVertexIdx == connectionInfo_[globalId1].solidVertexIdx)
193 {
194
2/4
✓ Branch 1 taken 3788 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3788 times.
✗ Branch 5 not taken.
7576 const auto voidElemIdx = voidGridGeometry.elementMapper().index(voidElement);
195
2/4
✓ Branch 1 taken 3788 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3788 times.
✗ Branch 5 not taken.
7576 connectionInfo_[globalId0].convectionVoidElementIdx.push_back(voidElemIdx);
196
2/6
✓ Branch 1 taken 3788 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3788 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
7576 connectionInfo_[globalId1].convectionVoidElementIdx.push_back(voidElemIdx);
197 }
198 }
199 }
200 }
201 }
202
203
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 1 times.
559 for (auto& entry : voidToSolidConnectionIds_)
204 {
205 556 removeDuplicates_(entry.second);
206
207
4/8
✓ Branch 2 taken 556 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 556 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 556 times.
✗ Branch 10 not taken.
✓ Branch 13 taken 556 times.
✗ Branch 14 not taken.
2780 std::cout << "void dof " << entry.first << " couples to " << entry.second.size() << " solid dofs: " << std::endl;
208
4/4
✓ Branch 0 taken 3594 times.
✓ Branch 1 taken 556 times.
✓ Branch 2 taken 3594 times.
✓ Branch 3 taken 556 times.
8856 for (auto& conn : entry.second)
209 {
210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3594 times.
3594 const auto& info = connectionInfo_[conn];
211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3594 times.
3594 assert(entry.first == info.voidVertexIdx);
212
2/4
✓ Branch 2 taken 3594 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 3594 times.
✗ Branch 6 not taken.
7188 std::cout << "solid vertex " << info.solidVertexIdx << " with elems ";
213
4/4
✓ Branch 0 taken 7576 times.
✓ Branch 1 taken 3594 times.
✓ Branch 2 taken 7576 times.
✓ Branch 3 taken 3594 times.
18358 for (const auto e : info.convectionVoidElementIdx)
214
2/4
✓ Branch 1 taken 7576 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7576 times.
✗ Branch 5 not taken.
7576 std::cout << e << " ";
215
1/2
✓ Branch 2 taken 3594 times.
✗ Branch 3 not taken.
7188 std:: cout << "||" << std::endl;
216 }
217
218
1/2
✓ Branch 1 taken 556 times.
✗ Branch 2 not taken.
556 std::cout << std::endl;
219 }
220
221
2/2
✓ Branch 0 taken 558 times.
✓ Branch 1 taken 1 times.
561 for (auto& entry : solidToVoidConnectionIds_)
222 {
223 558 removeDuplicates_(entry.second);
224
225
4/8
✓ Branch 2 taken 558 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 558 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 558 times.
✗ Branch 10 not taken.
✓ Branch 13 taken 558 times.
✗ Branch 14 not taken.
2790 std::cout << "solid dof " << entry.first << " couples to " << entry.second.size() << " void dofs: " << std::endl;
226
4/4
✓ Branch 0 taken 3594 times.
✓ Branch 1 taken 558 times.
✓ Branch 2 taken 3594 times.
✓ Branch 3 taken 558 times.
8862 for (auto& conn : entry.second)
227 {
228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3594 times.
3594 const auto& info = connectionInfo_[conn];
229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3594 times.
3594 assert(entry.first == info.solidVertexIdx);
230
2/4
✓ Branch 2 taken 3594 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 3594 times.
✗ Branch 6 not taken.
7188 std::cout << "void vertex " << info.voidVertexIdx << " with elems ";
231
4/4
✓ Branch 0 taken 7576 times.
✓ Branch 1 taken 3594 times.
✓ Branch 2 taken 7576 times.
✓ Branch 3 taken 3594 times.
18358 for (const auto e : info.convectionVoidElementIdx)
232
2/4
✓ Branch 1 taken 7576 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7576 times.
✗ Branch 5 not taken.
7576 std::cout << e << " ";
233
1/2
✓ Branch 2 taken 3594 times.
✗ Branch 3 not taken.
7188 std:: cout << "||" << std::endl;
234 }
235
236
1/2
✓ Branch 1 taken 558 times.
✗ Branch 2 not taken.
558 std::cout << std::endl;
237 }
238
239 // TODO maybe delete hostToSub maps? or make public?
240 1 }
241
242 const auto& voidToSolidStencils() const
243 { return voidToSolidStencils_; }
244
245 const auto& solidToVoidStencils() const
246 { return solidToVoidStencils_; }
247
248 const std::vector<bool>& isCoupledVoidDof() const
249 451157 { return isCoupledVoidDof_; }
250
251 const std::vector<bool>& isCoupledSolidDof() const
252 855759 { return isCoupledSolidDof_; }
253
254 //! Returns an iterator allowing for (const auto& conn : voidToSolidConnections(dofIdx)) {...}
255 auto voidToSolidConnections(const std::size_t dofIdx) const
256 {
257 97217619 const auto& ids = voidToSolidConnectionIds().at(dofIdx);
258 using Iterator = ConnectionIterator<std::vector<std::size_t>>;
259 64811746 return Dune::IteratorRange<Iterator>(Iterator(ids.cbegin(), connectionInfo()),
260
3/6
✓ Branch 4 taken 2014 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2014 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 2014 times.
✗ Branch 11 not taken.
65244777 Iterator(ids.cend(), connectionInfo()));
261 }
262
263 auto solidToVoidConnections(const std::size_t dofIdx) const
264 {
265 2604915 const auto& ids = solidToVoidConnectionIds().at(dofIdx);
266 using Iterator = ConnectionIterator<std::vector<std::size_t>>;
267 1736610 return Dune::IteratorRange<Iterator>(Iterator(ids.cbegin(), connectionInfo()),
268
3/6
✓ Branch 4 taken 4362 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4362 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 4362 times.
✗ Branch 11 not taken.
2556933 Iterator(ids.cend(), connectionInfo()));
269 }
270
271 const auto& voidToSolidConnectionIds() const
272
1/2
✓ Branch 9 taken 2014 times.
✗ Branch 10 not taken.
32426013 { return voidToSolidConnectionIds_; }
273
274 const auto& solidToVoidConnectionIds() const
275
1/2
✓ Branch 8 taken 4362 times.
✗ Branch 9 not taken.
907563 { return solidToVoidConnectionIds_; }
276
277 const auto& connectionInfo() const
278
7/14
✓ Branch 0 taken 3695232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10182624 times.
✗ Branch 3 not taken.
✓ Branch 7 taken 3594 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 3594 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 times.
✓ Branch 15 taken 4362 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 2014 times.
✗ Branch 19 not taken.
50326503 { return connectionInfo_; }
279
280 const auto& voidHostToSubVertexIdxMap() const
281 { return voidHostToSubVertexIdxMap_; }
282
283 const auto& solidHostToSubVertexIdxMap() const
284 { return solidHostToSubVertexIdxMap_; }
285
286 const auto& voidHostToSubElementIdxMap() const
287 { return voidHostToSubElementIdxMap_; }
288
289 const auto& solidHostToSubElementIdxMap() const
290 { return solidHostToSubElementIdxMap_; }
291
292 const auto& hostGridElementIndexToGlobalId() const
293
1/2
✓ Branch 1 taken 3594 times.
✗ Branch 2 not taken.
3594 { return hostGridElementIndexToGlobalId_; }
294
295 private:
296
297 template<class HostGridView, class HostGridData>
298 1 std::vector<HostGridConnectionInfo> getConnectionInfo_(const HostGridView& hostGridView,
299 const HostGridData& hostGridData)
300 {
301 1 std::vector<HostGridConnectionInfo> connectionInfo;
302 1 std::size_t connectionGlobalId = 0;
303
304
5/6
✓ Branch 1 taken 6785 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 6785 times.
✓ Branch 4 taken 1 times.
✓ Branch 6 taken 6785 times.
✗ Branch 7 not taken.
6786 for (const auto& element : elements(hostGridView))
305 {
306
8/14
✓ Branch 1 taken 6785 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6785 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 6785 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 6785 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 3594 times.
✓ Branch 12 taken 3191 times.
✓ Branch 13 taken 3594 times.
✓ Branch 14 taken 3191 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
27140 if (hostGridData.getParameter(element, "ThroatDomainType") == 2) // interconnection throat
307 {
308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3594 times.
3594 const auto& vertex0 = element.template subEntity<1>(0);
309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3594 times.
3594 const auto& vertex1 = element.template subEntity<1>(1);
310
311
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3594 times.
7188 HostGridConnectionInfo info;
312
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3594 times.
✓ Branch 3 taken 3594 times.
✗ Branch 4 not taken.
3594 info.hostGridElementIndex = hostGridView.indexSet().index(element);
313 3594 info.connectionGlobalId = connectionGlobalId++;
314
2/4
✓ Branch 1 taken 3594 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3594 times.
✗ Branch 5 not taken.
7188 info.voidVertexHostIdx = hostGridView.indexSet().index(vertex0);
315
2/4
✓ Branch 1 taken 3594 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3594 times.
✗ Branch 5 not taken.
7188 info.solidVertexHostIdx = hostGridView.indexSet().index(vertex1);
316
317
6/14
✓ Branch 1 taken 3594 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3594 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3594 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 3594 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3594 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 3594 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
7188 if (hostGridData.getParameter(vertex0, "PoreDomainType") == 1)
318 {
319 assert(hostGridData.getParameter(vertex1, "PoreDomainType") == 0);
320 using std::swap;
321 swap(info.voidVertexHostIdx, info.solidVertexHostIdx);
322 }
323
324
5/12
✓ Branch 1 taken 3594 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3594 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3594 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 3594 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 3594 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
10782 info.connectionArea = hostGridData.getParameter(element, "ThroatCrossSectionalArea");
325
2/4
✓ Branch 1 taken 3594 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3594 times.
✗ Branch 5 not taken.
3594 info.connectionLength = element.geometry().volume();
326
327
4/8
✓ Branch 1 taken 3594 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 117991 times.
✗ Branch 6 not taken.
✓ Branch 10 taken 114397 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 114397 times.
✗ Branch 14 not taken.
243170 for (const auto& intersection : intersections(hostGridView, element))
328 {
329
2/4
✓ Branch 0 taken 114397 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114397 times.
✗ Branch 3 not taken.
228794 if (!intersection.neighbor())
330 58476 continue;
331
332
1/2
✓ Branch 1 taken 114397 times.
✗ Branch 2 not taken.
114397 const auto& outsideElement = intersection.outside();
333
334 // skip other interconnection throats
335
8/14
✓ Branch 1 taken 114397 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 114397 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 114397 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 114397 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 55921 times.
✓ Branch 12 taken 58476 times.
✓ Branch 13 taken 55921 times.
✓ Branch 14 taken 58476 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
457588 if (hostGridData.getParameter(outsideElement, "ThroatDomainType") == 2)
336 continue;
337
338
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 55921 times.
✓ Branch 3 taken 55921 times.
✗ Branch 4 not taken.
55921 const auto outsideElementIdx = hostGridView.indexSet().index(outsideElement);
339
340
8/14
✓ Branch 1 taken 55921 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 55921 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 55921 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 55921 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 18283 times.
✓ Branch 12 taken 37638 times.
✓ Branch 13 taken 18283 times.
✓ Branch 14 taken 37638 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
223684 if (hostGridData.getParameter(outsideElement, "ThroatDomainType") == 0)
341
1/2
✓ Branch 1 taken 18283 times.
✗ Branch 2 not taken.
18283 info.voidElementHostIdx.push_back(outsideElementIdx);
342 else
343
1/2
✓ Branch 1 taken 37638 times.
✗ Branch 2 not taken.
37638 info.solidElementHostIdx.push_back(outsideElementIdx);
344
345 55921 std::array outsideDomainType = {-1, -1};
346
2/2
✓ Branch 0 taken 111842 times.
✓ Branch 1 taken 55921 times.
167763 for (int localVIdx = 0; localVIdx < 2; ++localVIdx)
347 {
348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111842 times.
111842 const auto& outsideVertex = outsideElement.template subEntity<1>(localVIdx);
349
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 111842 times.
✓ Branch 3 taken 111842 times.
✗ Branch 4 not taken.
111842 const auto outsideVertexIdx = hostGridView.indexSet().index(outsideVertex);
350
7/14
✓ Branch 1 taken 111842 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 111842 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 111842 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 111842 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 111842 times.
✓ Branch 13 taken 55921 times.
✓ Branch 14 taken 55921 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
223684 outsideDomainType[localVIdx] = hostGridData.getParameter(outsideVertex, "PoreDomainType");
351
352
5/8
✓ Branch 0 taken 55921 times.
✓ Branch 1 taken 55921 times.
✓ Branch 2 taken 55921 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 55921 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 55921 times.
✗ Branch 7 not taken.
111842 if (localVIdx == 1 && (outsideDomainType[1] != outsideDomainType[0]))
353 DUNE_THROW(Dune::IOError, "Pore with hostIdx " << hostGridView.indexSet().index(outsideElement.template subEntity<1>(0))
354 << " has domain type " << outsideDomainType[0]
355 << ", but pore with hostIdx " << outsideVertexIdx
356 << " has domain type " << outsideDomainType[1] << ". Check your grid file");
357
358
4/4
✓ Branch 0 taken 36566 times.
✓ Branch 1 taken 75276 times.
✓ Branch 2 taken 36566 times.
✓ Branch 3 taken 75276 times.
223684 if (outsideDomainType[localVIdx] == 0)
359
1/2
✓ Branch 1 taken 36566 times.
✗ Branch 2 not taken.
36566 info.coupledVoidVertexHostIdx.push_back(outsideVertexIdx);
360 else
361
1/2
✓ Branch 1 taken 75276 times.
✗ Branch 2 not taken.
75276 info.coupledSolidVertexHostIdx.push_back(outsideVertexIdx);
362 }
363 }
364
365
1/2
✓ Branch 1 taken 3594 times.
✗ Branch 2 not taken.
3594 connectionInfo.emplace_back(std::move(info));
366 }
367 }
368
369 1 return connectionInfo;
370 }
371
372 template<class HostGridView, class SubGridGeometry, class Map>
373 2 void fillVertexMap_(const HostGridView& hostGridView, const SubGridGeometry& subGridGeometry, Map& map)
374 {
375
4/4
✓ Branch 2 taken 1116 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 1116 times.
✓ Branch 5 taken 2 times.
2236 for (const auto& vertex : vertices(subGridGeometry.gridView()))
376 {
377 2232 const auto vIdxSub = subGridGeometry.vertexMapper().index(vertex);
378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1116 times.
1116 const auto vIdxHost = hostGridView.indexSet().index(vertex.impl().hostEntity());
379 1116 map[vIdxHost] = vIdxSub;
380 }
381 2 }
382
383 template<class HostGridView, class SubGridGeometry, class Map>
384 2 void fillElementMap_(const HostGridView& hostGridView, const SubGridGeometry& subGridGeometry, Map& map)
385 {
386
4/4
✓ Branch 2 taken 3191 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 3191 times.
✓ Branch 5 taken 2 times.
6386 for (const auto& element : elements(subGridGeometry.gridView()))
387 {
388 6382 const auto eIdxSub = subGridGeometry.elementMapper().index(element);
389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3191 times.
3191 const auto eIdxHost = hostGridView.indexSet().index(element.impl().hostEntity());
390 3191 map[eIdxHost] = eIdxSub;
391 }
392 2 }
393
394 //! Removes duplicate entries from the coupling stencils
395 void removeDuplicates_(std::vector<std::size_t>& stencil)
396 {
397 std::sort(stencil.begin(), stencil.end());
398 stencil.erase(std::unique(stencil.begin(), stencil.end()), stencil.end());
399 }
400
401 std::unordered_map<std::size_t, std::size_t> voidHostToSubVertexIdxMap_;
402 std::unordered_map<std::size_t, std::size_t> solidHostToSubVertexIdxMap_;
403 std::unordered_map<std::size_t, std::size_t> voidHostToSubElementIdxMap_;
404 std::unordered_map<std::size_t, std::size_t> solidHostToSubElementIdxMap_;
405
406 std::vector<bool> isCoupledVoidDof_;
407 std::vector<bool> isCoupledSolidDof_;
408
409 std::unordered_map<std::size_t, Stencil> voidToSolidStencils_;
410 std::unordered_map<std::size_t, Stencil> solidToVoidStencils_;
411
412 std::unordered_map<std::size_t, std::vector<std::size_t>> voidToSolidConnectionIds_;
413 std::unordered_map<std::size_t, std::vector<std::size_t>> solidToVoidConnectionIds_;
414
415 std::vector<SubGridConnectionInfo> connectionInfo_;
416 std::unordered_map<std::size_t, std::size_t> hostGridElementIndexToGlobalId_;
417 };
418
419 } // end namespace Dumux::PoreNetwork
420
421 #endif
422