40template<
class FromPatch,
class ToPatch>
41scalar PatchToPatchInterpolation<FromPatch, ToPatch>::projectionTol_ = 0.05;
46template<
class FromPatch,
class ToPatch>
47void PatchToPatchInterpolation<FromPatch, ToPatch>::calcPointAddressing()
const
51 pointWeightsPtr_ =
new FieldField<Field, scalar>(toPatch_.nPoints());
52 FieldField<Field, scalar>& pointWeights = *pointWeightsPtr_;
54 pointDistancePtr_ =
new scalarField(toPatch_.nPoints(), GREAT);
57 const pointField& fromPatchPoints = fromPatch_.localPoints();
58 const List<typename FromPatch::face_type>& fromPatchFaces =
59 fromPatch_.localFaces();
61 const pointField& toPatchPoints = toPatch_.localPoints();
62 const vectorField& projectionDirection = toPatch_.pointNormals();
63 const edgeList& toPatchEdges = toPatch_.edges();
64 const labelListList& toPatchPointEdges = toPatch_.pointEdges();
71 List<objectHit> proj =
72 toPatch_.projectPoints(fromPatch_, projectionDirection, alg_, dir_);
74 pointAddressingPtr_ =
new labelList(proj.size(), -1);
75 labelList& pointAddressing = *pointAddressingPtr_;
77 bool doWeights =
false;
79 forAll(pointAddressing, pointi)
83 const typename FromPatch::face_type& hitFace =
84 fromPatchFaces[proj[pointi].hitObject()];
88 if (proj[pointi].hit())
93 pointAddressing[pointi] = proj[pointi].hitObject();
98 toPatchPoints[pointi],
99 projectionDirection[pointi],
108 pointDistance[pointi] =
109 hitFace.contactSphereDiameter
111 toPatchPoints[pointi],
112 projectionDirection[pointi],
118 pointDistance[pointi] = curHit.distance();
122 hitPoint = curHit.hitPoint();
124 else if (projectionTol_ > SMALL)
130 toPatchPoints[pointi],
131 projectionDirection[pointi],
140 toPatchPoints[pointi]
141 + projectionDirection[pointi]*ph.distance()
146 scalar minEdgeLength = GREAT;
150 fromPatchFaces[proj[pointi].hitObject()].edges();
152 forAll(hitFaceEdges, edgeI)
158 hitFaceEdges[edgeI].
mag(fromPatchPoints)
162 const labelList& curEdges = toPatchPointEdges[pointi];
170 toPatchEdges[curEdges[edgeI]].
mag(toPatchPoints)
174 if (dist < minEdgeLength*projectionTol_)
179 pointAddressing[pointi] = proj[pointi].hitObject();
182 hitPoint = ph.missPoint();
187 pointDistance[pointi] =
188 hitFace.contactSphereDiameter
190 toPatchPoints[pointi],
191 projectionDirection[pointi],
197 pointDistance[pointi] =
199 projectionDirection[pointi]
200 /
mag(projectionDirection[pointi])
202 & (hitPoint - toPatchPoints[pointi]);
210 pointWeights.set(pointi,
new scalarField(hitFace.size()));
212 pointField hitFacePoints = hitFace.points(fromPatchPoints);
214 forAll(hitFacePoints, masterPointi)
216 pointWeights[pointi][masterPointi] =
221 hitFacePoints[masterPointi]
228 pointWeights[pointi] /=
sum(pointWeights[pointi]);
238template<
class FromPatch,
class ToPatch>
239void PatchToPatchInterpolation<FromPatch, ToPatch>::calcFaceAddressing()
const
241 faceWeightsPtr_ =
new FieldField<Field, scalar>(toPatch_.size());
242 FieldField<Field, scalar>& faceWeights = *faceWeightsPtr_;
244 faceDistancePtr_ =
new scalarField(toPatch_.size(), GREAT);
249 Info<<
"projecting face centres" <<
endl;
252 const pointField& fromPatchPoints = fromPatch_.points();
253 const typename FromPatch::FaceListType& fromPatchFaces = fromPatch_;
254 const labelListList& fromPatchFaceFaces = fromPatch_.faceFaces();
256 vectorField fromPatchFaceCentres(fromPatchFaces.size());
258 forAll(fromPatchFaceCentres, facei)
260 fromPatchFaceCentres[facei] =
261 fromPatchFaces[facei].centre(fromPatchPoints);
264 const pointField& toPatchPoints = toPatch_.points();
265 const typename ToPatch::FaceListType& toPatchFaces = toPatch_;
267 const vectorField& projectionDirection = toPatch_.faceNormals();
269 List<objectHit> proj =
270 toPatch_.projectFaceCentres
278 faceAddressingPtr_ =
new labelList(proj.size(), -1);
279 labelList& faceAddressing = *faceAddressingPtr_;
281 forAll(faceAddressing, facei)
283 if (proj[facei].hit())
286 faceAddressing[facei] = proj[facei].hitObject();
288 const typename FromPatch::face_type& hitFace =
289 fromPatchFaces[faceAddressing[facei]];
294 toPatchFaces[facei].centre(toPatchPoints),
295 projectionDirection[facei],
302 faceDistance[facei] = curHit.distance();
305 const point& hitFaceCentre =
306 fromPatchFaceCentres[faceAddressing[facei]];
310 fromPatchFaceFaces[faceAddressing[facei]];
312 scalar m =
mag(curHit.hitPoint() - hitFaceCentre);
317 || neighbours.empty()
321 faceWeights[facei][0] = 1.0;
329 faceWeights.set(facei,
new scalarField(neighbours.size() + 1));
331 faceWeights[facei][0] = 1.0/m;
335 faceWeights[facei][nI + 1] =
340 fromPatchFaceCentres[neighbours[nI]]
348 faceWeights[facei] /=
sum(faceWeights[facei]);
List< label > labelList
A List of labels.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
messageStream Info
Information stream (stdout output on master, null elsewhere)
vectorField pointField
pointField is a vectorField.
vector point
Point is a vector.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
List< labelList > labelListList
A List of labelList.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
PointHit< point > pointHit
A PointIndexHit for 3D points.
Field< vector > vectorField
Specialisation of Field<T> for vector.
static constexpr const zero Zero
Global zero (0)
List< edge > edgeList
A List of edges.
#define forAll(list, i)
Loop across all elements in list.