insertSurfaceNearPointPairs.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2013-2015 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*----------------------------------------------------------------------------*/
27 
28 #include "CV2D.H"
29 
30 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
31 
32 void Foam::CV2D::insertSurfaceNearPointPairs()
33 {
34  Info<< "insertSurfaceNearPointPairs: ";
35 
36  label nNearPoints = 0;
37 
38  for
39  (
40  Triangulation::Finite_edges_iterator eit = finite_edges_begin();
41  eit != finite_edges_end();
42  eit++
43  )
44  {
45  Vertex_handle v0h = eit->first->vertex(cw(eit->second));
46  Vertex_handle v1h = eit->first->vertex(ccw(eit->second));
47 
48  if (v0h->ppMaster() && v1h->ppMaster())
49  {
50  point2DFromPoint v0(toPoint2D(v0h->point()));
51  point2DFromPoint v1(toPoint2D(v1h->point()));
52 
53  // Check that the two triangle vertices are further apart than the
54  // minimum cell size
55  if (magSqr(v1 - v0) > meshControls().minCellSize2())
56  {
57  point2D e0(toPoint2D(circumcenter(eit->first)));
58 
59  point2D e1
60  (
61  toPoint2D(circumcenter(eit->first->neighbor(eit->second)))
62  );
63 
64  // Calculate the length^2 of the edge normal to the surface
65  scalar edgeLen2 = magSqr(e0 - e1);
66 
67  if (edgeLen2 < meshControls().minNearPointDist2())
68  {
69  pointIndexHit pHit;
70  label hitSurface = -1;
71 
72  qSurf_.findSurfaceNearest
73  (
74  toPoint3D(e0),
75  meshControls().minEdgeLen2(),
76  pHit,
77  hitSurface
78  );
79 
80  if (pHit.hit())
81  {
82  vectorField norm(1);
83  qSurf_.geometry()[hitSurface].getNormal
84  (
85  List<pointIndexHit>(1, pHit),
86  norm
87  );
88 
89  insertPointPair
90  (
91  meshControls().ppDist(),
92  toPoint2D(pHit.hitPoint()),
93  toPoint2D(norm[0])
94  );
95 
96  nNearPoints++;
97 
98  // Correct the edge iterator for the change in the
99  // number of edges following the point-pair insertion
100  eit = Finite_edges_iterator
101  (
102  finite_edges_end().base(),
103  eit.predicate(),
104  eit.base()
105  );
106  }
107  }
108  }
109  }
110  }
111 
112  Info<< nNearPoints << " point-pairs inserted" << endl;
113 }
114 
115 
116 // ************************************************************************* //
Foam::conformationSurfaces::findSurfaceNearest
void findSurfaceNearest(const point &sample, scalar nearestDistSqr, pointIndexHit &surfHit, label &hitSurface) const
Find the nearest point to the sample and return it to the.
Foam::CV2D::point2DFromPoint
const typedef point2D & point2DFromPoint
Definition: CV2D.H:356
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::vectorField
Field< vector > vectorField
Specialisation of Field<T> for vector.
Definition: primitiveFieldsFwd.H:54
Foam::magSqr
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
Foam::CV2D::toPoint2D
const point2D & toPoint2D(const Foam::point &) const
Definition: CV2DI.H:125
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::conformationSurfaces::geometry
const searchableSurfaces & geometry() const
Return reference to the searchableSurfaces object containing all.
Definition: conformationSurfacesI.H:30
Foam::point2D
vector2D point2D
Point2D is a vector.
Definition: point2D.H:43
Foam::pointIndexHit
PointIndexHit< point > pointIndexHit
A PointIndexHit for 3D points.
Definition: pointIndexHit.H:46
Foam::CV2D::meshControls
const cv2DControls & meshControls() const
Definition: CV2DI.H:119
Foam::CV2D::toPoint3D
Foam::point toPoint3D(const point2D &) const
Definition: CV2DI.H:142
CV2D.H