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()
71 List<objectHit> result(
nPoints());
73 const labelListList& masterFaceFaces = targetPatch.faceFaces();
75 const ToPatch& masterFaces = targetPatch;
82 forAll(masterFaceCentres, facei)
84 masterFaceCentres[facei] =
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);
241 scalar missDist = curHit.
point().dist(curPoint);
243 if (missDist < minDistance)
245 minDistance = missDist;
247 result[curLocalPointLabel] =
objectHit(
false, facei);
262 <<
nl <<
"Executed " << nNSquaredSearches
263 <<
" n-squared searches out of total of "
270template<
class FaceList,
class Po
intField>
271template<
class ToPatch>
275 const ToPatch& targetPatch,
279 >& projectionDirection,
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()
295 labelList slaveFaceOrder = meshTools::bandCompression(faceFaces());
298 Field<point_type> masterFaceCentres(targetPatch.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);
313 List<objectHit> result(this->size());
315 const PrimitivePatch<FaceList, PointField>& slaveFaces = *
this;
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;
364 PointHit<point_type> curHit =
365 masterFaces[curFace].ray
374 visitedTargetFace[curFace] =
true;
378 result[curLocalFaceLabel] = objectHit(
true, curFace);
388 if (curHit.eligibleMiss())
390 foundEligible =
true;
391 result[curLocalFaceLabel] = objectHit(
false, curFace);
399 point_type missPlanePoint =
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;
437 if (doNSquaredSearch || !foundEligible)
441 DebugInfo <<
"p " << curLocalFaceLabel <<
": ";
443 result[curLocalFaceLabel] = objectHit(
false, -1);
444 scalar minDistance = GREAT;
446 forAll(masterFaces, facei)
448 PointHit<point_type> curHit =
449 masterFaces[facei].ray
460 result[curLocalFaceLabel] = objectHit(
true, facei);
465 else if (curHit.eligibleMiss())
468 scalar missDist = curHit.point().dist(curFaceCentre);
470 if (missDist < minDistance)
472 minDistance = missDist;
474 result[curLocalFaceLabel] = objectHit(
false, facei);
490 <<
"Executed " << nNSquaredSearches
491 <<
" n-squared searches out of total of "
492 << this->size() <<
endl;
The bandCompression function renumbers the addressing such that the band of the matrix is reduced....
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
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 object and a (templated) point. It carries the info of a successful hi...
bool eligibleMiss() const noexcept
Is this an eligible miss.
scalar distance() const noexcept
Return distance to hit.
bool hit() const noexcept
Is there a hit.
const point_type & point() const noexcept
Return the point, no checks.
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.
const labelList & meshPoints() const
const labelList & localPointOrder() const
PrimitivePatch(const List< face > &faces, const const pointField &points)
std::remove_reference< PointField >::type::value_type point_type
The point type.
const labelListList & faceFaces() const
List< objectHit > projectPoints(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.
const Vector< Cmpt > & centre(const Foam::UList< Vector< Cmpt > > &) const noexcept
Return this (for point which is a typedef to Vector<scalar>).
This class describes a combination of target object index and success flag. Behaves somewhat like std...
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define DebugInfo
Report an information message using Foam::Info.
List< labelList > labelListList
List of labelList.
List< label > labelList
A List of labels.
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
vector point
Point is a vector.
List< bool > boolList
A List of bools.
GeometricField< Type, pointPatchField, pointMesh > PointField
A point field for a given type.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &f1, const label comm)
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.