1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
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
25 \*---------------------------------------------------------------------------*/
27 #include "STARCDsurfaceFormatCore.H"
29 #include "IStringStream.H"
31 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
33 bool Foam::fileFormats::STARCDsurfaceFormatCore::readHeader
43 "fileFormats::STARCDsurfaceFormatCore::readHeader(...)"
45 << "cannot read " << signature << " " << is.name()
55 IStringStream(line)() >> header;
58 IStringStream(line)() >> majorVersion;
60 // add other checks ...
61 if (header != signature)
63 Info<< "header mismatch " << signature << " " << is.name()
71 void Foam::fileFormats::STARCDsurfaceFormatCore::writeHeader
77 os << "PROSTAR_" << filetype << nl
90 bool Foam::fileFormats::STARCDsurfaceFormatCore::readPoints
105 "fileFormats::STARCDsurfaceFormatCore::readPoints(...)"
107 << "Cannot read file " << is.name()
111 readHeader(is, "PROSTAR_VERTEX");
113 DynamicList<point> dynPoints;
114 // STAR-CD index of points
115 DynamicList<label> dynPointId;
118 while ((is >> lineLabel).good())
124 dynPoints.append(point(x, y, z));
125 dynPointId.append(lineLabel);
128 points.transfer(dynPoints);
129 ids.transfer(dynPointId);
136 void Foam::fileFormats::STARCDsurfaceFormatCore::writePoints
139 const pointField& pointLst
142 writeHeader(os, "VERTEX");
144 // Set the precision of the points data to 10
147 // force decimal point for Fortran input
148 os.setf(std::ios::showpoint);
150 forAll(pointLst, ptI)
154 << pointLst[ptI].x() << " "
155 << pointLst[ptI].y() << " "
156 << pointLst[ptI].z() << nl;
162 void Foam::fileFormats::STARCDsurfaceFormatCore::writeCase
165 const pointField& pointLst,
167 const UList<surfZone>& zoneLst
170 word caseName = os.name().lessExt().name();
172 os << "! STAR-CD file written " << clock::dateTime().c_str() << nl
173 << "! " << pointLst.size() << " points, " << nFaces << " faces" << nl
174 << "! case " << caseName << nl
175 << "! ------------------------------" << nl;
177 forAll(zoneLst, zoneI)
179 os << "ctable " << zoneI + 1 << " shell" << nl
180 << "ctname " << zoneI + 1 << " "
181 << zoneLst[zoneI].name() << nl;
184 os << "! ------------------------------" << nl
185 << "*set icvo mxv - 1" << nl
186 << "vread " << caseName << ".vrt icvo,,,coded" << nl
187 << "cread " << caseName << ".cel icvo,,,add,coded" << nl
195 // ************************************************************************* //