1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2011 OpenCFD Ltd.
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 "csvSetWriter.H"
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 Foam::csvSetWriter<Type>::csvSetWriter()
40 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
43 Foam::csvSetWriter<Type>::~csvSetWriter()
47 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
50 Foam::fileName Foam::csvSetWriter<Type>::getFileName
52 const coordSet& points,
53 const wordList& valueSetNames
56 return this->getBaseName(points, valueSetNames) + ".csv";
61 void Foam::csvSetWriter<Type>::write
63 const coordSet& points,
64 const wordList& valueSetNames,
65 const List<const Field<Type>*>& valueSets,
69 writeHeader(points,valueSetNames,os);
71 // Collect sets into columns
72 List<const List<Type>*> columns(valueSets.size());
76 columns[i] = valueSets[i];
79 writeTable(points, columns, os);
84 void Foam::csvSetWriter<Type>::write
86 const bool writeTracks,
87 const PtrList<coordSet>& points,
88 const wordList& valueSetNames,
89 const List<List<Field<Type> > >& valueSets,
93 writeHeader(points[0],valueSetNames,os);
95 if (valueSets.size() != valueSetNames.size())
97 FatalErrorIn("csvSetWriter<Type>::write(..)")
98 << "Number of variables:" << valueSetNames.size() << endl
99 << "Number of valueSets:" << valueSets.size()
103 List<const List<Type>*> columns(valueSets.size());
105 forAll(points, trackI)
107 // Collect sets into columns
110 columns[i] = &valueSets[i][trackI];
113 writeTable(points[trackI], columns, os);
120 void Foam::csvSetWriter<Type>::writeSeparator(Ostream& os) const
128 // otherwise compiler complains about specialization
130 void csvSetWriter<scalar>::writeHeader
132 const coordSet& points,
133 const wordList& valueSetNames,
137 writeCoordHeader(points, os);
139 forAll(valueSetNames, i)
145 os << valueSetNames[i];
154 void Foam::csvSetWriter<Type>::writeHeader
156 const coordSet& points,
157 const wordList& valueSetNames,
161 writeCoordHeader(points, os);
163 forAll(valueSetNames, i)
165 for (label j=0; j<Type::nComponents; j++)
171 os << valueSetNames[i] << "_" << j;
180 void Foam::csvSetWriter<Type>::writeCoordHeader
182 const coordSet& points,
186 if (points.hasVectorAxis())
190 os << points.axis()[i];
202 // ************************************************************************* //