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 \*---------------------------------------------------------------------------*/
31 #include "polyPatch.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 void starMesh::createPolyBoundary()
37 label nBoundaryFacesFound = 0;
39 polyBoundaryPatchStartIndices_.setSize(boundary_.size());
41 label nCreatedFaces = nInternalFaces_;
43 const labelListList& PointCells = pointCells();
45 forAll (boundary_, patchI)
47 const faceList& curShapePatch = boundary_[patchI];
49 polyBoundaryPatchStartIndices_[patchI] = nCreatedFaces;
51 forAll (curShapePatch, faceI)
55 const face& curFace = curShapePatch[faceI];
57 meshFaces_[nCreatedFaces] = curFace;
59 // Must find which cell this face belongs to in order to
60 // mark it in the cellPolys_
61 const labelList& facePoints = curFace;
63 forAll(facePoints, pointI)
65 const labelList& facePointCells =
66 PointCells[facePoints[pointI]];
68 forAll(facePointCells, cellI)
70 const faceList& curCellFaces =
71 cellFaces_[facePointCells[cellI]];
73 forAll(curCellFaces, cellFaceI)
75 if (curCellFaces[cellFaceI] == curFace)
77 // Found the cell face corresponding to this face
83 cellPolys_[facePointCells[cellI]][cellFaceI]
89 cellPolys_[facePointCells[cellI]][cellFaceI]
94 << "void starMesh::createPolyBoundary()"
95 << ": Problem with face: " << curFace
96 << "\nProbably multiple definitions "
97 << "of a single boundary face. " << endl
98 << "Other boundary face: "
99 << curCellFaces[cellFaceI]
102 Info << "PROSTAR Command: vset,news,vlis";
103 forAll (curCellFaces[cellFaceI], spI)
105 // check if the point is given by STAR
106 // or created locally
109 curCellFaces[cellFaceI][spI] > -1
110 && curCellFaces[cellFaceI][spI]
111 < starPointID_.size()
117 [curCellFaces[cellFaceI][spI]];
124 Info << " $ bset,add,vset,all" << endl;
129 << "void starMesh::createPolyBoundary()"
130 << ": Problem with face: " << curFace
131 << "\nProbably trying to define a "
132 << "boundary face on a previously "
133 << "matched internal face. " << endl
135 << curCellFaces[cellFaceI]
138 Info << "PROSTAR Command: vset,news,vlis";
139 forAll (curCellFaces[cellFaceI], spI)
141 // check if the point is given by STAR
142 // or created locally
145 curCellFaces[cellFaceI][spI] > -1
146 && curCellFaces[cellFaceI][spI]
147 < starPointID_.size()
153 [curCellFaces[cellFaceI][spI]];
160 Info << " $ bset,add,vset,all" << endl;
165 cellPolys_[facePointCells[cellI]][cellFaceI] =
168 nBoundaryFacesFound++;
181 // check all cellPolys_ to see if there are any missing faces
182 label nMissingFaceFound = 0;
184 forAll (cellPolys_, cellI)
186 const labelList& curFaces = cellPolys_[cellI];
188 forAll (curFaces, faceI)
190 if (curFaces[faceI] < 0)
192 const face& missingFace = cellFaces_[cellI][faceI];
194 Info << "starMesh::createPolyBoundary() : "
195 << "missing face found in cell " << cellI
196 << ".\nType: " << cellShapes_[cellI].model().name()
197 << ". STAR cell number: " << starCellID_[cellI]
198 << ". Face: " << missingFace << endl;
202 Info << "PROSTAR Command: vset,news,vlis";
203 forAll (missingFace, spI)
205 // check if the point is given by STAR or created locally
208 missingFace[spI] > -1
209 && missingFace[spI] < starPointID_.size()
212 Info << "," << starPointID_[missingFace[spI]];
219 Info << " $ bset,add,vset,all" << endl;
224 if (nMissingFaceFound > 0)
226 Info << "Number of unmatched faces: " << nMissingFaceFound << endl;
229 // reset the size of the face list
230 meshFaces_.setSize(nCreatedFaces);
232 // check the mesh for face mismatch
233 // (faces addressed once or more than twice)
234 labelList markupFaces(meshFaces_.size(), 0);
236 forAll (cellPolys_, cellI)
238 const labelList& curFaces = cellPolys_[cellI];
240 forAll (curFaces, faceI)
242 markupFaces[curFaces[faceI]]++;
246 for (label i = nInternalFaces_; i < markupFaces.size(); i++)
251 label nProblemFacesFound = 0;
253 forAll (markupFaces, faceI)
255 if (markupFaces[faceI] != 2)
257 const face& problemFace = meshFaces_[faceI];
259 Info << "starMesh::createPolyBoundary() : "
260 << "problem with face " << faceI << ": addressed "
261 << markupFaces[faceI] << " times (should be 2!). Face: "
262 << problemFace << endl;
264 nProblemFacesFound++;
266 Info << "PROSTAR Command: vset,news,vlis";
267 forAll (problemFace, spI)
269 // check if the point is given by STAR or created locally
272 problemFace[spI] > -1
273 && problemFace[spI] < starPointID_.size()
276 Info << "," << starPointID_[problemFace[spI]];
283 Info << " $ bset,add,vset,all" << endl;
287 if (nProblemFacesFound > 0)
289 Info << "Number of incorrectly matched faces: "
290 << nProblemFacesFound << endl;
293 Info << "Number of boundary faces: " << nBoundaryFacesFound << endl;
294 Info << "Total number of faces: " << nCreatedFaces << endl;
298 List<polyPatch*> starMesh::polyBoundaryPatches(const polyMesh& pMesh)
300 List<polyPatch*> p(boundary_.size());
302 forAll (boundary_, patchI)
304 p[patchI] = polyPatch::New
308 boundary_[patchI].size(),
309 polyBoundaryPatchStartIndices_[patchI],
319 // ************************************************************************* //