mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: mergePoints.C : enforce correct use of merge tolerance
This commit is contained in:
@ -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) 2004-2010 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -61,11 +61,26 @@ bool Foam::mergePoints
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We're comparing distance squared to origin first.
|
||||||
|
// Say if starting from two close points:
|
||||||
|
// x, y, z
|
||||||
|
// x+mergeTol, y+mergeTol, z+mergeTol
|
||||||
|
// Then the magSqr of both will be
|
||||||
|
// x^2+y^2+z^2
|
||||||
|
// x^2+y^2+z^2 + 2*mergeTol*(x+z+y) + mergeTol^2*...
|
||||||
|
// so the difference will be 2*mergeTol*(x+y+z)
|
||||||
|
|
||||||
const scalar mergeTolSqr = sqr(mergeTol);
|
const scalar mergeTolSqr = sqr(mergeTol);
|
||||||
|
|
||||||
// Sort points by magSqr
|
// Sort points by magSqr
|
||||||
SortableList<scalar> sortedMagSqr(magSqr(points - compareOrigin));
|
const pointField d(points - compareOrigin);
|
||||||
|
SortableList<scalar> sortedMagSqr(magSqr(d));
|
||||||
|
scalarField sortedTol(points.size());
|
||||||
|
forAll(sortedMagSqr.indices(), sortI)
|
||||||
|
{
|
||||||
|
const point& pt = d[sortedMagSqr.indices()[sortI]];
|
||||||
|
sortedTol[sortI] = 2*mergeTol*(mag(pt.x())+mag(pt.y())+mag(pt.z()));
|
||||||
|
}
|
||||||
|
|
||||||
bool hasMerged = false;
|
bool hasMerged = false;
|
||||||
|
|
||||||
@ -94,7 +109,7 @@ bool Foam::mergePoints
|
|||||||
(
|
(
|
||||||
sortedMagSqr[prevSortI]
|
sortedMagSqr[prevSortI]
|
||||||
- sortedMagSqr[sortI]
|
- sortedMagSqr[sortI]
|
||||||
) <= mergeTolSqr;
|
) <= sortedTol[sortI];
|
||||||
prevSortI--
|
prevSortI--
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user