ENH: RASModel.C: clipping input to log
[OpenFOAM-1.7.x.git] / src / sampling / sampledSet / writers / xmgrace / xmgraceSetWriter.C
blob1df98d17c6fe1972e1696ddfef1a575ef6db2710
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 "xmgraceSetWriter.H"
27 #include "coordSet.H"
28 #include "fileName.H"
29 #include "OFstream.H"
32 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
34 template<class Type>
35 Foam::xmgraceSetWriter<Type>::xmgraceSetWriter()
37     writer<Type>()
41 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
43 template<class Type>
44 Foam::xmgraceSetWriter<Type>::~xmgraceSetWriter()
48 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
50 template<class Type>
51 Foam::fileName Foam::xmgraceSetWriter<Type>::getFileName
53     const coordSet& points,
54     const wordList& valueSetNames
55 ) const
57     return this->getBaseName(points, valueSetNames) + ".agr";
61 template<class Type>
62 void Foam::xmgraceSetWriter<Type>::write
64     const coordSet& points,
65     const wordList& valueSetNames,
66     const List<const Field<Type>*>& valueSets,
67     Ostream& os
68 ) const
70     os  << "@g0 on" << nl
71         << "@with g0" << nl
72         << "@    title \"" << points.name() << '"' << nl
73         << "@    xaxis label " << '"' << points.axis() << '"' << nl;
75     forAll(valueSets, i)
76     {
77         os  << "@    s" << i << " legend " << '"'
78             << valueSetNames[i] << '"' << nl
79             << "@target G0.S" << i << nl;
81         writeTable(points, *valueSets[i], os);
83         os  << '&' << nl;
84     }
88 template<class Type>
89 void Foam::xmgraceSetWriter<Type>::write
91     const bool writeTracks,
92     const PtrList<coordSet>& trackPoints,
93     const wordList& valueSetNames,
94     const List<List<Field<Type> > >& valueSets,
95     Ostream& os
96 ) const
98     if (valueSets.size() != valueSetNames.size())
99     {
100         FatalErrorIn("gnuplotSetWriter<Type>::write(..)")
101             << "Number of variables:" << valueSetNames.size() << endl
102             << "Number of valueSets:" << valueSets.size()
103             << exit(FatalError);
104     }
105     if (trackPoints.size() > 0)
106     {
107         os  << "@g0 on" << nl
108             << "@with g0" << nl
109             << "@    title \"" << trackPoints[0].name() << '"' << nl
110             << "@    xaxis label " << '"' << trackPoints[0].axis() << '"' << nl;
112         // Data index.
113         label sI = 0;
115         forAll(trackPoints, trackI)
116         {
117             forAll(valueSets, i)
118             {
119                 os  << "@    s" << sI << " legend " << '"'
120                     << valueSetNames[i] << "_track" << i << '"' << nl
121                     << "@target G0.S" << sI << nl;
122                 writeTable(trackPoints[trackI], valueSets[i][trackI], os);
123                 os  << '&' << nl;
125                 sI++;
126             }
127         }
128     }
131 // ************************************************************************* //