BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / sampling / sampledSurface / writers / starcd / starcdSurfaceWriter.C
blob86fb4b1c17db8e6994d65e8c7497751532bc5b99
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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"
29 #include "OFstream.H"
30 #include "OSspecific.H"
32 #include "makeSurfaceWriterMethods.H"
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 namespace Foam
38     makeSurfaceWriterType(starcdSurfaceWriter);
42 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
44 namespace Foam
46     template<>
47     inline void Foam::starcdSurfaceWriter::writeData
48     (
49         Ostream& os,
50         const scalar& v
51     )
52     {
53         os  << v << nl;
54     }
57     template<>
58     inline void Foam::starcdSurfaceWriter::writeData
59     (
60         Ostream& os,
61         const vector& v
62     )
63     {
64         os  << v[0] << ' ' << v[1] << ' ' << v[2] << nl;
65     }
68     template<>
69     inline void Foam::starcdSurfaceWriter::writeData
70     (
71         Ostream& os,
72         const sphericalTensor& v
73     )
74     {
75         os  << v[0] << nl;
76     }
81 template<class Type>
82 inline void Foam::starcdSurfaceWriter::writeData
84     Ostream& os,
85     const Type& v
90 template<class Type>
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,
100     const bool verbose
101 ) const
103     if (!isDir(outputDir))
104     {
105         mkDir(outputDir);
106     }
108     OFstream os(outputDir/fieldName + '_' + surfaceName + ".usr");
110     if (verbose)
111     {
112         Info<< "Writing field " << fieldName << " to " << os.name() << endl;
113     }
115     // no header, just write values
116     forAll(values, elemI)
117     {
118         os  << elemI+1 << ' ';
119         writeData(os, values[elemI]);
120     }
125 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
127 Foam::starcdSurfaceWriter::starcdSurfaceWriter()
129     surfaceWriter()
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,
147     const bool verbose
148 ) const
150     if (!isDir(outputDir))
151     {
152         mkDir(outputDir);
153     }
155     fileName outName(outputDir/surfaceName + ".inp");
157     if (verbose)
158     {
159         Info<< "Writing geometry to " << outName << endl;
160     }
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 // ************************************************************************* //