initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / applications / utilities / mesh / conversion / sammToFoam / createBoundaryFaces.C
blobdd4e7b944e9e5f2a7707b91c5db5f044950044b7
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
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 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
19     for more details.
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
25 Description
26     Create intermediate mesh files from SAMM files
28 \*---------------------------------------------------------------------------*/
30 #include "sammMesh.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 // Specialist version of face comparison to deal with
35 // PROSTAR boundary format idiosyncracies
36 bool sammMesh::sammEqualFace
38     const face& boundaryFace,
39     const face& cellFace
40 ) const
42     // A PROSTAR boundary face is defined by 4 vertices irrespective
43     // of its topology.
44     // In order to deal with all possibilities, two faces will be
45     // considered equal if three of the vertices are the same.
46     label nEqual = 0;
48     forAll (cellFace, cellFaceLabelI)
49     {
50         const label curCellFaceLabel = cellFace[cellFaceLabelI];
52         forAll (boundaryFace, bouFaceLabelI)
53         {
54             if (boundaryFace[bouFaceLabelI] == curCellFaceLabel)
55             {
56                 nEqual++;
58                 break;
59             }
60         }
61     }
63     if (nEqual >= 3)
64     {
65         return true;
66     }
67     else
68     {
69         return false;
70     }
74 void sammMesh::createBoundaryFaces()
76     forAll(boundary_, patchI)
77     {
78         faceList& patchFaces = boundary_[patchI];
80         const labelListList& PointCells = pointCells();
82         forAll(patchFaces, faceI)
83         {
84             bool found = false;
86             face& curFace = patchFaces[faceI];
87             const labelList& facePoints = curFace;
89             forAll(facePoints, pointI)
90             {
91                 const labelList& facePointCells =
92                     PointCells[facePoints[pointI]];
94                 forAll(facePointCells, cellI)
95                 {
96                     const faceList& curCellFaces =
97                         cellFaces_[facePointCells[cellI]];
99                     forAll(curCellFaces, cellFaceI)
100                     {
101                         if (sammEqualFace(curCellFaces[cellFaceI], curFace))
102                         {
103                             // Found the cell face corresponding to this face
104                             found = true;
106                             // Set boundary face to the corresponding cell face
107                             // which guarantees it is outward-pointing
108                             curFace = curCellFaces[cellFaceI];
109                         }
110                         if (found) break;
111                     }
112                     if (found) break;
113                 }
114                 if (found) break;
115             }
116             if (!found)
117             {
118                 FatalErrorIn("sammMesh::createBoundaryFaces()")
119                     << "Face " << faceI
120                     << " does not have neighbour cell." << endl
121                     << "    face : " << endl << curFace
122                     << abort(FatalError);
123             }
124         }
125     }
129 // ************************************************************************* //