37 template<
class FromPatch,
class ToPatch>
38 scalar PatchToPatchInterpolation<FromPatch, ToPatch>::projectionTol_ = 0.05;
43 template<
class FromPatch,
class ToPatch>
44 void PatchToPatchInterpolation<FromPatch, ToPatch>::calcPointAddressing()
const 48 pointWeightsPtr_ =
new FieldField<Field, scalar>(toPatch_.nPoints());
49 FieldField<Field, scalar>& pointWeights = *pointWeightsPtr_;
51 pointDistancePtr_ =
new scalarField(toPatch_.nPoints(), great);
54 const pointField& fromPatchPoints = fromPatch_.localPoints();
55 const List<typename FromPatch::FaceType>& fromPatchFaces =
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();
68 List<objectHit> proj =
69 toPatch_.projectPoints(fromPatch_, projectionDirection, alg_, dir_);
71 pointAddressingPtr_ =
new labelList(proj.size(), -1);
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();
119 hitPoint = curHit.hitPoint();
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();
179 hitPoint = ph.missPoint();
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>
236 void PatchToPatchInterpolation<FromPatch, ToPatch>::calcFaceAddressing()
const 238 faceWeightsPtr_ =
new FieldField<Field, scalar>(toPatch_.size());
239 FieldField<Field, scalar>& faceWeights = *faceWeightsPtr_;
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();
266 List<objectHit> proj =
267 toPatch_.projectFaceCentres
275 faceAddressingPtr_ =
new labelList(proj.size(), -1);
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]];
309 scalar m =
mag(curHit.hitPoint() - hitFaceCentre);
314 || neighbours.empty()
318 faceWeights[facei][0] = 1.0;
326 faceWeights.set(facei,
new scalarField(neighbours.size() + 1));
328 faceWeights[facei][0] = 1.0/m;
332 faceWeights[facei][nI + 1] =
337 fromPatchFaceCentres[neighbours[nI]]
345 faceWeights[facei] /=
sum(faceWeights[facei]);
List< labelList > labelListList
A List of labelList.
#define forAll(list, i)
Loop across all elements in list.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
vectorField pointField
pointField is a vectorField.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
List< label > labelList
A List of labels.
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
vector point
Point is a vector.
dimensioned< scalar > mag(const dimensioned< Type > &)
Field< vector > vectorField
Specialisation of Field<T> for vector.
PointHit< point > pointHit
scalar distance() const
Return distance to hit.