OpenFOAM logo
Open Source CFD Toolkit

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