1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2011 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 from PROSTAR files
27 \*---------------------------------------------------------------------------*/
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 label starMesh::readVtxLabel(IFstream& is)
38 for (int i=0; i<15; i++)
49 scalar starMesh::readVtxCmpt(IFstream& is)
53 for (int i=0; i<16; i++)
60 return scalar(atof(lcs));
64 void starMesh::readToNl(IFstream& is)
70 } while (is && c != '\n');
74 void starMesh::readPoints(const scalar scaleFactor)
79 fileName pointsFileName(casePrefix_ + ".vrt");
82 IFstream pointsFile(pointsFileName);
84 // Pass 1: get # points and maximum vertex label
86 if (pointsFile.good())
93 pointLabel = readVtxLabel(pointsFile);
95 if (!pointsFile) break;
97 maxLabel = max(maxLabel, pointLabel);
99 readVtxCmpt(pointsFile);
100 readVtxCmpt(pointsFile);
101 readVtxCmpt(pointsFile);
103 readToNl(pointsFile);
110 FatalErrorIn("starMesh::readPoints()")
111 << "Cannot read file " << pointsFileName
112 << abort(FatalError);
116 Info<< "Number of points = " << nPoints << endl << endl;
118 points_.setSize(nPoints);
121 starPointID_.setSize(nPoints);
123 // Reset STAR point ID, just in case
127 starPointLabelLookup_.setSize(maxLabel+1);
129 // reset point labels to invalid value
130 starPointLabelLookup_ = -1;
134 // Pass 2: construct pointlist and conversion table
135 // from Star vertex numbers to Foam pointLabels
137 IFstream pointsFile(pointsFileName);
142 pointLabel = readVtxLabel(pointsFile);
143 points_[p].x() = readVtxCmpt(pointsFile);
144 points_[p].y() = readVtxCmpt(pointsFile);
145 points_[p].z() = readVtxCmpt(pointsFile);
147 readToNl(pointsFile);
150 starPointID_[p] = pointLabel;
153 starPointLabelLookup_[pointLabel] = p;
156 if (scaleFactor > 1.0 + SMALL || scaleFactor < 1.0 - SMALL)
158 points_ *= scaleFactor;
164 << "void starMesh::readPoints() : "
165 << "no points in file "
167 << abort(FatalError);
172 // ************************************************************************* //