39 template<
class FromPatch,
class ToPatch>
40 scalar PatchToPatchInterpolation<FromPatch, ToPatch>::projectionTol_ = 0.05;
45 template<
class FromPatch,
class ToPatch>
46 void PatchToPatchInterpolation<FromPatch, ToPatch>::calcPointAddressing()
const
50 pointWeightsPtr_ =
new FieldField<Field, scalar>(toPatch_.nPoints());
51 FieldField<Field, scalar>& pointWeights = *pointWeightsPtr_;
53 pointDistancePtr_ =
new scalarField(toPatch_.nPoints(), GREAT);
56 const pointField& fromPatchPoints = fromPatch_.localPoints();
57 const List<typename FromPatch::FaceType>& fromPatchFaces =
58 fromPatch_.localFaces();
60 const pointField& toPatchPoints = toPatch_.localPoints();
61 const vectorField& projectionDirection = toPatch_.pointNormals();
62 const edgeList& toPatchEdges = toPatch_.edges();
63 const labelListList& toPatchPointEdges = toPatch_.pointEdges();
70 List<objectHit> proj =
71 toPatch_.projectPoints(fromPatch_, projectionDirection, alg_, dir_);
73 pointAddressingPtr_ =
new labelList(proj.size(), -1);
74 labelList& pointAddressing = *pointAddressingPtr_;
76 bool doWeights =
false;
78 forAll(pointAddressing, pointi)
82 const typename FromPatch::FaceType& hitFace =
83 fromPatchFaces[proj[pointi].hitObject()];
87 if (proj[pointi].hit())
92 pointAddressing[pointi] = proj[pointi].hitObject();
97 toPatchPoints[pointi],
98 projectionDirection[pointi],
107 pointDistance[pointi] =
108 hitFace.contactSphereDiameter
110 toPatchPoints[pointi],
111 projectionDirection[pointi],
117 pointDistance[pointi] = curHit.
distance();
121 hitPoint = curHit.hitPoint();
123 else if (projectionTol_ > SMALL)
129 toPatchPoints[pointi],
130 projectionDirection[pointi],
139 toPatchPoints[pointi]
140 + projectionDirection[pointi]*ph.distance()
145 scalar minEdgeLength = GREAT;
149 fromPatchFaces[proj[pointi].hitObject()].edges();
151 forAll(hitFaceEdges, edgeI)
157 hitFaceEdges[edgeI].
mag(fromPatchPoints)
161 const labelList& curEdges = toPatchPointEdges[pointi];
169 toPatchEdges[curEdges[edgeI]].
mag(toPatchPoints)
173 if (dist < minEdgeLength*projectionTol_)
178 pointAddressing[pointi] = proj[pointi].hitObject();
181 hitPoint = ph.missPoint();
186 pointDistance[pointi] =
187 hitFace.contactSphereDiameter
189 toPatchPoints[pointi],
190 projectionDirection[pointi],
196 pointDistance[pointi] =
198 projectionDirection[pointi]
199 /
mag(projectionDirection[pointi])
201 & (hitPoint - toPatchPoints[pointi]);
209 pointWeights.set(pointi,
new scalarField(hitFace.size()));
211 pointField hitFacePoints = hitFace.points(fromPatchPoints);
213 forAll(hitFacePoints, masterPointi)
215 pointWeights[pointi][masterPointi] =
220 hitFacePoints[masterPointi]
227 pointWeights[pointi] /=
sum(pointWeights[pointi]);
237 template<
class FromPatch,
class ToPatch>
238 void PatchToPatchInterpolation<FromPatch, ToPatch>::calcFaceAddressing()
const
240 faceWeightsPtr_ =
new FieldField<Field, scalar>(toPatch_.size());
241 FieldField<Field, scalar>& faceWeights = *faceWeightsPtr_;
243 faceDistancePtr_ =
new scalarField(toPatch_.size(), GREAT);
248 Info<<
"projecting face centres" <<
endl;
251 const pointField& fromPatchPoints = fromPatch_.points();
252 const typename FromPatch::FaceListType& fromPatchFaces = fromPatch_;
253 const labelListList& fromPatchFaceFaces = fromPatch_.faceFaces();
255 vectorField fromPatchFaceCentres(fromPatchFaces.size());
257 forAll(fromPatchFaceCentres, facei)
259 fromPatchFaceCentres[facei] =
260 fromPatchFaces[facei].centre(fromPatchPoints);
263 const pointField& toPatchPoints = toPatch_.points();
264 const typename ToPatch::FaceListType& toPatchFaces = toPatch_;
266 const vectorField& projectionDirection = toPatch_.faceNormals();
268 List<objectHit> proj =
269 toPatch_.projectFaceCentres
277 faceAddressingPtr_ =
new labelList(proj.size(), -1);
278 labelList& faceAddressing = *faceAddressingPtr_;
280 forAll(faceAddressing, facei)
282 if (proj[facei].hit())
285 faceAddressing[facei] = proj[facei].hitObject();
287 const typename FromPatch::FaceType& hitFace =
288 fromPatchFaces[faceAddressing[facei]];
293 toPatchFaces[facei].centre(toPatchPoints),
294 projectionDirection[facei],
301 faceDistance[facei] = curHit.
distance();
304 const point& hitFaceCentre =
305 fromPatchFaceCentres[faceAddressing[facei]];
309 fromPatchFaceFaces[faceAddressing[facei]];
311 scalar m =
mag(curHit.hitPoint() - hitFaceCentre);
316 || neighbours.empty()
320 faceWeights[facei][0] = 1.0;
328 faceWeights.set(facei,
new scalarField(neighbours.size() + 1));
330 faceWeights[facei][0] = 1.0/m;
334 faceWeights[facei][nI + 1] =
339 fromPatchFaceCentres[neighbours[nI]]
347 faceWeights[facei] /=
sum(faceWeights[facei]);