OpenFOAM logo
Open Source CFD Toolkit

edge.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-2005 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 the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     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, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     edge
00027 
00028 Description
00029     An edge is a list of two point labels. The functionality it provides
00030     supports the discretisation on a 2-D flat mesh.
00031 
00032 SourceFiles
00033     edgeI.H
00034 
00035 \*---------------------------------------------------------------------------*/
00036 
00037 #ifndef edge_H
00038 #define edge_H
00039 
00040 #include "FixedList.H"
00041 #include "pointField.H"
00042 #include "linePointRef.H"
00043 
00044 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00045 
00046 namespace Foam
00047 {
00048 
00049 /*---------------------------------------------------------------------------*\
00050                            Class edge Declaration
00051 \*---------------------------------------------------------------------------*/
00052 
00053 class edge
00054 :
00055     public FixedList<label, 2>
00056 {
00057 
00058 public:
00059 
00060     // Constructors
00061 
00062         //- Null constructor for lists
00063         inline edge();
00064 
00065         //- Construct from components
00066         inline edge(const label a, const label b);
00067 
00068         //- Construct from Istream
00069         inline edge(Istream&);
00070 
00071 
00072     // Member Functions
00073 
00074         //- Return start vertex label
00075         inline label start() const;
00076 
00077         //- Return start vertex label
00078         inline label& start();
00079 
00080         //- Return end vertex label
00081         inline label end() const;
00082 
00083         //- Return end vertex label
00084         inline label& end();
00085 
00086         //- Given one vertex, return the other
00087         inline label otherVertex(const label a) const;
00088 
00089         //- Return common vertex
00090         inline label commonVertex(const edge& a) const;
00091 
00092         //- Return reverse edge
00093         inline edge reverseEdge() const;
00094 
00095         //- Return centre (centroid)
00096         inline point centre(const pointField&) const;
00097 
00098         //- Return the vector (end - start)
00099         inline vector vec(const pointField&) const;
00100 
00101         //- Return scalar magnitude
00102         inline scalar mag(const pointField&) const;
00103 
00104         //- Return edge line
00105         inline linePointRef line(const pointField&) const;
00106 
00107 
00108     // Friend Operators
00109 
00110         inline friend bool operator==(const edge& a, const edge& b);
00111         inline friend bool operator!=(const edge& a, const edge& b);
00112 };
00113 
00114 
00115 //- Hash<edge> specialisation 
00116 //  Simple commutative hash.
00117 template<>
00118 inline label Hash<edge>::operator()(const edge& e) const
00119 {
00120     return e[0]*e[1] + e[0]+e[1];
00121 }
00122 
00123 
00124 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00125 
00126 } // End namespace Foam
00127 
00128 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00129 
00130 #include "edgeI.H"
00131 
00132 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00133 
00134 #endif
00135 
00136 // ************************************************************************* //
For further information go to www.openfoam.org