edgeFaceCirculator.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-2017 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 Class
27  Foam::edgeFaceCirculator
28 
29 Description
30  Walks from starting face around edge.
31 
32  Implicit description of edge:
33  - face
34  - index in face. edge is always between f[index] and f[index+1]
35  - direction (cell to walk into)
36 
37  -# Use in-place: \n
38  \code
39  edgeFaceCirculator circ(..);
40  // Optionally rotate to beginning: circ.setCanonical();
41 
42  // Walk
43  do
44  {
45  Info<< "face:" << circ.face() << endl;
46  ++circ;
47  }
48  while (circ != circ.end());
49  \endcode
50 
51  -# Use like STL iterator: \n
52  \code
53  edgeFaceCirculator circ(..);
54  for
55  (
56  edgeFaceCirculator iter = circ.begin();
57  iter != circ.end();
58  ++iter
59  )
60  {
61  Info<< "face:" << iter.face() << endl;
62  }
63  \endcode
64 
65 
66 SourceFiles
67  edgeFaceCirculator.C
68 
69 \*---------------------------------------------------------------------------*/
70 
71 #ifndef edgeFaceCirculator_H
72 #define edgeFaceCirculator_H
73 
74 #include "face.H"
75 #include "ListOps.H"
76 
77 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
78 
79 namespace Foam
80 {
81 
82 // Forward declaration of classes
83 class primitiveMesh;
84 
85 /*---------------------------------------------------------------------------*\
86  Class edgeFaceCirculator Declaration
87 \*---------------------------------------------------------------------------*/
88 
90 {
91  // Private Member Data
92 
93  //- The underlying mesh pointer
94  const primitiveMesh* meshPtr_;
95 
96  //- Current face
97  label faceLabel_;
98 
99  //- Current side of face
100  bool ownerSide_;
101 
102  //- Edge (between index and index+1 on faces[faceLabel_]
103  label index_;
104 
105  //- Is boundary edge?
106  bool isBoundaryEdge_;
107 
108  //- Starting face so we know when to stop. Used when circulating over
109  // internal edges.
110  label startFaceLabel_;
111 
112 
113  // Private Member Functions
114 
115  //- The underlying mesh
116  inline const primitiveMesh& mesh() const;
117 
118  //- Set to end() iterator
119  inline void setEnd();
120 
121  //- Check and set faceLabel_ and ownerSide_
122  inline void setFace(const label facei, const label celli);
123 
124  //- Set faceLabel_ to be the other face on the cell that uses the edge.
125  inline void otherFace(const label celli);
126 
127  //- Construct null - this is also an end iterator
128  inline edgeFaceCirculator();
129 
130 
131 public:
132 
133  // Constructors
134 
135  //- Construct from components
136  inline edgeFaceCirculator
137  (
138  const primitiveMesh& mesh,
139  const label faceLabel,
140  const bool ownerSide,
141  const label index,
142  const bool isBoundaryEdge
143  );
144 
145  //- Construct as copy
146  inline edgeFaceCirculator(const edgeFaceCirculator& circ);
147 
148 
149  // Member Functions
150 
151  //- Helper: find index in face of edge or -1. Index is such that edge is
152  // between f[index] and f[index+1]
153  inline static label getMinIndex
154  (
155  const face& f,
156  const label v0,
157  const label v1
158  );
159 
160  //- Return the face label, -1 for end iterator
161  inline label faceLabel() const;
162 
163  //- Return true if the face label corresponds to an internal face
164  inline bool isInternalFace() const;
165 
166  inline bool ownerSide() const;
167 
168  inline label index() const;
169 
170  //- Helper: get the neighbouring cell according to the ownerSide.
171  // Returns -1 if on neighbourside of boundary face.
172  inline label cellLabel() const;
173 
174  //- Helper: return true if normal of generated face points along
175  // edge from v0 to v1. (v0 and v1 have to be on edge)
176  inline bool sameOrder(const label v0, const label v1) const;
177 
178  //- Set edge to a unique state so different ones can be compared.
179  // Internal edge: minimum face index.
180  // Boundary edge: walk back until boundary face.
181  inline void setCanonical();
182 
183 
184  // Member Operators
185 
186  inline void operator=(const edgeFaceCirculator& iter);
187 
188  inline bool operator==(const edgeFaceCirculator& iter) const;
189 
190  inline bool operator!=(const edgeFaceCirculator& iter) const;
191 
192  //- Step to next face. Uses no edge addressing!
193  inline edgeFaceCirculator& operator++();
194 
195  //- Iterator set to the beginning face. For internal edges this is
196  // the current face. For boundary edges this is the first boundary face
197  // reached from walking back (i.e. in opposite direction to ++)
198  inline edgeFaceCirculator begin() const;
199  inline edgeFaceCirculator cbegin() const;
200 
201  //- Iterator set to beyond the end of the walk.
202  inline const edgeFaceCirculator end() const;
203  inline const edgeFaceCirculator cend() const;
204 };
205 
206 
207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208 
209 } // End namespace Foam
210 
211 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212 
213 #include "edgeFaceCirculatorI.H"
214 
215 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
216 
217 #endif
218 
219 // ************************************************************************* //
Foam::edgeFaceCirculator::operator=
void operator=(const edgeFaceCirculator &iter)
Definition: edgeFaceCirculatorI.H:341
Foam::edgeFaceCirculator::ownerSide
bool ownerSide() const
Definition: edgeFaceCirculatorI.H:190
Foam::edgeFaceCirculator::operator!=
bool operator!=(const edgeFaceCirculator &iter) const
Definition: edgeFaceCirculatorI.H:371
face.H
Foam::edgeFaceCirculator::operator++
edgeFaceCirculator & operator++()
Step to next face. Uses no edge addressing!
Definition: edgeFaceCirculatorI.H:379
Foam::edgeFaceCirculator::index
label index() const
Definition: edgeFaceCirculatorI.H:196
Foam::edgeFaceCirculator::getMinIndex
static label getMinIndex(const face &f, const label v0, const label v1)
Helper: find index in face of edge or -1. Index is such that edge is.
Definition: edgeFaceCirculatorI.H:143
Foam::edgeFaceCirculator
Walks from starting face around edge.
Definition: edgeFaceCirculator.H:88
Foam::edgeFaceCirculator::setCanonical
void setCanonical()
Set edge to a unique state so different ones can be compared.
Definition: edgeFaceCirculatorI.H:237
edgeFaceCirculatorI.H
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::edgeFaceCirculator::sameOrder
bool sameOrder(const label v0, const label v1) const
Helper: return true if normal of generated face points along.
Definition: edgeFaceCirculatorI.H:217
Foam::edgeFaceCirculator::operator==
bool operator==(const edgeFaceCirculator &iter) const
Definition: edgeFaceCirculatorI.H:351
Foam::edgeFaceCirculator::cbegin
edgeFaceCirculator cbegin() const
Definition: edgeFaceCirculatorI.H:444
f
labelList f(nPoints)
Foam::edgeFaceCirculator::cellLabel
label cellLabel() const
Helper: get the neighbouring cell according to the ownerSide.
Definition: edgeFaceCirculatorI.H:202
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:72
ListOps.H
Various functions to operate on Lists.
Foam::edgeFaceCirculator::isInternalFace
bool isInternalFace() const
Return true if the face label corresponds to an internal face.
Definition: edgeFaceCirculatorI.H:179
Foam::edgeFaceCirculator::cend
const edgeFaceCirculator cend() const
Definition: edgeFaceCirculatorI.H:468
Foam::edgeFaceCirculator::begin
edgeFaceCirculator begin() const
Iterator set to the beginning face. For internal edges this is.
Definition: edgeFaceCirculatorI.H:425
Foam::edgeFaceCirculator::faceLabel
label faceLabel() const
Return the face label, -1 for end iterator.
Definition: edgeFaceCirculatorI.H:173
Foam::edgeFaceCirculator::end
const edgeFaceCirculator end() const
Iterator set to beyond the end of the walk.
Definition: edgeFaceCirculatorI.H:463
Foam::primitiveMesh
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:78