1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
25 Create intermediate mesh files from PROSTAR files
27 \*---------------------------------------------------------------------------*/
31 #include "wallPolyPatch.H"
32 #include "oldCyclicPolyPatch.H"
33 #include "symmetryPolyPatch.H"
34 #include "preservePatchTypes.H"
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 void starMesh::readBoundary()
41 label nPatches=0, nFaces=0;
42 labelList nPatchFaces(1000);
44 label lineIndex, starLabel;
45 label starRegion, configNumber;
47 labelList pointLabels(4);
48 labelList pointLabelsTri(3);
50 labelList patchLabels(1000, -1);
53 patchTypes_.setSize(1000);
54 patchNames_.setSize(1000);
56 fileName boundaryFileName(casePrefix_ + ".bnd");
59 IFstream boundaryFile(boundaryFileName);
61 // Collect no. of faces (nFaces),
62 // no. of patches (nPatches)
63 // and for each of these patches the number of faces
64 // (nPatchFaces[patchLabel])
65 // and a conversion table from Star regions to (Foam) patchLabels
67 if (boundaryFile.good())
69 forAll(nPatchFaces, faceLabel)
71 nPatchFaces[faceLabel] = 0;
74 while ((boundaryFile >> lineIndex).good())
79 for (int i=0; i<4; i++)
81 boundaryFile >> starLabel;
84 boundaryFile >> starRegion;
85 boundaryFile >> configNumber;
86 boundaryFile >> patchType;
88 // Build translation table to convert star patch to foam patch
89 label patchLabel = patchLabels[starRegion];
92 patchLabel = nPatches;
93 patchLabels[starRegion] = patchLabel;
94 patchTypes_[patchLabel] = patchType;
95 patchNames_[patchLabel] = patchType + name(starRegion);
99 Info<< "Star region " << starRegion
100 << " with type " << patchType
101 << " is now Foam patch " << patchLabel << endl;
105 nPatchFaces[patchLabel]++;
110 << "Setting size of boundary to " << nPatches
113 nPatchFaces.setSize(nPatches);
117 FatalErrorIn("starMesh::readBoundary()")
118 << "Cannot read file "
120 << abort(FatalError);
126 boundary_.setSize(nPatchFaces.size());
127 patchTypes_.setSize(nPatchFaces.size());
128 patchNames_.setSize(nPatchFaces.size());
130 // size the lists and reset the counters to be used again
131 forAll(boundary_, patchLabel)
133 boundary_[patchLabel].setSize(nPatchFaces[patchLabel]);
135 nPatchFaces[patchLabel] = 0;
138 IFstream boundaryFile(boundaryFileName);
140 for (label faceI=0; faceI<nFaces; faceI++)
142 boundaryFile >> lineIndex;
144 for (int i = 0; i < 4; i++)
146 boundaryFile >> starLabel;
148 // convert Star label to Foam point label
149 // through lookup-list starPointLabelLookup_
150 pointLabels[i] = starPointLabelLookup_[starLabel];
152 if (pointLabels[i] < 0)
154 Info<< "Boundary file not consistent with vertex file\n"
155 << "Star vertex number " << starLabel
156 << " does not exist\n";
161 boundaryFile >> starRegion;
162 label patchLabel = patchLabels[starRegion];
164 boundaryFile >> configNumber;
165 boundaryFile >> patchType;
169 pointLabels[2] == pointLabels[3]
172 //Info<< "Converting collapsed quad into triangle"
173 // << " for face " << faceI
174 // << " in Star boundary " << lineIndex << endl;
176 pointLabelsTri[0] = pointLabels[0];
177 pointLabelsTri[1] = pointLabels[1];
178 pointLabelsTri[2] = pointLabels[2];
180 boundary_[patchLabel][nPatchFaces[patchLabel]]
181 = face(pointLabelsTri);
185 boundary_[patchLabel][nPatchFaces[patchLabel]]
189 // increment counter of faces in current patch
190 nPatchFaces[patchLabel]++;
193 forAll(boundary_, patchLabel)
195 word patchType = patchTypes_[patchLabel];
197 if (patchType == "SYMP")
199 patchTypes_[patchLabel] = symmetryPolyPatch::typeName;
201 else if (patchType == "WALL")
203 patchTypes_[patchLabel] = wallPolyPatch::typeName;
205 else if (patchType == "CYCL")
207 // incorrect. should be cyclicPatch but this
208 // requires info on connected faces.
209 patchTypes_[patchLabel] = oldCyclicPolyPatch::typeName;
213 patchTypes_[patchLabel] = polyPatch::typeName;
216 Info<< "Foam patch " << patchLabel
217 << " is of type " << patchTypes_[patchLabel]
218 << " with name " << patchNames_[patchLabel] << endl;
223 WarningIn("void starMesh::readBoundary()")
224 << "no boundary faces in file "
229 patchPhysicalTypes_.setSize(patchTypes_.size());
231 PtrList<dictionary> patchDicts;
237 polyMesh::meshSubDir,
244 forAll(patchDicts, patchI)
246 if (patchDicts.set(patchI))
248 const dictionary& dict = patchDicts[patchI];
249 dict.readIfPresent("type", patchTypes_[patchI]);
250 dict.readIfPresent("physicalType", patchPhysicalTypes_[patchI]);
256 // ************************************************************************* //