FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

edgeFaceCirculator.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 Class
00025     Foam::edgeFaceCirculator
00026 
00027 Description
00028     Walks from starting face around edge.
00029 
00030     Implicit description of edge:
00031     - face
00032     - index in face. edge is always between f[index] and f[index+1]
00033     - direction (cell to walk into)
00034 
00035     -# Use in-place: \n
00036         @code
00037             edgeFaceCirculator circ(..);
00038             // Optionally rotate to beginning: circ.setCanonical();
00039 
00040             // Walk
00041             do
00042             {
00043                 Info<< "face:" << circ.face() << endl;
00044                 ++circ;
00045             }
00046             while (circ != circ.end());
00047         @endcode
00048 
00049     -# Use like STL iterator: \n
00050         @code
00051             edgeFaceCirculator circ(..);
00052             for
00053             (
00054                 edgeFaceCirculator iter = circ.begin();
00055                 iter != circ.end();
00056                 ++iter
00057             )
00058             {
00059                 Info<< "face:" << iter.face() << endl;
00060             }
00061         @endcode
00062 
00063 
00064 SourceFiles
00065     edgeFaceCirculator.C
00066 
00067 \*---------------------------------------------------------------------------*/
00068 
00069 #ifndef edgeFaceCirculator_H
00070 #define edgeFaceCirculator_H
00071 
00072 #include <OpenFOAM/face.H>
00073 #include <OpenFOAM/ListOps.H>
00074 
00075 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00076 
00077 namespace Foam
00078 {
00079 
00080 // Forward declaration of classes
00081 class primitiveMesh;
00082 
00083 /*---------------------------------------------------------------------------*\
00084                            Class edgeFaceCirculator Declaration
00085 \*---------------------------------------------------------------------------*/
00086 
00087 class edgeFaceCirculator
00088 {
00089     // Static data members
00090 
00091         //- end iterator
00092         static const edgeFaceCirculator endConstIter;
00093 
00094 
00095     // Private data
00096 
00097         //- Mesh
00098         const primitiveMesh& mesh_;
00099 
00100         //- Current face
00101         label faceLabel_;
00102 
00103         //- Current side of face
00104         bool ownerSide_;
00105 
00106         //- Edge (between index and index+1 on faces[faceLabel_]
00107         label index_;
00108 
00109         //- Is boundary edge?
00110         bool isBoundaryEdge_;
00111 
00112         //- Starting face so we know when to stop. Used when circulating over
00113         //  internal edges.
00114         label startFaceLabel_;
00115 
00116 
00117     // Private Member Functions
00118 
00119         //- Set to end() iterator
00120         inline void setEnd();
00121 
00122         //- Check and set faceLabel_ and ownerSide_
00123         inline void setFace(const label faceI, const label cellI);
00124 
00125         //- Set faceLabel_ to be the other face on the cell that uses the
00126         //  edge.
00127         inline void otherFace(const label cellI);
00128 
00129 
00130 public:
00131 
00132     // Constructors
00133 
00134         //- Construct from components
00135         inline edgeFaceCirculator
00136         (
00137             const primitiveMesh& mesh,
00138             const label faceLabel,
00139             const bool ownerSide,
00140             const label index,
00141             const bool isBoundaryEdge
00142         );
00143 
00144         //- Construct as copy
00145         inline edgeFaceCirculator(const edgeFaceCirculator&);
00146 
00147 
00148     // Member Functions
00149 
00150         //- Helper: find index in face of edge or -1. Index is such that edge is
00151         //  between f[index] and f[index+1]
00152         inline static label getMinIndex
00153         (
00154             const face& f,
00155             const label v0,
00156             const label v1
00157         );
00158 
00159         inline label faceLabel() const;
00160 
00161         inline bool ownerSide() const;
00162 
00163         inline label index() const;
00164 
00165         //- Helper: get the neighbouring cell according to the ownerSide.
00166         //  Returns -1 if on neighbourside of boundary face.
00167         inline label cellLabel() const;
00168 
00169         //- Helper: return true if normal of generated face points along
00170         //  edge from v0 to v1. (v0 and v1 have to be on edge)
00171         inline bool sameOrder(const label v0, const label v1) const;
00172 
00173         //- Set edge to a unique state so different ones can be compared.
00174         //  Internal edge: minimum face index.
00175         //  Boundary edge: walk back until boundary face.
00176         inline void setCanonical();
00177 
00178 
00179     // Member Operators
00180 
00181         inline void operator=(const edgeFaceCirculator& iter);
00182 
00183         inline bool operator==(const edgeFaceCirculator& iter) const;
00184 
00185         inline bool operator!=(const edgeFaceCirculator& iter) const;
00186 
00187         //- Step to next face. Uses no edge addressing!
00188         inline edgeFaceCirculator& operator++();
00189 
00190         //- iterator set to the beginning face. For internal edges this is
00191         //  the current face. For boundary edges this is the first boundary face
00192         //  reached from walking back (i.e. in opposite direction to ++)
00193         inline edgeFaceCirculator begin() const;
00194         inline edgeFaceCirculator cbegin() const;
00195 
00196         //- iterator set to beyond the end of the walk.
00197         inline const edgeFaceCirculator& end() const;
00198         inline const edgeFaceCirculator& cend() const;
00199 };
00200 
00201 
00202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00203 
00204 } // End namespace Foam
00205 
00206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00207 
00208 #include <meshTools/edgeFaceCirculatorI.H>
00209 
00210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00211 
00212 #endif
00213 
00214 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines