FreeFOAM The Cross-Platform CFD Toolkit
createPolyBoundary.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 Description
25  Create intermediate mesh files from SAMM files
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "sammMesh.H"
30 #include <OpenFOAM/polyPatch.H>
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 void sammMesh::createPolyBoundary()
35 {
36  label nBoundaryFacesFound = 0;
37 
38  polyBoundaryPatchStartIndices_.setSize(boundary_.size());
39 
40  label nCreatedFaces = nInternalFaces_;
41 
42  const labelListList& PointCells = pointCells();
43 
44  forAll (boundary_, patchI)
45  {
46  const faceList& curShapePatch = boundary_[patchI];
47 
48  polyBoundaryPatchStartIndices_[patchI] = nCreatedFaces;
49 
50  forAll (curShapePatch, faceI)
51  {
52  bool found = false;
53 
54  const face& curFace = curShapePatch[faceI];
55 
56  meshFaces_[nCreatedFaces] = curFace;
57 
58  // Must find which cell this face belongs to in order to
59  // mark it in the cellPolys_
60  const labelList& facePoints = curFace;
61 
62  forAll(facePoints, pointI)
63  {
64  const labelList& facePointCells =
65  PointCells[facePoints[pointI]];
66 
67  forAll(facePointCells, cellI)
68  {
69  const faceList& curCellFaces =
70  cellFaces_[facePointCells[cellI]];
71 
72  forAll(curCellFaces, cellFaceI)
73  {
74  if (curCellFaces[cellFaceI] == curFace)
75  {
76  // Found the cell face corresponding to this face
77  found = true;
78 
79  // Debugging
80  if
81  (
82  cellPolys_[facePointCells[cellI]][cellFaceI]
83  != -1
84  )
85  {
87  (
88  "void sammMesh::createPolyBoundary()"
89  ) << "This looks like an already detected "
90  << "internal face"
91  << abort(FatalError);
92  }
93 
94  cellPolys_[facePointCells[cellI]][cellFaceI] =
95  nCreatedFaces;
96 
97  nBoundaryFacesFound++;
98  }
99  if (found) break;
100  }
101  if (found) break;
102  }
103  if (found) break;
104  }
105 
106  nCreatedFaces++;
107  }
108  }
109 
110  // reset the size of the face list
111  meshFaces_.setSize(nCreatedFaces);
112 
113  Info << "Number of boundary faces: " << nBoundaryFacesFound << endl;
114  Info << "Total number of faces: " << nCreatedFaces << endl;
115 }
116 
117 
118 List<polyPatch* > sammMesh::polyBoundaryPatches(const polyMesh& pMesh)
119 {
120  List<polyPatch* > p(boundary_.size());
121 
122  forAll (boundary_, patchI)
123  {
124  const faceList& curShapePatch = boundary_[patchI];
125 
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();
135 
136  p[patchI]->physicalType() = patchPhysicalTypes_[patchI];
137  }
138 
139  return p;
140 }
141 
142 
143 // ************************ vim: set sw=4 sts=4 et: ************************ //