Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "gnuplotSetWriter.H"
00027 #include <OpenFOAM/clock.H>
00028 #include <sampling/coordSet.H>
00029 #include <OpenFOAM/fileName.H>
00030 #include <OpenFOAM/OFstream.H>
00031 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00032
00033
00034
00035
00036 template<class Type>
00037 Foam::gnuplotSetWriter<Type>::gnuplotSetWriter()
00038 :
00039 writer<Type>()
00040 {}
00041
00042
00043
00044 template<class Type>
00045 Foam::gnuplotSetWriter<Type>::~gnuplotSetWriter()
00046 {}
00047
00048
00049
00050
00051 template<class Type>
00052 Foam::fileName Foam::gnuplotSetWriter<Type>::getFileName
00053 (
00054 const coordSet& points,
00055 const wordList& valueSetNames
00056 ) const
00057 {
00058 return this->getBaseName(points, valueSetNames) + ".gplt";
00059 }
00060
00061
00062 template<class Type>
00063 void Foam::gnuplotSetWriter<Type>::write
00064 (
00065 const coordSet& points,
00066 const wordList& valueSetNames,
00067 const List<const Field<Type>*>& valueSets,
00068 Ostream& os
00069 ) const
00070 {
00071 os << "set term postscript color" << nl
00072 << "set output \"" << points.name() << ".ps\"" << nl
00073 << "plot";
00074
00075 forAll(valueSets, i)
00076 {
00077 if (i != 0)
00078 {
00079 os << ',';
00080 }
00081
00082 os << " \"-\" title \"" << valueSetNames[i] << "\" with lines";
00083 }
00084 os << nl;
00085
00086
00087 forAll(valueSets, i)
00088 {
00089 this->writeTable(points, *valueSets[i], os);
00090 os << "e" << nl;
00091 }
00092 }
00093
00094
00095 template<class Type>
00096 void Foam::gnuplotSetWriter<Type>::write
00097 (
00098 const bool writeTracks,
00099 const PtrList<coordSet>& trackPoints,
00100 const wordList& valueSetNames,
00101 const List<List<Field<Type> > >& valueSets,
00102 Ostream& os
00103 ) const
00104 {
00105 if (valueSets.size() != valueSetNames.size())
00106 {
00107 FatalErrorIn("gnuplotSetWriter<Type>::write(..)")
00108 << "Number of variables:" << valueSetNames.size() << endl
00109 << "Number of valueSets:" << valueSets.size()
00110 << exit(FatalError);
00111 }
00112 if (trackPoints.size() > 0)
00113 {
00114 os << "set term postscript color" << nl
00115 << "set output \"" << trackPoints[0].name() << ".ps\"" << nl;
00116
00117 forAll(trackPoints, trackI)
00118 {
00119 os << "plot";
00120
00121 forAll(valueSets, i)
00122 {
00123 if (i != 0)
00124 {
00125 os << ',';
00126 }
00127
00128 os << " \"-\" title \"" << valueSetNames[i] << "\" with lines";
00129 }
00130 os << nl;
00131
00132 forAll(valueSets, i)
00133 {
00134 this->writeTable
00135 (
00136 trackPoints[trackI],
00137 valueSets[i][trackI],
00138 os
00139 );
00140 os << "e" << nl;
00141 }
00142 }
00143 }
00144 }
00145
00146
00147