40template<
class FaceList,
class Po
intField>
41template<
class ToPatch>
45 const ToPatch& targetPatch,
49 >& projectionDirection,
56 if (projectionDirection.size() !=
nPoints())
59 <<
"Projection direction field does not correspond to "
60 <<
"patch points." <<
endl
61 <<
"Size: " << projectionDirection.size()
62 <<
" Number of points: " <<
nPoints()
66 const labelList& slavePointOrder = localPointOrder();
68 const labelList& slaveMeshPoints = meshPoints();
73 const labelListList& masterFaceFaces = targetPatch.faceFaces();
75 const ToPatch& masterFaces = targetPatch;
82 forAll(masterFaceCentres, facei)
84 masterFaceCentres[facei] =
85 average(masterFaces[facei].
points(masterPoints));
97 label nNSquaredSearches = 0;
99 forAll(slavePointOrder, pointi)
102 const label curLocalPointLabel = slavePointOrder[pointi];
105 points_[slaveMeshPoints[curLocalPointLabel]];
108 projectionDirection[curLocalPointLabel];
112 boolList visitedTargetFace(targetPatch.size(),
false);
113 bool doNSquaredSearch =
false;
115 bool foundEligible =
false;
117 scalar sqrDistance = GREAT;
123 doNSquaredSearch =
true;
130 doNSquaredSearch =
false;
134 masterFaces[curFace].ray
143 visitedTargetFace[curFace] =
true;
147 result[curLocalPointLabel] =
objectHit(
true, curFace);
159 foundEligible =
true;
160 result[curLocalPointLabel] =
objectHit(
false, curFace);
170 curPoint + curProjectionDir*curHit.
distance();
172 const labelList& masterNbrs = masterFaceFaces[curFace];
175 magSqr(missPlanePoint - masterFaceCentres[curFace]);
184 - masterFaceCentres[masterNbrs[nbrI]]
190 curFace = masterNbrs[nbrI];
194 if (visitedTargetFace[curFace])
198 doNSquaredSearch =
true;
209 doNSquaredSearch || !foundEligible
214 DebugInfo <<
"p " << curLocalPointLabel <<
": ";
216 result[curLocalPointLabel] =
objectHit(
false, -1);
217 scalar minDistance = GREAT;
219 forAll(masterFaces, facei)
222 masterFaces[facei].ray
233 result[curLocalPointLabel] =
objectHit(
true, facei);
244 if (missDist < minDistance)
246 minDistance = missDist;
248 result[curLocalPointLabel] =
objectHit(
false, facei);
263 <<
nl <<
"Executed " << nNSquaredSearches
264 <<
" n-squared searches out of total of "
271template<
class FaceList,
class Po
intField>
272template<
class ToPatch>
276 const ToPatch& targetPatch,
280 >& projectionDirection,
287 if (projectionDirection.size() != this->size())
290 <<
"Projection direction field does not correspond to patch faces."
291 <<
endl <<
"Size: " << projectionDirection.size()
292 <<
" Number of points: " << this->size()
296 labelList slaveFaceOrder = meshTools::bandCompression(faceFaces());
301 const labelListList& masterFaceFaces = targetPatch.faceFaces();
303 const ToPatch& masterFaces = targetPatch;
305 const typename ToPatch::PointFieldType& masterPoints = targetPatch.points();
307 forAll(masterFaceCentres, facei)
309 masterFaceCentres[facei] =
310 masterFaces[facei].centre(masterPoints);
329 label nNSquaredSearches = 0;
331 forAll(slaveFaceOrder, facei)
334 const label curLocalFaceLabel = slaveFaceOrder[facei];
336 const point& curFaceCentre =
337 slaveFaces[curLocalFaceLabel].centre(slaveGlobalPoints);
339 const vector& curProjectionDir =
340 projectionDirection[curLocalFaceLabel];
344 boolList visitedTargetFace(targetPatch.size(),
false);
345 bool doNSquaredSearch =
false;
347 bool foundEligible =
false;
349 scalar sqrDistance = GREAT;
355 doNSquaredSearch =
true;
362 doNSquaredSearch =
false;
366 masterFaces[curFace].ray
375 visitedTargetFace[curFace] =
true;
379 result[curLocalFaceLabel] =
objectHit(
true, curFace);
391 foundEligible =
true;
392 result[curLocalFaceLabel] =
objectHit(
false, curFace);
401 curFaceCentre + curProjectionDir*curHit.
distance();
404 magSqr(missPlanePoint - masterFaceCentres[curFace]);
406 const labelList& masterNbrs = masterFaceFaces[curFace];
415 - masterFaceCentres[masterNbrs[nbrI]]
421 curFace = masterNbrs[nbrI];
425 if (visitedTargetFace[curFace])
429 doNSquaredSearch =
true;
438 if (doNSquaredSearch || !foundEligible)
442 DebugInfo <<
"p " << curLocalFaceLabel <<
": ";
444 result[curLocalFaceLabel] =
objectHit(
false, -1);
445 scalar minDistance = GREAT;
447 forAll(masterFaces, facei)
450 masterFaces[facei].ray
461 result[curLocalFaceLabel] =
objectHit(
true, facei);
472 if (missDist < minDistance)
474 minDistance = missDist;
476 result[curLocalFaceLabel] =
objectHit(
false, facei);
492 <<
"Executed " << nNSquaredSearches
493 <<
" n-squared searches out of total of "
494 << this->size() <<
endl;
The bandCompression function renumbers the addressing such that the band of the matrix is reduced....
Generic templated field type.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Describes the interaction of a face and a point. It carries the info of a successful hit and (if succ...
bool eligibleMiss() const noexcept
Is this an eligible miss.
scalar distance() const noexcept
Return distance to hit.
const point_type & missPoint() const
Return the miss point. Fatal if hit.
bool hit() const noexcept
Is there a hit.
A list of faces which address into the list of points.
List< objectHit > projectFaceCentres(const ToPatch &targetPatch, const Field< point_type > &projectionDirection, const intersection::algorithm=intersection::FULL_RAY, const intersection::direction=intersection::VECTOR) const
Project vertices of patch onto another patch.
std::remove_reference< PointField >::type::value_type point_type
The point type.
This class describes a combination of target object index and success flag. Behaves somewhat like std...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define DebugInfo
Report an information message using Foam::Info.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
errorManip< error > abort(error &err)
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.