116 void bind(
const IndexSet& indexSet,
117 const Problem& problem,
118 const FVElementGeometry& fvGeometry)
122 stencil_ = &indexSet.nodalIndexSet().gridScvIndices();
125 std::size_t numFacetElems = 0;
126 std::size_t numOutsideFaces = 0;
127 std::vector<bool> isOnInteriorBoundary(indexSet.numFaces(),
false);
128 for (LocalIndexType fIdx = 0; fIdx < indexSet.numFaces(); ++fIdx)
130 const auto& scvf = fvGeometry.scvf(indexSet.gridScvfIndex(fIdx));
131 const auto element = fvGeometry.gridGeometry().element(scvf.insideScvIdx());
132 if (problem.couplingManager().isOnInteriorBoundary(
element, scvf))
135 numOutsideFaces += scvf.numOutsideScvs();
136 isOnInteriorBoundary[fIdx] =
true;
137 interiorBoundaryData_.emplace_back( scvf.index() );
142 numFaces_ = indexSet.numFaces() + numOutsideFaces;
143 const auto numLocalScvs = indexSet.numScvs();
144 const auto numGlobalScvfs = indexSet.nodalIndexSet().numScvfs();
147 elements_.clear(); elements_.reserve(numLocalScvs);
148 scvs_.clear(); scvs_.reserve(numLocalScvs);
149 scvfs_.clear(); scvfs_.reserve(numFaces_);
150 localFaceData_.clear(); localFaceData_.reserve(numGlobalScvfs);
151 dirichletData_.clear(); dirichletData_.reserve(numFaces_);
155 numKnowns_ = numLocalScvs + numFacetElems;
158 std::unordered_map<GridIndexType, LocalIndexType> scvfIndexMap;
161 LocalIndexType facetElementCounter = 0;
162 for (LocalIndexType faceIdxLocal = 0; faceIdxLocal < indexSet.numFaces(); ++faceIdxLocal)
164 const auto gridScvfIdx = indexSet.gridScvfIndex(faceIdxLocal);
165 const auto& flipScvfIdxSet = fvGeometry.gridGeometry().flipScvfIndexSet()[gridScvfIdx];
166 const auto& scvf = fvGeometry.scvf(gridScvfIdx);
167 const auto element = fvGeometry.gridGeometry().element(scvf.insideScvIdx());
170 const auto& neighborScvIndicesLocal = indexSet.neighboringLocalScvIndices(faceIdxLocal);
171 const auto numNeighborScvs = neighborScvIndicesLocal.size();
174 const auto curLocalScvfIdx = scvfs_.size();
175 scvfIndexMap[gridScvfIdx] = curLocalScvfIdx;
176 localFaceData_.emplace_back(curLocalScvfIdx, neighborScvIndicesLocal[0], scvf.index());
179 if (isOnInteriorBoundary[faceIdxLocal])
181 const LocalIndexType facetLocalDofIdx = numLocalScvs + facetElementCounter++;
182 const bool isDirichlet = problem.interiorBoundaryTypes(
element, scvf).hasOnlyDirichlet();
186 scvfs_.emplace_back(scvf, neighborScvIndicesLocal, facetLocalDofIdx,
true, facetLocalDofIdx);
188 scvfs_.emplace_back(scvf, neighborScvIndicesLocal, numUnknowns_++,
false, facetLocalDofIdx);
191 for (LocalIndexType i = 1; i < numNeighborScvs; ++i)
193 const auto outsideGridScvfIdx = flipScvfIdxSet[i-1];
194 const auto& flipScvf = fvGeometry.scvf(outsideGridScvfIdx);
195 const auto& outsideFlipScvfIdxSet = fvGeometry.gridGeometry().flipScvfIndexSet()[outsideGridScvfIdx];
199 auto outsideNeighborScvIdxSet = neighborScvIndicesLocal;
200 outsideNeighborScvIdxSet[0] = outsideNeighborScvIdxSet[i];
201 for (LocalIndexType j = 0; j < outsideFlipScvfIdxSet.size(); ++j)
203 const auto flipScvfIdx = outsideFlipScvfIdxSet[j];
204 auto it = std::find(flipScvfIdxSet.begin(), flipScvfIdxSet.end(), flipScvfIdx);
207 if (it != flipScvfIdxSet.end())
208 outsideNeighborScvIdxSet[j+1] = neighborScvIndicesLocal[std::distance(flipScvfIdxSet.begin(), it)+1];
213 assert(flipScvfIdx == gridScvfIdx);
214 outsideNeighborScvIdxSet[j+1] = neighborScvIndicesLocal[0];
218 scvfIndexMap[outsideGridScvfIdx] = curLocalScvfIdx+i;
219 localFaceData_.emplace_back(curLocalScvfIdx+i, outsideNeighborScvIdxSet[0], flipScvf.index());
221 scvfs_.emplace_back(flipScvf, outsideNeighborScvIdxSet, facetLocalDofIdx,
true, facetLocalDofIdx);
223 scvfs_.emplace_back(flipScvf, outsideNeighborScvIdxSet, numUnknowns_++,
false, facetLocalDofIdx);
228 else if (scvf.boundary())
230 if (problem.boundaryTypes(
element, scvf).hasOnlyDirichlet())
232 scvfs_.emplace_back(scvf, neighborScvIndicesLocal, numKnowns_++,
true);
233 dirichletData_.emplace_back(scvf.outsideScvIdx());
236 scvfs_.emplace_back(scvf, neighborScvIndicesLocal, numUnknowns_++,
false);
242 scvfs_.emplace_back(scvf, neighborScvIndicesLocal, numUnknowns_++,
false);
245 for (LocalIndexType i = 1; i < numNeighborScvs; ++i)
248 const auto outsideLocalScvIdx = neighborScvIndicesLocal[i];
249 const auto& flipScvfIndex = fvGeometry.gridGeometry().flipScvfIndexSet()[scvf.index()][i-1];
250 const auto& flipScvf = fvGeometry.scvf(flipScvfIndex);
251 scvfIndexMap[flipScvfIndex] = curLocalScvfIdx;
252 localFaceData_.emplace_back(curLocalScvfIdx,
261 for (LocalIndexType scvIdxLocal = 0; scvIdxLocal < numLocalScvs; scvIdxLocal++)
263 elements_.emplace_back(fvGeometry.gridGeometry().element(
stencil()[scvIdxLocal] ));
264 scvs_.emplace_back(fvGeometry.gridGeometry().mpfaHelper(),
266 fvGeometry.scv(
stencil()[scvIdxLocal] ),