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-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::edgeFaceCirculator
28
29Description
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
66SourceFiles
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
79namespace Foam
80{
81
82// Forward declaration of classes
83class primitiveMesh;
84
85/*---------------------------------------------------------------------------*\
86 Class edgeFaceCirculator Declaration
87\*---------------------------------------------------------------------------*/
90{
91 // Private Member Data
92
93 //- The underlying mesh pointer
94 const primitiveMesh* meshPtr_;
95
96 //- Is current side of face the owner side?
97 bool ownerSide_;
98
99 //- Is boundary edge?
100 bool isBoundaryEdge_;
101
102 //- Current face
103 label faceLabel_;
104
105 //- Edge (between index and index+1 on faces[faceLabel_]
106 label index_;
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 //- Default construct - this is also an end iterator
128 inline edgeFaceCirculator();
129
130
131public:
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!
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// ************************************************************************* //
Various functions to operate on Lists.
Walks from starting face around edge.
void operator=(const edgeFaceCirculator &iter)
edgeFaceCirculator & operator++()
Step to next face. Uses no edge addressing!
bool isInternalFace() const
Return true if the face label corresponds to an internal face.
bool sameOrder(const label v0, const label v1) const
Helper: return true if normal of generated face points along.
label faceLabel() const
Return the face label, -1 for end iterator.
const edgeFaceCirculator cend() const
label cellLabel() const
Helper: get the neighbouring cell according to the ownerSide.
void setCanonical()
Set edge to a unique state so different ones can be compared.
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.
edgeFaceCirculator cbegin() const
edgeFaceCirculator begin() const
Iterator set to the beginning face. For internal edges this is.
bool operator!=(const edgeFaceCirculator &iter) const
bool operator==(const edgeFaceCirculator &iter) const
const edgeFaceCirculator end() const
Iterator set to beyond the end of the walk.
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:79
dynamicFvMesh & mesh
Namespace for OpenFOAM.
labelList f(nPoints)