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