40 template<
class FaceList,
class Po
intField>
41 template<
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] =
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 " 270 template<
class FaceList,
class Po
intField>
271 template<
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()
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;
437 if (doNSquaredSearch || !foundEligible)
441 DebugInfo <<
"p " << curLocalFaceLabel <<
": ";
443 result[curLocalFaceLabel] =
objectHit(
false, -1);
444 scalar minDistance = GREAT;
446 forAll(masterFaces, facei)
449 masterFaces[facei].ray
460 result[curLocalFaceLabel] =
objectHit(
true, facei);
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;
std::remove_reference< PointField >::type::value_type point_type
The point type.
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.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
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.
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
tmp< GeometricField< Type, faPatchField, areaMesh > > average(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Area-weighted average a edgeField creating a areaField.
#define forAll(list, i)
Loop across all elements in list.
bool hit() const noexcept
Is there a hit.
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...
Generic templated field type.
Describes the interaction of a object and a (templated) point. It carries the info of a successful hi...
errorManip< error > abort(error &err)
This class describes a combination of target object index and success flag. Behaves somewhat like std...
#define DebugInfo
Report an information message using Foam::Info.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
scalar distance() const noexcept
Return distance to hit.
const point_type & point() const noexcept
Return the point, no checks.
bool eligibleMiss() const noexcept
Is this an eligible miss.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)