1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 Collection of static functions to do various simple mesh related things.
34 \*---------------------------------------------------------------------------*/
41 #include "labelList.H"
42 #include "pointField.H"
45 #include "primitivePatch.H"
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 /*---------------------------------------------------------------------------*\
56 Namespace meshTools Declaration
57 \*---------------------------------------------------------------------------*/
61 // Bit identifiers for octants (p=plus, m=min e.g. plusXminYminZ)
63 static const label mXmYmZ = 0;
64 static const label pXmYmZ = 1;
65 static const label mXpYmZ = 2;
66 static const label pXpYmZ = 3;
68 static const label mXmYpZ = 4;
69 static const label pXmYpZ = 5;
70 static const label mXpYpZ = 6;
71 static const label pXpYpZ = 7;
73 static const label mXmYmZMask = 1 << mXmYmZ;
74 static const label pXmYmZMask = 1 << pXmYmZ;
75 static const label mXpYmZMask = 1 << mXpYmZ;
76 static const label pXpYmZMask = 1 << pXpYmZ;
78 static const label mXmYpZMask = 1 << mXmYpZ;
79 static const label pXmYpZMask = 1 << pXmYpZ;
80 static const label mXpYpZMask = 1 << mXpYpZ;
81 static const label pXpYpZMask = 1 << pXpYpZ;
86 //- Check if n is in same direction as normals of all faceLabels
90 const vectorField& faceNormals,
91 const labelList& faceLabels
94 //- Calculate point normals on a 'box' mesh (all edges aligned with
96 vectorField calcBoxPointNormals(const primitivePatch& pp);
98 //- Normalized edge vector
99 vector normEdgeVec(const primitiveMesh&, const label edgeI);
104 //- Write obj representation of point
111 //- Write obj representation of faces subset
117 const labelList& faceLabels
120 //- Write obj representation of faces
128 //- Write obj representation of cell subset
135 const labelList& cellLabels
139 // Cell/face/edge walking
141 //- Is edge used by cell
144 const primitiveMesh&,
149 //- Is edge used by face
152 const primitiveMesh&,
157 //- Is face used by cell
160 const primitiveMesh&,
165 //- Return edge among candidates that uses the two vertices.
168 const edgeList& edges,
169 const labelList& candidates,
174 //- Return edge between two vertices. Returns -1 if no edge.
177 const primitiveMesh&,
182 //- Return edge shared by two faces. Throws error if no edge found.
185 const primitiveMesh&,
190 //- Return face shared by two cells. Throws error if none found.
193 const primitiveMesh&,
198 //- Get faces on cell using edgeI. Throws error if no two found.
201 const primitiveMesh&,
208 //- Return label of other edge (out of candidates edgeLabels)
209 // connected to vertex but not edgeI. Throws error if none found.
212 const primitiveMesh&,
213 const labelList& edgeLabels,
218 //- Return face on cell using edgeI but not faceI. Throws error
222 const primitiveMesh&,
228 //- Return cell on other side of face. Throws error
229 // if face not internal.
232 const primitiveMesh&,
237 //- Returns label of edge nEdges away from startEdge (in the direction
241 const primitiveMesh&,
243 const label startEdgeI,
244 const label startVertI,
249 // Constraints on position
251 //- Set the constrained components of position to mesh centre
252 void constrainToMeshCentre
254 const polyMesh& mesh,
257 void constrainToMeshCentre
259 const polyMesh& mesh,
263 //- Set the constrained components of directions/velocity to zero
264 void constrainDirection
266 const polyMesh& mesh,
267 const Vector<label>& dirs,
270 void constrainDirection
272 const polyMesh& mesh,
273 const Vector<label>& dirs,
278 // Hex only functionality.
280 //- Given edge on hex find other 'parallel', non-connected edges.
281 void getParallelEdges
283 const primitiveMesh&,
291 //- Given edge on hex find all 'parallel' (i.e. non-connected)
292 // edges and average direction of them
295 const primitiveMesh&,
300 //- Reverse of edgeToCutDir: given direction find edge bundle and
301 // return one of them.
304 const primitiveMesh&,
309 } // End namespace meshTools
312 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
314 } // End namespace Foam
316 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
320 // ************************************************************************* //