primitiveMeshCheckPointNearness.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | foam-extend: Open Source CFD
4  \\ / O peration | Version: 3.2
5  \\ / A nd | Web: http://www.foam-extend.org
6  \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9  This file is part of foam-extend.
10 
11  foam-extend 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 3 of the License, or (at your
14  option) any later version.
15 
16  foam-extend is distributed in the hope that it will be useful, but
17  WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "primitiveMesh.H"
27 #include "SortableList.H"
28 
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 
32 (
33  const bool report,
34  const scalar reportDistSqr,
35  labelHashSet* setPtr
36 ) const
37 {
38  const pointField& points = this->points();
39 
40  // Sort points
42 
43  label nClose = 0;
44 
45  for (label i = 1; i < sortedMag.size(); i++)
46  {
47  label pti = sortedMag.indices()[i];
48 
49  // Compare pti to any previous points with similar sortedMag
50  for
51  (
52  label j = i-1;
53  j >= 0 && (sortedMag[j] > sortedMag[i]-reportDistSqr);
54  --j
55  )
56  {
57  label prevPtI = sortedMag.indices()[j];
58 
59  if (magSqr(points[pti] - points[prevPtI]) < reportDistSqr)
60  {
61  // Commented out in 1.6.x. HJ, 17/Aug/2010
63  //const labelList& pEdges = pointEdges()[pti];
64  //
65  //bool connected = false;
66  //
67  //forAll(pEdges, pEdgei)
68  //{
69  // if (edges()[pEdges[pEdgei]].otherVertex(prevPtI) != -1)
70  // {
71  // connected = true;
72  // break;
73  // }
74  //}
75  //
76  //if (!connected)
77  {
78  nClose++;
79 
80  if (setPtr)
81  {
82  setPtr->insert(pti);
83  setPtr->insert(prevPtI);
84  }
85  }
86  }
87  }
88  }
89 
90  reduce(nClose, sumOp<label>());
91 
92  if (nClose > 0)
93  {
94  if (report)
95  {
96  Info<< " <<Points closer than " << Foam::sqrt(reportDistSqr)
97  << " together found, number: " << nClose
98  << endl;
99  }
100 
101  return true;
102  }
103  else
104  {
105  return false;
106  }
107 }
108 
109 
110 // ************************************************************************* //
Foam::primitiveMesh::checkPointNearness
bool checkPointNearness(const bool report, const scalar reportDistSqr, labelHashSet *setPtr=NULL) const
Check for point-point-nearness,.
Definition: primitiveMeshCheckPointNearness.C:32
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::HashSet< label, Hash< label > >
SortableList.H
Foam::reduce
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
Definition: PstreamReduceOps.H:43
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::Info
messageStream Info
Foam::SortableList
A list that is sorted upon construction or when explicitly requested with the sort() method.
Definition: List.H:65
Foam::sumOp
Definition: ops.H:162
Foam::sqrt
dimensionedScalar sqrt(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:142
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::HashSet::insert
bool insert(const Key &key)
Insert a new entry.
Definition: HashSet.H:116
Foam::SortableList::indices
const labelList & indices() const
Return the list of sorted indices. Updated every sort.
Definition: SortableList.H:90
Foam::magSqr
dimensioned< scalar > magSqr(const dimensioned< Type > &)