1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "PatchTools.H"
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 template<class> class FaceList,
39 Foam::PatchTools::checkOrientation
41 const PrimitivePatch<Face, FaceList, PointField, PointType>& p,
46 bool foundError = false;
48 // Check edge normals, face normals, point normals.
49 forAll(p.faceEdges(), faceI)
51 const labelList& edgeLabels = p.faceEdges()[faceI];
54 if (edgeLabels.size() < 3)
58 Info<< "Face[" << faceI << "] " << p[faceI]
59 << " has fewer than 3 edges. Edges: " << edgeLabels
68 if (edgeLabels[i] < 0 || edgeLabels[i] >= p.nEdges())
72 Info<< "edge number " << edgeLabels[i]
73 << " on face " << faceI
75 << "This usually means the input surface has "
76 << "edges with more than 2 faces connected."
92 //- Compute normal from 3 points, use the first as the origin
93 // minor warpage should not be a problem
94 const Face& f = p[faceI];
95 const point& p0 = p.points()[f[0]];
96 const point& p1 = p.points()[f[1]];
97 const point& p2 = p.points()[f.last()];
99 const vector pointNormal((p1 - p0) ^ (p2 - p0));
100 if ((pointNormal & p.faceNormals()[faceI]) < 0)
107 << "Normal calculated from points inconsistent"
108 << " with faceNormal" << nl
109 << "face: " << f << nl
110 << "points: " << p0 << ' ' << p1 << ' ' << p2 << nl
111 << "pointNormal:" << pointNormal << nl
112 << "faceNormal:" << p.faceNormals()[faceI] << endl;
118 forAll(p.edges(), edgeI)
120 const edge& e = p.edges()[edgeI];
121 const labelList& neighbouringFaces = p.edgeFaces()[edgeI];
123 if (neighbouringFaces.size() == 2)
125 // we use localFaces() since edges() are LOCAL
126 // these are both already available
127 const Face& faceA = p.localFaces()[neighbouringFaces[0]];
128 const Face& faceB = p.localFaces()[neighbouringFaces[1]];
130 // If the faces are correctly oriented, the edges must go in
131 // different directions on connected faces.
132 if (faceA.edgeDirection(e) == faceB.edgeDirection(e))
136 Info<< "face orientation incorrect." << nl
137 << "localEdge[" << edgeI << "] " << e
138 << " between faces:" << nl
139 << " face[" << neighbouringFaces[0] << "] "
140 << p[neighbouringFaces[0]]
141 << " localFace: " << faceA
143 << " face[" << neighbouringFaces[1] << "] "
144 << p[neighbouringFaces[1]]
145 << " localFace: " << faceB
150 setPtr->insert(edgeI);
156 else if (neighbouringFaces.size() != 1)
161 << "Wrong number of edge neighbours." << nl
162 << "edge[" << edgeI << "] " << e
163 << " with points:" << p.localPoints()[e.start()]
164 << ' ' << p.localPoints()[e.end()]
165 << " has neighbouringFaces:" << neighbouringFaces << endl;
170 setPtr->insert(edgeI);
181 // ************************************************************************* //