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