Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / sampling / sampledSet / writers / jplot / jplotSetWriter.C
blob9628c57e8ee0e2969dfbc86fe65c03d86c32cce3
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2004-2010 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
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 "jplotSetWriter.H"
27 #include "clock.H"
28 #include "coordSet.H"
29 #include "fileName.H"
30 #include "OFstream.H"
33 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
35 template<class Type>
36 Foam::Ostream& Foam::jplotSetWriter<Type>::writeHeader(Ostream& os) const
38     return os
39         << "# JPlot input file" << nl
40         << "#" << nl << nl
41         << "# Generated by sample on " << clock::date().c_str() << nl;
45 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
47 template<class Type>
48 Foam::jplotSetWriter<Type>::jplotSetWriter()
50     writer<Type>()
54 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
56 template<class Type>
57 Foam::jplotSetWriter<Type>::~jplotSetWriter()
61 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
63 template<class Type>
64 Foam::fileName Foam::jplotSetWriter<Type>::getFileName
66     const coordSet& points,
67     const wordList& valueSetNames
68 ) const
70     return this->getBaseName(points, valueSetNames) + ".dat";
74 template<class Type>
75 void Foam::jplotSetWriter<Type>::write
77     const coordSet& points,
78     const wordList& valueSetNames,
79     const List<const Field<Type>*>& valueSets,
80     Ostream& os
81 ) const
83     os  << "# JPlot file" << nl
84         << "# column 1: " << points.name() << nl;
86     forAll(valueSets, i)
87     {
88         os  << "# column " << i + 2 << ": " << valueSetNames[i] << nl;
89     }
91     // Collect sets into columns
92     List<const List<Type>*> columns(valueSets.size());
94     forAll(valueSets, i)
95     {
96         columns[i] = valueSets[i];
97     }
99     this->writeTable(points, columns, os);
103 // ************************************************************************* //