/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . Description All to do with snapping to the surface \*----------------------------------------------------------------------------*/ #include "autoSnapDriver.H" #include "motionSmoother.H" #include "polyTopoChange.H" #include "syncTools.H" #include "fvMesh.H" #include "Time.H" #include "OFstream.H" #include "mapPolyMesh.H" #include "pointEdgePoint.H" #include "PointEdgeWave.H" #include "mergePoints.H" #include "snapParameters.H" #include "refinementSurfaces.H" #include "unitConversion.H" #include "localPointRegion.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { defineTypeNameAndDebug(autoSnapDriver, 0); } // End namespace Foam // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // Calculate geometrically collocated points, Requires PackedList to be // sized and initalised! Foam::label Foam::autoSnapDriver::getCollocatedPoints ( const scalar tol, const pointField& points, PackedBoolList& isCollocatedPoint ) { labelList pointMap; label nUnique = mergePoints ( points, // points tol, // mergeTol false, // verbose pointMap ); bool hasMerged = (nUnique < points.size()); if (!returnReduce(hasMerged, orOp())) { return 0; } // 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(nUnique, -1); forAll(pointMap, oldPointI) { label newPointI = pointMap[oldPointI]; if (firstOldPoint[newPointI] == -1) { // First use of oldPointI. Store. firstOldPoint[newPointI] = oldPointI; } else if (firstOldPoint[newPointI] == -2) { // Third or more reference of oldPointI -> non-manifold isCollocatedPoint.set(oldPointI, 1u); nCollocated++; } else { // Second reference of oldPointI -> non-manifold isCollocatedPoint.set(firstOldPoint[newPointI], 1u); nCollocated++; isCollocatedPoint.set(oldPointI, 1u); nCollocated++; // Mark with special value to save checking next time round firstOldPoint[newPointI] = -2; } } return returnReduce(nCollocated, sumOp