1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 Create intermediate mesh files from PROSTAR files
28 \*---------------------------------------------------------------------------*/
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 void starMesh::createPolyCells()
36 // loop through all cell faces and create connectivity. This will produce
37 // a global face list and will describe all cells as lists of face labels
39 // count the maximum number of faces and set the size of the cellPolys_
40 cellPolys_.setSize(cellShapes_.size());
44 forAll (cellPolys_, cellI)
46 cell& curCell = cellPolys_[cellI];
48 curCell.setSize(cellFaces_[cellI].size());
55 maxFaces += cellFaces_[cellI].size();
58 Info << "Maximum possible number of faces in mesh: " << maxFaces << endl;
60 meshFaces_.setSize(maxFaces);
62 // set reference to point-cell addressing
63 const labelListList& PointCells = pointCells();
69 forAll(cellFaces_, cellI)
72 // Insertion cannot be done in one go as the faces need to be
73 // added into the list in the increasing order of neighbour
74 // cells. Therefore, all neighbours will be detected first
75 // and then added in the correct order.
77 const faceList& curFaces = cellFaces_[cellI];
79 // Record the neighbour cell
80 labelList neiCells(curFaces.size(), -1);
82 // Record the face of neighbour cell
83 labelList faceOfNeiCell(curFaces.size(), -1);
85 label nNeighbours = 0;
88 forAll(curFaces, faceI)
90 // Skip faces that have already been matched
91 if (cellPolys_[cellI][faceI] >= 0) continue;
95 const face& curFace = curFaces[faceI];
97 // get the list of labels
98 const labelList& curPoints = curFace;
101 forAll(curPoints, pointI)
103 // get the list of cells sharing this point
104 const labelList& curNeighbours = PointCells[curPoints[pointI]];
106 // For all neighbours
107 forAll(curNeighbours, neiI)
109 label curNei = curNeighbours[neiI];
111 // reject neighbours with the lower label. This should
112 // also reject current cell.
115 // get the list of search faces
116 const faceList& searchFaces = cellFaces_[curNei];
118 forAll(searchFaces, neiFaceI)
120 if (searchFaces[neiFaceI] == curFace)
125 // Record the neighbour cell and face
126 neiCells[faceI] = curNei;
127 faceOfNeiCell[faceI] = neiFaceI;
138 } // End of current points
139 } // End of current faces
141 // Add the faces in the increasing order of neighbours
142 for (label neiSearch = 0; neiSearch < nNeighbours; neiSearch++)
144 // Find the lowest neighbour which is still valid
146 label minNei = cellPolys_.size();
148 forAll (neiCells, ncI)
150 if (neiCells[ncI] > -1 && neiCells[ncI] < minNei)
153 minNei = neiCells[ncI];
159 // Add the face to the list of faces
160 meshFaces_[nInternalFaces_] = curFaces[nextNei];
163 cellPolys_[cellI][nextNei] = nInternalFaces_;
165 // Mark for neighbour
166 cellPolys_[neiCells[nextNei]][faceOfNeiCell[nextNei]] =
169 // Stop the neighbour from being used again
170 neiCells[nextNei] = -1;
172 // Increment number of faces counter
177 FatalErrorIn("void starMesh::createPolyCells()")
178 << "Error in internal face insertion"
179 << abort(FatalError);
184 // I won't reset the size of internal faces, because more faces will be
185 // added in createPolyBoundary()
189 // ************************ vim: set sw=4 sts=4 et: ************************ //