initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / sampling / sampledSet / writers / jplot / jplotSetWriter.C
blob53b0d5e08b66080ea568b3622a35651a545a2171
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
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 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
19     for more details.
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 "jplotSetWriter.H"
28 #include "clock.H"
29 #include "coordSet.H"
30 #include "fileName.H"
31 #include "OFstream.H"
34 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
36 template<class Type>
37 Foam::Ostream& Foam::jplotSetWriter<Type>::writeHeader(Ostream& os) const
39     return os
40         << "# JPlot input file" << nl
41         << "#" << nl << nl
42         << "# Generated by sample on " << clock::date().c_str() << endl;
46 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
48 template<class Type>
49 Foam::jplotSetWriter<Type>::jplotSetWriter()
51     writer<Type>()
55 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
57 template<class Type>
58 Foam::jplotSetWriter<Type>::~jplotSetWriter()
62 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
64 template<class Type>
65 Foam::fileName Foam::jplotSetWriter<Type>::getFileName
67     const coordSet& points,
68     const wordList& valueSetNames
69 ) const
71     return this->getBaseName(points, valueSetNames) + ".dat";
75 template<class Type>
76 void Foam::jplotSetWriter<Type>::write
78     const coordSet& points,
79     const wordList& valueSetNames,
80     const List<const Field<Type>*>& valueSets,
81     Ostream& os
82 ) const
84     os  << "# JPlot file" << nl
85         << "# column 1: " << points.name() << endl;
87     forAll(valueSets, i)
88     {
89         os  << "# column " << i + 2 << ": " << valueSetNames[i] << endl;
90     }
92     // Collect sets into columns
93     List<const List<Type>*> columns(valueSets.size());
95     forAll(valueSets, i)
96     {
97         columns[i] = valueSets[i];
98     }
100     writeTable(points, columns, os);
104 // ************************************************************************* //