fixed writing out entries in advective bc
[OpenFOAM-1.6-ext.git] / src / OpenFOAM / meshes / primitiveMesh / primitiveMeshCheck / primitiveMeshCheckPointNearness.C
blob7fd911a39ec37471e10f67693e212bd8d8cfaa7a
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software; you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "primitiveMesh.H"
28 #include "SortableList.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 bool Foam::primitiveMesh::checkPointNearness
34     const bool report,
35     const scalar reportDistSqr,
36     labelHashSet* setPtr
37 ) const
39     const pointField& points = this->points();
41     // Sort points
42     SortableList<scalar> sortedMag(magSqr(points));
44     label nClose = 0;
46     for (label i = 1; i < sortedMag.size(); i++)
47     {
48         label pti = sortedMag.indices()[i];
50         // Compare pti to any previous points with similar sortedMag
51         for
52         (
53             label j = i-1;
54             j >= 0 && (sortedMag[j] > sortedMag[i]-reportDistSqr);
55             --j
56         )
57         {
58             label prevPtI = sortedMag.indices()[j];
60             if (magSqr(points[pti] - points[prevPtI]) < reportDistSqr)
61             {
62                 // Commented out in 1.6.x.  HJ, 17/Aug/2010
63                 //// Check if unconnected.
64                 //const labelList& pEdges = pointEdges()[pti];
65                 //
66                 //bool connected = false;
67                 //
68                 //forAll(pEdges, pEdgei)
69                 //{
70                 //    if (edges()[pEdges[pEdgei]].otherVertex(prevPtI) != -1)
71                 //    {
72                 //        connected = true;
73                 //        break;
74                 //    }
75                 //}
76                 //
77                 //if (!connected)
78                 {
79                     nClose++;
81                     if (setPtr)
82                     {
83                         setPtr->insert(pti);
84                         setPtr->insert(prevPtI);
85                     }
86                 }
87             }
88         }
89     }
91     reduce(nClose, sumOp<label>());
93     if (nClose > 0)
94     {
95         if (report)
96         {
97             Info<< "  <<Points closer than " << Foam::sqrt(reportDistSqr)
98                 << " together found, number: " << nClose
99                 << endl;
100         }
102         return true;
103     }
104     else
105     {
106         return false;
107     }
111 // ************************************************************************* //