Commit 17a38cff authored by mattijs's avatar mattijs
Browse files

ENH: mergePoints: new API, now templated

parent 735dd361
......@@ -49,19 +49,17 @@ void Foam::meshDualiser::checkPolyTopoChange(const polyTopoChange& meshMod)
}
labelList oldToNew;
pointField newPoints;
bool hasMerged = mergePoints
label nUnique = mergePoints
(
points,
1E-6,
false,
oldToNew,
newPoints
oldToNew
);
if (hasMerged)
if (nUnique < points.size())
{
labelListList newToOld(invertOneToMany(newPoints.size(), oldToNew));
labelListList newToOld(invertOneToMany(nUnique, oldToNew));
forAll(newToOld, newI)
{
......@@ -225,17 +223,15 @@ Foam::label Foam::meshDualiser::addInternalFace
pointField facePoints(meshMod.points(), newFace);
labelList oldToNew;
pointField newPoints;
bool hasMerged = mergePoints
label nUnique = mergePoints
(
facePoints,
1E-6,
false,
oldToNew,
newPoints
oldToNew
);
if (hasMerged)
if (nUnique < facePoints.size())
{
FatalErrorIn("addInternalFace(..)")
<< "verts:" << verts << " newFace:" << newFace
......
......@@ -45,6 +45,7 @@ primitives/Tensor/lists/symmTensorList.C
primitives/Tensor/lists/tensorList.C
primitives/Vector/complexVector/complexVector.C
primitives/Vector/floatVector/floatVector.C
primitives/Vector/labelVector/labelVector.C
primitives/Vector/vector/vector.C
primitives/Vector/lists/vectorList.C
......@@ -501,7 +502,6 @@ meshes/treeBoundBox/treeBoundBox.C
meshTools = meshes/meshTools
$(meshTools)/matchPoints.C
$(meshTools)/mergePoints.C
fields/UniformDimensionedFields/uniformDimensionedFields.C
fields/cloud/cloud.C
......
......@@ -36,7 +36,6 @@ License
#include "removeCells.H"
#include "polyModifyFace.H"
#include "polyRemovePoint.H"
#include "mergePoints.H"
#include "mapDistributePolyMesh.H"
#include "surfaceFields.H"
#include "syncTools.H"
......
......@@ -1859,24 +1859,22 @@ Foam::Map<Foam::label> Foam::polyMeshAdder::findSharedPoints
);
labelList toMergedPoints;
pointField mergedPoints;
bool hasMerged = Foam::mergePoints
label nUnique = Foam::mergePoints
(
connectedPoints,
mergeDist,
false,
toMergedPoints,
mergedPoints
toMergedPoints
);
if (hasMerged)
if (nUnique < connectedPoints.size())
{
// Invert toMergedPoints
const labelListList mergeSets
(
invertOneToMany
(
mergedPoints.size(),
nUnique,
toMergedPoints
)
);
......@@ -1919,8 +1917,7 @@ Foam::Map<Foam::label> Foam::polyMeshAdder::findSharedPoints
//- Old: geometric merging. Causes problems for two close shared points.
//labelList sharedToMerged;
//pointField mergedPoints;
//bool hasMerged = Foam::mergePoints
//label nUnique = Foam::mergePoints
//(
// pointField
// (
......@@ -1929,8 +1926,7 @@ Foam::Map<Foam::label> Foam::polyMeshAdder::findSharedPoints
// ),
// mergeDist,
// false,
// sharedToMerged,
// mergedPoints
// sharedToMerged
//);
//
//// Find out which sets of points get merged and create a map from
......@@ -1938,7 +1934,7 @@ Foam::Map<Foam::label> Foam::polyMeshAdder::findSharedPoints
//
//Map<label> pointToMaster(10*sharedToMerged.size());
//
//if (hasMerged)
//if (nUnique < sharedPointLabels.size())
//{
// labelListList mergeSets
// (
......
......@@ -63,27 +63,26 @@ Foam::label Foam::autoSnapDriver::getCollocatedPoints
)
{
labelList pointMap;
pointField newPoints;
bool hasMerged = mergePoints
label nUnique = mergePoints
(
points, // points
tol, // mergeTol
false, // verbose
pointMap,
newPoints
pointMap
);
bool hasMerged = (nUnique < points.size());
if (!returnReduce(hasMerged, orOp<bool>()))
{
return 0;
}
// Determine which newPoints are referenced more than once
// Determine which merged points are referenced more than once
label nCollocated = 0;
// Per old point the newPoint. Or -1 (not set yet) or -2 (already seen
// twice)
labelList firstOldPoint(newPoints.size(), -1);
labelList firstOldPoint(nUnique, -1);
forAll(pointMap, oldPointI)
{
label newPointI = pointMap[oldPointI];
......
......@@ -2096,7 +2096,8 @@ Foam::triSurface Foam::triSurfaceTools::mergePoints
(
newTriangles,
surf.patches(),
newPoints
newPoints,
true //reuse storage
);
}
else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment