orientedSurface.H
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) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2020 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
27Class
28 Foam::orientedSurface
29
30Description
31 Given point flip all faces such that normals point in same direction.
32
33SourceFiles
34 orientedSurface.C
35
36\*---------------------------------------------------------------------------*/
37
38#ifndef orientedSurface_H
39#define orientedSurface_H
40
41#include "triSurface.H"
42#include "typeInfo.H"
43
44// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45
46namespace Foam
47{
48
49// Forward Declarations
50class triSurfaceSearch;
51
52/*---------------------------------------------------------------------------*\
53 Class orientedSurface Declaration
54\*---------------------------------------------------------------------------*/
57:
58 public triSurface
59{
60public:
61
62 // Data types
63
64 //- Enumeration listing whether face needs to be flipped.
65 enum sideStat
66 {
68 FLIP,
70 };
71
72private:
73
74 // Private Member Functions
75
76 //- From changed faces get the changed edges
77 static labelList faceToEdge
78 (
79 const triSurface&,
80 const labelList& changedFaces
81 );
82
83 //- From changed edges check the orientation of the connected faces
84 // and flip them. Return changed faces.
85 static labelList edgeToFace
86 (
87 const triSurface&,
88 const labelList& changedEdges,
89 labelList& flip
90 );
91
92 //- Walk from face across connected faces. Change orientation to be
93 // consistent with startFacei.
94 static void walkSurface
95 (
96 const triSurface& s,
97 const label startFacei,
98 labelList& flipState
99 );
100
101 //- Given nearest point and face check orientation to nearest face
102 // and flip if necessary (only marked in flipState) and propagate.
103 static void propagateOrientation
104 (
105 const triSurface&,
106 const point& outsidePoint,
107 const bool orientOutside,
108 const label nearestFacei,
109 const point& nearestPt,
110 labelList& flipState
111 );
112
113 //- Find a face on zoneI and count number of intersections to determine
114 // orientation
115 static void findZoneSide
116 (
117 const triSurfaceSearch& surfSearches,
118 const labelList& faceZone,
119 const label zoneI,
120 const point& visiblePoint,
121 label& zoneFacei,
122 bool& isOutside
123 );
124
125 //- Given flipState reverse triangles of *this. Return true if
126 // anything flipped.
127 static bool flipSurface(triSurface& s, const labelList& flipState);
128
129 //- Make surface surface has consistent orientation across connected
130 // triangles.
131 static bool orientConsistent(triSurface& s);
132
133
134public:
136 ClassName("orientedSurface");
137
138
139 // Constructors
140
141 //- Default construct
143
144 //- Construct from triSurface and sample point which is either
145 // outside (orientOutside = true) or inside (orientOutside = false).
146 // Uses orient.
148 (
149 const triSurface&,
150 const point& samplePoint,
151 const bool orientOutside = true
152 );
153
154 //- Construct from triSurface. Calculates outside point as being
155 // outside the bounding box of the surface.
156 orientedSurface(const triSurface&, const bool orientOutside = true);
157
158
159 // Member Functions
160
161 //- Flip faces such that normals are consistent with point:
162 // orientOutside=true : point outside surface
163 // orientOutside=false : point inside surface
164 // Bases orientation on normal on nearest point (linear search) and
165 // walks to rest. Surface needs to be manifold.
166 static bool orient(triSurface&, const point&, const bool orientOutside);
167
168 //- Flip faces such that normals are consistent with point:
169 // orientOutside=true : point outside surface
170 // orientOutside=false : point inside surface
171 // Uses intersection count to orient. Handles open surfaces.
172 static bool orient
173 (
174 triSurface& s,
175 const triSurfaceSearch& querySurf,
176 const point& samplePoint,
177 const bool orientOutside
178 );
179};
180
181
182// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183
184} // End namespace Foam
185
186// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187
188#endif
189
190// ************************************************************************* //
A subset of mesh faces organised as a primitive patch.
Definition: faceZone.H:67
Given point flip all faces such that normals point in same direction.
static bool orient(triSurface &, const point &, const bool orientOutside)
Flip faces such that normals are consistent with point:
ClassName("orientedSurface")
orientedSurface()
Default construct.
sideStat
Enumeration listing whether face needs to be flipped.
Helper class to search on triSurface.
Triangulated surface description with patch information.
Definition: triSurface.H:79
#define ClassName(TypeNameString)
Add typeName information from argument TypeNameString to a class.
Definition: className.H:67
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Namespace for OpenFOAM.