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 | Copyright (C) 2011-2015 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
92  static const edgeFaceCirculator endConstIter;
93 
94 
95  // Private data
96 
97  //- Mesh
98  const primitiveMesh& mesh_;
99 
100  //- Current face
102 
103  //- Current side of face
104  bool ownerSide_;
105 
106  //- Edge (between index and index+1 on faces[faceLabel_]
107  label index_;
108 
109  //- Is boundary edge?
110  bool isBoundaryEdge_;
111 
112  //- Starting face so we know when to stop. Used when circulating over
113  // internal edges.
115 
116 
117  // Private Member Functions
118 
119  //- Set to end() iterator
120  inline void setEnd();
121 
122  //- Check and set faceLabel_ and ownerSide_
123  inline void setFace(const label faceI, const label cellI);
124 
125  //- Set faceLabel_ to be the other face on the cell that uses the
126  // edge.
127  inline void otherFace(const label cellI);
128 
129 
130 public:
131 
132  // Constructors
133 
134  //- Construct from components
135  inline edgeFaceCirculator
136  (
137  const primitiveMesh& mesh,
138  const label faceLabel,
139  const bool ownerSide,
140  const label index,
141  const bool isBoundaryEdge
142  );
143 
144  //- Construct as copy
145  inline edgeFaceCirculator(const edgeFaceCirculator&);
146 
147 
148  // Member Functions
149 
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
153  (
154  const face& f,
155  const label v0,
156  const label v1
157  );
158 
159  inline label faceLabel() const;
160 
161  inline bool ownerSide() const;
162 
163  inline label index() const;
164 
165  //- Helper: get the neighbouring cell according to the ownerSide.
166  // Returns -1 if on neighbourside of boundary face.
167  inline label cellLabel() const;
168 
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;
172 
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();
177 
178 
179  // Member Operators
180 
181  inline void operator=(const edgeFaceCirculator& iter);
182 
183  inline bool operator==(const edgeFaceCirculator& iter) const;
184 
185  inline bool operator!=(const edgeFaceCirculator& iter) const;
186 
187  //- Step to next face. Uses no edge addressing!
188  inline edgeFaceCirculator& operator++();
189 
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;
195 
196  //- Iterator set to beyond the end of the walk.
197  inline const edgeFaceCirculator& end() const;
198  inline const edgeFaceCirculator& cend() const;
199 };
200 
201 
202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 
204 } // End namespace Foam
205 
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 
208 #include "edgeFaceCirculatorI.H"
209 
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211 
212 #endif
213 
214 // ************************************************************************* //
Foam::edgeFaceCirculator::operator=
void operator=(const edgeFaceCirculator &iter)
Definition: edgeFaceCirculatorI.H:314
Foam::edgeFaceCirculator::isBoundaryEdge_
bool isBoundaryEdge_
Is boundary edge?
Definition: edgeFaceCirculator.H:109
Foam::edgeFaceCirculator::ownerSide
bool ownerSide() const
Definition: edgeFaceCirculatorI.H:161
Foam::edgeFaceCirculator::operator!=
bool operator!=(const edgeFaceCirculator &iter) const
Definition: edgeFaceCirculatorI.H:344
face.H
Foam::edgeFaceCirculator::operator++
edgeFaceCirculator & operator++()
Step to next face. Uses no edge addressing!
Definition: edgeFaceCirculatorI.H:352
Foam::edgeFaceCirculator::index
label index() const
Definition: edgeFaceCirculatorI.H:167
Foam::edgeFaceCirculator::setEnd
void setEnd()
Set to end() iterator.
Definition: edgeFaceCirculatorI.H:30
Foam::edgeFaceCirculator::startFaceLabel_
label startFaceLabel_
Starting face so we know when to stop. Used when circulating over.
Definition: edgeFaceCirculator.H:113
Foam::edgeFaceCirculator::faceLabel_
label faceLabel_
Current face.
Definition: edgeFaceCirculator.H:100
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:125
Foam::edgeFaceCirculator
Walks from starting face around edge.
Definition: edgeFaceCirculator.H:86
Foam::edgeFaceCirculator::setFace
void setFace(const label faceI, const label cellI)
Check and set faceLabel_ and ownerSide_.
Definition: edgeFaceCirculatorI.H:38
Foam::label
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
Foam::edgeFaceCirculator::endConstIter
static const edgeFaceCirculator endConstIter
End iterator.
Definition: edgeFaceCirculator.H:91
Foam::edgeFaceCirculator::edgeFaceCirculator
edgeFaceCirculator(const primitiveMesh &mesh, const label faceLabel, const bool ownerSide, const label index, const bool isBoundaryEdge)
Construct from components.
Definition: edgeFaceCirculatorI.H:93
Foam::edgeFaceCirculator::setCanonical
void setCanonical()
Set edge to a unique state so different ones can be compared.
Definition: edgeFaceCirculatorI.H:210
Foam::edgeFaceCirculator::otherFace
void otherFace(const label cellI)
Set faceLabel_ to be the other face on the cell that uses the.
Definition: edgeFaceCirculatorI.H:55
Foam::edgeFaceCirculator::mesh_
const primitiveMesh & mesh_
Mesh.
Definition: edgeFaceCirculator.H:97
Foam::edgeFaceCirculator::end
const edgeFaceCirculator & end() const
Iterator set to beyond the end of the walk.
Definition: edgeFaceCirculatorI.H:436
edgeFaceCirculatorI.H
Foam::edgeFaceCirculator::cend
const edgeFaceCirculator & cend() const
Definition: edgeFaceCirculatorI.H:441
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
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:190
Foam::edgeFaceCirculator::ownerSide_
bool ownerSide_
Current side of face.
Definition: edgeFaceCirculator.H:103
Foam::edgeFaceCirculator::operator==
bool operator==(const edgeFaceCirculator &iter) const
Definition: edgeFaceCirculatorI.H:324
Foam::edgeFaceCirculator::cbegin
edgeFaceCirculator cbegin() const
Definition: edgeFaceCirculatorI.H:417
f
labelList f(nPoints)
Foam::edgeFaceCirculator::cellLabel
label cellLabel() const
Helper: get the neighbouring cell according to the ownerSide.
Definition: edgeFaceCirculatorI.H:173
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
ListOps.H
Various functions to operate on Lists.
Foam::edgeFaceCirculator::index_
label index_
Edge (between index and index+1 on faces[faceLabel_].
Definition: edgeFaceCirculator.H:106
Foam::edgeFaceCirculator::begin
edgeFaceCirculator begin() const
Iterator set to the beginning face. For internal edges this is.
Definition: edgeFaceCirculatorI.H:398
Foam::edgeFaceCirculator::faceLabel
label faceLabel() const
Definition: edgeFaceCirculatorI.H:155
Foam::primitiveMesh
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:79