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;
87 <<
"Cannot find any point that is different from first point"
88 <<
p0 <<
". Are all your points coincident?"
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?"
128 <<
" Used points " <<
p0 <<
' ' <<
points[index1]
130 <<
" to define coordinate system with normal " <<
n <<
endl;
133 return coordSystem::cartesian
142 void Foam::pointToPointPlanarInterpolation::calcWeights
163 <<
"Did not find a corresponding sourcePoint for every face"
167 nearestVertex_.setSize(destPoints.size());
168 nearestVertexWeight_.setSize(destPoints.size());
171 nearestVertex_[i][0] = destToSource[i];
172 nearestVertex_[i][1] = -1;
173 nearestVertex_[i][2] = -1;
175 nearestVertexWeight_[i][0] = 1.0;
176 nearestVertexWeight_[i][1] = 0.0;
177 nearestVertexWeight_[i][2] = 0.0;
184 label v0 = nearestVertex_[i][0];
186 Pout<<
"For location " << destPoints[i]
187 <<
" sampling vertex " << v0
188 <<
" at:" << sourcePoints[v0]
189 <<
" distance:" <<
mag(sourcePoints[v0]-destPoints[i])
193 OBJstream str(
"destToSource.obj");
194 Pout<<
"pointToPointPlanarInterpolation::calcWeights :"
195 <<
" Dumping lines from face centres to original points to "
200 label v0 = nearestVertex_[i][0];
201 str.write(
linePointRef(destPoints[i], sourcePoints[v0]));
207 auto tlocalVertices = referenceCS_.localPosition(sourcePoints);
208 auto& localVertices = tlocalVertices.ref();
210 const boundBox bb(localVertices,
true);
211 const point bbMid(bb.centre());
216 <<
" Perturbing points with " << perturb_
217 <<
" fraction of a random position inside " << bb
218 <<
" to break any ties on regular meshes."
231 List<vector2D> localVertices2D(localVertices.size());
234 localVertices2D[i][0] = localVertices[i][0];
235 localVertices2D[i][1] = localVertices[i][1];
240 auto tlocalFaceCentres = referenceCS_.localPosition(destPoints);
241 const pointField& localFaceCentres = tlocalFaceCentres();
245 Pout<<
"pointToPointPlanarInterpolation::calcWeights :"
246 <<
" Dumping triangulated surface to triangulation.stl" <<
endl;
247 s.write(
"triangulation.stl");
249 OBJstream str(
"localFaceCentres.obj");
250 Pout<<
"pointToPointPlanarInterpolation::calcWeights :"
251 <<
" Dumping face centres to " << str.
name() <<
endl;
253 forAll(localFaceCentres, i)
255 str.write(localFaceCentres[i]);
272 Pout<<
"source:" << i <<
" at:" << sourcePoints[i]
273 <<
" 2d:" << localVertices[i]
277 OBJstream str(
"stencil.obj");
278 Pout<<
"pointToPointPlanarInterpolation::calcWeights :"
279 <<
" Dumping stencil to " << str.
name() <<
endl;
283 label v0 = nearestVertex_[i][0];
284 label v1 = nearestVertex_[i][1];
285 label v2 = nearestVertex_[i][2];
287 Pout<<
"For location " << destPoints[i]
288 <<
" 2d:" << localFaceCentres[i]
289 <<
" sampling vertices" <<
nl
291 <<
" at:" << sourcePoints[v0]
292 <<
" weight:" << nearestVertexWeight_[i][0] <<
nl;
294 str.write(
linePointRef(destPoints[i], sourcePoints[v0]));
299 <<
" at:" << sourcePoints[v1]
300 <<
" weight:" << nearestVertexWeight_[i][1] <<
nl;
301 str.write(
linePointRef(destPoints[i], sourcePoints[v1]));
306 <<
" at:" << sourcePoints[v2]
307 <<
" weight:" << nearestVertexWeight_[i][2] <<
nl;
308 str.write(
linePointRef(destPoints[i], sourcePoints[v2]));
324 const scalar perturb,
325 const bool nearestOnly
329 nearestOnly_(nearestOnly),
331 nPoints_(sourcePoints.size())
335 referenceCS_ = calcCoordinateSystem(sourcePoints);
337 calcWeights(sourcePoints, destPoints);
351 referenceCS_(referenceCS),
352 nPoints_(sourcePoints.size())
354 calcWeights(sourcePoints, destPoints);
360 const scalar perturb,
361 const bool nearestOnly,
363 const label sourceSize,
369 nearestOnly_(nearestOnly),
370 referenceCS_(referenceCS),
371 nPoints_(sourceSize),
372 nearestVertex_(nearestVertex),
373 nearestVertexWeight_(nearestVertexWeight)
403 names[i] = times[i].name();
412 const label startSampleTime,
413 const scalar timeVal,
418 lo = startSampleTime;
421 for (
label i = startSampleTime+1; i < times.size(); i++)
423 if (times[i].value() > timeVal)
444 if (lo < times.size()-1)
454 Pout<<
"findTime : Found time " << timeVal <<
" after"
455 <<
" index:" << lo <<
" time:" << times[lo].value()
460 Pout<<
"findTime : Found time " << timeVal <<
" inbetween"
461 <<
" index:" << lo <<
" time:" << times[lo].value()
462 <<
" and index:" << hi <<
" time:" << times[hi].value()