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]);
202 pointWeights.set(pointi,
new scalarField(hitFace.size()));
204 pointField hitFacePoints = hitFace.points(fromPatchPoints);
206 forAll(hitFacePoints, masterPointi)
208 pointWeights[pointi][masterPointi] =
211 hitPoint.dist(hitFacePoints[masterPointi])
216 pointWeights[pointi] /=
sum(pointWeights[pointi]);
226 template<
class FromPatch,
class ToPatch>
227 void PatchToPatchInterpolation<FromPatch, ToPatch>::calcFaceAddressing()
const 229 faceWeightsPtr_.reset(
new FieldField<Field, scalar>(toPatch_.size()));
230 auto& faceWeights = *faceWeightsPtr_;
232 faceDistancePtr_.reset(
new scalarField(toPatch_.size(), GREAT));
233 auto& faceDistance = *faceDistancePtr_;
237 Info<<
"projecting face centres" <<
endl;
240 const pointField& fromPatchPoints = fromPatch_.points();
241 const auto& fromPatchFaces = fromPatch_;
242 const labelListList& fromPatchFaceFaces = fromPatch_.faceFaces();
244 vectorField fromPatchFaceCentres(fromPatchFaces.size());
246 forAll(fromPatchFaceCentres, facei)
248 fromPatchFaceCentres[facei] =
249 fromPatchFaces[facei].centre(fromPatchPoints);
252 const pointField& toPatchPoints = toPatch_.points();
253 const auto& toPatchFaces = toPatch_;
255 const vectorField& projectionDirection = toPatch_.faceNormals();
257 List<objectHit> proj =
258 toPatch_.projectFaceCentres
266 faceAddressingPtr_.reset(
new labelList(proj.size(), -1));
267 auto& faceAddressing = *faceAddressingPtr_;
269 forAll(faceAddressing, facei)
271 if (proj[facei].hit())
274 faceAddressing[facei] = proj[facei].hitObject();
276 const auto& hitFace = fromPatchFaces[faceAddressing[facei]];
281 toPatchFaces[facei].centre(toPatchPoints),
282 projectionDirection[facei],
289 faceDistance[facei] = curHit.distance();
292 const point& hitFaceCentre =
293 fromPatchFaceCentres[faceAddressing[facei]];
297 fromPatchFaceFaces[faceAddressing[facei]];
299 scalar m = curHit.hitPoint().dist(hitFaceCentre);
304 || neighbours.empty()
308 faceWeights[facei][0] = 1.0;
316 faceWeights.set(facei,
new scalarField(neighbours.size() + 1));
318 faceWeights[facei][0] = 1.0/m;
322 faceWeights[facei][nI + 1] =
325 curHit.hitPoint().dist
327 fromPatchFaceCentres[neighbours[nI]]
334 faceWeights[facei] /=
sum(faceWeights[facei]);
List< labelList > labelListList
A List of labelList.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
std::enable_if< std::is_same< bool, TypeT >::value, bool >::type set(const label i, bool val=true)
A bitSet::set() method for a list of bool.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
#define forAll(list, i)
Loop across all elements in list.
vectorField pointField
pointField is a vectorField.
List< edge > edgeList
A List of edges.
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)