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