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 "rawSurfaceWriter.H"
29 #include "OSspecific.H"
32 #include "makeSurfaceWriterMethods.H"
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 makeSurfaceWriterType(rawSurfaceWriter);
42 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
44 inline void Foam::rawSurfaceWriter::writeLocation
47 const pointField& points,
51 const point& pt = points[pointI];
52 os << pt.x() << ' ' << pt.y() << ' ' << pt.z() << ' ';
56 inline void Foam::rawSurfaceWriter::writeLocation
59 const pointField& points,
60 const faceList& faces,
64 const point& ct = faces[faceI].centre(points);
65 os << ct.x() << ' ' << ct.y() << ' ' << ct.z() << ' ';
72 void Foam::rawSurfaceWriter::writeHeader
75 const word& fieldName,
76 const Field<scalar>& values
79 os << values.size() << nl
80 << "# x y z " << fieldName << nl;
85 void Foam::rawSurfaceWriter::writeHeader
88 const word& fieldName,
89 const Field<vector>& values
92 os << values.size() << nl
102 void Foam::rawSurfaceWriter::writeHeader
105 const word& fieldName,
106 const Field<sphericalTensor>& values
109 os << values.size() << nl
111 << fieldName << "_ii" << nl;
116 void Foam::rawSurfaceWriter::writeHeader
119 const word& fieldName,
120 const Field<symmTensor>& values
123 os << values.size() << nl
124 << "# xx xy xz yy yz ";
125 for (int i=0; i<6; ++i)
127 os << fieldName << "_" << i << " ";
134 void Foam::rawSurfaceWriter::writeHeader
137 const word& fieldName,
138 const Field<tensor>& values
141 os << values.size() << nl
142 << "# xx xy xz yx yy yz zx zy zz";
143 for (int i=0; i<9; ++i)
145 os << fieldName << "_" << i << " ";
152 inline void Foam::rawSurfaceWriter::writeData
163 inline void Foam::rawSurfaceWriter::writeData
169 os << v[0] << ' ' << v[1] << ' ' << v[2] << nl;
174 inline void Foam::rawSurfaceWriter::writeData
177 const sphericalTensor& v
185 inline void Foam::rawSurfaceWriter::writeData
191 os << v[0] << ' ' << v[1] << ' ' << v[2] << ' '
192 << v[3] << ' ' << v[4] << ' ' << v[5] << nl;
197 inline void Foam::rawSurfaceWriter::writeData
203 os << v[0] << ' ' << v[1] << ' ' << v[2] << ' '
204 << v[3] << ' ' << v[4] << ' ' << v[5] << ' '
205 << v[6] << ' ' << v[7] << ' ' << v[8] << nl;
212 void Foam::rawSurfaceWriter::writeTemplate
214 const fileName& outputDir,
215 const fileName& surfaceName,
216 const pointField& points,
217 const faceList& faces,
218 const word& fieldName,
219 const Field<Type>& values,
220 const bool isNodeValues,
224 if (!isDir(outputDir))
229 OFstream os(outputDir/fieldName + '_' + surfaceName + ".raw");
233 Info<< "Writing field " << fieldName << " to " << os.name() << endl;
237 os << "# " << fieldName;
240 os << " POINT_DATA ";
248 writeHeader(os, fieldName, values);
253 forAll(values, elemI)
255 writeLocation(os, points, elemI);
256 writeData(os, values[elemI]);
261 forAll(values, elemI)
263 writeLocation(os, points, faces, elemI);
264 writeData(os, values[elemI]);
271 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
273 Foam::rawSurfaceWriter::rawSurfaceWriter()
279 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
281 Foam::rawSurfaceWriter::~rawSurfaceWriter()
285 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
287 void Foam::rawSurfaceWriter::write
289 const fileName& outputDir,
290 const fileName& surfaceName,
291 const pointField& points,
292 const faceList& faces,
296 if (!isDir(outputDir))
301 OFstream os(outputDir/surfaceName + ".raw");
305 Info<< "Writing geometry to " << os.name() << endl;
310 os << "# geometry NO_DATA " << faces.size() << nl
313 // Write faces centres
316 writeLocation(os, points, faces, elemI);
324 // create write methods
325 defineSurfaceWriterWriteFields(Foam::rawSurfaceWriter);
328 // ************************************************************************* //