ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / applications / utilities / mesh / conversion / sammToFoam / createPolyBoundary.C
blob25f09764a9e07d27075b32b403620dd79a982764
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"
30 #include "polyPatch.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 void sammMesh::createPolyBoundary()
36     label nBoundaryFacesFound = 0;
38     polyBoundaryPatchStartIndices_.setSize(boundary_.size());
40     label nCreatedFaces = nInternalFaces_;
42     const labelListList& PointCells = pointCells();
44     forAll(boundary_, patchI)
45     {
46         const faceList& curShapePatch = boundary_[patchI];
48         polyBoundaryPatchStartIndices_[patchI] = nCreatedFaces;
50         forAll(curShapePatch, faceI)
51         {
52             bool found = false;
54             const face& curFace = curShapePatch[faceI];
56             meshFaces_[nCreatedFaces] = curFace;
58             // Must find which cell this face belongs to in order to
59             // mark it in the cellPolys_
60             const labelList& facePoints = curFace;
62             forAll(facePoints, pointI)
63             {
64                 const labelList& facePointCells =
65                     PointCells[facePoints[pointI]];
67                 forAll(facePointCells, cellI)
68                 {
69                     const faceList& curCellFaces =
70                         cellFaces_[facePointCells[cellI]];
72                     forAll(curCellFaces, cellFaceI)
73                     {
74                         if (curCellFaces[cellFaceI] == curFace)
75                         {
76                             // Found the cell face corresponding to this face
77                             found = true;
79                             // Debugging
80                             if
81                             (
82                                 cellPolys_[facePointCells[cellI]][cellFaceI]
83                              != -1
84                             )
85                             {
86                                 FatalErrorIn
87                                 (
88                                     "void sammMesh::createPolyBoundary()"
89                                 )   << "This looks like an already detected "
90                                     << "internal face"
91                                     << abort(FatalError);
92                             }
94                             cellPolys_[facePointCells[cellI]][cellFaceI] =
95                                 nCreatedFaces;
97                             nBoundaryFacesFound++;
98                         }
99                         if (found) break;
100                     }
101                     if (found) break;
102                 }
103                 if (found) break;
104             }
106             nCreatedFaces++;
107         }
108     }
110     // reset the size of the face list
111     meshFaces_.setSize(nCreatedFaces);
113     Info<< "Number of boundary faces: " << nBoundaryFacesFound << endl;
114     Info<< "Total number of faces: " << nCreatedFaces << endl;
118 List<polyPatch* > sammMesh::polyBoundaryPatches(const polyMesh& pMesh)
120     List<polyPatch* > p(boundary_.size());
122     forAll(boundary_, patchI)
123     {
124         const faceList& curShapePatch = boundary_[patchI];
126         p[patchI] = polyPatch::New
127         (
128             patchTypes_[patchI],
129             patchNames_[patchI],
130             curShapePatch.size(),
131             polyBoundaryPatchStartIndices_[patchI],
132             patchI,
133             pMesh.boundaryMesh()
134         ).ptr();
136         p[patchI]->physicalType() = patchPhysicalTypes_[patchI];
137     }
139     return p;
143 // ************************************************************************* //