mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: pointToPointPlanarInterpolation: additional nearest only interpolation
This commit is contained in:
@ -1,7 +1,9 @@
|
|||||||
EXE_INC = \
|
EXE_INC = \
|
||||||
-I$(LIB_SRC)/triSurface/lnInclude \
|
-I$(LIB_SRC)/triSurface/lnInclude \
|
||||||
|
-I$(LIB_SRC)/surfMesh/lnInclude \
|
||||||
-I$(LIB_SRC)/fileFormats/lnInclude
|
-I$(LIB_SRC)/fileFormats/lnInclude
|
||||||
|
|
||||||
LIB_LIBS = \
|
LIB_LIBS = \
|
||||||
-ltriSurface \
|
-ltriSurface \
|
||||||
|
-lsurfMesh \
|
||||||
-lfileFormats
|
-lfileFormats
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -29,8 +29,9 @@ License
|
|||||||
#include "vector2D.H"
|
#include "vector2D.H"
|
||||||
#include "triSurface.H"
|
#include "triSurface.H"
|
||||||
#include "triSurfaceTools.H"
|
#include "triSurfaceTools.H"
|
||||||
#include "OFstream.H"
|
#include "OBJstream.H"
|
||||||
#include "Time.H"
|
#include "Time.H"
|
||||||
|
#include "matchPoints.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -138,6 +139,65 @@ void Foam::pointToPointPlanarInterpolation::calcWeights
|
|||||||
const pointField& sourcePoints,
|
const pointField& sourcePoints,
|
||||||
const pointField& destPoints
|
const pointField& destPoints
|
||||||
)
|
)
|
||||||
|
{
|
||||||
|
if (nearestOnly_)
|
||||||
|
{
|
||||||
|
labelList destToSource;
|
||||||
|
bool fullMatch = matchPoints
|
||||||
|
(
|
||||||
|
destPoints,
|
||||||
|
sourcePoints,
|
||||||
|
scalarField(destPoints.size(), GREAT),
|
||||||
|
true, // verbose
|
||||||
|
destToSource
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!fullMatch)
|
||||||
|
{
|
||||||
|
FatalErrorIn("pointToPointPlanarInterpolation::calcWeights(..)")
|
||||||
|
<< "Did not find a corresponding sourcePoint for every face"
|
||||||
|
<< " centre" << exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
nearestVertex_.setSize(destPoints.size());
|
||||||
|
nearestVertexWeight_.setSize(destPoints.size());
|
||||||
|
forAll(nearestVertex_, i)
|
||||||
|
{
|
||||||
|
nearestVertex_[i][0] = destToSource[i];
|
||||||
|
nearestVertex_[i][1] = -1;
|
||||||
|
nearestVertex_[i][2] = -1;
|
||||||
|
|
||||||
|
nearestVertexWeight_[i][0] = 1.0;
|
||||||
|
nearestVertexWeight_[i][1] = 0.0;
|
||||||
|
nearestVertexWeight_[i][2] = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
forAll(destPoints, i)
|
||||||
|
{
|
||||||
|
label v0 = nearestVertex_[i][0];
|
||||||
|
|
||||||
|
Pout<< "For location " << destPoints[i]
|
||||||
|
<< " sampling vertex " << v0
|
||||||
|
<< " at:" << sourcePoints[v0]
|
||||||
|
<< " distance:" << mag(sourcePoints[v0]-destPoints[i])
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
OBJstream str("destToSource.obj");
|
||||||
|
Pout<< "pointToPointPlanarInterpolation::calcWeights :"
|
||||||
|
<< " Dumping lines from face centres to original points to "
|
||||||
|
<< str.name() << endl;
|
||||||
|
|
||||||
|
forAll(destPoints, i)
|
||||||
|
{
|
||||||
|
label v0 = nearestVertex_[i][0];
|
||||||
|
str.write(linePointRef(destPoints[i], sourcePoints[v0]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
tmp<vectorField> tlocalVertices
|
tmp<vectorField> tlocalVertices
|
||||||
(
|
(
|
||||||
@ -150,7 +210,7 @@ void Foam::pointToPointPlanarInterpolation::calcWeights
|
|||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Info<< "pointToPointPlanarInterpolation::readData :"
|
Info<< "pointToPointPlanarInterpolation::calcWeights :"
|
||||||
<< " Perturbing points with " << perturb_
|
<< " Perturbing points with " << perturb_
|
||||||
<< " fraction of a random position inside " << bb
|
<< " fraction of a random position inside " << bb
|
||||||
<< " to break any ties on regular meshes."
|
<< " to break any ties on regular meshes."
|
||||||
@ -186,18 +246,17 @@ void Foam::pointToPointPlanarInterpolation::calcWeights
|
|||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Pout<< "pointToPointPlanarInterpolation::readData :"
|
Pout<< "pointToPointPlanarInterpolation::calcWeights :"
|
||||||
<<" Dumping triangulated surface to triangulation.stl" << endl;
|
<<" Dumping triangulated surface to triangulation.stl" << endl;
|
||||||
s.write("triangulation.stl");
|
s.write("triangulation.stl");
|
||||||
|
|
||||||
OFstream str("localFaceCentres.obj");
|
OBJstream str("localFaceCentres.obj");
|
||||||
Pout<< "readSamplePoints :"
|
Pout<< "pointToPointPlanarInterpolation::calcWeights :"
|
||||||
<< " Dumping face centres to " << str.name() << endl;
|
<< " Dumping face centres to " << str.name() << endl;
|
||||||
|
|
||||||
forAll(localFaceCentres, i)
|
forAll(localFaceCentres, i)
|
||||||
{
|
{
|
||||||
const point& p = localFaceCentres[i];
|
str.write(localFaceCentres[i]);
|
||||||
str<< "v " << p.x() << ' ' << p.y() << ' ' << p.z() << nl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,7 +278,6 @@ void Foam::pointToPointPlanarInterpolation::calcWeights
|
|||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
forAll(destPoints, i)
|
forAll(destPoints, i)
|
||||||
{
|
{
|
||||||
label v0 = nearestVertex_[i][0];
|
label v0 = nearestVertex_[i][0];
|
||||||
@ -250,6 +308,7 @@ void Foam::pointToPointPlanarInterpolation::calcWeights
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
@ -258,13 +317,14 @@ Foam::pointToPointPlanarInterpolation::pointToPointPlanarInterpolation
|
|||||||
(
|
(
|
||||||
const pointField& sourcePoints,
|
const pointField& sourcePoints,
|
||||||
const pointField& destPoints,
|
const pointField& destPoints,
|
||||||
const scalar perturb
|
const scalar perturb,
|
||||||
|
const bool nearestOnly
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
perturb_(perturb),
|
perturb_(perturb),
|
||||||
|
nearestOnly_(nearestOnly),
|
||||||
referenceCS_(calcCoordinateSystem(sourcePoints)),
|
referenceCS_(calcCoordinateSystem(sourcePoints)),
|
||||||
nPoints_(sourcePoints.size())
|
nPoints_(sourcePoints.size())
|
||||||
|
|
||||||
{
|
{
|
||||||
calcWeights(sourcePoints, destPoints);
|
calcWeights(sourcePoints, destPoints);
|
||||||
}
|
}
|
||||||
@ -279,6 +339,7 @@ Foam::pointToPointPlanarInterpolation::pointToPointPlanarInterpolation
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
perturb_(perturb),
|
perturb_(perturb),
|
||||||
|
nearestOnly_(false),
|
||||||
referenceCS_(referenceCS),
|
referenceCS_(referenceCS),
|
||||||
nPoints_(sourcePoints.size())
|
nPoints_(sourcePoints.size())
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -56,6 +56,9 @@ class pointToPointPlanarInterpolation
|
|||||||
//- Perturbation factor
|
//- Perturbation factor
|
||||||
const scalar perturb_;
|
const scalar perturb_;
|
||||||
|
|
||||||
|
//- Whether to use nearest point only (avoids triangulation, projection)
|
||||||
|
const bool nearestOnly_;
|
||||||
|
|
||||||
//- Coordinate system
|
//- Coordinate system
|
||||||
coordinateSystem referenceCS_;
|
coordinateSystem referenceCS_;
|
||||||
|
|
||||||
@ -91,12 +94,15 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from 3D locations. Determines local coordinate system
|
//- Construct from 3D locations. Determines local coordinate system
|
||||||
// from sourcePoints and maps onto that.
|
// from sourcePoints and maps onto that. If nearestOnly skips any
|
||||||
|
// local coordinate system and triangulation and uses nearest vertex
|
||||||
|
// only
|
||||||
pointToPointPlanarInterpolation
|
pointToPointPlanarInterpolation
|
||||||
(
|
(
|
||||||
const pointField& sourcePoints,
|
const pointField& sourcePoints,
|
||||||
const pointField& destPoints,
|
const pointField& destPoints,
|
||||||
const scalar perturb
|
const scalar perturb,
|
||||||
|
const bool nearestOnly = false
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Construct from coordinate system and locations.
|
//- Construct from coordinate system and locations.
|
||||||
|
|||||||
Reference in New Issue
Block a user