1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 Foam::edgeFaceCirculator
29 Walks from starting face around edge.
31 Implicit description of edge:
33 - index in face. edge is always between f[index] and f[index+1]
34 - direction (cell to walk into)
38 edgeFaceCirculator circ(..);
39 // Optionally rotate to beginning: circ.setCanonical();
44 Info<< "face:" << circ.face() << endl;
47 while (circ != circ.end());
50 -# Use like STL iterator: \n
52 edgeFaceCirculator circ(..);
55 edgeFaceCirculator iter = circ.begin();
60 Info<< "face:" << iter.face() << endl;
68 \*---------------------------------------------------------------------------*/
70 #ifndef edgeFaceCirculator_H
71 #define edgeFaceCirculator_H
76 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
81 // Forward declaration of classes
84 /*---------------------------------------------------------------------------*\
85 Class edgeFaceCirculator Declaration
86 \*---------------------------------------------------------------------------*/
88 class edgeFaceCirculator
90 // Static data members
93 static const edgeFaceCirculator endConstIter;
99 const primitiveMesh& mesh_;
104 //- Current side of face
107 //- Edge (between index and index+1 on faces[faceLabel_]
110 //- Is boundary edge?
111 bool isBoundaryEdge_;
113 //- Starting face so we know when to stop. Used when circulating over
115 label startFaceLabel_;
118 // Private Member Functions
120 //- Set to end() iterator
121 inline void setEnd();
123 //- Check and set faceLabel_ and ownerSide_
124 inline void setFace(const label faceI, const label cellI);
126 //- Set faceLabel_ to be the other face on the cell that uses the
128 inline void otherFace(const label cellI);
135 //- Construct from components
136 inline edgeFaceCirculator
138 const primitiveMesh& mesh,
139 const label faceLabel,
140 const bool ownerSide,
142 const bool isBoundaryEdge
145 //- Construct as copy
146 inline edgeFaceCirculator(const edgeFaceCirculator&);
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
160 inline label faceLabel() const;
162 inline bool ownerSide() const;
164 inline label index() const;
166 //- Helper: get the neighbouring cell according to the ownerSide.
167 // Returns -1 if on neighbourside of boundary face.
168 inline label cellLabel() const;
170 //- Helper: return true if normal of generated face points along
171 // edge from v0 to v1. (v0 and v1 have to be on edge)
172 inline bool sameOrder(const label v0, const label v1) const;
174 //- Set edge to a unique state so different ones can be compared.
175 // Internal edge: minimum face index.
176 // Boundary edge: walk back until boundary face.
177 inline void setCanonical();
182 inline void operator=(const edgeFaceCirculator& iter);
184 inline bool operator==(const edgeFaceCirculator& iter) const;
186 inline bool operator!=(const edgeFaceCirculator& iter) const;
188 //- Step to next face. Uses no edge addressing!
189 inline edgeFaceCirculator& operator++();
191 //- iterator set to the beginning face. For internal edges this is
192 // the current face. For boundary edges this is the first boundary face
193 // reached from walking back (i.e. in opposite direction to ++)
194 inline edgeFaceCirculator begin() const;
195 inline edgeFaceCirculator cbegin() const;
197 //- iterator set to beyond the end of the walk.
198 inline const edgeFaceCirculator& end() const;
199 inline const edgeFaceCirculator& cend() const;
203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205 } // End namespace Foam
207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209 #include "edgeFaceCirculatorI.H"
211 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 // ************************************************************************* //