1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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/>.
24 \*---------------------------------------------------------------------------*/
26 #include "STARCDCore.H"
29 #include "PackedBoolList.H"
30 #include "IStringStream.H"
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 Foam::fileFormats::STARCDCore::STARCDCore()
38 // * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
40 bool Foam::fileFormats::STARCDCore::readHeader
50 "fileFormats::STARCDCore::readHeader(...)"
52 << "cannot read " << signature << " " << is.name()
62 IStringStream(line)() >> header;
65 IStringStream(line)() >> majorVersion;
67 // add other checks ...
68 if (header != signature)
70 Info<< "header mismatch " << signature << " " << is.name()
78 void Foam::fileFormats::STARCDCore::writeHeader
84 os << "PROSTAR_" << filetype << nl
97 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
99 bool Foam::fileFormats::STARCDCore::readPoints
110 "fileFormats::STARCDedgeFormat::readPoints(...)"
112 << "Cannot read file " << is.name()
116 readHeader(is, "PROSTAR_VERTEX");
119 // reuse memory if possible
120 DynamicList<point> dynPoints(points.xfer());
121 DynamicList<label> dynPointId(ids.xfer()); // STAR-CD index of points
127 while ((is >> lineLabel).good())
133 dynPoints.append(point(x, y, z));
134 dynPointId.append(lineLabel);
137 points.transfer(dynPoints);
138 ids.transfer(dynPointId);
144 void Foam::fileFormats::STARCDCore::writePoints
147 const pointField& pointLst
150 writeHeader(os, "VERTEX");
152 // Set the precision of the points data to 10
155 // force decimal point for Fortran input
156 os.setf(std::ios::showpoint);
158 forAll(pointLst, ptI)
162 << pointLst[ptI].x() << " "
163 << pointLst[ptI].y() << " "
164 << pointLst[ptI].z() << nl;
172 // ************************************************************************* //