ENH: RASModel.C: clipping input to log
[OpenFOAM-1.7.x.git] / src / sampling / sampledSet / writers / gnuplot / gnuplotSetWriter.C
blobb9c5466b6c79fe354674dd94878e6adfbae1b25d
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-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 "gnuplotSetWriter.H"
27 #include "clock.H"
28 #include "coordSet.H"
29 #include "fileName.H"
30 #include "OFstream.H"
31 #include "addToRunTimeSelectionTable.H"
34 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
36 template<class Type>
37 Foam::gnuplotSetWriter<Type>::gnuplotSetWriter()
39     writer<Type>()
42 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
44 template<class Type>
45 Foam::gnuplotSetWriter<Type>::~gnuplotSetWriter()
49 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
51 template<class Type>
52 Foam::fileName Foam::gnuplotSetWriter<Type>::getFileName
54     const coordSet& points,
55     const wordList& valueSetNames
56 ) const
58     return this->getBaseName(points, valueSetNames) + ".gplt";
62 template<class Type>
63 void Foam::gnuplotSetWriter<Type>::write
65     const coordSet& points,
66     const wordList& valueSetNames,
67     const List<const Field<Type>*>& valueSets,
68     Ostream& os
69 ) const
71     os  << "set term postscript color" << nl
72         << "set output \"" << points.name() << ".ps\"" << nl
73         << "plot";
75     forAll(valueSets, i)
76     {
77         if (i != 0)
78         {
79             os << ',';
80         }
82         os  << " \"-\" title \"" << valueSetNames[i] << "\" with lines";
83     }
84     os  << nl;
87     forAll(valueSets, i)
88     {
89         writeTable(points, *valueSets[i], os);
90         os  << "e" << nl;
91     }
95 template<class Type>
96 void Foam::gnuplotSetWriter<Type>::write
98     const bool writeTracks,
99     const PtrList<coordSet>& trackPoints,
100     const wordList& valueSetNames,
101     const List<List<Field<Type> > >& valueSets,
102     Ostream& os
103 ) const
105     if (valueSets.size() != valueSetNames.size())
106     {
107         FatalErrorIn("gnuplotSetWriter<Type>::write(..)")
108             << "Number of variables:" << valueSetNames.size() << endl
109             << "Number of valueSets:" << valueSets.size()
110             << exit(FatalError);
111     }
112     if (trackPoints.size() > 0)
113     {
114         os  << "set term postscript color" << nl
115             << "set output \"" << trackPoints[0].name() << ".ps\"" << nl;
117         forAll(trackPoints, trackI)
118         {
119             os  << "plot";
121             forAll(valueSets, i)
122             {
123                 if (i != 0)
124                 {
125                     os << ',';
126                 }
128                 os  << " \"-\" title \"" << valueSetNames[i] << "\" with lines";
129             }
130             os << nl;
132             forAll(valueSets, i)
133             {
134                 writeTable(trackPoints[trackI], valueSets[i][trackI], os);
135                 os  << "e" << nl;
136             }
137         }
138     }
142 // ************************************************************************* //