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 -------------------------------------------------------------------------------
11 License
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 Class
28  Foam::orientedSurface
29 
30 Description
31  Given point flip all faces such that normals point in same direction.
32 
33 SourceFiles
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 
46 namespace Foam
47 {
48 
49 // Forward Declarations
50 class triSurfaceSearch;
51 
52 /*---------------------------------------------------------------------------*\
53  Class orientedSurface Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 class orientedSurface
57 :
58  public triSurface
59 {
60 public:
61 
62  // Data types
63 
64  //- Enumeration listing whether face needs to be flipped.
65  enum sideStat
66  {
67  UNVISITED,
68  FLIP,
69  NOFLIP
70  };
71 
72 private:
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 
130 public:
131 
132  ClassName("orientedSurface");
133 
134 
135  // Constructors
136 
137  //- Default construct
138  orientedSurface();
139 
140  //- Construct from triSurface and sample point which is either
141  // outside (orientOutside = true) or inside (orientOutside = false).
142  // Uses orient.
144  (
145  const triSurface&,
146  const point& samplePoint,
147  const bool orientOutside = true
148  );
149 
150  //- Construct from triSurface. Calculates outside point as being
151  // outside the bounding box of the surface.
152  orientedSurface(const triSurface&, const bool orientOutside = true);
153 
154 
155  // Member Functions
156 
157  //- Flip faces such that normals are consistent with point:
158  // orientOutside=true : point outside surface
159  // orientOutside=false : point inside surface
160  // Bases orientation on normal on nearest point (linear search) and
161  // walks to rest. Surface needs to be manifold.
162  static bool orient(triSurface&, const point&, const bool orientOutside);
163 
164  //- Flip faces such that normals are consistent with point:
165  // orientOutside=true : point outside surface
166  // orientOutside=false : point inside surface
167  // Uses intersection count to orient. Handles open surfaces.
168  static bool orient
169  (
170  triSurface& s,
171  const triSurfaceSearch& querySurf,
172  const point& samplePoint,
173  const bool orientOutside
174  );
175 
176  //- Make sure surface has consistent orientation across connected
177  // triangles. Does not change anything if it has.
178  static bool orientConsistent(triSurface& s);
179 };
180 
181 
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 
184 } // End namespace Foam
185 
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187 
188 #endif
189 
190 // ************************************************************************* //
ClassName("orientedSurface")
static bool orient(triSurface &, const point &, const bool orientOutside)
Flip faces such that normals are consistent with point:
Given point flip all faces such that normals point in same direction.
orientedSurface()
Default construct.
Helper class to search on triSurface.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
static bool orientConsistent(triSurface &s)
Make sure surface has consistent orientation across connected.
Basic run-time type information using word as the type&#39;s name. Used to enhance the standard RTTI to c...
A subset of mesh faces organised as a primitive patch.
Definition: faceZone.H:60
Triangulated surface description with patch information.
Definition: triSurface.H:71
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.
sideStat
Enumeration listing whether face needs to be flipped.