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