34 const Foam::label Foam::enrichedPatch::enrichedFaceRatio_ = 3;
46 if (enrichedFacesPtr_)
49 <<
"Enriched faces already calculated."
62 enrichedFacesPtr_.reset
64 new faceList(masterPatch_.size() + slavePatch_.size())
66 auto& enrichedFaces = *enrichedFacesPtr_;
68 label nEnrichedFaces = 0;
70 const pointField& masterLocalPoints = masterPatch_.localPoints();
71 const faceList& masterLocalFaces = masterPatch_.localFaces();
72 const labelListList& masterFaceEdges = masterPatch_.faceEdges();
74 const faceList& slaveLocalFaces = slavePatch_.localFaces();
75 const labelListList& slaveFaceEdges = slavePatch_.faceEdges();
88 const face& oldFace = slavePatch_[facei];
89 const face& oldLocalFace = slaveLocalFaces[facei];
90 const labelList& curEdges = slaveFaceEdges[facei];
103 const label mappedPointi = pmm.lookup(oldFace[i], oldFace[i]);
105 newFace.append(mappedPointi);
111 projectedSlavePoints[oldLocalFace[i]]
117 pointsIntoSlaveEdges[curEdges[i]];
125 if (pointsOnEdge.size())
130 const point& startPoint =
131 projectedSlavePoints[oldLocalFace[i]];
133 const point& endPoint =
134 projectedSlavePoints[oldLocalFace.nextLabel(i)];
136 vector e = (endPoint - startPoint);
138 const scalar magSqrE =
magSqr(
e);
147 <<
"Zero length edge in slave patch for face " << i
148 <<
". This is not allowed."
152 pointField positionOnEdge(pointsOnEdge.size());
154 forAll(pointsOnEdge, edgePointi)
156 positionOnEdge[edgePointi] =
157 pointMap()[pointsOnEdge[edgePointi]];
159 weightOnEdge[edgePointi] =
164 positionOnEdge[edgePointi]
173 if (
min(weightOnEdge) < 0 ||
max(weightOnEdge) > 1)
176 <<
" not on the edge for edge " << curEdges[i]
177 <<
" of face " << facei <<
" in slave patch." <<
nl
178 <<
"Min weight: " <<
min(weightOnEdge)
179 <<
" Max weight: " <<
max(weightOnEdge)
187 forAll(weightOnEdge, passI)
191 label nextPoint = -1;
196 if (weightOnEdge[wI] < dist)
198 dist = weightOnEdge[wI];
205 newFace.append(pointsOnEdge[nextPoint]);
206 weightOnEdge[nextPoint] = GREAT;
211 pointsOnEdge[nextPoint],
212 positionOnEdge[nextPoint]
223 enrichedFaces[nEnrichedFaces].transfer(newFace);
230 forAll(masterPatch_, facei)
232 const face& oldFace = masterPatch_[facei];
233 const face& oldLocalFace = masterLocalFaces[facei];
234 const labelList& curEdges = masterFaceEdges[facei];
247 const label mappedPointi = pmm.lookup(oldFace[i], oldFace[i]);
249 newFace.append(mappedPointi);
255 masterLocalPoints[oldLocalFace[i]]
261 pointsIntoMasterEdges[curEdges[i]];
265 if (pointsOnEdge.size())
270 const point& startPoint =
271 masterLocalPoints[oldLocalFace[i]];
273 const point& endPoint =
274 masterLocalPoints[oldLocalFace.nextLabel(i)];
276 vector e = (endPoint - startPoint);
278 const scalar magSqrE =
magSqr(
e);
287 <<
"Zero length edge in master patch for face " << i
288 <<
". This is not allowed."
292 pointField positionOnEdge(pointsOnEdge.size());
294 forAll(pointsOnEdge, edgePointi)
296 positionOnEdge[edgePointi] =
297 pointMap()[pointsOnEdge[edgePointi]];
299 weightOnEdge[edgePointi] =
304 positionOnEdge[edgePointi] - startPoint
312 if (
min(weightOnEdge) < 0 ||
max(weightOnEdge) > 1)
315 <<
" not on the edge for edge " << curEdges[i]
316 <<
" of face " << facei <<
" in master patch." <<
nl
317 <<
"Min weight: " <<
min(weightOnEdge)
318 <<
" Max weight: " <<
max(weightOnEdge)
326 forAll(weightOnEdge, passI)
330 label nextPoint = -1;
335 if (weightOnEdge[wI] < dist)
337 dist = weightOnEdge[wI];
344 newFace.append(pointsOnEdge[nextPoint]);
345 weightOnEdge[nextPoint] = GREAT;
350 pointsOnEdge[nextPoint],
351 positionOnEdge[nextPoint]
362 enrichedFaces[nEnrichedFaces].transfer(newFace);
371 Info<<
"Enriched patch support OK. Slave faces: "
372 << slavePatch_.size() <<
" Master faces: "
373 << masterPatch_.size() <<
endl;
378 <<
"Error in enriched patch support"
389 if (!enrichedFacesPtr_)
392 <<
"void enrichedPatch::calcEnrichedFaces\n"
394 <<
" const labelListList& pointsIntoMasterEdges,\n"
395 <<
" const labelListList& pointsIntoSlaveEdges,\n"
396 <<
" const pointField& projectedSlavePoints\n"
398 <<
" before trying to access faces."
402 return *enrichedFacesPtr_;