initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / applications / utilities / mesh / conversion / sammToFoam / createPolyBoundary.C
blobefca6a37b5854ff93dc7fc29b5aa95e276a87e9e
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"
31 #include "polyPatch.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 void sammMesh::createPolyBoundary()
37     label nBoundaryFacesFound = 0;
39     polyBoundaryPatchStartIndices_.setSize(boundary_.size());
41     label nCreatedFaces = nInternalFaces_;
43     const labelListList& PointCells = pointCells();
45     forAll (boundary_, patchI)
46     {
47         const faceList& curShapePatch = boundary_[patchI];
49         polyBoundaryPatchStartIndices_[patchI] = nCreatedFaces;
51         forAll (curShapePatch, faceI)
52         {
53             bool found = false;
55             const face& curFace = curShapePatch[faceI];
57             meshFaces_[nCreatedFaces] = curFace;
59             // Must find which cell this face belongs to in order to
60             // mark it in the cellPolys_
61             const labelList& facePoints = curFace;
63             forAll(facePoints, pointI)
64             {
65                 const labelList& facePointCells =
66                     PointCells[facePoints[pointI]];
68                 forAll(facePointCells, cellI)
69                 {
70                     const faceList& curCellFaces =
71                         cellFaces_[facePointCells[cellI]];
73                     forAll(curCellFaces, cellFaceI)
74                     {
75                         if (curCellFaces[cellFaceI] == curFace)
76                         {
77                             // Found the cell face corresponding to this face
78                             found = true;
80                             // Debugging
81                             if
82                             (
83                                 cellPolys_[facePointCells[cellI]][cellFaceI]
84                              != -1
85                             )
86                             {
87                                 FatalErrorIn
88                                 (
89                                     "void sammMesh::createPolyBoundary()"
90                                 )   << "This looks like an already detected "
91                                     << "internal face"
92                                     << abort(FatalError);
93                             }
95                             cellPolys_[facePointCells[cellI]][cellFaceI] =
96                                 nCreatedFaces;
98                             nBoundaryFacesFound++;
99                         }
100                         if (found) break;
101                     }
102                     if (found) break;
103                 }
104                 if (found) break;
105             }
107             nCreatedFaces++;
108         }
109     }
111     // reset the size of the face list
112     meshFaces_.setSize(nCreatedFaces);
114     Info << "Number of boundary faces: " << nBoundaryFacesFound << endl;
115     Info << "Total number of faces: " << nCreatedFaces << endl;
119 List<polyPatch* > sammMesh::polyBoundaryPatches(const polyMesh& pMesh)
121     List<polyPatch* > p(boundary_.size());
123     forAll (boundary_, patchI)
124     {
125         const faceList& curShapePatch = boundary_[patchI];
127         p[patchI] = polyPatch::New
128         (
129             patchTypes_[patchI],
130             patchNames_[patchI],
131             curShapePatch.size(),
132             polyBoundaryPatchStartIndices_[patchI],
133             patchI,
134             pMesh.boundaryMesh()
135         ).ptr();
137         p[patchI]->physicalType() = patchPhysicalTypes_[patchI];
138     }
140     return p;
144 // ************************************************************************* //