From b3bea42ada63ec1786a9d46cf05608397aa1d206 Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 22 Feb 2016 12:15:34 +0000 Subject: [PATCH] Migrated pointToPointPlanarInterpolation updates from old development line --- .../pointToPointPlanarInterpolation.C | 50 ++++++++++++++++++- .../pointToPointPlanarInterpolation.H | 29 ++++++++++- 2 files changed, 77 insertions(+), 2 deletions(-) diff --git a/src/meshTools/triSurface/triSurfaceTools/pointToPointPlanarInterpolation.C b/src/meshTools/triSurface/triSurfaceTools/pointToPointPlanarInterpolation.C index e61a40391e..b191f076a2 100644 --- a/src/meshTools/triSurface/triSurfaceTools/pointToPointPlanarInterpolation.C +++ b/src/meshTools/triSurface/triSurfaceTools/pointToPointPlanarInterpolation.C @@ -272,6 +272,10 @@ void Foam::pointToPointPlanarInterpolation::calcWeights << endl; } + OBJstream str("stencil.obj"); + Pout<< "pointToPointPlanarInterpolation::calcWeights :" + << " Dumping stencil to " << str.name() << endl; + forAll(destPoints, i) { label v0 = nearestVertex_[i][0]; @@ -285,17 +289,21 @@ void Foam::pointToPointPlanarInterpolation::calcWeights << " at:" << sourcePoints[v0] << " weight:" << nearestVertexWeight_[i][0] << nl; + str.write(linePointRef(destPoints[i], sourcePoints[v0])); + if (v1 != -1) { Pout<< " " << v1 << " at:" << sourcePoints[v1] << " weight:" << nearestVertexWeight_[i][1] << nl; + str.write(linePointRef(destPoints[i], sourcePoints[v1])); } if (v2 != -1) { Pout<< " " << v2 << " at:" << sourcePoints[v2] << " weight:" << nearestVertexWeight_[i][2] << nl; + str.write(linePointRef(destPoints[i], sourcePoints[v2])); } Pout<< endl; @@ -317,7 +325,10 @@ Foam::pointToPointPlanarInterpolation::pointToPointPlanarInterpolation : perturb_(perturb), nearestOnly_(nearestOnly), - referenceCS_(calcCoordinateSystem(sourcePoints)), + referenceCS_ + ( + nearestOnly ? coordinateSystem() : calcCoordinateSystem(sourcePoints) + ), nPoints_(sourcePoints.size()) { calcWeights(sourcePoints, destPoints); @@ -341,6 +352,43 @@ Foam::pointToPointPlanarInterpolation::pointToPointPlanarInterpolation } +Foam::pointToPointPlanarInterpolation::pointToPointPlanarInterpolation +( + const scalar perturb, + const bool nearestOnly, + const coordinateSystem& referenceCS, + const label sourceSize, + const List >& nearestVertex, + const List >& nearestVertexWeight +) +: + perturb_(perturb), + nearestOnly_(nearestOnly), + referenceCS_(referenceCS), + nPoints_(sourceSize), + nearestVertex_(nearestVertex), + nearestVertexWeight_(nearestVertexWeight) +{} + + +Foam::autoPtr +Foam::pointToPointPlanarInterpolation::clone() const +{ + return autoPtr + ( + new pointToPointPlanarInterpolation + ( + perturb_, + nearestOnly_, + referenceCS_, + nPoints_, + nearestVertex_, + nearestVertexWeight_ + ) + ); +} + + // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // Foam::wordList Foam::pointToPointPlanarInterpolation::timeNames diff --git a/src/meshTools/triSurface/triSurfaceTools/pointToPointPlanarInterpolation.H b/src/meshTools/triSurface/triSurfaceTools/pointToPointPlanarInterpolation.H index 85f6743485..ce468fcc02 100644 --- a/src/meshTools/triSurface/triSurfaceTools/pointToPointPlanarInterpolation.H +++ b/src/meshTools/triSurface/triSurfaceTools/pointToPointPlanarInterpolation.H @@ -73,6 +73,7 @@ class pointToPointPlanarInterpolation // patch List> nearestVertexWeight_; + // Private Member Functions //- Calculate a local coordinate system from set of points @@ -85,6 +86,7 @@ class pointToPointPlanarInterpolation const pointField& destPoints ); + public: // Declare name of the class and its debug switch @@ -114,9 +116,35 @@ public: const scalar perturb ); + //- Construct from components + pointToPointPlanarInterpolation + ( + const scalar perturb, + const bool nearestOnly, + const coordinateSystem& referenceCS, + const label sourceSize, + const List >& nearestVertex, + const List >& nearestVertexWeight + ); + + //- Construct and return a clone + autoPtr clone() const; + // Member Functions + //- Perturbation factor (for triangulation) + scalar perturb() const + { + return perturb_; + } + + //- Whether to use nearest point only (avoids triangulation, projection) + bool nearestOnly() const + { + return nearestOnly_; + } + //- Return the coordinateSystem const coordinateSystem& referenceCS() const { @@ -158,7 +186,6 @@ public: //- Interpolate from field on source points to dest points template tmp> interpolate(const Field& sourceFld) const; - };