1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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/>.
28 An edge is a list of two point labels. The functionality it provides
29 supports the discretisation on a 2-D flat mesh.
34 \*---------------------------------------------------------------------------*/
39 #include "FixedList.H"
40 #include "pointField.H"
41 #include "linePointRef.H"
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 // Forward declaration of friend functions and operators
51 inline bool operator==(const edge& a, const edge& b);
52 inline bool operator!=(const edge& a, const edge& b);
55 /*---------------------------------------------------------------------------*\
56 Class edge Declaration
57 \*---------------------------------------------------------------------------*/
61 public FixedList<label, 2>
66 // Static data members
68 static const char* const typeName;
73 //- Null constructor for lists
76 //- Construct from components
77 inline edge(const label a, const label b);
79 //- Construct from FixedList
80 inline edge(const FixedList<label, 2>&);
82 //- Construct from Istream
83 inline edge(Istream&);
88 //- Return start vertex label
89 inline label start() const;
91 //- Return start vertex label
92 inline label& start();
94 //- Return end vertex label
95 inline label end() const;
97 //- Return end vertex label
100 //- Given one vertex, return the other
101 inline label otherVertex(const label a) const;
103 //- Return common vertex
104 inline label commonVertex(const edge& a) const;
106 //- Flip the edge in-place.
109 //- Return reverse edge
110 inline edge reverseEdge() const;
112 //- Return centre (centroid)
113 inline point centre(const pointField&) const;
115 //- Return the vector (end - start)
116 inline vector vec(const pointField&) const;
118 //- Return scalar magnitude
119 inline scalar mag(const pointField&) const;
122 inline linePointRef line(const pointField&) const;
128 // - -1: same edge, but different orientation
129 static inline int compare(const edge&, const edge&);
134 friend bool operator==(const edge& a, const edge& b);
135 friend bool operator!=(const edge& a, const edge& b);
139 //- Hash specialization for hashing edges - a commutative hash value.
140 // Hash incrementally.
142 inline unsigned Hash<edge>::operator()(const edge& e, unsigned seed) const
148 val = Hash<label>()(e[0], val);
149 val = Hash<label>()(e[1], val);
153 val = Hash<label>()(e[1], val);
154 val = Hash<label>()(e[0], val);
161 //- Hash specialization for hashing edges - a commutative hash value.
162 // Hash incrementally.
164 inline unsigned Hash<edge>::operator()(const edge& e) const
166 return Hash<edge>()(e, 0);
171 inline bool contiguous<edge>() {return true;}
174 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 } // End namespace Foam
178 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
186 // ************************************************************************* //