1 /*---------------------------------------------------------------------------*\
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 -------------------------------------------------------------------------------
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/>.
25 Create intermediate mesh files from SAMM files
27 \*---------------------------------------------------------------------------*/
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 void sammMesh::createPolyCells()
35 // loop through all cell faces and create connectivity. This will produce
36 // a global face list and will describe all cells as lists of face labels
38 // count the maximum number of faces and set the size of the cellPolys_
39 cellPolys_.setSize(cellShapes_.size());
43 forAll (cellPolys_, cellI)
45 cell& curCell = cellPolys_[cellI];
47 curCell.setSize(cellFaces_[cellI].size());
54 maxFaces += cellFaces_[cellI].size();
57 Info << "Maximum possible number of faces in mesh: " << maxFaces << endl;
59 meshFaces_.setSize(maxFaces);
61 // set reference to point-cell addressing
62 const labelListList& PointCells = pointCells();
68 forAll(cellFaces_, cellI)
71 // Insertion cannot be done in one go as the faces need to be
72 // added into the list in the increasing order of neighbour
73 // cells. Therefore, all neighbours will be detected first
74 // and then added in the correct order.
76 const faceList& curFaces = cellFaces_[cellI];
78 // Record the neighbour cell
79 labelList neiCells(curFaces.size(), -1);
81 // Record the face of neighbour cell
82 labelList faceOfNeiCell(curFaces.size(), -1);
84 label nNeighbours = 0;
87 forAll(curFaces, faceI)
89 // Skip faces that have already been matched
90 if (cellPolys_[cellI][faceI] >= 0) continue;
94 const face& curFace = curFaces[faceI];
96 // get the list of labels
97 const labelList& curPoints = curFace;
100 forAll(curPoints, pointI)
102 // get the list of cells sharing this point
103 const labelList& curNeighbours = PointCells[curPoints[pointI]];
105 // For all neighbours
106 forAll(curNeighbours, neiI)
108 label curNei = curNeighbours[neiI];
110 // reject neighbours with the lower label. This should
111 // also reject current cell.
114 // get the list of search faces
115 const faceList& searchFaces = cellFaces_[curNei];
117 forAll(searchFaces, neiFaceI)
119 if (searchFaces[neiFaceI] == curFace)
124 // Record the neighbour cell and face
125 neiCells[faceI] = curNei;
126 faceOfNeiCell[faceI] = neiFaceI;
137 } // End of current points
138 } // End of current faces
140 // Add the faces in the increasing order of neighbours
141 for (label neiSearch = 0; neiSearch < nNeighbours; neiSearch++)
143 // Find the lowest neighbour which is still valid
145 label minNei = cellPolys_.size();
147 forAll (neiCells, ncI)
149 if (neiCells[ncI] > -1 && neiCells[ncI] < minNei)
152 minNei = neiCells[ncI];
158 // Add the face to the list of faces
159 meshFaces_[nInternalFaces_] = curFaces[nextNei];
162 cellPolys_[cellI][nextNei] = nInternalFaces_;
164 // Mark for neighbour
165 cellPolys_[neiCells[nextNei]][faceOfNeiCell[nextNei]] =
168 // Stop the neighbour from being used again
169 neiCells[nextNei] = -1;
171 // Increment number of faces counter
176 FatalErrorIn("void starMesh::createPolyCells()")
177 << "Error in internal face insertion"
178 << abort(FatalError);
183 // I won't reset the size of internal faces, because more faces will be
184 // added in createPolyBoundary()
188 // ************************************************************************* //