FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

primitiveMeshCheckPointNearness.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include <OpenFOAM/primitiveMesh.H>
00027 #include <OpenFOAM/SortableList.H>
00028 
00029 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00030 
00031 bool Foam::primitiveMesh::checkPointNearness
00032 (
00033     const bool report,
00034     const scalar reportDistSqr,
00035     labelHashSet* setPtr
00036 ) const
00037 {
00038     const pointField& points = this->points();
00039 
00040     // Sort points
00041     SortableList<scalar> sortedMag(magSqr(points));
00042 
00043     label nClose = 0;
00044 
00045     for (label i = 1; i < sortedMag.size(); i++)
00046     {
00047         label pti = sortedMag.indices()[i];
00048 
00049         // Compare pti to any previous points with similar sortedMag
00050         for
00051         (
00052             label j = i-1;
00053             j >= 0 && (sortedMag[j] > sortedMag[i]-reportDistSqr);
00054             --j
00055         )
00056         {
00057             label prevPtI = sortedMag.indices()[j];
00058 
00059             if (magSqr(points[pti] - points[prevPtI]) < reportDistSqr)
00060             {
00062                 //const labelList& pEdges = pointEdges()[pti];
00063                 //
00064                 //bool connected = false;
00065                 //
00066                 //forAll(pEdges, pEdgei)
00067                 //{
00068                 //    if (edges()[pEdges[pEdgei]].otherVertex(prevPtI) != -1)
00069                 //    {
00070                 //        connected = true;
00071                 //        break;
00072                 //    }
00073                 //}
00074                 //
00075                 //if (!connected)
00076                 {
00077                     nClose++;
00078 
00079                     if (setPtr)
00080                     {
00081                         setPtr->insert(pti);
00082                         setPtr->insert(prevPtI);
00083                     }
00084                 }
00085             }
00086         }
00087     }
00088 
00089     reduce(nClose, sumOp<label>());
00090 
00091     if (nClose > 0)
00092     {
00093         if (report)
00094         {
00095             Info<< "  <<Points closer than " << Foam::sqrt(reportDistSqr)
00096                 << " together found, number: " << nClose
00097                 << endl;
00098         }
00099 
00100         return true;
00101     }
00102     else
00103     {
00104         return false;
00105     }
00106 }
00107 
00108 
00109 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines