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 #include "wallPolyPatch.H"
33 #include "cyclicPolyPatch.H"
34 #include "symmetryPolyPatch.H"
35 #include "preservePatchTypes.H"
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 void starMesh::readBoundary()
42 label nPatches=0, nFaces=0;
43 labelList nPatchFaces(1000);
45 label lineIndex, starLabel;
46 label starRegion, configNumber;
48 labelList pointLabels(4);
49 labelList pointLabelsTri(3);
51 labelList patchLabels(1000, -1);
54 patchTypes_.setSize(1000);
55 patchNames_.setSize(1000);
57 fileName boundaryFileName(casePrefix_ + ".bnd");
60 IFstream boundaryFile(boundaryFileName);
62 // Collect no. of faces (nFaces),
63 // no. of patches (nPatches)
64 // and for each of these patches the number of faces
65 // (nPatchFaces[patchLabel])
66 // and a conversion table from Star regions to (Foam) patchLabels
68 if (boundaryFile.good())
70 forAll(nPatchFaces, faceLabel)
72 nPatchFaces[faceLabel] = 0;
75 while ((boundaryFile >> lineIndex).good())
80 for (int i=0; i<4; i++)
82 boundaryFile >> starLabel;
85 boundaryFile >> starRegion;
86 boundaryFile >> configNumber;
87 boundaryFile >> patchType;
89 // Build translation table to convert star patch to foam patch
90 label patchLabel = patchLabels[starRegion];
93 patchLabel = nPatches;
94 patchLabels[starRegion] = patchLabel;
95 patchTypes_[patchLabel] = patchType;
96 patchNames_[patchLabel] = patchType + name(starRegion);
100 Info<< "Star region " << starRegion
101 << " with type " << patchType
102 << " is now Foam patch " << patchLabel << endl;
106 nPatchFaces[patchLabel]++;
111 << "Setting size of boundary to " << nPatches
114 nPatchFaces.setSize(nPatches);
118 FatalErrorIn("starMesh::readBoundary()")
119 << "Cannot read file "
121 << abort(FatalError);
127 boundary_.setSize(nPatchFaces.size());
128 patchTypes_.setSize(nPatchFaces.size());
129 patchNames_.setSize(nPatchFaces.size());
131 // size the lists and reset the counters to be used again
132 forAll(boundary_, patchLabel)
134 boundary_[patchLabel].setSize(nPatchFaces[patchLabel]);
136 nPatchFaces[patchLabel] = 0;
139 IFstream boundaryFile(boundaryFileName);
141 for (label faceI=0; faceI<nFaces; faceI++)
143 boundaryFile >> lineIndex;
145 for (int i = 0; i < 4; i++)
147 boundaryFile >> starLabel;
149 // convert Star label to Foam point label
150 // through lookup-list starPointLabelLookup_
151 pointLabels[i] = starPointLabelLookup_[starLabel];
153 if (pointLabels[i] < 0)
155 Info<< "Boundary file not consistent with vertex file\n"
156 << "Star vertex number " << starLabel
157 << " does not exist\n";
162 boundaryFile >> starRegion;
163 label patchLabel = patchLabels[starRegion];
165 boundaryFile >> configNumber;
166 boundaryFile >> patchType;
170 pointLabels[2] == pointLabels[3]
173 //Info<< "Converting collapsed quad into triangle"
174 // << " for face " << faceI
175 // << " in Star boundary " << lineIndex << endl;
177 pointLabelsTri[0] = pointLabels[0];
178 pointLabelsTri[1] = pointLabels[1];
179 pointLabelsTri[2] = pointLabels[2];
181 boundary_[patchLabel][nPatchFaces[patchLabel]]
182 = face(pointLabelsTri);
186 boundary_[patchLabel][nPatchFaces[patchLabel]]
190 // increment counter of faces in current patch
191 nPatchFaces[patchLabel]++;
194 forAll(boundary_, patchLabel)
196 word patchType = patchTypes_[patchLabel];
198 if (patchType == "SYMP")
200 patchTypes_[patchLabel] = symmetryPolyPatch::typeName;
202 else if (patchType == "WALL")
204 patchTypes_[patchLabel] = wallPolyPatch::typeName;
206 else if (patchType == "CYCL")
208 // incorrect. should be cyclicPatch but this
209 // requires info on connected faces.
210 patchTypes_[patchLabel] = cyclicPolyPatch::typeName;
214 patchTypes_[patchLabel] = polyPatch::typeName;
217 Info<< "Foam patch " << patchLabel
218 << " is of type " << patchTypes_[patchLabel]
219 << " with name " << patchNames_[patchLabel] << endl;
224 WarningIn("void starMesh::readBoundary()")
225 << "no boundary faces in file "
230 patchPhysicalTypes_.setSize(patchTypes_.size());
236 polyMesh::defaultRegion,
246 // ************************************************************************* //