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 "starcdSurfaceWriter.H"
28 #include "MeshedSurfaceProxy.H"
30 #include "OSspecific.H"
32 #include "makeSurfaceWriterMethods.H"
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 makeSurfaceWriterType(starcdSurfaceWriter);
42 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
47 inline void Foam::starcdSurfaceWriter::writeData
58 inline void Foam::starcdSurfaceWriter::writeData
64 os << v[0] << ' ' << v[1] << ' ' << v[2] << nl;
69 inline void Foam::starcdSurfaceWriter::writeData
72 const sphericalTensor& v
82 inline void Foam::starcdSurfaceWriter::writeData
91 void Foam::starcdSurfaceWriter::writeTemplate
93 const fileName& outputDir,
94 const fileName& surfaceName,
95 const pointField& points,
96 const faceList& faces,
97 const word& fieldName,
98 const Field<Type>& values,
99 const bool isNodeValues,
103 if (!isDir(outputDir))
108 OFstream os(outputDir/fieldName + '_' + surfaceName + ".usr");
112 Info<< "Writing field " << fieldName << " to " << os.name() << endl;
115 // no header, just write values
116 forAll(values, elemI)
118 os << elemI+1 << ' ';
119 writeData(os, values[elemI]);
125 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
127 Foam::starcdSurfaceWriter::starcdSurfaceWriter()
133 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
135 Foam::starcdSurfaceWriter::~starcdSurfaceWriter()
139 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
141 void Foam::starcdSurfaceWriter::write
143 const fileName& outputDir,
144 const fileName& surfaceName,
145 const pointField& points,
146 const faceList& faces,
150 if (!isDir(outputDir))
155 fileName outName(outputDir/surfaceName + ".inp");
159 Info<< "Writing geometry to " << outName << endl;
162 MeshedSurfaceProxy<face>(points, faces).write(outName);
166 // create write methods
167 defineSurfaceWriterWriteField(Foam::starcdSurfaceWriter, scalar);
168 defineSurfaceWriterWriteField(Foam::starcdSurfaceWriter, vector);
169 defineSurfaceWriterWriteField(Foam::starcdSurfaceWriter, sphericalTensor);
172 // ************************************************************************* //