40 template<
class>
class FaceList,
44 template<
class ToPatch>
49 const ToPatch& targetPatch,
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;
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;
135 masterFaces[curFace].ray
144 visitedTargetFace[curFace] =
true;
148 result[curLocalPointLabel] =
objectHit(
true, curFace);
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)
226 masterFaces[facei].ray
237 result[curLocalPointLabel] =
objectHit(
true, facei);
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,
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()
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);
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;
380 masterFaces[curFace].ray
389 visitedTargetFace[curFace] =
true;
393 result[curLocalFaceLabel] =
objectHit(
true, curFace);
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)
467 masterFaces[facei].ray
478 result[curLocalFaceLabel] =
objectHit(
true, facei);
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;
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void size(const label)
Override size to be inconsistent with allocated storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Point & missPoint() const
Return miss point.
A list of faces which address into the list of points.
The bandCompression function renumbers the addressing such that the band of the matrix is reduced...
bool hit() const
Is there a hit.
This class describes the interaction of a face and a point. It carries the info of a successful hit a...
errorManip< error > abort(error &err)
This class describes a combination of target object index and success flag.
List< objectHit > projectFaceCentres(const ToPatch &targetPatch, const Field< PointType > &projectionDirection, const intersection::algorithm=intersection::FULL_RAY, const intersection::direction=intersection::VECTOR) const
Project vertices of patch onto another patch.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
List< objectHit > projectPoints(const ToPatch &targetPatch, const Field< PointType > &projectionDirection, const intersection::algorithm=intersection::FULL_RAY, const intersection::direction=intersection::VECTOR) const
Project vertices of patch onto another patch.
labelList bandCompression(const labelListList &addressing)
Renumbers the addressing to reduce the band of the matrix.
tmp< GeometricField< Type, fvPatchField, volMesh > > average(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Area-weighted average a surfaceField creating a volField.
dimensioned< scalar > mag(const dimensioned< Type > &)
scalar distance() const
Return distance to hit.
bool eligibleMiss() const
Is this an eligible miss.