OpenFOAM logo
Open Source CFD Toolkit

faceEdge.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     faceEdge
00027 
00028 Description
00029     Implicit description of face edge (from tet decomposition).
00030     Face edge is edge between vertex of face and face centre.
00031     Stores
00032         - face label
00033         - index in face (gives the mesh vertex)
00034 
00035 
00036 SourceFiles
00037 
00038 \*---------------------------------------------------------------------------*/
00039 
00040 #ifndef faceEdge_H
00041 #define faceEdge_H
00042 
00043 #include "label.H"
00044 #include "primitiveMesh.H"
00045 
00046 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00047 
00048 namespace Foam
00049 {
00050 
00051 // Class forward declarations
00052 
00053 /*---------------------------------------------------------------------------*\
00054                            Class faceEdge Declaration
00055 \*---------------------------------------------------------------------------*/
00056 
00057 class faceEdge
00058 {
00059     // Private data
00060 
00061         //- face label
00062         label faceLabel_;
00063 
00064         //- index in face
00065         label faceIndex_;
00066 
00067 public:
00068 
00069     // Public classes
00070 
00071         // Hash function
00072         class faceEdgeHash
00073         {
00074 
00075         public:
00076 
00077             faceEdgeHash()
00078             {}
00079 
00080             //- simple hashing function of labels
00081             label operator()(const faceEdge& fe, const label tableSize)
00082                 const
00083             {
00084                 // Note: mag since multiply might overflow and produce
00085                 // negative numbers
00086                 return
00087                     mag
00088                     (
00089                         fe.faceLabel()
00090                       + (fe.faceLabel() * fe.faceLabel())
00091                       + fe.faceIndex()
00092                       + (fe.faceIndex() * fe.faceIndex())
00093                     )
00094                   % tableSize;
00095             }
00096         };
00097 
00098 
00099     // Constructors
00100 
00101         //- Construct null
00102         inline faceEdge()
00103         :
00104             faceLabel_(-1),
00105             faceIndex_(-1)
00106         {}
00107 
00108         //- Construct from components
00109         inline faceEdge(const label faceLabel, const label faceIndex)
00110         :
00111             faceLabel_(faceLabel),
00112             faceIndex_(faceIndex)
00113         {}
00114 
00115     // Member Functions
00116 
00117         label faceLabel() const
00118         {   
00119             return faceLabel_;
00120         }
00121 
00122         label faceIndex() const
00123         {   
00124             return faceIndex_;
00125         }
00126 
00127         template <class T>
00128         T interpolate
00129         (
00130             const primitiveMesh& mesh,
00131             const Field<T>& faceField,
00132             const Field<T>& vertField,
00133             const scalar weight
00134         ) const
00135         {
00136             const face& f = mesh.faces()[faceLabel_];
00137 
00138             return
00139                 (1-weight)*vertField[f[faceIndex_]]
00140               + weight*faceField[faceLabel_];
00141         }
00142 
00143 
00144         point coord(const primitiveMesh& mesh, const scalar weight) const
00145         {
00146             return interpolate(mesh, mesh.faceCentres(), mesh.points(), weight);
00147         }
00148 
00149 
00150     // Member Operators
00151 
00152         bool operator==(const faceEdge& fe) const
00153         {
00154             return
00155                 (faceLabel() == fe.faceLabel())
00156              && (faceIndex() == fe.faceIndex());
00157         }
00158 
00159 
00160     // IOstream Operators
00161 
00162         inline friend Ostream& operator<<(Ostream& os, const faceEdge& fe)
00163         {
00164             os  << token::BEGIN_LIST
00165                 << fe.faceLabel_ << token::SPACE
00166                 << fe.faceIndex_
00167                 << token::END_LIST;
00168 
00169             // Check state of Ostream
00170             os.check("Ostream& operator<<(Ostream&, const faceEdge&)");
00171 
00172             return os;
00173         }
00174 };
00175 
00176 
00177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00178 
00179 } // End namespace Foam
00180 
00181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00182 
00183 #endif
00184 
00185 // ************************************************************************* //
For further information go to www.openfoam.org