OpenFOAM logo
Open Source CFD Toolkit

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