insertSurfaceNearPointPairs.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) 2013-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 "CV2D.H"
27 
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
29 
30 void Foam::CV2D::insertSurfaceNearPointPairs()
31 {
32  Info<< "insertSurfaceNearPointPairs: ";
33 
34  label nNearPoints = 0;
35 
36  for
37  (
38  Triangulation::Finite_edges_iterator eit = finite_edges_begin();
39  eit != finite_edges_end();
40  eit++
41  )
42  {
43  Vertex_handle v0h = eit->first->vertex(cw(eit->second));
44  Vertex_handle v1h = eit->first->vertex(ccw(eit->second));
45 
46  if (v0h->ppMaster() && v1h->ppMaster())
47  {
48  point2DFromPoint v0(toPoint2D(v0h->point()));
49  point2DFromPoint v1(toPoint2D(v1h->point()));
50 
51  // Check that the two triangle vertices are further apart than the
52  // minimum cell size
53  if (magSqr(v1 - v0) > meshControls().minCellSize2())
54  {
55  point2D e0(toPoint2D(circumcenter(eit->first)));
56 
57  point2D e1
58  (
59  toPoint2D(circumcenter(eit->first->neighbor(eit->second)))
60  );
61 
62  // Calculate the length^2 of the edge normal to the surface
63  scalar edgeLen2 = magSqr(e0 - e1);
64 
65  if (edgeLen2 < meshControls().minNearPointDist2())
66  {
67  pointIndexHit pHit;
68  label hitSurface = -1;
69 
70  qSurf_.findSurfaceNearest
71  (
72  toPoint3D(e0),
73  meshControls().minEdgeLen2(),
74  pHit,
75  hitSurface
76  );
77 
78  if (pHit.hit())
79  {
80  vectorField norm(1);
81  qSurf_.geometry()[hitSurface].getNormal
82  (
83  List<pointIndexHit>(1, pHit),
84  norm
85  );
86 
87  insertPointPair
88  (
89  meshControls().ppDist(),
90  toPoint2D(pHit.hitPoint()),
91  toPoint2D(norm[0])
92  );
93 
94  nNearPoints++;
95 
96  // Correct the edge iterator for the change in the
97  // number of edges following the point-pair insertion
98  eit = Finite_edges_iterator
99  (
100  finite_edges_end().base(),
101  eit.predicate(),
102  eit.base()
103  );
104  }
105  }
106  }
107  }
108  }
109 
110  Info<< nNearPoints << " point-pairs inserted" << endl;
111 }
112 
113 
114 // ************************************************************************* //
const searchableSurfaces & geometry() const
Return reference to the searchableSurfaces object containing all.
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
vector2D point2D
Point2D is a vector.
Definition: point2D.H:41
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:256
point toPoint3D(const point2D &) const
Definition: CV2DI.H:141
const cv2DControls & meshControls() const
Definition: CV2DI.H:118
PointIndexHit< point > pointIndexHit
Definition: pointIndexHit.H:42
const point2D & toPoint2D(const point &) const
Definition: CV2DI.H:124
void findSurfaceNearest(const point &sample, scalar nearestDistSqr, pointIndexHit &surfHit, label &hitSurface) const
Find the nearest point to the sample and return it to the.
const point2D & point2DFromPoint
Definition: CV2D.H:354
dimensioned< scalar > magSqr(const dimensioned< Type > &)
messageStream Info
Field< vector > vectorField
Specialisation of Field<T> for vector.