FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

xmgraceSetWriter.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "xmgraceSetWriter.H"
00027 #include <sampling/coordSet.H>
00028 #include <OpenFOAM/fileName.H>
00029 #include <OpenFOAM/OFstream.H>
00030 
00031 
00032 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00033 
00034 template<class Type>
00035 Foam::xmgraceSetWriter<Type>::xmgraceSetWriter()
00036 :
00037     writer<Type>()
00038 {}
00039 
00040 
00041 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00042 
00043 template<class Type>
00044 Foam::xmgraceSetWriter<Type>::~xmgraceSetWriter()
00045 {}
00046 
00047 
00048 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00049 
00050 template<class Type>
00051 Foam::fileName Foam::xmgraceSetWriter<Type>::getFileName
00052 (
00053     const coordSet& points,
00054     const wordList& valueSetNames
00055 ) const
00056 {
00057     return this->getBaseName(points, valueSetNames) + ".agr";
00058 }
00059 
00060 
00061 template<class Type>
00062 void Foam::xmgraceSetWriter<Type>::write
00063 (
00064     const coordSet& points,
00065     const wordList& valueSetNames,
00066     const List<const Field<Type>*>& valueSets,
00067     Ostream& os
00068 ) const
00069 {
00070     os  << "@g0 on" << nl
00071         << "@with g0" << nl
00072         << "@    title \"" << points.name() << '"' << nl
00073         << "@    xaxis label " << '"' << points.axis() << '"' << nl;
00074 
00075     forAll(valueSets, i)
00076     {
00077         os  << "@    s" << i << " legend " << '"'
00078             << valueSetNames[i] << '"' << nl
00079             << "@target G0.S" << i << nl;
00080 
00081         this->writeTable(points, *valueSets[i], os);
00082 
00083         os  << '&' << nl;
00084     }
00085 }
00086 
00087 
00088 template<class Type>
00089 void Foam::xmgraceSetWriter<Type>::write
00090 (
00091     const bool writeTracks,
00092     const PtrList<coordSet>& trackPoints,
00093     const wordList& valueSetNames,
00094     const List<List<Field<Type> > >& valueSets,
00095     Ostream& os
00096 ) const
00097 {
00098     if (valueSets.size() != valueSetNames.size())
00099     {
00100         FatalErrorIn("gnuplotSetWriter<Type>::write(..)")
00101             << "Number of variables:" << valueSetNames.size() << endl
00102             << "Number of valueSets:" << valueSets.size()
00103             << exit(FatalError);
00104     }
00105     if (trackPoints.size() > 0)
00106     {
00107         os  << "@g0 on" << nl
00108             << "@with g0" << nl
00109             << "@    title \"" << trackPoints[0].name() << '"' << nl
00110             << "@    xaxis label " << '"' << trackPoints[0].axis() << '"' << nl;
00111 
00112         // Data index.
00113         label sI = 0;
00114 
00115         forAll(trackPoints, trackI)
00116         {
00117             forAll(valueSets, i)
00118             {
00119                 os  << "@    s" << sI << " legend " << '"'
00120                     << valueSetNames[i] << "_track" << i << '"' << nl
00121                     << "@target G0.S" << sI << nl;
00122                 this->writeTable
00123                 (
00124                     trackPoints[trackI],
00125                     valueSets[i][trackI],
00126                     os
00127                 );
00128                 os  << '&' << nl;
00129 
00130                 sI++;
00131             }
00132         }
00133     }
00134 }
00135 
00136 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines