![]() |
|
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 face 00027 00028 Description 00029 00030 SourceFiles 00031 faceI.H 00032 face.C 00033 faceIntersection.C 00034 faceContactSphere.C 00035 faceAreaInContact.C 00036 00037 \*---------------------------------------------------------------------------*/ 00038 00039 #ifndef face_H 00040 #define face_H 00041 00042 #include "pointField.H" 00043 #include "labelList.H" 00044 #include "edgeList.H" 00045 #include "vectorField.H" 00046 #include "faceListFwd.H" 00047 #include "intersection.H" 00048 00049 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00050 00051 namespace Foam 00052 { 00053 00054 class pointHit; 00055 00056 /*---------------------------------------------------------------------------*\ 00057 Class face Declaration 00058 \*---------------------------------------------------------------------------*/ 00059 00060 class face 00061 : 00062 public labelList 00063 { 00064 // Private Member Functions 00065 00066 //- Edge to the right of face vertex i 00067 inline label right(const label i) const; 00068 00069 //- Edge to the left of face vertex i 00070 inline label left(const label i) const; 00071 00072 //- Construct list of edge vectors for face 00073 tmp<vectorField> calcEdges 00074 ( 00075 const pointField& points 00076 ) const; 00077 00078 //- Cos between neighbouring edges 00079 scalar edgeCos 00080 ( 00081 const vectorField& edges, 00082 const label index 00083 ) const; 00084 00085 //- Find index of largest internal angle on face 00086 label mostConcaveAngle 00087 ( 00088 const pointField& points, 00089 const vectorField& edges, 00090 scalar& edgeCos 00091 ) const; 00092 00093 //- Enumeration listing the modes for split() 00094 enum splitMode 00095 { 00096 COUNTTRIANGLE, // count if split into triangles 00097 COUNTQUAD, // count if split into triangles&quads 00098 SPLITTRIANGLE, // split into triangles 00099 SPLITQUAD // split into triangles&quads 00100 }; 00101 00102 //- Split face into triangles or triangles&quads. Stores results 00103 // quadFaces[quadI], triFaces[triI] 00104 void split 00105 ( 00106 const splitMode mode, 00107 const pointField& points, 00108 label& triI, 00109 label& quadI, 00110 faceList& triFaces, 00111 faceList& quadFaces 00112 ) const; 00113 00114 00115 public: 00116 00117 // Constructors 00118 00119 //- Construct null 00120 inline face(); 00121 00122 //- Construct given size 00123 explicit inline face(label); 00124 00125 //- Construct from components 00126 explicit inline face(const labelList&); 00127 00128 //- Construct from Istream 00129 inline face(Istream&); 00130 00131 00132 // Member Functions 00133 00134 //- Collapse face by removing duplicate point labels 00135 void collapse(); 00136 00137 //- Return the points corresponding to this face 00138 inline pointField points(const pointField& meshPoints) const; 00139 00140 //- Centre point of face 00141 point centre(const pointField&) const; 00142 00143 //- Scalar magnitude 00144 inline scalar mag(const pointField&) const; 00145 00146 //- Vector normal; magnitude is equal to area of face 00147 vector normal(const pointField&) const; 00148 00149 //- Return face with reverse direction 00150 face reverseFace() const; 00151 00152 //- Navigation through face vertices 00153 00154 //- Which vertex on face (face index given a global index) 00155 label which(const label globalIndex) const; 00156 00157 //- Next vertex on face 00158 inline label nextLabel(const label i) const; 00159 00160 //- Previous vertex on face 00161 inline label prevLabel(const label i) const; 00162 00163 00164 //- Return the volume swept out by the face when its points move 00165 scalar sweptVol 00166 ( 00167 const pointField& oldPoints, 00168 const pointField& newPoints 00169 ) const; 00170 00171 //- Return potential intersection with face with a ray starting 00172 // at p, direction n (does not need to be normalized) 00173 // Does face-center decomposition and returns triangle intersection 00174 // point closest to p. 00175 // For a hit, the distance is signed. Positive number 00176 // represents the point in front of triangle 00177 // In case of miss the point is the nearest point on the face 00178 // and the distance is the distance between the intersection point 00179 // and the original point. 00180 // The half-ray or full-ray intersection and the contact 00181 // sphere adjustment of the projection vector is set by the 00182 // intersection parameters 00183 pointHit ray 00184 ( 00185 const point& p, 00186 const vector& n, 00187 const pointField& meshPoints, 00188 const intersection::algorithm alg = intersection::FULL_RAY, 00189 const intersection::direction dir = intersection::VECTOR 00190 ) const; 00191 00192 //- Return nearest point to face 00193 pointHit nearestPoint 00194 ( 00195 const point& p, 00196 const pointField& meshPoints 00197 ) const; 00198 00199 //- Return contact sphere diameter 00200 scalar contactSphereDiameter 00201 ( 00202 const point& p, 00203 const vector& n, 00204 const pointField& meshPoints 00205 ) const; 00206 00207 //- Return area in contact, given the displacement in vertices 00208 scalar areaInContact 00209 ( 00210 const pointField& points, 00211 const scalarField& v 00212 ) const; 00213 00214 //- Return number of edges 00215 inline label nEdges() const; 00216 00217 //- Return edges in face point ordering, i.e. edges()[0] is edge 00218 // between [0] and [1] 00219 edgeList edges() const; 00220 00221 //- Return n-th face edge 00222 inline edge faceEdge(const label n) const; 00223 00224 00225 // Face splitting utilities 00226 00227 //- Number of triangles after splitting 00228 label nTriangles(const pointField& points) const; 00229 00230 //- Split into triangles using existing points. Result in 00231 // triFaces[triI..triI+nTri]. Splits intelligently to maximize 00232 // triangle quality. 00233 void triangles 00234 ( 00235 const pointField& points, 00236 label& triI, 00237 faceList& triFaces 00238 ) const; 00239 00240 //- Number of triangles and quads after splitting 00241 void nTrianglesQuads 00242 ( 00243 const pointField& points, 00244 label& nTris, 00245 label& nQuads 00246 ) const; 00247 00248 //- Split into triangles and quads. Result in triFaces (starting at 00249 // triI and quadFaces (starting at quadI) 00250 void trianglesQuads 00251 ( 00252 const pointField& points, 00253 label& triI, 00254 label& quadI, 00255 faceList& triFaces, 00256 faceList& quadFaces 00257 ) const; 00258 00259 00260 // Friend Operators 00261 00262 friend bool operator==(const face&, const face&); 00263 friend bool operator!=(const face&, const face&); 00264 00265 00266 // Istream Operator 00267 00268 inline friend Istream& operator>>(Istream&, face&); 00269 }; 00270 00271 00272 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00273 00274 } // End namespace Foam 00275 00276 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00277 00278 #include "faceI.H" 00279 00280 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00281 00282 #endif 00283 00284 // ************************************************************************* //