OpenFOAM logo
The Open Source CFD Toolbox
  Programmer’s C++ Doxygen OpenCFD Solutions Contact OpenFOAM

faceI.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-2007 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 \*---------------------------------------------------------------------------*/
00026 
00027 namespace Foam
00028 {
00029 
00030 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00031 
00032 // Edge to the right of face vertex i
00033 inline label face::right(const label i) const
00034 {
00035     return i;
00036 }
00037 
00038 
00039 // Edge to the left of face vertex i
00040 inline label face::left(const label i) const
00041 {
00042     return i == 0 ? size() - 1 : (i - 1);
00043 }
00044 
00045 
00046 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00047 
00048 // Construct NULL
00049 inline face::face()
00050 {}
00051 
00052 
00053 // Construct given size
00054 inline face::face(label s)
00055 :
00056     labelList(s, -1)
00057 {}
00058 
00059 
00060 // Construct from components
00061 inline face::face(const labelList& l)
00062 :
00063     labelList(l)
00064 {}
00065 
00066 
00067 // Construct from Istream
00068 inline face::face(Istream& is)
00069 {
00070     is >> *this;
00071 }
00072 
00073 
00074 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00075 
00076 inline pointField face::points(const pointField& meshPoints) const
00077 {
00078     // There are as many points as there labels for them
00079     pointField p(size());
00080 
00081     // For each point in list, set it to the point in 'pnts' addressed
00082     // by 'labs'
00083     forAll(p, i)
00084     {
00085         p[i] = meshPoints[operator[](i)];
00086     }
00087 
00088     // Return list
00089     return p;
00090 }
00091 
00092 
00093 inline scalar face::mag(const pointField& p) const
00094 {
00095     return ::Foam::mag(normal(p));
00096 }
00097 
00098 
00099 inline label face::nEdges() const
00100 {
00101     // for a closed polygon a number of edges is the same as number of points
00102     return size();
00103 }
00104 
00105 
00106 inline edge face::faceEdge(const label n) const
00107 {
00108     return edge(operator[](n), operator[](fcIndex(n)));
00109 }
00110 
00111 
00112 // Next vertex on face
00113 inline label face::nextLabel(const label i) const
00114 {
00115     return operator[](fcIndex(i));
00116 }
00117 
00118 
00119 // Previous vertex on face
00120 inline label face::prevLabel(const label i) const
00121 {
00122     return operator[](rcIndex(i));
00123 }
00124 
00125 
00126 // * * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * //
00127 
00128 inline Istream& operator>>(Istream& is, face& f)
00129 {
00130     if (is.version() == IOstream::originalVersion)
00131     {
00132         // Read starting (
00133         is.readBegin("face");
00134 
00135         // Read the 'name' token for the face
00136         token t(is);
00137 
00138         // Read labels
00139         is >> static_cast<labelList&>(f);
00140 
00141         // Read end)
00142         is.readEnd("face");
00143     }
00144     else
00145     {
00146         is >> static_cast<labelList&>(f);
00147     }
00148 
00149     // Check state of Ostream
00150     is.check("Istream& operator>>(Istream&, face&)");
00151 
00152     return is;
00153 }
00154 
00155 
00156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00157 
00158 } // End namespace Foam
00159 
00160 // ************************************************************************* //
Copyright © 2000-2007 OpenCFD Ltd