mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
multiple line writing; vtk output
This commit is contained in:
@ -22,6 +22,7 @@ FoamFile
|
|||||||
// jplot
|
// jplot
|
||||||
// gnuplot
|
// gnuplot
|
||||||
// raw
|
// raw
|
||||||
|
// vtk
|
||||||
setFormat raw;
|
setFormat raw;
|
||||||
|
|
||||||
// Surface output format. Choice of
|
// Surface output format. Choice of
|
||||||
|
|||||||
@ -18,6 +18,7 @@ $(setWriters)/writers.C
|
|||||||
$(setWriters)/gnuplot/gnuplotSetWriterRunTime.C
|
$(setWriters)/gnuplot/gnuplotSetWriterRunTime.C
|
||||||
$(setWriters)/jplot/jplotSetWriterRunTime.C
|
$(setWriters)/jplot/jplotSetWriterRunTime.C
|
||||||
$(setWriters)/raw/rawSetWriterRunTime.C
|
$(setWriters)/raw/rawSetWriterRunTime.C
|
||||||
|
$(setWriters)/vtk/vtkSetWriterRunTime.C
|
||||||
$(setWriters)/xmgrace/xmgraceSetWriterRunTime.C
|
$(setWriters)/xmgrace/xmgraceSetWriterRunTime.C
|
||||||
|
|
||||||
cuttingPlane/cuttingPlane.C
|
cuttingPlane/cuttingPlane.C
|
||||||
|
|||||||
@ -69,29 +69,73 @@ void Foam::gnuplotSetWriter<Type>::write
|
|||||||
Ostream& os
|
Ostream& os
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
os << "set term postscript color" << endl
|
os << "set term postscript color" << nl
|
||||||
<< "set output \"" << points.name() << ".ps\"" << endl
|
<< "set output \"" << points.name() << ".ps\"" << nl
|
||||||
<< "plot";
|
<< "plot";
|
||||||
|
|
||||||
bool firstField = true;
|
|
||||||
|
|
||||||
forAll(valueSets, i)
|
forAll(valueSets, i)
|
||||||
{
|
{
|
||||||
if (!firstField)
|
if (i != 0)
|
||||||
{
|
{
|
||||||
os << ',';
|
os << ',';
|
||||||
}
|
}
|
||||||
firstField = false;
|
|
||||||
|
|
||||||
os << "'-' title \"" << valueSetNames[i] << "\" with lines";
|
os << " \"-\" title \"" << valueSetNames[i] << "\" with lines";
|
||||||
}
|
}
|
||||||
os << endl;
|
os << nl;
|
||||||
|
|
||||||
|
|
||||||
forAll(valueSets, i)
|
forAll(valueSets, i)
|
||||||
{
|
{
|
||||||
os << endl;
|
|
||||||
writeTable(points, *valueSets[i], os);
|
writeTable(points, *valueSets[i], os);
|
||||||
|
os << "e" << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::gnuplotSetWriter<Type>::write
|
||||||
|
(
|
||||||
|
const bool writeTracks,
|
||||||
|
const PtrList<coordSet>& trackPoints,
|
||||||
|
const wordList& valueSetNames,
|
||||||
|
const List<List<Field<Type> > >& valueSets,
|
||||||
|
Ostream& os
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if (valueSets.size() != valueSetNames.size())
|
||||||
|
{
|
||||||
|
FatalErrorIn("gnuplotSetWriter<Type>::write(..)")
|
||||||
|
<< "Number of variables:" << valueSetNames.size() << endl
|
||||||
|
<< "Number of valueSets:" << valueSets.size()
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
if (trackPoints.size() > 0)
|
||||||
|
{
|
||||||
|
os << "set term postscript color" << nl
|
||||||
|
<< "set output \"" << trackPoints[0].name() << ".ps\"" << nl;
|
||||||
|
|
||||||
|
forAll(trackPoints, trackI)
|
||||||
|
{
|
||||||
|
os << "plot";
|
||||||
|
|
||||||
|
forAll(valueSets, i)
|
||||||
|
{
|
||||||
|
if (i != 0)
|
||||||
|
{
|
||||||
|
os << ',';
|
||||||
|
}
|
||||||
|
|
||||||
|
os << " \"-\" title \"" << valueSetNames[i] << "\" with lines";
|
||||||
|
}
|
||||||
|
os << nl;
|
||||||
|
|
||||||
|
forAll(valueSets, i)
|
||||||
|
{
|
||||||
|
writeTable(trackPoints[trackI], valueSets[i][trackI], os);
|
||||||
|
os << "e" << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -76,13 +76,22 @@ public:
|
|||||||
const wordList&
|
const wordList&
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
void write
|
virtual void write
|
||||||
(
|
(
|
||||||
const coordSet&,
|
const coordSet&,
|
||||||
const wordList&,
|
const wordList&,
|
||||||
const List<const Field<Type>*>&,
|
const List<const Field<Type>*>&,
|
||||||
Ostream&
|
Ostream&
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
virtual void write
|
||||||
|
(
|
||||||
|
const bool writeTracks,
|
||||||
|
const PtrList<coordSet>&,
|
||||||
|
const wordList& valueSetNames,
|
||||||
|
const List<List<Field<Type> > >&,
|
||||||
|
Ostream&
|
||||||
|
) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -39,7 +39,7 @@ Foam::Ostream& Foam::jplotSetWriter<Type>::writeHeader(Ostream& os) const
|
|||||||
return os
|
return os
|
||||||
<< "# JPlot input file" << nl
|
<< "# JPlot input file" << nl
|
||||||
<< "#" << nl << nl
|
<< "#" << nl << nl
|
||||||
<< "# Generated by sample on " << clock::date().c_str() << endl;
|
<< "# Generated by sample on " << clock::date().c_str() << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -82,11 +82,11 @@ void Foam::jplotSetWriter<Type>::write
|
|||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
os << "# JPlot file" << nl
|
os << "# JPlot file" << nl
|
||||||
<< "# column 1: " << points.name() << endl;
|
<< "# column 1: " << points.name() << nl;
|
||||||
|
|
||||||
forAll(valueSets, i)
|
forAll(valueSets, i)
|
||||||
{
|
{
|
||||||
os << "# column " << i + 2 << ": " << valueSetNames[i] << endl;
|
os << "# column " << i + 2 << ": " << valueSetNames[i] << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collect sets into columns
|
// Collect sets into columns
|
||||||
|
|||||||
@ -80,13 +80,35 @@ public:
|
|||||||
const wordList&
|
const wordList&
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
void write
|
virtual void write
|
||||||
(
|
(
|
||||||
const coordSet&,
|
const coordSet&,
|
||||||
const wordList&,
|
const wordList&,
|
||||||
const List<const Field<Type>*>&,
|
const List<const Field<Type>*>&,
|
||||||
Ostream&
|
Ostream&
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
virtual void write
|
||||||
|
(
|
||||||
|
const bool writeTracks,
|
||||||
|
const PtrList<coordSet>&,
|
||||||
|
const wordList& valueSetNames,
|
||||||
|
const List<List<Field<Type> > >&,
|
||||||
|
Ostream&
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
notImplemented
|
||||||
|
(
|
||||||
|
"jplotSetWriter<Type>::write\n"
|
||||||
|
"(\n"
|
||||||
|
" const bool,\n"
|
||||||
|
" const PtrList<coordSet>&,\n"
|
||||||
|
" const wordList&,\n"
|
||||||
|
" const List<List<Field<Type> > >&,\n"
|
||||||
|
" Ostream&\n"
|
||||||
|
") const"
|
||||||
|
);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -79,4 +79,38 @@ void Foam::rawSetWriter<Type>::write
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::rawSetWriter<Type>::write
|
||||||
|
(
|
||||||
|
const bool writeTracks,
|
||||||
|
const PtrList<coordSet>& points,
|
||||||
|
const wordList& valueSetNames,
|
||||||
|
const List<List<Field<Type> > >& valueSets,
|
||||||
|
Ostream& os
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if (valueSets.size() != valueSetNames.size())
|
||||||
|
{
|
||||||
|
FatalErrorIn("rawSetWriter<Type>::write(..)")
|
||||||
|
<< "Number of variables:" << valueSetNames.size() << endl
|
||||||
|
<< "Number of valueSets:" << valueSets.size()
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<const List<Type>*> columns(valueSets.size());
|
||||||
|
|
||||||
|
forAll(points, trackI)
|
||||||
|
{
|
||||||
|
// Collect sets into columns
|
||||||
|
forAll(valueSets, i)
|
||||||
|
{
|
||||||
|
columns[i] = &valueSets[i][trackI];
|
||||||
|
}
|
||||||
|
|
||||||
|
writeTable(points[trackI], columns, os);
|
||||||
|
os << nl << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -83,6 +83,15 @@ public:
|
|||||||
const List<const Field<Type>*>&,
|
const List<const Field<Type>*>&,
|
||||||
Ostream&
|
Ostream&
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
virtual void write
|
||||||
|
(
|
||||||
|
const bool writeTracks,
|
||||||
|
const PtrList<coordSet>&,
|
||||||
|
const wordList& valueSetNames,
|
||||||
|
const List<List<Field<Type> > >&,
|
||||||
|
Ostream&
|
||||||
|
) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
196
src/sampling/sampledSet/writers/vtk/vtkSetWriter.C
Normal file
196
src/sampling/sampledSet/writers/vtk/vtkSetWriter.C
Normal file
@ -0,0 +1,196 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by the
|
||||||
|
Free Software Foundation; either version 2 of the License, or (at your
|
||||||
|
option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||||
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "vtkSetWriter.H"
|
||||||
|
#include "coordSet.H"
|
||||||
|
#include "fileName.H"
|
||||||
|
#include "OFstream.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::vtkSetWriter<Type>::vtkSetWriter()
|
||||||
|
:
|
||||||
|
writer<Type>()
|
||||||
|
{}
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::vtkSetWriter<Type>::~vtkSetWriter()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::fileName Foam::vtkSetWriter<Type>::getFileName
|
||||||
|
(
|
||||||
|
const coordSet& points,
|
||||||
|
const wordList& valueSetNames
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return this->getBaseName(points, valueSetNames) + ".vtk";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::vtkSetWriter<Type>::write
|
||||||
|
(
|
||||||
|
const coordSet& points,
|
||||||
|
const wordList& valueSetNames,
|
||||||
|
const List<const Field<Type>*>& valueSets,
|
||||||
|
Ostream& os
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
os << "# vtk DataFile Version 2.0" << nl
|
||||||
|
<< points.name() << nl
|
||||||
|
<< "ASCII" << nl
|
||||||
|
<< "DATASET POLYDATA" << nl
|
||||||
|
<< "POINTS " << points.size() << " float" << nl;
|
||||||
|
|
||||||
|
forAll(points, i)
|
||||||
|
{
|
||||||
|
const vector& pt = points[i];
|
||||||
|
os << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
os << "POINT_DATA " << points.size() << nl
|
||||||
|
<< " FIELD attributes " << valueSetNames.size() << nl;
|
||||||
|
|
||||||
|
forAll(valueSetNames, setI)
|
||||||
|
{
|
||||||
|
os << valueSetNames[setI] << ' ' << pTraits<Type>::nComponents << ' '
|
||||||
|
<< points.size() << " float" << nl;
|
||||||
|
|
||||||
|
const Field<Type>& fld = *valueSets[setI];
|
||||||
|
|
||||||
|
forAll(fld, pointI)
|
||||||
|
{
|
||||||
|
if (pointI != 0)
|
||||||
|
{
|
||||||
|
os << ' ';
|
||||||
|
}
|
||||||
|
writer<Type>::write(fld[pointI], os);
|
||||||
|
}
|
||||||
|
os << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::vtkSetWriter<Type>::write
|
||||||
|
(
|
||||||
|
const bool writeTracks,
|
||||||
|
const PtrList<coordSet>& tracks,
|
||||||
|
const wordList& valueSetNames,
|
||||||
|
const List<List<Field<Type> > >& valueSets,
|
||||||
|
Ostream& os
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if (valueSets.size() != valueSetNames.size())
|
||||||
|
{
|
||||||
|
FatalErrorIn("vtkSetWriter<Type>::write(..)")
|
||||||
|
<< "Number of variables:" << valueSetNames.size() << endl
|
||||||
|
<< "Number of valueSets:" << valueSets.size()
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
label nTracks = tracks.size();
|
||||||
|
label nPoints = 0;
|
||||||
|
forAll(tracks, i)
|
||||||
|
{
|
||||||
|
nPoints += tracks[i].size();
|
||||||
|
}
|
||||||
|
|
||||||
|
os << "# vtk DataFile Version 2.0" << nl
|
||||||
|
<< tracks[0].name() << nl
|
||||||
|
<< "ASCII" << nl
|
||||||
|
<< "DATASET POLYDATA" << nl
|
||||||
|
<< "POINTS " << nPoints << " float" << nl;
|
||||||
|
|
||||||
|
forAll(tracks, trackI)
|
||||||
|
{
|
||||||
|
const coordSet& points = tracks[trackI];
|
||||||
|
forAll(points, i)
|
||||||
|
{
|
||||||
|
const vector& pt = points[i];
|
||||||
|
os << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (writeTracks)
|
||||||
|
{
|
||||||
|
os << "LINES " << nTracks << ' ' << nPoints+nTracks << nl;
|
||||||
|
|
||||||
|
// Write ids of track points to file
|
||||||
|
label globalPtI = 0;
|
||||||
|
forAll(tracks, trackI)
|
||||||
|
{
|
||||||
|
const coordSet& points = tracks[trackI];
|
||||||
|
|
||||||
|
os << points.size();
|
||||||
|
forAll(points, i)
|
||||||
|
{
|
||||||
|
os << ' ' << globalPtI;
|
||||||
|
globalPtI++;
|
||||||
|
}
|
||||||
|
os << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
os << "POINT_DATA " << nPoints << nl
|
||||||
|
<< " FIELD attributes " << valueSetNames.size() << nl;
|
||||||
|
|
||||||
|
forAll(valueSetNames, setI)
|
||||||
|
{
|
||||||
|
os << valueSetNames[setI] << ' ' << pTraits<Type>::nComponents << ' '
|
||||||
|
<< nPoints << " float" << nl;
|
||||||
|
|
||||||
|
const List<Field<Type> >& fieldVals = valueSets[setI];
|
||||||
|
|
||||||
|
forAll(fieldVals, i)
|
||||||
|
{
|
||||||
|
const Field<Type>& vals = fieldVals[i];
|
||||||
|
|
||||||
|
forAll(vals, j)
|
||||||
|
{
|
||||||
|
if (j != 0)
|
||||||
|
{
|
||||||
|
os << ' ';
|
||||||
|
}
|
||||||
|
writer<Type>::write(vals[j], os);
|
||||||
|
}
|
||||||
|
os << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
112
src/sampling/sampledSet/writers/vtk/vtkSetWriter.H
Normal file
112
src/sampling/sampledSet/writers/vtk/vtkSetWriter.H
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by the
|
||||||
|
Free Software Foundation; either version 2 of the License, or (at your
|
||||||
|
option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||||
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::vtkSetWriter
|
||||||
|
|
||||||
|
Description
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
vtkSetWriter.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef vtkSetWriter_H
|
||||||
|
#define vtkSetWriter_H
|
||||||
|
|
||||||
|
#include "writer.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class vtkSetWriter Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
class vtkSetWriter
|
||||||
|
:
|
||||||
|
public writer<Type>
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("vtk");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct null
|
||||||
|
vtkSetWriter();
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~vtkSetWriter();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
virtual fileName getFileName
|
||||||
|
(
|
||||||
|
const coordSet&,
|
||||||
|
const wordList&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
virtual void write
|
||||||
|
(
|
||||||
|
const coordSet&,
|
||||||
|
const wordList&,
|
||||||
|
const List<const Field<Type>*>&,
|
||||||
|
Ostream&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
virtual void write
|
||||||
|
(
|
||||||
|
const bool writeTracks,
|
||||||
|
const PtrList<coordSet>&,
|
||||||
|
const wordList& valueSetNames,
|
||||||
|
const List<List<Field<Type> > >&,
|
||||||
|
Ostream&
|
||||||
|
) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
# include "vtkSetWriter.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
38
src/sampling/sampledSet/writers/vtk/vtkSetWriterRunTime.C
Normal file
38
src/sampling/sampledSet/writers/vtk/vtkSetWriterRunTime.C
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by the
|
||||||
|
Free Software Foundation; either version 2 of the License, or (at your
|
||||||
|
option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||||
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "vtkSetWriter.H"
|
||||||
|
#include "writers.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
makeSetWriters(vtkSetWriter);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -110,7 +110,7 @@ void Foam::writer<Type>::writeTable
|
|||||||
|
|
||||||
os << token::SPACE;
|
os << token::SPACE;
|
||||||
write(values[pointI], os);
|
write(values[pointI], os);
|
||||||
os << endl;
|
os << nl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ void Foam::writer<Type>::writeTable
|
|||||||
const List<Type>& values = *valuesPtrList[i];
|
const List<Type>& values = *valuesPtrList[i];
|
||||||
write(values[pointI], os);
|
write(values[pointI], os);
|
||||||
}
|
}
|
||||||
os << endl;
|
os << nl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,7 +179,7 @@ Foam::Ostream& Foam::writer<Type>::writeVS
|
|||||||
|
|
||||||
if (d <= VSType::nComponents-1)
|
if (d <= VSType::nComponents-1)
|
||||||
{
|
{
|
||||||
os << token::TAB;
|
os << ' ' << token::TAB;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return os;
|
return os;
|
||||||
|
|||||||
@ -162,6 +162,19 @@ public:
|
|||||||
Ostream&
|
Ostream&
|
||||||
) const = 0;
|
) const = 0;
|
||||||
|
|
||||||
|
//- General entry point for writing of multiple coordSets.
|
||||||
|
// Each coordSet (track) has same data variables.
|
||||||
|
// The data is per variable, per track, per point of track.
|
||||||
|
// If writeTracks adds connecting lines (wherever applicable)
|
||||||
|
virtual void write
|
||||||
|
(
|
||||||
|
const bool writeTracks,
|
||||||
|
const PtrList<coordSet>&,
|
||||||
|
const wordList& valueSetNames,
|
||||||
|
const List<List<Field<Type> > >&,
|
||||||
|
Ostream&
|
||||||
|
) const = 0;
|
||||||
|
|
||||||
//- Write scalar as ascii
|
//- Write scalar as ascii
|
||||||
virtual Ostream& write(const scalar, Ostream&) const;
|
virtual Ostream& write(const scalar, Ostream&) const;
|
||||||
|
|
||||||
|
|||||||
@ -68,19 +68,64 @@ void Foam::xmgraceSetWriter<Type>::write
|
|||||||
Ostream& os
|
Ostream& os
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
os << "@title \"" << points.name() << '"' << endl
|
os << "@g0 on" << nl
|
||||||
<< "@xaxis label " << '"' << points.axis() << '"' << endl;
|
<< "@with g0" << nl
|
||||||
|
<< "@ title \"" << points.name() << '"' << nl
|
||||||
|
<< "@ xaxis label " << '"' << points.axis() << '"' << nl;
|
||||||
|
|
||||||
forAll(valueSets, i)
|
forAll(valueSets, i)
|
||||||
{
|
{
|
||||||
os << "@s" << i << " legend " << '"'
|
os << "@ s" << i << " legend " << '"'
|
||||||
<< valueSetNames[i] << '"' << endl
|
<< valueSetNames[i] << '"' << nl
|
||||||
<< "@target G0.S" << i << endl
|
<< "@target G0.S" << i << nl;
|
||||||
<< "@type xy" << endl;
|
|
||||||
|
|
||||||
writeTable(points, *valueSets[i], os);
|
writeTable(points, *valueSets[i], os);
|
||||||
|
|
||||||
os << endl;
|
os << '&' << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::xmgraceSetWriter<Type>::write
|
||||||
|
(
|
||||||
|
const bool writeTracks,
|
||||||
|
const PtrList<coordSet>& trackPoints,
|
||||||
|
const wordList& valueSetNames,
|
||||||
|
const List<List<Field<Type> > >& valueSets,
|
||||||
|
Ostream& os
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if (valueSets.size() != valueSetNames.size())
|
||||||
|
{
|
||||||
|
FatalErrorIn("gnuplotSetWriter<Type>::write(..)")
|
||||||
|
<< "Number of variables:" << valueSetNames.size() << endl
|
||||||
|
<< "Number of valueSets:" << valueSets.size()
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
if (trackPoints.size() > 0)
|
||||||
|
{
|
||||||
|
os << "@g0 on" << nl
|
||||||
|
<< "@with g0" << nl
|
||||||
|
<< "@ title \"" << trackPoints[0].name() << '"' << nl
|
||||||
|
<< "@ xaxis label " << '"' << trackPoints[0].axis() << '"' << nl;
|
||||||
|
|
||||||
|
// Data index.
|
||||||
|
label sI = 0;
|
||||||
|
|
||||||
|
forAll(trackPoints, trackI)
|
||||||
|
{
|
||||||
|
forAll(valueSets, i)
|
||||||
|
{
|
||||||
|
os << "@ s" << sI << " legend " << '"'
|
||||||
|
<< valueSetNames[i] << "_track" << i << '"' << nl
|
||||||
|
<< "@target G0.S" << sI << nl;
|
||||||
|
writeTable(trackPoints[trackI], valueSets[i][trackI], os);
|
||||||
|
os << '&' << nl;
|
||||||
|
|
||||||
|
sI++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -76,13 +76,22 @@ public:
|
|||||||
const wordList&
|
const wordList&
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
void write
|
virtual void write
|
||||||
(
|
(
|
||||||
const coordSet&,
|
const coordSet&,
|
||||||
const wordList&,
|
const wordList&,
|
||||||
const List<const Field<Type>*>&,
|
const List<const Field<Type>*>&,
|
||||||
Ostream&
|
Ostream&
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
virtual void write
|
||||||
|
(
|
||||||
|
const bool writeTracks,
|
||||||
|
const PtrList<coordSet>&,
|
||||||
|
const wordList& valueSetNames,
|
||||||
|
const List<List<Field<Type> > >&,
|
||||||
|
Ostream&
|
||||||
|
) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user