37 template<
class FaceList,
class Po
intField>
38 template<
class ToPatch>
42 const ToPatch& targetPatch,
53 <<
"Projection direction field does not correspond to "
54 <<
"patch points." <<
endl
55 <<
"Size: " << projectionDirection.
size()
56 <<
" Number of points: " <<
nPoints()
60 const labelList& slavePointOrder = localPointOrder();
62 const labelList& slaveMeshPoints = meshPoints();
67 const labelListList& masterFaceFaces = targetPatch.faceFaces();
69 const ToPatch& masterFaces = targetPatch;
76 forAll(masterFaceCentres, facei)
78 masterFaceCentres[facei] =
91 label nNSquaredSearches = 0;
93 forAll(slavePointOrder, pointi)
96 const label curLocalPointLabel = slavePointOrder[pointi];
99 points_[slaveMeshPoints[curLocalPointLabel]];
102 projectionDirection[curLocalPointLabel];
106 boolList visitedTargetFace(targetPatch.size(),
false);
107 bool doNSquaredSearch =
false;
109 bool foundEligible =
false;
111 scalar sqrDistance = great;
117 doNSquaredSearch =
true;
124 doNSquaredSearch =
false;
128 masterFaces[curFace].ray
137 visitedTargetFace[curFace] =
true;
141 result[curLocalPointLabel] =
objectHit(
true, curFace);
153 foundEligible =
true;
154 result[curLocalPointLabel] =
objectHit(
false, curFace);
164 curPoint + curProjectionDir*curHit.
distance();
166 const labelList& masterNbrs = masterFaceFaces[curFace];
169 magSqr(missPlanePoint - masterFaceCentres[curFace]);
178 - masterFaceCentres[masterNbrs[nbrI]]
184 curFace = masterNbrs[nbrI];
188 if (visitedTargetFace[curFace])
192 doNSquaredSearch =
true;
197 if (debug)
Info<<
".";
203 doNSquaredSearch || !foundEligible
210 Info<<
"p " << curLocalPointLabel <<
": ";
213 result[curLocalPointLabel] =
objectHit(
false, -1);
214 scalar minDistance = great;
216 forAll(masterFaces, facei)
219 masterFaces[facei].ray
230 result[curLocalPointLabel] =
objectHit(
true, facei);
241 if (missDist < minDistance)
243 minDistance = missDist;
245 result[curLocalPointLabel] =
objectHit(
false, facei);
253 Info<< result[curLocalPointLabel] <<
nl;
258 if (debug)
Info<<
"x";
264 Info<<
nl <<
"Executed " << nNSquaredSearches
265 <<
" n-squared searches out of total of "
273 template<
class FaceList,
class Po
intField>
274 template<
class ToPatch>
278 const ToPatch& targetPatch,
286 if (projectionDirection.
size() != this->size())
289 <<
"Projection direction field does not correspond to patch faces."
290 <<
endl <<
"Size: " << projectionDirection.
size()
291 <<
" Number of points: " << this->size()
300 const labelListList& masterFaceFaces = targetPatch.faceFaces();
302 const ToPatch& masterFaces = targetPatch;
304 const typename ToPatch::PointFieldType& masterPoints = targetPatch.points();
306 forAll(masterFaceCentres, facei)
308 masterFaceCentres[facei] =
309 masterFaces[facei].centre(masterPoints);
328 label nNSquaredSearches = 0;
330 forAll(slaveFaceOrder, facei)
333 const label curLocalFaceLabel = slaveFaceOrder[facei];
335 const point& curFaceCentre =
336 slaveFaces[curLocalFaceLabel].centre(slaveGlobalPoints);
338 const vector& curProjectionDir =
339 projectionDirection[curLocalFaceLabel];
343 boolList visitedTargetFace(targetPatch.size(),
false);
344 bool doNSquaredSearch =
false;
346 bool foundEligible =
false;
348 scalar sqrDistance = great;
354 doNSquaredSearch =
true;
361 doNSquaredSearch =
false;
365 masterFaces[curFace].ray
374 visitedTargetFace[curFace] =
true;
378 result[curLocalFaceLabel] =
objectHit(
true, curFace);
390 foundEligible =
true;
391 result[curLocalFaceLabel] =
objectHit(
false, curFace);
400 curFaceCentre + curProjectionDir*curHit.
distance();
403 magSqr(missPlanePoint - masterFaceCentres[curFace]);
405 const labelList& masterNbrs = masterFaceFaces[curFace];
414 - masterFaceCentres[masterNbrs[nbrI]]
420 curFace = masterNbrs[nbrI];
424 if (visitedTargetFace[curFace])
428 doNSquaredSearch =
true;
433 if (debug)
Info<<
".";
437 if (doNSquaredSearch || !foundEligible)
443 Info<<
"p " << curLocalFaceLabel <<
": ";
446 result[curLocalFaceLabel] =
objectHit(
false, -1);
447 scalar minDistance = great;
449 forAll(masterFaces, facei)
452 masterFaces[facei].ray
463 result[curLocalFaceLabel] =
objectHit(
true, facei);
474 if (missDist < minDistance)
476 minDistance = missDist;
478 result[curLocalFaceLabel] =
objectHit(
false, facei);
486 Info<< result[curLocalFaceLabel] <<
nl;
491 if (debug)
Info<<
"x";
497 Info<<
nl <<
"Executed " << nNSquaredSearches
498 <<
" n-squared searches out of total of "
499 << this->size() <<
endl;
#define forAll(list, i)
Loop across all elements in list.
The bandCompression function renumbers the addressing such that the band of the matrix is reduced....
void size(const label)
Override size to be inconsistent with allocated storage.
This class describes the interaction of a face and a point. It carries the info of a successful hit a...
scalar distance() const
Return distance to hit.
const Point & missPoint() const
Return miss point.
bool eligibleMiss() const
Is this an eligible miss.
bool hit() const
Is there a hit.
A list of faces which address into the list of points.
std::remove_reference< PointField >::type::value_type PointType
List< objectHit > projectPoints(const ToPatch &targetPatch, const Field< PointType > &projectionDirection, const intersection::algorithm=intersection::algorithm::fullRay, const intersection::direction=intersection::direction::vector) const
Project vertices of patch onto another patch.
List< objectHit > projectFaceCentres(const ToPatch &targetPatch, const Field< PointType > &projectionDirection, const intersection::algorithm=intersection::algorithm::fullRay, const intersection::direction=intersection::direction::vector) const
Project vertices of patch onto another patch.
This class describes a combination of target object index and success flag.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
tmp< VolField< Type > > average(const SurfaceField< Type > &ssf)
Area-weighted average a surfaceField creating a volField.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
labelList bandCompression(const labelListList &addressing)
Renumbers the addressing to reduce the band of the matrix.
dimensioned< scalar > mag(const dimensioned< Type > &)
dimensioned< scalar > magSqr(const dimensioned< Type > &)