104 void bind(
const IndexSet& indexSet,
105 const Problem& problem,
106 const FVElementGeometry& fvGeometry)
110 stencil_ = &indexSet.nodalIndexSet().gridScvIndices();
113 std::size_t numFacetElems = 0;
114 std::size_t numOutsideFaces = 0;
115 std::vector<bool> isOnInteriorBoundary(indexSet.numFaces(),
false);
116 for (LocalIndexType fIdx = 0; fIdx < indexSet.numFaces(); ++fIdx)
118 const auto& scvf = fvGeometry.scvf(indexSet.gridScvfIndex(fIdx));
119 const auto element = fvGeometry.gridGeometry().element(scvf.insideScvIdx());
120 if (problem.couplingManager().isOnInteriorBoundary(
element, scvf))
123 if (!scvf.boundary())
124 numOutsideFaces += scvf.numOutsideScvs();
125 isOnInteriorBoundary[fIdx] =
true;
126 interiorBoundaryData_.emplace_back( scvf.index() );
131 numFaces_ = indexSet.numFaces() + numOutsideFaces;
132 const auto numLocalScvs = indexSet.numScvs();
133 const auto numGlobalScvfs = indexSet.nodalIndexSet().numScvfs();
136 elements_.clear(); elements_.reserve(numLocalScvs);
137 scvs_.clear(); scvs_.reserve(numLocalScvs);
138 scvfs_.clear(); scvfs_.reserve(numFaces_);
139 localFaceData_.clear(); localFaceData_.reserve(numGlobalScvfs);
140 dirichletData_.clear(); dirichletData_.reserve(numFaces_);
144 numKnowns_ = numLocalScvs + numFacetElems;
147 std::unordered_map<GridIndexType, LocalIndexType> scvfIndexMap;
150 LocalIndexType facetElementCounter = 0;
151 for (LocalIndexType faceIdxLocal = 0; faceIdxLocal < indexSet.numFaces(); ++faceIdxLocal)
153 const auto gridScvfIdx = indexSet.gridScvfIndex(faceIdxLocal);
154 const auto& flipScvfIdxSet = fvGeometry.gridGeometry().flipScvfIndexSet()[gridScvfIdx];
155 const auto& scvf = fvGeometry.scvf(gridScvfIdx);
156 const auto element = fvGeometry.gridGeometry().element(scvf.insideScvIdx());
159 const auto& neighborScvIndicesLocal = indexSet.neighboringLocalScvIndices(faceIdxLocal);
160 const auto numNeighborScvs = neighborScvIndicesLocal.size();
163 const auto curLocalScvfIdx = scvfs_.size();
164 scvfIndexMap[gridScvfIdx] = curLocalScvfIdx;
165 localFaceData_.emplace_back(curLocalScvfIdx, neighborScvIndicesLocal[0], scvf.index());
168 if (isOnInteriorBoundary[faceIdxLocal])
170 const LocalIndexType facetLocalDofIdx = numLocalScvs + facetElementCounter++;
171 const bool isDirichlet = problem.interiorBoundaryTypes(
element, scvf).hasOnlyDirichlet();
175 scvfs_.emplace_back(scvf, neighborScvIndicesLocal, facetLocalDofIdx,
true, facetLocalDofIdx);
177 scvfs_.emplace_back(scvf, neighborScvIndicesLocal, numUnknowns_++,
false, facetLocalDofIdx);
180 if (!scvf.boundary())
182 for (LocalIndexType i = 1; i < numNeighborScvs; ++i)
184 const auto outsideGridScvfIdx = flipScvfIdxSet[i-1];
185 const auto& flipScvf = fvGeometry.scvf(outsideGridScvfIdx);
186 const auto& outsideFlipScvfIdxSet = fvGeometry.gridGeometry().flipScvfIndexSet()[outsideGridScvfIdx];
190 auto outsideNeighborScvIdxSet = neighborScvIndicesLocal;
191 outsideNeighborScvIdxSet[0] = outsideNeighborScvIdxSet[i];
192 for (LocalIndexType j = 0; j < outsideFlipScvfIdxSet.size(); ++j)
194 const auto flipScvfIdx = outsideFlipScvfIdxSet[j];
195 auto it = std::find(flipScvfIdxSet.begin(), flipScvfIdxSet.end(), flipScvfIdx);
198 if (it != flipScvfIdxSet.end())
199 outsideNeighborScvIdxSet[j+1] = neighborScvIndicesLocal[std::distance(flipScvfIdxSet.begin(), it)+1];
204 assert(flipScvfIdx == gridScvfIdx);
205 outsideNeighborScvIdxSet[j+1] = neighborScvIndicesLocal[0];
209 scvfIndexMap[outsideGridScvfIdx] = curLocalScvfIdx+i;
210 localFaceData_.emplace_back(curLocalScvfIdx+i, outsideNeighborScvIdxSet[0], flipScvf.index());
212 scvfs_.emplace_back(flipScvf, outsideNeighborScvIdxSet, facetLocalDofIdx,
true, facetLocalDofIdx);
214 scvfs_.emplace_back(flipScvf, outsideNeighborScvIdxSet, numUnknowns_++,
false, facetLocalDofIdx);
220 else if (scvf.boundary())
222 if (problem.boundaryTypes(
element, scvf).hasOnlyDirichlet())
224 scvfs_.emplace_back(scvf, neighborScvIndicesLocal, numKnowns_++,
true);
225 dirichletData_.emplace_back(scvf.outsideScvIdx());
228 scvfs_.emplace_back(scvf, neighborScvIndicesLocal, numUnknowns_++,
false);
234 scvfs_.emplace_back(scvf, neighborScvIndicesLocal, numUnknowns_++,
false);
237 for (LocalIndexType i = 1; i < numNeighborScvs; ++i)
240 const auto outsideLocalScvIdx = neighborScvIndicesLocal[i];
241 const auto& flipScvfIndex = fvGeometry.gridGeometry().flipScvfIndexSet()[scvf.index()][i-1];
242 const auto& flipScvf = fvGeometry.scvf(flipScvfIndex);
243 scvfIndexMap[flipScvfIndex] = curLocalScvfIdx;
244 localFaceData_.emplace_back(curLocalScvfIdx,
253 for (LocalIndexType scvIdxLocal = 0; scvIdxLocal < numLocalScvs; scvIdxLocal++)
255 elements_.emplace_back(fvGeometry.gridGeometry().element(
stencil()[scvIdxLocal] ));
256 scvs_.emplace_back(fvGeometry.gridGeometry().mpfaHelper(),
258 fvGeometry.scv(
stencil()[scvIdxLocal] ),