FreeFOAM The Cross-Platform CFD Toolkit
createPatches.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 
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "blockMesh.H"
30 
31 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32 
33 Foam::faceList Foam::blockMesh::createPatchFaces
34 (
35  const polyPatch& patchTopologyFaces
36 )
37 {
38  blockMesh& blocks = *this;
39 
40  labelList blockLabels = patchTopologyFaces.polyPatch::faceCells();
41 
42  label nFaces=0;
43 
44  forAll(patchTopologyFaces, patchTopologyFaceLabel)
45  {
46  label blockLabel = blockLabels[patchTopologyFaceLabel];
47 
48  faceList blockFaces
49  (
50  blocks[blockLabel].blockDef().blockShape().faces()
51  );
52 
53  forAll(blockFaces, blockFaceLabel)
54  {
55  if
56  (
57  blockFaces[blockFaceLabel]
58  == patchTopologyFaces[patchTopologyFaceLabel]
59  )
60  {
61  nFaces +=
62  blocks[blockLabel].boundaryPatches()[blockFaceLabel].size();
63  }
64  }
65  }
66 
67 
68  faceList patchFaces(nFaces);
69  face quadFace(4);
70  label faceLabel = 0;
71 
72  forAll(patchTopologyFaces, patchTopologyFaceLabel)
73  {
74  label blockLabel = blockLabels[patchTopologyFaceLabel];
75 
76  faceList blockFaces
77  (
78  blocks[blockLabel].blockDef().blockShape().faces()
79  );
80 
81  forAll(blockFaces, blockFaceLabel)
82  {
83  if
84  (
85  blockFaces[blockFaceLabel]
86  == patchTopologyFaces[patchTopologyFaceLabel]
87  )
88  {
89  const labelListList& blockPatchFaces =
90  blocks[blockLabel].boundaryPatches()[blockFaceLabel];
91 
92  forAll(blockPatchFaces, blockFaceLabel)
93  {
94  // Lookup the face points
95  // and collapse duplicate point labels
96 
97  quadFace[0] =
98  mergeList_
99  [
100  blockPatchFaces[blockFaceLabel][0]
101  + blockOffsets_[blockLabel]
102  ];
103 
104  label nUnique = 1;
105 
106  for
107  (
108  label facePointLabel = 1;
109  facePointLabel < 4;
110  facePointLabel++
111  )
112  {
113  quadFace[nUnique] =
114  mergeList_
115  [
116  blockPatchFaces[blockFaceLabel][facePointLabel]
117  + blockOffsets_[blockLabel]
118  ];
119 
120  if (quadFace[nUnique] != quadFace[nUnique-1])
121  {
122  nUnique++;
123  }
124  }
125 
126  if (quadFace[nUnique-1] == quadFace[0])
127  {
128  nUnique--;
129  }
130 
131  if (nUnique == 4)
132  {
133  patchFaces[faceLabel++] = quadFace;
134  }
135  else if (nUnique == 3)
136  {
137  patchFaces[faceLabel++] = face
138  (
140  );
141  }
142  // else the face has collapsed to an edge or point
143  }
144  }
145  }
146  }
147 
148  patchFaces.setSize(faceLabel);
149 
150  return patchFaces;
151 }
152 
153 
154 Foam::faceListList Foam::blockMesh::createPatches()
155 {
156  Info<< "\nCreating patches\n";
157 
158  const polyPatchList& patchTopologies = topology().boundaryMesh();
159  faceListList patches(patchTopologies.size());
160 
161  forAll(patchTopologies, patchLabel)
162  {
163  patches[patchLabel] =
164  createPatchFaces(patchTopologies[patchLabel]);
165  }
166 
167  return patches;
168 }
169 
170 // ************************ vim: set sw=4 sts=4 et: ************************ //