Forward compatibility: flex
[foam-extend-3.2.git] / applications / utilities / mesh / conversion / sammToFoam / createPolyBoundary.C
blob21b190b02ae31e4fe18f95a661e686edecf6a0c0
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend 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 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  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 // ************************************************************************* //