40 template<
class>
class FaceList,
44 template<
class ToPatch>
49 const ToPatch& targetPatch,
50 const Field<PointType>& projectionDirection,
51 const intersection::algorithm alg,
57 if (projectionDirection.size() !=
nPoints())
60 <<
"Projection direction field does not correspond to "
61 <<
"patch points." <<
endl
62 <<
"Size: " << projectionDirection.size()
63 <<
" Number of points: " <<
nPoints()
67 const labelList& slavePointOrder = localPointOrder();
69 const labelList& slaveMeshPoints = meshPoints();
74 const labelListList& masterFaceFaces = targetPatch.faceFaces();
76 const ToPatch& masterFaces = targetPatch;
78 const Field<PointType>& masterPoints = targetPatch.points();
81 Field<PointType> masterFaceCentres(targetPatch.size());
83 forAll(masterFaceCentres, faceI)
85 masterFaceCentres[faceI] =
98 label nNSquaredSearches = 0;
100 forAll(slavePointOrder, pointI)
103 const label curLocalPointLabel = slavePointOrder[pointI];
105 const PointType& curPoint =
106 points_[slaveMeshPoints[curLocalPointLabel]];
108 const PointType& curProjectionDir =
109 projectionDirection[curLocalPointLabel];
113 boolList visitedTargetFace(targetPatch.size(),
false);
114 bool doNSquaredSearch =
false;
116 bool foundEligible =
false;
118 scalar sqrDistance = GREAT;
124 doNSquaredSearch =
true;
131 doNSquaredSearch =
false;
134 PointHit<PointType> curHit =
135 masterFaces[curFace].ray
144 visitedTargetFace[curFace] =
true;
148 result[curLocalPointLabel] = objectHit(
true, curFace);
158 if (curHit.eligibleMiss())
160 foundEligible =
true;
161 result[curLocalPointLabel] = objectHit(
false, curFace);
170 PointType missPlanePoint =
171 curPoint + curProjectionDir*curHit.distance();
173 const labelList& masterNbrs = masterFaceFaces[curFace];
176 magSqr(missPlanePoint - masterFaceCentres[curFace]);
185 - masterFaceCentres[masterNbrs[nbrI]]
191 curFace = masterNbrs[nbrI];
195 if (visitedTargetFace[curFace])
199 doNSquaredSearch =
true;
204 if (debug)
Info<<
".";
210 doNSquaredSearch || !foundEligible
217 Info<<
"p " << curLocalPointLabel <<
": ";
220 result[curLocalPointLabel] = objectHit(
false, -1);
221 scalar minDistance = GREAT;
223 forAll(masterFaces, faceI)
225 PointHit<PointType> curHit =
226 masterFaces[faceI].ray
237 result[curLocalPointLabel] = objectHit(
true, faceI);
242 else if (curHit.eligibleMiss())
246 Foam::mag(curHit.missPoint() - curPoint);
248 if (missDist < minDistance)
250 minDistance = missDist;
252 result[curLocalPointLabel] = objectHit(
false, faceI);
260 Info<< result[curLocalPointLabel] <<
nl;
265 if (debug)
Info<<
"x";
271 Info<<
nl <<
"Executed " << nNSquaredSearches
272 <<
" n-squared searches out of total of "
283 template<
class>
class FaceList,
287 template<
class ToPatch>
292 const ToPatch& targetPatch,
293 const Field<PointType>& projectionDirection,
294 const intersection::algorithm alg,
300 if (projectionDirection.size() != this->size())
303 <<
"Projection direction field does not correspond to patch faces."
304 <<
endl <<
"Size: " << projectionDirection.size()
305 <<
" Number of points: " << this->size()
312 Field<PointType> masterFaceCentres(targetPatch.size());
314 const labelListList& masterFaceFaces = targetPatch.faceFaces();
316 const ToPatch& masterFaces = targetPatch;
318 const typename ToPatch::PointFieldType& masterPoints = targetPatch.points();
320 forAll(masterFaceCentres, faceI)
322 masterFaceCentres[faceI] =
323 masterFaces[faceI].centre(masterPoints);
329 const PrimitivePatch<Face, FaceList, PointField, PointType>& slaveFaces =
332 const PointField& slaveGlobalPoints =
points();
343 label nNSquaredSearches = 0;
345 forAll(slaveFaceOrder, faceI)
348 const label curLocalFaceLabel = slaveFaceOrder[faceI];
350 const point& curFaceCentre =
351 slaveFaces[curLocalFaceLabel].
centre(slaveGlobalPoints);
353 const vector& curProjectionDir =
354 projectionDirection[curLocalFaceLabel];
358 boolList visitedTargetFace(targetPatch.size(),
false);
359 bool doNSquaredSearch =
false;
361 bool foundEligible =
false;
363 scalar sqrDistance = GREAT;
369 doNSquaredSearch =
true;
376 doNSquaredSearch =
false;
379 PointHit<PointType> curHit =
380 masterFaces[curFace].ray
389 visitedTargetFace[curFace] =
true;
393 result[curLocalFaceLabel] = objectHit(
true, curFace);
403 if (curHit.eligibleMiss())
405 foundEligible =
true;
406 result[curLocalFaceLabel] = objectHit(
false, curFace);
414 PointType missPlanePoint =
415 curFaceCentre + curProjectionDir*curHit.distance();
418 magSqr(missPlanePoint - masterFaceCentres[curFace]);
420 const labelList& masterNbrs = masterFaceFaces[curFace];
429 - masterFaceCentres[masterNbrs[nbrI]]
435 curFace = masterNbrs[nbrI];
439 if (visitedTargetFace[curFace])
443 doNSquaredSearch =
true;
448 if (debug)
Info<<
".";
452 if (doNSquaredSearch || !foundEligible)
458 Info<<
"p " << curLocalFaceLabel <<
": ";
461 result[curLocalFaceLabel] = objectHit(
false, -1);
462 scalar minDistance = GREAT;
464 forAll(masterFaces, faceI)
466 PointHit<PointType> curHit =
467 masterFaces[faceI].ray
478 result[curLocalFaceLabel] = objectHit(
true, faceI);
483 else if (curHit.eligibleMiss())
487 Foam::mag(curHit.missPoint() - curFaceCentre);
489 if (missDist < minDistance)
491 minDistance = missDist;
493 result[curLocalFaceLabel] = objectHit(
false, faceI);
501 Info<< result[curLocalFaceLabel] <<
nl;
506 if (debug)
Info<<
"x";
512 Info<<
nl <<
"Executed " << nNSquaredSearches
513 <<
" n-squared searches out of total of "
514 << this->size() <<
endl;