Go to the documentation of this file.
30 #include "triSurface.H"
55 <<
"Only " <<
points.size() <<
" provided." <<
nl
56 <<
"Need at least three non-colinear points"
57 <<
" to be able to interpolate."
66 scalar maxDist = -GREAT;
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."
115 Info<<
"pointToPointPlanarInterpolation::calcCoordinateSystem :"
116 <<
" Used points " << p0 <<
' ' <<
points[index1]
118 <<
" to define coordinate system with normal " <<
n <<
endl;
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])
183 Pout<<
"pointToPointPlanarInterpolation::calcWeights :"
184 <<
" Dumping lines from face centres to original points to "
189 label v0 = nearestVertex_[i][0];
198 referenceCS_.localPosition(sourcePoints)
202 const boundBox bb(localVertices,
true);
207 Info<<
"pointToPointPlanarInterpolation::calcWeights :"
208 <<
" Perturbing points with " << perturb_
209 <<
" fraction of a random position inside " << bb
210 <<
" to break any ties on regular meshes."
226 localVertices2D[i][0] = localVertices[i][0];
227 localVertices2D[i][1] = localVertices[i][1];
230 triSurface s(triSurfaceTools::delaunay2D(localVertices2D));
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");
248 Pout<<
"pointToPointPlanarInterpolation::calcWeights :"
249 <<
" Dumping face centres to " << str.
name() <<
endl;
251 forAll(localFaceCentres, i)
253 str.
write(localFaceCentres[i]);
258 triSurfaceTools::calcInterpolationWeights
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 <<
" inbetween"
413 <<
" index:" << lo <<
" time:" << times[lo].value()
414 <<
" and index:" << hi <<
" time:" << times[hi].value()
Simple random number generator.
point midpoint() const
The midpoint of the bounding box.
const point & max() const
Maximum describing the bounding box.
OFstream which keeps track of vertices.
#define forAll(list, i)
Loop across all elements in list.
A class for managing temporary objects.
virtual Ostream & write(const char)
Write character.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< scalar > mag(const dimensioned< Type > &)
static bool findTime(const instantList ×, const label startSampleTime, const scalar timeVal, label &lo, label &hi)
Helper: find time. Return true if succesful.
Determine correspondence between points. See below.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Pre-declare SubField and related Field type.
Triangulated surface description with patch information.
const point & min() const
Minimum describing the bounding box.
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))
errorManipArg< error, int > exit(error &err, const int errNo=1)
line< point, const point & > linePointRef
Line using referred points.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
prefixOSstream Pout(cout, "Pout")
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
volScalarField scalarField(fieldObject, mesh)
void calcWeights(const pointField &sourcePoints, const pointField &destPoints)
Calculate addressing and weights.
A bounding box defined in terms of the points at its extremities.
const fileName & name() const
Return the name of the stream.
void size(const label)
Override size to be inconsistent with allocated storage.
defineTypeNameAndDebug(combustionModel, 0)
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.
coordinateSystem calcCoordinateSystem(const pointField &) const
Calculate a local coordinate system from set of points.
cachedRandom rndGen(label(0), -1)
static wordList timeNames(const instantList &)
Helper: extract words of times.
Base class for other coordinate system specifications.
pointToPointPlanarInterpolation(const pointField &sourcePoints, const pointField &destPoints, const scalar perturb, const bool nearestOnly=false)
Construct from 3D locations. Determines local coordinate system.