50 Foam::pointToPointPlanarInterpolation::calcCoordinateSystem
58 <<
"Only " <<
points.size() <<
" provided." <<
nl
59 <<
"Need at least three non-colinear points"
60 <<
" to be able to interpolate."
69 scalar maxDist = ROOTVSMALL;
71 for (label i = 1; i <
points.size(); i++)
87 <<
"Cannot find any point that is different from first point"
88 <<
p0 <<
". Are all your points coincident?"
98 for (label i = 1; i <
points.size(); i++)
105 scalar magE2 =
mag(e2);
117 <<
"Cannot find points that define a plane with a valid normal."
118 <<
nl <<
"Have so far points " <<
p0 <<
" and " << p1
119 <<
". Are all your points on a single line instead of a plane?"
126 <<
" Used points " <<
p0 <<
' ' <<
points[index1]
128 <<
" to define coordinate system with normal " <<
n <<
endl;
130 return coordSystem::cartesian
139 void Foam::pointToPointPlanarInterpolation::calcWeights
160 <<
"Did not find a corresponding sourcePoint for every face"
164 nearestVertex_.setSize(destPoints.size());
165 nearestVertexWeight_.setSize(destPoints.size());
168 nearestVertex_[i][0] = destToSource[i];
169 nearestVertex_[i][1] = -1;
170 nearestVertex_[i][2] = -1;
172 nearestVertexWeight_[i][0] = 1.0;
173 nearestVertexWeight_[i][1] = 0.0;
174 nearestVertexWeight_[i][2] = 0.0;
181 label v0 = nearestVertex_[i][0];
183 Pout<<
"For location " << destPoints[i]
184 <<
" sampling vertex " << v0
185 <<
" at:" << sourcePoints[v0]
186 <<
" distance:" <<
mag(sourcePoints[v0]-destPoints[i])
190 OBJstream str(
"destToSource.obj");
191 Pout<<
"pointToPointPlanarInterpolation::calcWeights :"
192 <<
" Dumping lines from face centres to original points to "
197 label v0 = nearestVertex_[i][0];
198 str.write(
linePointRef(destPoints[i], sourcePoints[v0]));
204 auto tlocalVertices = referenceCS_.localPosition(sourcePoints);
205 auto& localVertices = tlocalVertices.ref();
207 const boundBox bb(localVertices,
true);
208 const point bbMid(bb.centre());
211 <<
" Perturbing points with " << perturb_
212 <<
" fraction of a random position inside " << bb
213 <<
" to break any ties on regular meshes." <<
nl
225 List<vector2D> localVertices2D(localVertices.size());
228 localVertices2D[i][0] = localVertices[i][0];
229 localVertices2D[i][1] = localVertices[i][1];
234 auto tlocalFaceCentres = referenceCS_.localPosition(destPoints);
235 const pointField& localFaceCentres = tlocalFaceCentres();
239 Pout<<
"pointToPointPlanarInterpolation::calcWeights :"
240 <<
" Dumping triangulated surface to triangulation.stl" <<
endl;
241 s.write(
"triangulation.stl");
243 OBJstream str(
"localFaceCentres.obj");
244 Pout<<
"pointToPointPlanarInterpolation::calcWeights :"
245 <<
" Dumping face centres to " << str.
name() <<
endl;
247 forAll(localFaceCentres, i)
249 str.write(localFaceCentres[i]);
266 Pout<<
"source:" << i <<
" at:" << sourcePoints[i]
267 <<
" 2d:" << localVertices[i]
271 OBJstream str(
"stencil.obj");
272 Pout<<
"pointToPointPlanarInterpolation::calcWeights :"
273 <<
" Dumping stencil to " << str.
name() <<
endl;
277 label v0 = nearestVertex_[i][0];
278 label v1 = nearestVertex_[i][1];
279 label v2 = nearestVertex_[i][2];
281 Pout<<
"For location " << destPoints[i]
282 <<
" 2d:" << localFaceCentres[i]
283 <<
" sampling vertices" <<
nl
285 <<
" at:" << sourcePoints[v0]
286 <<
" weight:" << nearestVertexWeight_[i][0] <<
nl;
288 str.write(
linePointRef(destPoints[i], sourcePoints[v0]));
293 <<
" at:" << sourcePoints[v1]
294 <<
" weight:" << nearestVertexWeight_[i][1] <<
nl;
295 str.write(
linePointRef(destPoints[i], sourcePoints[v1]));
300 <<
" at:" << sourcePoints[v2]
301 <<
" weight:" << nearestVertexWeight_[i][2] <<
nl;
302 str.write(
linePointRef(destPoints[i], sourcePoints[v2]));
318 const scalar perturb,
319 const bool nearestOnly
323 nearestOnly_(nearestOnly),
325 nPoints_(sourcePoints.size())
329 referenceCS_ = calcCoordinateSystem(sourcePoints);
331 calcWeights(sourcePoints, destPoints);
345 referenceCS_(referenceCS),
346 nPoints_(sourcePoints.size())
348 calcWeights(sourcePoints, destPoints);
354 const scalar perturb,
355 const bool nearestOnly,
357 const label sourceSize,
363 nearestOnly_(nearestOnly),
364 referenceCS_(referenceCS),
365 nPoints_(sourceSize),
366 nearestVertex_(nearestVertex),
367 nearestVertexWeight_(nearestVertexWeight)
397 names[i] = times[i].name();
406 const label startSampleTime,
407 const scalar timeVal,
412 lo = startSampleTime;
415 for (label i = startSampleTime+1; i < times.size(); i++)
417 if (times[i].value() > timeVal)
438 if (lo < times.size()-1)
448 Pout<<
"findTime : Found time " << timeVal <<
" after"
449 <<
" index:" << lo <<
" time:" << times[lo].value()
454 Pout<<
"findTime : Found time " << timeVal <<
" inbetween"
455 <<
" index:" << lo <<
" time:" << times[lo].value()
456 <<
" and index:" << hi <<
" time:" << times[hi].value()