FreeFOAM The Cross-Platform CFD Toolkit
faceI.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
27 
28 // Edge to the right of face vertex i
29 inline Foam::label Foam::face::right(const label i) const
30 {
31  return i;
32 }
33 
34 
35 // Edge to the left of face vertex i
36 inline Foam::label Foam::face::left(const label i) const
37 {
38  return i ? i-1 : size()-1;
39 }
40 
41 
42 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
43 
45 {}
46 
47 
48 inline Foam::face::face(label s)
49 :
50  labelList(s, -1)
51 {}
52 
53 
54 inline Foam::face::face(const UList<label>& lst)
55 :
56  labelList(lst)
57 {}
58 
59 
60 inline Foam::face::face(const labelList& lst)
61 :
62  labelList(lst)
63 {}
64 
65 
67 :
68  labelList(lst)
69 {}
70 
71 
73 {
74  is >> *this;
75 }
76 
77 
78 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
79 
80 inline Foam::pointField Foam::face::points(const pointField& meshPoints) const
81 {
82  // There are as many points as there labels for them
83  pointField p(size());
84 
85  // For each point in list, set it to the point in 'pnts' addressed
86  // by 'labs'
87  forAll(p, i)
88  {
89  p[i] = meshPoints[operator[](i)];
90  }
91 
92  // Return list
93  return p;
94 }
95 
96 
97 inline Foam::scalar Foam::face::mag(const pointField& p) const
98 {
100 }
101 
102 
103 inline Foam::label Foam::face::nEdges() const
104 {
105  // for a closed polygon a number of edges is the same as number of points
106  return size();
107 }
108 
109 
110 inline Foam::edge Foam::face::faceEdge(const label n) const
111 {
112  return edge(operator[](n), operator[](fcIndex(n)));
113 }
114 
115 
116 // Next vertex on face
117 inline Foam::label Foam::face::nextLabel(const label i) const
118 {
119  return operator[](fcIndex(i));
120 }
121 
122 
123 // Previous vertex on face
124 inline Foam::label Foam::face::prevLabel(const label i) const
125 {
126  return operator[](rcIndex(i));
127 }
128 
129 // Number of triangles directly known from number of vertices
130 inline Foam::label Foam::face::nTriangles() const
131 {
132  return size() - 2;
133 }
134 
135 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
136 
137 inline bool Foam::operator==(const face& a, const face& b)
138 {
139  return face::compare(a,b) != 0;
140 }
141 
142 
143 inline bool Foam::operator!=(const face& a, const face& b)
144 {
145  return face::compare(a,b) == 0;
146 }
147 
148 
149 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
150 
152 {
154  {
155  // Read starting (
156  is.readBegin("face");
157 
158  // Read the 'name' token for the face
159  token t(is);
160 
161  // Read labels
162  is >> static_cast<labelList&>(f);
163 
164  // Read end)
165  is.readEnd("face");
166  }
167  else
168  {
169  is >> static_cast<labelList&>(f);
170  }
171 
172  // Check state of Ostream
173  is.check("Istream& operator>>(Istream&, face&)");
174 
175  return is;
176 }
177 
178 // ************************ vim: set sw=4 sts=4 et: ************************ //