50Foam::pointToPointPlanarInterpolation::calcCoordinateSystem
58 <<
"Need at least 3 non-collinear points for planar interpolation,"
59 <<
" but only had " <<
points.size() <<
" points" <<
nl
67 scalar maxDistSqr = ROOTVSMALL;
69 for (label i = 1; i <
points.size(); ++i)
73 if (maxDistSqr < mag2)
82 <<
"Cannot find any point that is different from first point"
83 <<
p0 <<
". Are all your points coincident?"
91 maxDistSqr = ROOTVSMALL;
92 for (label i = 1; i <
points.size(); i++)
97 e2.removeCollinear(e1);
99 const scalar mag2 =
magSqr(e2);
101 if (maxDistSqr < mag2)
111 <<
"Cannot find points that define a plane with a valid normal."
112 <<
nl <<
"Have so far points " <<
p0 <<
" and " <<
points[index1]
113 <<
". Are all your points on a single line instead of a plane?"
122 <<
" to define coordinate system with normal " <<
n <<
endl;
124 return coordSystem::cartesian
135void Foam::pointToPointPlanarInterpolation::calcWeights
156 <<
"Did not find a corresponding sourcePoint for every face"
160 nearestVertex_.resize(destPoints.size());
161 nearestVertexWeight_.resize(destPoints.size());
164 nearestVertex_[i][0] = destToSource[i];
165 nearestVertex_[i][1] = -1;
166 nearestVertex_[i][2] = -1;
168 nearestVertexWeight_[i][0] = 1.0;
169 nearestVertexWeight_[i][1] = 0.0;
170 nearestVertexWeight_[i][2] = 0.0;
177 label v0 = nearestVertex_[i][0];
179 Pout<<
"For location " << destPoints[i]
180 <<
" sampling vertex " << v0
181 <<
" at:" << sourcePoints[v0]
182 <<
" distance:" <<
mag(sourcePoints[v0]-destPoints[i])
190 Pout<<
"pointToPointPlanarInterpolation::calcWeights :"
191 <<
" Dumping lines from face centres to original points to "
192 << str.name() <<
endl;
196 const label v0 = nearestVertex_[i][0];
197 str.writeLine(destPoints[i], sourcePoints[v0]);
203 auto tlocalVertices = referenceCS_.localPosition(sourcePoints);
204 auto& localVertices = tlocalVertices.ref();
206 const boundBox bb(localVertices,
true);
207 const point bbMid(bb.centre());
210 <<
" Perturbing points with " << perturb_
211 <<
" fraction of a random position inside " << bb
212 <<
" to break any ties on regular meshes." <<
nl
227 localVertices2D[i][0] = localVertices[i][0];
228 localVertices2D[i][1] = localVertices[i][1];
233 auto tlocalFaceCentres = referenceCS_.localPosition(destPoints);
234 const pointField& localFaceCentres = tlocalFaceCentres();
243 Pout<<
"pointToPointPlanarInterpolation::calcWeights :"
244 <<
" Dumping triangulated surface to " << outName <<
endl;
252 Pout<<
"pointToPointPlanarInterpolation::calcWeights :"
253 <<
" Dumping face centres to " <<
os.
name() <<
endl;
271 Pout<<
"source:" << i <<
" at:" << sourcePoints[i]
272 <<
" 2d:" << localVertices[i]
280 Pout<<
"pointToPointPlanarInterpolation::calcWeights :"
281 <<
" Dumping stencil to " << str.name() <<
endl;
285 const label v0 = nearestVertex_[i][0];
286 const label v1 = nearestVertex_[i][1];
287 const label v2 = nearestVertex_[i][2];
289 Pout<<
"For location " << destPoints[i]
290 <<
" 2d:" << localFaceCentres[i]
291 <<
" sampling vertices" <<
nl
293 <<
" at:" << sourcePoints[v0]
294 <<
" weight:" << nearestVertexWeight_[i][0] <<
nl;
296 str.writeLine(destPoints[i], sourcePoints[v0]);
301 <<
" at:" << sourcePoints[v1]
302 <<
" weight:" << nearestVertexWeight_[i][1] <<
nl;
303 str.writeLine(destPoints[i], sourcePoints[v1]);
308 <<
" at:" << sourcePoints[v2]
309 <<
" weight:" << nearestVertexWeight_[i][2] <<
nl;
310 str.writeLine(destPoints[i], sourcePoints[v2]);
326 const scalar perturb,
327 const bool nearestOnly
331 nearestOnly_(nearestOnly),
333 nPoints_(sourcePoints.size())
337 referenceCS_ = calcCoordinateSystem(sourcePoints);
339 calcWeights(sourcePoints, destPoints);
345 const coordinateSystem& referenceCS,
354 nPoints_(sourcePoints.size())
356 calcWeights(sourcePoints, destPoints);
362 const scalar perturb,
363 const bool nearestOnly,
365 const label sourceSize,
371 nearestOnly_(nearestOnly),
372 referenceCS_(referenceCS),
373 nPoints_(sourceSize),
390 names[i] = times[i].name();
A 1D vector of objects of type <T> with a fixed length <N>.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
An OFstream that keeps track of vertices and provides convenience output methods for OBJ files.
virtual Ostream & write(const char c) override
Write character.
virtual const fileName & name() const override
Read/write access to the name of the stream.
Type position(const Type &start, const Type &end)
Return a sample on the interval [start,end].
void size(const label n)
Older name for setAddressableSize.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
A bounding box defined in terms of min/max extrema points.
A Cartesian coordinate system.
Base class for coordinate system specification, the default coordinate system type is cartesian .
A class for handling file names.
Interpolates between two sets of unstructured points using 2D Delaunay triangulation....
const List< FixedList< scalar, 3 > > & nearestVertexWeight() const noexcept
Interpolation factors to face centres of underlying patch.
static wordList timeNames(const instantList ×)
Helper: extract words of times.
label sourceSize() const noexcept
Number of source points.
bool nearestOnly() const noexcept
Whether to use nearest point only (avoids triangulation, projection).
const coordSystem::cartesian & referenceCS() const noexcept
Return the Cartesian reference coordinate system.
scalar perturb() const noexcept
Perturbation factor (for triangulation).
pointToPointPlanarInterpolation(const pointToPointPlanarInterpolation &)=default
Copy construct.
const List< FixedList< label, 3 > > & nearestVertex() const noexcept
Interpolation addressing to face centres of underlying patch.
Triangulated surface description with patch information.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
const volScalarField & p0
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.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))
Determine correspondence between points. See below.
#define DebugInFunction
Report an information message using Foam::Info.
Namespace for handling debugging switches.
List< word > wordList
List of word.
List< label > labelList
A List of labels.
quaternion normalised(const quaternion &q)
Return the normalised (unit) quaternion of the given quaternion.
List< instant > instantList
List of instants.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
vector point
Point is a vector.
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.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
vectorField pointField
pointField is a vectorField.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.