50 Foam::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
135 void 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 " 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 224 List<vector2D> localVertices2D(localVertices.size());
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;
255 os.
write(localFaceCentres);
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,
353 referenceCS_(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),
374 nearestVertex_(
std::move(nearestVertex)),
375 nearestVertexWeight_(
std::move(nearestVertexWeight))
390 names[i] = times[i].name();
Base class for coordinate system specification, the default coordinate system type is cartesian ...
static wordList timeNames(const instantList ×)
Helper: extract words of times.
void size(const label n)
Older name for setAddressableSize.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static int myProcNo(label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
quaternion normalised(const quaternion &q)
Return the normalised (unit) quaternion of the given quaternion.
virtual const fileName & name() const override
Get the name of the output serial stream. (eg, the name of the Fstream file name) ...
Determine correspondence between points. See below.
#define forAll(list, i)
Loop across all elements in list.
A Cartesian coordinate system.
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.
vectorField pointField
pointField is a vectorField.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
#define DebugInFunction
Report an information message using Foam::Info.
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
int debug
Static debugging option.
defineTypeNameAndDebug(combustionModel, 0)
bool nearestOnly() const noexcept
Whether to use nearest point only (avoids triangulation, projection)
decomposeUsingBbs false
Use bounding boxes (default) or unique decomposition of triangles (i.e. do not duplicate triangles) ...
vector point
Point is a vector.
List< label > labelList
A List of labels.
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))
pointToPointPlanarInterpolation(const pointToPointPlanarInterpolation &)=default
Copy construct.
Type position(const Type &start, const Type &end)
Return a sample on the interval [start,end].
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
const volScalarField & p0
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)