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