pointIndexHitList.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2018 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "pointIndexHitList.H"
27 
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29 
30 Foam::scalar Foam::minDist(const List<pointIndexHit>& hitList)
31 {
32  scalar minDist = GREAT;
33 
34  for (label hi1=0; hi1<hitList.size() - 1; ++hi1)
35  {
36  const pointIndexHit& pHit1 = hitList[hi1];
37 
38  if (pHit1.hit())
39  {
40  for (label hi2=hi1 + 1; hi2<hitList.size(); ++hi2)
41  {
42  const pointIndexHit& pHit2 = hitList[hi2];
43 
44  if (pHit2.hit())
45  {
46  minDist =
47  min(mag(pHit1.hitPoint() - pHit2.hitPoint()), minDist);
48  }
49  }
50  }
51  }
52 
53  return minDist;
54 }
55 
56 
57 // ************************************************************************* //
static const scalar GREAT
Definition: scalar.H:111
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
Definition: PointIndexHit.H:53
scalar minDist(const List< pointIndexHit > &hitList)
const Point & hitPoint() const
Return hit point.
bool hit() const
Is there a hit.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
dimensioned< scalar > mag(const dimensioned< Type > &)