1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2011 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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
25 Foam::edgeFaceCirculator
28 Walks from starting face around edge.
30 Implicit description of edge:
32 - index in face. edge is always between f[index] and f[index+1]
33 - direction (cell to walk into)
37 edgeFaceCirculator circ(..);
38 // Optionally rotate to beginning: circ.setCanonical();
43 Info<< "face:" << circ.face() << endl;
46 while (circ != circ.end());
49 -# Use like STL iterator: \n
51 edgeFaceCirculator circ(..);
54 edgeFaceCirculator iter = circ.begin();
59 Info<< "face:" << iter.face() << endl;
67 \*---------------------------------------------------------------------------*/
69 #ifndef edgeFaceCirculator_H
70 #define edgeFaceCirculator_H
75 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
80 // Forward declaration of classes
83 /*---------------------------------------------------------------------------*\
84 Class edgeFaceCirculator Declaration
85 \*---------------------------------------------------------------------------*/
87 class edgeFaceCirculator
89 // Static data members
92 static const edgeFaceCirculator endConstIter;
98 const primitiveMesh& mesh_;
103 //- Current side of face
106 //- Edge (between index and index+1 on faces[faceLabel_]
109 //- Is boundary edge?
110 bool isBoundaryEdge_;
112 //- Starting face so we know when to stop. Used when circulating over
114 label startFaceLabel_;
117 // Private Member Functions
119 //- Set to end() iterator
120 inline void setEnd();
122 //- Check and set faceLabel_ and ownerSide_
123 inline void setFace(const label faceI, const label cellI);
125 //- Set faceLabel_ to be the other face on the cell that uses the
127 inline void otherFace(const label cellI);
134 //- Construct from components
135 inline edgeFaceCirculator
137 const primitiveMesh& mesh,
138 const label faceLabel,
139 const bool ownerSide,
141 const bool isBoundaryEdge
144 //- Construct as copy
145 inline edgeFaceCirculator(const edgeFaceCirculator&);
150 //- Helper: find index in face of edge or -1. Index is such that edge is
151 // between f[index] and f[index+1]
152 inline static label getMinIndex
159 inline label faceLabel() const;
161 inline bool ownerSide() const;
163 inline label index() const;
165 //- Helper: get the neighbouring cell according to the ownerSide.
166 // Returns -1 if on neighbourside of boundary face.
167 inline label cellLabel() const;
169 //- Helper: return true if normal of generated face points along
170 // edge from v0 to v1. (v0 and v1 have to be on edge)
171 inline bool sameOrder(const label v0, const label v1) const;
173 //- Set edge to a unique state so different ones can be compared.
174 // Internal edge: minimum face index.
175 // Boundary edge: walk back until boundary face.
176 inline void setCanonical();
181 inline void operator=(const edgeFaceCirculator& iter);
183 inline bool operator==(const edgeFaceCirculator& iter) const;
185 inline bool operator!=(const edgeFaceCirculator& iter) const;
187 //- Step to next face. Uses no edge addressing!
188 inline edgeFaceCirculator& operator++();
190 //- iterator set to the beginning face. For internal edges this is
191 // the current face. For boundary edges this is the first boundary face
192 // reached from walking back (i.e. in opposite direction to ++)
193 inline edgeFaceCirculator begin() const;
194 inline edgeFaceCirculator cbegin() const;
196 //- iterator set to beyond the end of the walk.
197 inline const edgeFaceCirculator& end() const;
198 inline const edgeFaceCirculator& cend() const;
202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204 } // End namespace Foam
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208 #include "edgeFaceCirculatorI.H"
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 // ************************************************************************* //