47 Foam::pointToPointPlanarInterpolation::calcCoordinateSystem
52 if (points.size() < 3)
55 <<
"Only " << points.size() <<
" provided." <<
nl 56 <<
"Need at least three non-colinear points" 57 <<
" to be able to interpolate." 61 const point& p0 = points[0];
66 scalar maxDist = -great;
68 for (
label i = 1; i < points.size(); i++)
70 const vector d = points[i] - p0;
81 const point& p1 = points[index1];
85 for (
label i = 1; i < points.size(); i++)
89 const point& p2 = points[i];
92 scalar magE2 =
mag(e2);
104 <<
"Cannot find points that make valid normal." <<
nl 105 <<
"Have so far points " << p0 <<
" and " << p1
106 <<
"Need at least three points which are not in a line." 110 vector n = e1^(points[index2]-p0);
116 <<
" Used points " << p0 <<
' ' << points[index1]
117 <<
' ' << points[index2]
118 <<
" to define coordinate system with normal " << n <<
endl;
121 return coordinateSystem
131 void Foam::pointToPointPlanarInterpolation::calcWeights
152 <<
"Did not find a corresponding sourcePoint for every face" 156 nearestVertex_.setSize(destPoints.size());
157 nearestVertexWeight_.setSize(destPoints.size());
160 nearestVertex_[i][0] = destToSource[i];
161 nearestVertex_[i][1] = -1;
162 nearestVertex_[i][2] = -1;
164 nearestVertexWeight_[i][0] = 1.0;
165 nearestVertexWeight_[i][1] = 0.0;
166 nearestVertexWeight_[i][2] = 0.0;
173 label v0 = nearestVertex_[i][0];
175 Pout<<
"For location " << destPoints[i]
176 <<
" sampling vertex " << v0
177 <<
" at:" << sourcePoints[v0]
178 <<
" distance:" <<
mag(sourcePoints[v0]-destPoints[i])
182 OBJstream str(
"destToSource.obj");
183 Pout<<
"pointToPointPlanarInterpolation::calcWeights :" 184 <<
" Dumping lines from face centres to original points to " 189 label v0 = nearestVertex_[i][0];
190 str.write(
linePointRef(destPoints[i], sourcePoints[v0]));
196 tmp<vectorField> tlocalVertices
198 referenceCS_.localPosition(sourcePoints)
202 const boundBox bb(localVertices,
true);
203 const point bbMid(bb.midpoint());
208 <<
" Perturbing points with " << perturb_
209 <<
" fraction of a random position inside " << bb
210 <<
" to break any ties on regular meshes." 223 List<vector2D> localVertices2D(localVertices.size());
226 localVertices2D[i][0] = localVertices[i][0];
227 localVertices2D[i][1] = localVertices[i][1];
232 tmp<pointField> tlocalFaceCentres
234 referenceCS_.localPosition
239 const pointField& localFaceCentres = tlocalFaceCentres();
243 Pout<<
"pointToPointPlanarInterpolation::calcWeights :" 244 <<
" Dumping triangulated surface to triangulation.stl" <<
endl;
245 s.write(
"triangulation.stl");
247 OBJstream str(
"localFaceCentres.obj");
248 Pout<<
"pointToPointPlanarInterpolation::calcWeights :" 249 <<
" Dumping face centres to " << str.
name() <<
endl;
251 forAll(localFaceCentres, i)
253 str.write(localFaceCentres[i]);
270 Pout<<
"source:" << i <<
" at:" << sourcePoints[i]
271 <<
" 2d:" << localVertices[i]
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;
291 <<
" at:" << sourcePoints[v1]
292 <<
" weight:" << nearestVertexWeight_[i][1] <<
nl;
297 <<
" at:" << sourcePoints[v2]
298 <<
" weight:" << nearestVertexWeight_[i][2] <<
nl;
314 const scalar perturb,
315 const bool nearestOnly
319 nearestOnly_(nearestOnly),
320 referenceCS_(calcCoordinateSystem(sourcePoints)),
321 nPoints_(sourcePoints.
size())
323 calcWeights(sourcePoints, destPoints);
337 referenceCS_(referenceCS),
338 nPoints_(sourcePoints.
size())
340 calcWeights(sourcePoints, destPoints);
355 names[i] = times[i].name();
364 const label startSampleTime,
365 const scalar timeVal,
370 lo = startSampleTime;
373 for (
label i = startSampleTime+1; i < times.
size(); i++)
375 if (times[i].value() > timeVal)
396 if (lo < times.
size()-1)
406 Pout<<
"findTime : Found time " << timeVal <<
" after" 407 <<
" index:" << lo <<
" time:" << times[lo].value()
412 Pout<<
"findTime : Found time " << timeVal <<
" in between" 413 <<
" index:" << lo <<
" time:" << times[lo].value()
414 <<
" and index:" << hi <<
" time:" << times[hi].value()
Base class for other coordinate system specifications.
virtual const fileName & name() const
Return the name of the stream.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
errorManipArg< error, int > exit(error &err, const int errNo=1)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Type sampleAB(const Type &a, const Type &b)
Advance the state and return a sample of a given type from a.
void size(const label)
Override size to be inconsistent with allocated storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static wordList timeNames(const instantList &)
Helper: extract words of times.
Vector< scalar > vector
A scalar version of the templated Vector.
Determine correspondence between points. See below.
bool matchPoints(const UList< point > &pts0, const UList< point > &pts1, const UList< scalar > &matchDistance, const bool verbose, labelList &from0To1, const point &origin=point::zero)
Determine correspondence between pointFields. Gets passed.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
vectorField pointField
pointField is a vectorField.
line< point, const point & > linePointRef
Line using referred points.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
List< label > labelList
A List of labels.
static bool findTime(const instantList ×, const label startSampleTime, const scalar timeVal, label &lo, label &hi)
Helper: find time. Return true if successful.
defineTypeNameAndDebug(combustionModel, 0)
pointToPointPlanarInterpolation(const pointField &sourcePoints, const pointField &destPoints, const scalar perturb, const bool nearestOnly=false)
Construct from 3D locations. Determines local coordinate system.
vector point
Point is a vector.
prefixOSstream Pout(cout, "Pout")
dimensioned< scalar > mag(const dimensioned< Type > &)
Field< vector > vectorField
Specialisation of Field<T> for vector.
#define InfoInFunction
Report an information message using Foam::Info.