ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / applications / utilities / mesh / conversion / sammToFoam / createBoundaryFaces.C
blob7511a8d2cafc866aebca42eccfc1aa4ba3bc816a
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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 Description
25     Create intermediate mesh files from SAMM files
27 \*---------------------------------------------------------------------------*/
29 #include "sammMesh.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 // Specialist version of face comparison to deal with
34 // PROSTAR boundary format idiosyncracies
35 bool sammMesh::sammEqualFace
37     const face& boundaryFace,
38     const face& cellFace
39 ) const
41     // A PROSTAR boundary face is defined by 4 vertices irrespective
42     // of its topology.
43     // In order to deal with all possibilities, two faces will be
44     // considered equal if three of the vertices are the same.
45     label nEqual = 0;
47     forAll(cellFace, cellFaceLabelI)
48     {
49         const label curCellFaceLabel = cellFace[cellFaceLabelI];
51         forAll(boundaryFace, bouFaceLabelI)
52         {
53             if (boundaryFace[bouFaceLabelI] == curCellFaceLabel)
54             {
55                 nEqual++;
57                 break;
58             }
59         }
60     }
62     if (nEqual >= 3)
63     {
64         return true;
65     }
66     else
67     {
68         return false;
69     }
73 void sammMesh::createBoundaryFaces()
75     forAll(boundary_, patchI)
76     {
77         faceList& patchFaces = boundary_[patchI];
79         const labelListList& PointCells = pointCells();
81         forAll(patchFaces, faceI)
82         {
83             bool found = false;
85             face& curFace = patchFaces[faceI];
86             const labelList& facePoints = curFace;
88             forAll(facePoints, pointI)
89             {
90                 const labelList& facePointCells =
91                     PointCells[facePoints[pointI]];
93                 forAll(facePointCells, cellI)
94                 {
95                     const faceList& curCellFaces =
96                         cellFaces_[facePointCells[cellI]];
98                     forAll(curCellFaces, cellFaceI)
99                     {
100                         if (sammEqualFace(curCellFaces[cellFaceI], curFace))
101                         {
102                             // Found the cell face corresponding to this face
103                             found = true;
105                             // Set boundary face to the corresponding cell face
106                             // which guarantees it is outward-pointing
107                             curFace = curCellFaces[cellFaceI];
108                         }
109                         if (found) break;
110                     }
111                     if (found) break;
112                 }
113                 if (found) break;
114             }
115             if (!found)
116             {
117                 FatalErrorIn("sammMesh::createBoundaryFaces()")
118                     << "Face " << faceI
119                     << " does not have neighbour cell." << endl
120                     << "    face : " << endl << curFace
121                     << abort(FatalError);
122             }
123         }
124     }
128 // ************************************************************************* //