OpenFOAM logo
Open Source CFD Toolkit

meshTools.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 Namespace
00026     meshTools
00027 
00028 Description
00029     Collection of static functions to do various simple mesh related things.
00030 
00031 SourceFiles
00032     meshTools.C
00033 
00034 \*---------------------------------------------------------------------------*/
00035 
00036 #ifndef meshTools_H
00037 #define meshTools_H
00038 
00039 #include "label.H"
00040 #include "vector.H"
00041 #include "labelList.H"
00042 #include "pointField.H"
00043 #include "faceList.H"
00044 #include "cellList.H"
00045 #include "primitivePatch.H"
00046 
00047 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00048 
00049 namespace Foam
00050 {
00051 
00052 class primitiveMesh;
00053 
00054 
00055 /*---------------------------------------------------------------------------*\
00056                         Namespace meshTools Declaration
00057 \*---------------------------------------------------------------------------*/
00058 
00059 namespace meshTools
00060 {
00061     // Bit identifiers for octants (p=plus, m=min e.g. plusXminYminZ)
00062 
00063     static const label mXmYmZ = 0;
00064     static const label pXmYmZ = 1;
00065     static const label mXpYmZ = 2;
00066     static const label pXpYmZ = 3;
00067 
00068     static const label mXmYpZ = 4;
00069     static const label pXmYpZ = 5;
00070     static const label mXpYpZ = 6;
00071     static const label pXpYpZ = 7;
00072 
00073     static const label mXmYmZMask = 1 << mXmYmZ;
00074     static const label pXmYmZMask = 1 << pXmYmZ;
00075     static const label mXpYmZMask = 1 << mXpYmZ;
00076     static const label pXpYmZMask = 1 << pXpYmZ;
00077 
00078     static const label mXmYpZMask = 1 << mXmYpZ;
00079     static const label pXmYpZMask = 1 << pXmYpZ;
00080     static const label mXpYpZMask = 1 << mXpYpZ;
00081     static const label pXpYpZMask = 1 << pXpYpZ;
00082 
00083 
00084     //- Check if n is in same direction as normals of all faceLabels
00085     bool visNormal
00086     (
00087         const vector& n,
00088         const vectorField& faceNormals,
00089         const labelList& faceLabels
00090     );
00091 
00092     //- Calculate point normals on a 'box' mesh (all edges aligned with
00093     //  coordinate axes)
00094     vectorField calcBoxPointNormals(const primitivePatch& pp);
00095 
00096     //- Normalized edge vector
00097     vector normEdgeVec(const primitiveMesh&, const label edgeI);
00098 
00099     //- Write obj representation of point
00100     void writeOBJ
00101     (
00102         Ostream& os,
00103         const point& pt
00104     );
00105 
00106 
00107     //- Write obj representation of faces subset
00108     void writeOBJ
00109     (
00110         Ostream& os,
00111         const faceList&,
00112         const pointField&,
00113         const labelList& faceLabels
00114     );
00115 
00116     //- Write obj representation of faces
00117     void writeOBJ
00118     (
00119         Ostream& os,
00120         const faceList&,
00121         const pointField&
00122     );
00123 
00124     //- Write obj representation of cell subset
00125     void writeOBJ
00126     (
00127         Ostream& os,
00128         const cellList&,
00129         const faceList&,
00130         const pointField&,
00131         const labelList& cellLabels
00132     );
00133 
00134     //- Is edge used by cell
00135     bool edgeOnCell
00136     (
00137         const primitiveMesh&,
00138         const label cellI,
00139         const label edgeI
00140     );
00141 
00142     //- Is edge used by face
00143     bool edgeOnFace
00144     (
00145         const primitiveMesh&,
00146         const label faceI,
00147         const label edgeI
00148     );
00149     
00150     //- Is face used by cell
00151     bool faceOnCell
00152     (
00153         const primitiveMesh&,
00154         const label cellI,
00155         const label faceI
00156     );
00157 
00158     //- Return edge among candidates that uses the two vertices.
00159     label findEdge
00160     (
00161         const edgeList& edges,
00162         const labelList& candidates,
00163         const label v0,
00164         const label v1
00165     );
00166 
00167     //- Return edge between two vertices. Returns -1 if no edge.
00168     label findEdge
00169     (
00170         const primitiveMesh&,
00171         const label v0,
00172         const label v1
00173     );
00174 
00175     //- Return edge shared by two faces. Throws error if no edge found.
00176     label getSharedEdge
00177     (
00178         const primitiveMesh&,
00179         const label f0,
00180         const label f1
00181     );
00182     
00183     //- Return face shared by two cells. Throws error if none found.
00184     label getSharedFace
00185     (
00186         const primitiveMesh&,
00187         const label cell0,
00188         const label cell1
00189     );
00190 
00191     //- Get faces on cell using edgeI. Throws error if no two found.
00192     void getEdgeFaces
00193     (
00194         const primitiveMesh&,
00195         const label cellI,
00196         const label edgeI,
00197         label& face0,
00198         label& face1
00199     );
00200 
00201     //- Return label of other edge (out of candidates edgeLabels)
00202     //  connected to vertex but not edgeI. Throws error if none found.
00203     label otherEdge
00204     (
00205         const primitiveMesh&,
00206         const labelList& edgeLabels,
00207         const label edgeI,
00208         const label vertI
00209     );
00210     
00211     //- Return face on cell using edgeI but not faceI. Throws error 
00212     //  if none found.
00213     label otherFace
00214     (
00215         const primitiveMesh&,
00216         const label cellI,
00217         const label faceI,
00218         const label edgeI
00219     );
00220 
00221     //- Return cell on other side of face. Throws error 
00222     //  if face not internal.
00223     label otherCell
00224     (
00225         const primitiveMesh&,
00226         const label cellI,
00227         const label faceI
00228     );
00229     
00230     //- Returns label of edge nEdges away from startEdge (in the direction
00231     // of startVertI)
00232     label walkFace
00233     (
00234         const primitiveMesh&,
00235         const label faceI,
00236         const label startEdgeI,
00237         const label startVertI,
00238         const label nEdges
00239     );
00240 
00241     
00242     //
00243     // Hex only functionality.
00244     //
00245 
00246     //- Given edge on hex find other 'parallel', non-connected edges.
00247     void getParallelEdges
00248     (
00249         const primitiveMesh&,
00250         const label cellI,
00251         const label e0,
00252         label&,
00253         label&,
00254         label&
00255     );
00256 
00257     //- Given edge on hex find all 'parallel' (i.e. non-connected)
00258     //  edges and average direction of them
00259     vector edgeToCutDir
00260     (
00261         const primitiveMesh&,
00262         const label cellI,
00263         const label edgeI
00264     );
00265 
00266     //- Reverse of edgeToCutDir: given direction find edge bundle and
00267     //  return one of them.
00268     label cutDirToEdge
00269     (
00270         const primitiveMesh&,
00271         const label cellI,
00272         const vector& cutDir
00273     );
00274     
00275 } // End namespace meshTools
00276 
00277 
00278 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00279 
00280 } // End namespace Foam
00281 
00282 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00283 
00284 #endif
00285 
00286 // ************************************************************************* //
For further information go to www.openfoam.org