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 numOutsideFaces += scvf.numOutsideScvs();
124 isOnInteriorBoundary[fIdx] =
true;
125 interiorBoundaryData_.emplace_back( scvf.index() );
130 numFaces_ = indexSet.numFaces() + numOutsideFaces;
131 const auto numLocalScvs = indexSet.numScvs();
132 const auto numGlobalScvfs = indexSet.nodalIndexSet().numScvfs();
135 elements_.clear(); elements_.reserve(numLocalScvs);
136 scvs_.clear(); scvs_.reserve(numLocalScvs);
137 scvfs_.clear(); scvfs_.reserve(numFaces_);
138 localFaceData_.clear(); localFaceData_.reserve(numGlobalScvfs);
139 dirichletData_.clear(); dirichletData_.reserve(numFaces_);
143 numKnowns_ = numLocalScvs + numFacetElems;
146 std::unordered_map<GridIndexType, LocalIndexType> scvfIndexMap;
149 LocalIndexType facetElementCounter = 0;
150 for (LocalIndexType faceIdxLocal = 0; faceIdxLocal < indexSet.numFaces(); ++faceIdxLocal)
152 const auto gridScvfIdx = indexSet.gridScvfIndex(faceIdxLocal);
153 const auto& flipScvfIdxSet = fvGeometry.gridGeometry().flipScvfIndexSet()[gridScvfIdx];
154 const auto& scvf = fvGeometry.scvf(gridScvfIdx);
155 const auto element = fvGeometry.gridGeometry().element(scvf.insideScvIdx());
158 const auto& neighborScvIndicesLocal = indexSet.neighboringLocalScvIndices(faceIdxLocal);
159 const auto numNeighborScvs = neighborScvIndicesLocal.size();
162 const auto curLocalScvfIdx = scvfs_.size();
163 scvfIndexMap[gridScvfIdx] = curLocalScvfIdx;
164 localFaceData_.emplace_back(curLocalScvfIdx, neighborScvIndicesLocal[0], scvf.index());
167 if (isOnInteriorBoundary[faceIdxLocal])
169 const LocalIndexType facetLocalDofIdx = numLocalScvs + facetElementCounter++;
170 const bool isDirichlet = problem.interiorBoundaryTypes(
element, scvf).hasOnlyDirichlet();
174 scvfs_.emplace_back(scvf, neighborScvIndicesLocal, facetLocalDofIdx,
true, facetLocalDofIdx);
176 scvfs_.emplace_back(scvf, neighborScvIndicesLocal, numUnknowns_++,
false, facetLocalDofIdx);
179 for (LocalIndexType i = 1; i < numNeighborScvs; ++i)
181 const auto outsideGridScvfIdx = flipScvfIdxSet[i-1];
182 const auto& flipScvf = fvGeometry.scvf(outsideGridScvfIdx);
183 const auto& outsideFlipScvfIdxSet = fvGeometry.gridGeometry().flipScvfIndexSet()[outsideGridScvfIdx];
187 auto outsideNeighborScvIdxSet = neighborScvIndicesLocal;
188 outsideNeighborScvIdxSet[0] = outsideNeighborScvIdxSet[i];
189 for (LocalIndexType j = 0; j < outsideFlipScvfIdxSet.size(); ++j)
191 const auto flipScvfIdx = outsideFlipScvfIdxSet[j];
192 auto it = std::find(flipScvfIdxSet.begin(), flipScvfIdxSet.end(), flipScvfIdx);
195 if (it != flipScvfIdxSet.end())
196 outsideNeighborScvIdxSet[j+1] = neighborScvIndicesLocal[std::distance(flipScvfIdxSet.begin(), it)+1];
201 assert(flipScvfIdx == gridScvfIdx);
202 outsideNeighborScvIdxSet[j+1] = neighborScvIndicesLocal[0];
206 scvfIndexMap[outsideGridScvfIdx] = curLocalScvfIdx+i;
207 localFaceData_.emplace_back(curLocalScvfIdx+i, outsideNeighborScvIdxSet[0], flipScvf.index());
209 scvfs_.emplace_back(flipScvf, outsideNeighborScvIdxSet, facetLocalDofIdx,
true, facetLocalDofIdx);
211 scvfs_.emplace_back(flipScvf, outsideNeighborScvIdxSet, numUnknowns_++,
false, facetLocalDofIdx);
216 else if (scvf.boundary())
218 if (problem.boundaryTypes(
element, scvf).hasOnlyDirichlet())
220 scvfs_.emplace_back(scvf, neighborScvIndicesLocal, numKnowns_++,
true);
221 dirichletData_.emplace_back(scvf.outsideScvIdx());
224 scvfs_.emplace_back(scvf, neighborScvIndicesLocal, numUnknowns_++,
false);
230 scvfs_.emplace_back(scvf, neighborScvIndicesLocal, numUnknowns_++,
false);
233 for (LocalIndexType i = 1; i < numNeighborScvs; ++i)
236 const auto outsideLocalScvIdx = neighborScvIndicesLocal[i];
237 const auto& flipScvfIndex = fvGeometry.gridGeometry().flipScvfIndexSet()[scvf.index()][i-1];
238 const auto& flipScvf = fvGeometry.scvf(flipScvfIndex);
239 scvfIndexMap[flipScvfIndex] = curLocalScvfIdx;
240 localFaceData_.emplace_back(curLocalScvfIdx,
249 for (LocalIndexType scvIdxLocal = 0; scvIdxLocal < numLocalScvs; scvIdxLocal++)
251 elements_.emplace_back(fvGeometry.gridGeometry().element(
stencil()[scvIdxLocal] ));
252 scvs_.emplace_back(fvGeometry.gridGeometry().mpfaHelper(),
254 fvGeometry.scv(
stencil()[scvIdxLocal] ),