40 template<
class FromPatch,
class ToPatch>
41 void PatchToPatchInterpolation<FromPatch, ToPatch>::calcPointAddressing()
const 45 pointWeightsPtr_.reset(
new FieldField<Field, scalar>(toPatch_.nPoints()));
46 auto& pointWeights = *pointWeightsPtr_;
48 pointDistancePtr_.reset(
new scalarField(toPatch_.nPoints(), GREAT));
49 auto& pointDistance = *pointDistancePtr_;
51 const pointField& fromPatchPoints = fromPatch_.localPoints();
52 const auto& fromPatchFaces = fromPatch_.localFaces();
54 const pointField& toPatchPoints = toPatch_.localPoints();
55 const vectorField& projectionDirection = toPatch_.pointNormals();
56 const edgeList& toPatchEdges = toPatch_.edges();
57 const labelListList& toPatchPointEdges = toPatch_.pointEdges();
64 List<objectHit> proj =
65 toPatch_.projectPoints(fromPatch_, projectionDirection, alg_, dir_);
67 pointAddressingPtr_.reset(
new labelList(proj.size(), -1));
68 auto& pointAddressing = *pointAddressingPtr_;
70 bool doWeights =
false;
72 forAll(pointAddressing, pointi)
76 const auto& hitFace = fromPatchFaces[proj[pointi].hitObject()];
80 if (proj[pointi].hit())
85 pointAddressing[pointi] = proj[pointi].hitObject();
90 toPatchPoints[pointi],
91 projectionDirection[pointi],
100 pointDistance[pointi] =
101 hitFace.contactSphereDiameter
103 toPatchPoints[pointi],
104 projectionDirection[pointi],
110 pointDistance[pointi] = curHit.distance();
114 hitPoint = curHit.hitPoint();
116 else if (projectionTol_ > SMALL)
122 toPatchPoints[pointi],
123 projectionDirection[pointi],
132 toPatchPoints[pointi]
133 + projectionDirection[pointi]*ph.distance()
138 scalar minEdgeLength = GREAT;
142 fromPatchFaces[proj[pointi].hitObject()].edges();
144 forAll(hitFaceEdges, edgeI)
150 hitFaceEdges[edgeI].
mag(fromPatchPoints)
154 const labelList& curEdges = toPatchPointEdges[pointi];
162 toPatchEdges[curEdges[edgeI]].
mag(toPatchPoints)
166 if (dist < minEdgeLength*projectionTol_)
171 pointAddressing[pointi] = proj[pointi].hitObject();
174 hitPoint = ph.missPoint();
179 pointDistance[pointi] =
180 hitFace.contactSphereDiameter
182 toPatchPoints[pointi],
183 projectionDirection[pointi],
189 pointDistance[pointi] =
191 projectionDirection[pointi]
192 /
mag(projectionDirection[pointi])
194 & (hitPoint - toPatchPoints[pointi]);
204 hitFace.points(fromPatchPoints)
207 auto& pointiWeights =
208 pointWeights.emplace_set(pointi, hitFacePoints.size());
210 scalar sumWeight = 0;
212 forAll(hitFacePoints, masterPointi)
214 const point&
p = hitFacePoints[masterPointi];
218 1.0 / (hitPoint.dist(
p) + VSMALL)
221 pointiWeights[masterPointi] = w;
225 pointiWeights /= sumWeight;
229 pointWeights.emplace_set(pointi);
235 template<
class FromPatch,
class ToPatch>
236 void PatchToPatchInterpolation<FromPatch, ToPatch>::calcFaceAddressing()
const 238 faceWeightsPtr_.reset(
new FieldField<Field, scalar>(toPatch_.size()));
239 auto& faceWeights = *faceWeightsPtr_;
241 faceDistancePtr_.reset(
new scalarField(toPatch_.size(), GREAT));
242 auto& faceDistance = *faceDistancePtr_;
246 Info<<
"projecting face centres" <<
endl;
249 const pointField& fromPatchPoints = fromPatch_.points();
250 const auto& 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 auto& toPatchFaces = toPatch_;
264 const vectorField& projectionDirection = toPatch_.faceNormals();
266 List<objectHit> proj =
267 toPatch_.projectFaceCentres
275 faceAddressingPtr_.reset(
new labelList(proj.size(), -1));
276 auto& faceAddressing = *faceAddressingPtr_;
278 forAll(faceAddressing, facei)
280 if (proj[facei].hit())
283 faceAddressing[facei] = proj[facei].hitObject();
285 const auto& hitFace = fromPatchFaces[faceAddressing[facei]];
290 toPatchFaces[facei].centre(toPatchPoints),
291 projectionDirection[facei],
298 faceDistance[facei] = curHit.distance();
301 const point& hitFaceCentre =
302 fromPatchFaceCentres[faceAddressing[facei]];
306 fromPatchFaceFaces[faceAddressing[facei]];
308 const point& hitPoint = curHit.hitPoint();
310 scalar m = hitPoint.dist(hitFaceCentre);
315 || neighbours.empty()
318 auto& faceiWeights = faceWeights.emplace_set(facei, 1);
319 faceiWeights[0] = 1.0;
329 faceWeights.emplace_set(facei, neighbours.size() + 1);
331 faceiWeights[0] = 1.0/m;
333 scalar sumWeight = faceiWeights[0];
337 const point&
p = fromPatchFaceCentres[neighbours[nbri]];
341 1.0 / (hitPoint.dist(
p) + VSMALL)
344 faceWeights[nbri+1] = w;
348 faceiWeights /= sumWeight;
353 faceWeights.emplace_set(facei);
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
List< edge > edgeList
List of edge.
Ostream & endl(Ostream &os)
Add newline and flush stream.
List< labelList > labelListList
List of labelList.
#define forAll(list, i)
Loop across all elements in list.
vectorField pointField
pointField is a vectorField.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
int debug
Static debugging option.
vector point
Point is a vector.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Field< vector > vectorField
Specialisation of Field<T> for vector.
List< label > labelList
A List of labels.
PointHit< point > pointHit
A PointHit with a 3D point.
static constexpr const zero Zero
Global zero (0)