34 const Foam::label Foam::enrichedPatch::enrichedFaceRatio_ = 3;
45 if (enrichedFacesPtr_)
49 "void enrichedPatch::calcEnrichedFaces\n"
51 " const labelListList& pointsIntoMasterEdges,\n"
52 " const labelListList& pointsIntoSlaveEdges,\n"
53 " const pointField& projectedSlavePoints\n"
55 ) <<
"Enriched faces already calculated."
68 enrichedFacesPtr_ =
new faceList(masterPatch_.size() + slavePatch_.size());
69 faceList& enrichedFaces = *enrichedFacesPtr_;
71 label nEnrichedFaces = 0;
73 const pointField& masterLocalPoints = masterPatch_.localPoints();
74 const faceList& masterLocalFaces = masterPatch_.localFaces();
75 const labelListList& masterFaceEdges = masterPatch_.faceEdges();
77 const faceList& slaveLocalFaces = slavePatch_.localFaces();
78 const labelListList& slaveFaceEdges = slavePatch_.faceEdges();
89 forAll (slavePatch_, faceI)
91 const face oldFace = slavePatch_[faceI];
92 const face oldLocalFace = slaveLocalFaces[faceI];
94 const labelList& curEdges = slaveFaceEdges[faceI];
104 pmm.
find(oldFace[i]);
106 if (mpIter == pmm.
end())
109 newFace.append(oldFace[i]);
115 projectedSlavePoints[oldLocalFace[i]]
121 newFace.append(mpIter());
127 projectedSlavePoints[oldLocalFace[i]]
134 pointsIntoSlaveEdges[curEdges[i]];
138 if (slavePointsOnEdge.
size())
142 const point& startPoint = projectedSlavePoints[oldLocalFace[i]];
145 projectedSlavePoints[oldLocalFace.nextLabel(i)]
148 scalar magSqrE =
magSqr(e);
158 "void enrichedPatch::calcEnrichedFaces\n"
160 " const labelListList& pointsIntoMasterEdges,\n"
161 " const labelListList& pointsIntoSlaveEdges,\n"
162 " const pointField& projectedSlavePoints\n"
164 ) <<
"Zero length edge in slave patch for face " << i
165 <<
". This is not allowed."
171 forAll (slavePointsOnEdge, edgePointI)
173 slavePosOnEdge[edgePointI] =
174 pointMap().find(slavePointsOnEdge[edgePointI])();
176 edgePointWeights[edgePointI] =
177 (e & (slavePosOnEdge[edgePointI] - startPoint));
183 if (
min(edgePointWeights) < 0 ||
max(edgePointWeights) > 1)
187 "void enrichedPatch::calcEnrichedFaces\n"
189 " const labelListList& pointsIntoMasterEdges,\n"
190 " const labelListList& pointsIntoSlaveEdges,\n"
191 " const pointField& projectedSlavePoints\n"
193 ) <<
"Invalid point edge weights. Some of points are"
194 <<
" not on the edge for edge " << curEdges[i]
195 <<
" of face " << faceI <<
" in slave patch." <<
nl
196 <<
"Min weight: " <<
min(edgePointWeights)
197 <<
" Max weight: " <<
max(edgePointWeights)
205 for (label passI = 0; passI < edgePointWeights.size(); passI++)
209 label nextPoint = -1;
212 forAll (edgePointWeights, wI)
214 if (edgePointWeights[wI] < dist)
216 dist = edgePointWeights[wI];
223 newFace.append(slavePointsOnEdge[nextPoint]);
224 edgePointWeights[nextPoint] = GREAT;
229 slavePointsOnEdge[nextPoint],
230 slavePosOnEdge[nextPoint]
238 enrichedFaces[nEnrichedFaces].transfer(newFace);
244 forAll (masterPatch_, faceI)
246 const face& oldFace = masterPatch_[faceI];
247 const face& oldLocalFace = masterLocalFaces[faceI];
249 const labelList& curEdges = masterFaceEdges[faceI];
259 pmm.
find(oldFace[i]);
261 if (mpIter == pmm.
end())
264 newFace.append(oldFace[i]);
270 masterLocalPoints[oldLocalFace[i]]
276 newFace.append(mpIter());
279 pointMap().insert(mpIter(), masterLocalPoints[oldLocalFace[i]]);
285 pointsIntoMasterEdges[curEdges[i]];
289 if (masterPointsOnEdge.
size())
293 const point& startPoint = masterLocalPoints[oldLocalFace[i]];
296 masterLocalPoints[oldLocalFace.nextLabel(i)]
299 scalar magSqrE =
magSqr(e);
309 "void enrichedPatch::calcEnrichedFaces\n"
311 " const labelListList& pointsIntoMasterEdges,\n"
312 " const labelListList& pointsIntoSlaveEdges,\n"
313 " const pointField& projectedSlavePoints\n"
315 ) <<
"Zero length edge in master patch for face " << i
316 <<
". This is not allowed."
322 forAll (masterPointsOnEdge, edgePointI)
324 masterPosOnEdge[edgePointI] =
325 pointMap().find(masterPointsOnEdge[edgePointI])();
327 edgePointWeights[edgePointI] =
328 (e & (masterPosOnEdge[edgePointI] - startPoint));
334 if (
min(edgePointWeights) < 0 ||
max(edgePointWeights) > 1)
338 "void enrichedPatch::calcEnrichedFaces\n"
340 " const labelListList& pointsIntoMasterEdges,\n"
341 " const labelListList& pointsIntoSlaveEdges,\n"
342 " const pointField& projectedSlavePoints\n"
344 ) <<
"Invalid point edge weights. Some of points are"
345 <<
" not on the edge for edge " << curEdges[i]
346 <<
" of face " << faceI <<
" in master patch." <<
nl
347 <<
"Min weight: " <<
min(edgePointWeights)
348 <<
" Max weight: " <<
max(edgePointWeights)
356 for (label pass = 0; pass < edgePointWeights.size(); pass++)
360 label nextPoint = -1;
363 forAll (edgePointWeights, wI)
365 if (edgePointWeights[wI] < dist)
367 dist = edgePointWeights[wI];
374 newFace.append(masterPointsOnEdge[nextPoint]);
375 edgePointWeights[nextPoint] = GREAT;
380 masterPointsOnEdge[nextPoint],
381 masterPosOnEdge[nextPoint]
389 enrichedFaces[nEnrichedFaces].transfer(newFace);
398 Info<<
"Enriched patch support OK. Slave faces: "
399 << slavePatch_.size() <<
" Master faces: "
400 << masterPatch_.size() <<
endl;
406 "void enrichedPatch::calcEnrichedFaces\n"
408 " const labelListList& pointsIntoMasterEdges,\n"
409 " const labelListList& pointsIntoSlaveEdges,\n"
410 " const pointField& projectedSlavePoints\n"
412 ) <<
"Error in enriched patch support"
423 if (!enrichedFacesPtr_)
425 FatalErrorIn(
"const faceList& enrichedPatch::enrichedFaces() const")
426 <<
"Enriched faces not available yet. Please use "
427 <<
"void enrichedPatch::calcEnrichedFaces\n"
429 <<
" const labelListList& pointsIntoMasterEdges,\n"
430 <<
" const labelListList& pointsIntoSlaveEdges,\n"
431 <<
" const pointField& projectedSlavePoints\n"
433 <<
" before trying to access faces."
437 return *enrichedFacesPtr_;