42 template<
class>
class FaceList,
46 template<
class ToPatch>
51 const ToPatch& targetPatch,
59 if (projectionDirection.size() !=
nPoints())
62 <<
"Projection direction field does not correspond to "
63 <<
"patch points." <<
endl
64 <<
"Size: " << projectionDirection.size()
65 <<
" Number of points: " <<
nPoints()
69 const labelList& slavePointOrder = localPointOrder();
71 const labelList& slaveMeshPoints = meshPoints();
76 const labelListList& masterFaceFaces = targetPatch.faceFaces();
78 const ToPatch& masterFaces = targetPatch;
85 forAll(masterFaceCentres, facei)
87 masterFaceCentres[facei] =
100 label nNSquaredSearches = 0;
102 forAll(slavePointOrder, pointi)
105 const label curLocalPointLabel = slavePointOrder[pointi];
107 const PointType& curPoint =
108 points_[slaveMeshPoints[curLocalPointLabel]];
110 const PointType& curProjectionDir =
111 projectionDirection[curLocalPointLabel];
115 boolList visitedTargetFace(targetPatch.size(),
false);
116 bool doNSquaredSearch =
false;
118 bool foundEligible =
false;
120 scalar sqrDistance = GREAT;
126 doNSquaredSearch =
true;
133 doNSquaredSearch =
false;
137 masterFaces[curFace].ray
146 visitedTargetFace[curFace] =
true;
150 result[curLocalPointLabel] =
objectHit(
true, curFace);
162 foundEligible =
true;
163 result[curLocalPointLabel] =
objectHit(
false, curFace);
172 PointType missPlanePoint =
173 curPoint + curProjectionDir*curHit.
distance();
175 const labelList& masterNbrs = masterFaceFaces[curFace];
178 magSqr(missPlanePoint - masterFaceCentres[curFace]);
187 - masterFaceCentres[masterNbrs[nbrI]]
193 curFace = masterNbrs[nbrI];
197 if (visitedTargetFace[curFace])
201 doNSquaredSearch =
true;
212 doNSquaredSearch || !foundEligible
219 Info<<
"p " << curLocalPointLabel <<
": ";
222 result[curLocalPointLabel] =
objectHit(
false, -1);
223 scalar minDistance = GREAT;
225 forAll(masterFaces, facei)
228 masterFaces[facei].ray
239 result[curLocalPointLabel] =
objectHit(
true, facei);
250 if (missDist < minDistance)
252 minDistance = missDist;
254 result[curLocalPointLabel] =
objectHit(
false, facei);
262 Info<< result[curLocalPointLabel] <<
nl;
273 Info<<
nl <<
"Executed " << nNSquaredSearches
274 <<
" n-squared searches out of total of "
285 template<
class>
class FaceList,
289 template<
class ToPatch>
294 const ToPatch& targetPatch,
302 if (projectionDirection.size() != this->size())
305 <<
"Projection direction field does not correspond to patch faces."
306 <<
endl <<
"Size: " << projectionDirection.size()
307 <<
" Number of points: " << this->size()
316 const labelListList& masterFaceFaces = targetPatch.faceFaces();
318 const ToPatch& masterFaces = targetPatch;
320 const typename ToPatch::PointFieldType& masterPoints = targetPatch.points();
322 forAll(masterFaceCentres, facei)
324 masterFaceCentres[facei] =
325 masterFaces[facei].centre(masterPoints);
334 const PointField& slaveGlobalPoints =
points();
345 label nNSquaredSearches = 0;
347 forAll(slaveFaceOrder, facei)
350 const label curLocalFaceLabel = slaveFaceOrder[facei];
352 const point& curFaceCentre =
353 slaveFaces[curLocalFaceLabel].centre(slaveGlobalPoints);
355 const vector& curProjectionDir =
356 projectionDirection[curLocalFaceLabel];
360 boolList visitedTargetFace(targetPatch.size(),
false);
361 bool doNSquaredSearch =
false;
363 bool foundEligible =
false;
365 scalar sqrDistance = GREAT;
371 doNSquaredSearch =
true;
378 doNSquaredSearch =
false;
382 masterFaces[curFace].ray
391 visitedTargetFace[curFace] =
true;
395 result[curLocalFaceLabel] =
objectHit(
true, curFace);
407 foundEligible =
true;
408 result[curLocalFaceLabel] =
objectHit(
false, curFace);
416 PointType missPlanePoint =
417 curFaceCentre + curProjectionDir*curHit.
distance();
420 magSqr(missPlanePoint - masterFaceCentres[curFace]);
422 const labelList& masterNbrs = masterFaceFaces[curFace];
431 - masterFaceCentres[masterNbrs[nbrI]]
437 curFace = masterNbrs[nbrI];
441 if (visitedTargetFace[curFace])
445 doNSquaredSearch =
true;
454 if (doNSquaredSearch || !foundEligible)
460 Info<<
"p " << curLocalFaceLabel <<
": ";
463 result[curLocalFaceLabel] =
objectHit(
false, -1);
464 scalar minDistance = GREAT;
466 forAll(masterFaces, facei)
469 masterFaces[facei].ray
480 result[curLocalFaceLabel] =
objectHit(
true, facei);
491 if (missDist < minDistance)
493 minDistance = missDist;
495 result[curLocalFaceLabel] =
objectHit(
false, facei);
503 Info<< result[curLocalFaceLabel] <<
nl;
514 Info<<
nl <<
"Executed " << nNSquaredSearches
515 <<
" n-squared searches out of total of "
516 << this->size() <<
endl;