37 template<
class FromPatch,
class ToPatch>
43 template<
class FromPatch,
class ToPatch>
51 pointDistancePtr_ =
new scalarField(toPatch_.nPoints(), GREAT);
54 const pointField& fromPatchPoints = fromPatch_.localPoints();
56 fromPatch_.localFaces();
58 const pointField& toPatchPoints = toPatch_.localPoints();
59 const vectorField& projectionDirection = toPatch_.pointNormals();
60 const edgeList& toPatchEdges = toPatch_.edges();
61 const labelListList& toPatchPointEdges = toPatch_.pointEdges();
69 toPatch_.projectPoints(fromPatch_, projectionDirection, alg_, dir_);
72 labelList& pointAddressing = *pointAddressingPtr_;
74 bool doWeights =
false;
76 forAll(pointAddressing, pointI)
80 const typename FromPatch::FaceType& hitFace =
81 fromPatchFaces[proj[pointI].hitObject()];
85 if (proj[pointI].hit())
90 pointAddressing[pointI] = proj[pointI].hitObject();
95 toPatchPoints[pointI],
96 projectionDirection[pointI],
105 pointDistance[pointI] =
106 hitFace.contactSphereDiameter
108 toPatchPoints[pointI],
109 projectionDirection[pointI],
115 pointDistance[pointI] = curHit.
distance();
121 else if (projectionTol_ > SMALL)
127 toPatchPoints[pointI],
128 projectionDirection[pointI],
137 toPatchPoints[pointI]
138 + projectionDirection[pointI]*ph.
distance()
143 scalar minEdgeLength = GREAT;
147 fromPatchFaces[proj[pointI].hitObject()].edges();
149 forAll(hitFaceEdges, edgeI)
155 hitFaceEdges[edgeI].
mag(fromPatchPoints)
159 const labelList& curEdges = toPatchPointEdges[pointI];
167 toPatchEdges[curEdges[edgeI]].
mag(toPatchPoints)
171 if (dist < minEdgeLength*projectionTol_)
176 pointAddressing[pointI] = proj[pointI].hitObject();
184 pointDistance[pointI] =
185 hitFace.contactSphereDiameter
187 toPatchPoints[pointI],
188 projectionDirection[pointI],
194 pointDistance[pointI] =
196 projectionDirection[pointI]
197 /
mag(projectionDirection[pointI])
199 & (hitPoint - toPatchPoints[pointI]);
207 pointWeights.set(pointI,
new scalarField(hitFace.size()));
209 pointField hitFacePoints = hitFace.points(fromPatchPoints);
211 forAll(hitFacePoints, masterPointI)
213 pointWeights[pointI][masterPointI] =
218 hitFacePoints[masterPointI]
225 pointWeights[pointI] /=
sum(pointWeights[pointI]);
235 template<
class FromPatch,
class ToPatch>
241 faceDistancePtr_ =
new scalarField(toPatch_.size(), GREAT);
246 Info<<
"projecting face centres" <<
endl;
249 const pointField& fromPatchPoints = fromPatch_.points();
250 const typename FromPatch::FaceListType& fromPatchFaces = fromPatch_;
251 const labelListList& fromPatchFaceFaces = fromPatch_.faceFaces();
253 vectorField fromPatchFaceCentres(fromPatchFaces.size());
255 forAll(fromPatchFaceCentres, faceI)
257 fromPatchFaceCentres[faceI] =
258 fromPatchFaces[faceI].centre(fromPatchPoints);
261 const pointField& toPatchPoints = toPatch_.points();
262 const typename ToPatch::FaceListType& toPatchFaces = toPatch_;
264 const vectorField& projectionDirection = toPatch_.faceNormals();
267 toPatch_.projectFaceCentres
276 labelList& faceAddressing = *faceAddressingPtr_;
278 forAll(faceAddressing, faceI)
280 if (proj[faceI].hit())
283 faceAddressing[faceI] = proj[faceI].hitObject();
285 const typename FromPatch::FaceType& hitFace =
286 fromPatchFaces[faceAddressing[faceI]];
291 toPatchFaces[faceI].centre(toPatchPoints),
292 projectionDirection[faceI],
299 faceDistance[faceI] = curHit.
distance();
302 const point& hitFaceCentre =
303 fromPatchFaceCentres[faceAddressing[faceI]];
307 fromPatchFaceFaces[faceAddressing[faceI]];
314 || neighbours.empty()
318 faceWeights[faceI][0] = 1.0;
328 faceWeights[faceI][0] = 1.0/m;
332 faceWeights[faceI][nI + 1] =
337 fromPatchFaceCentres[neighbours[nI]]
345 faceWeights[faceI] /=
sum(faceWeights[faceI]);