jplotSetWriter.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "jplotSetWriter.H"
27 #include "clock.H"
28 #include "coordSet.H"
29 #include "fileName.H"
30 #include "OFstream.H"
31 
32 
33 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
34 
35 template<class Type>
37 {
38  return os
39  << "# JPlot input file" << nl
40  << "#" << nl << nl
41  << "# Generated by sample on " << clock::date().c_str() << nl;
42 }
43 
44 
45 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
46 
47 template<class Type>
49 :
50  writer<Type>()
51 {}
52 
53 
54 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
55 
56 template<class Type>
58 {}
59 
60 
61 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
62 
63 template<class Type>
65 (
66  const coordSet& points,
67  const wordList& valueSetNames
68 ) const
69 {
70  return this->getBaseName(points, valueSetNames) + ".dat";
71 }
72 
73 
74 template<class Type>
76 (
77  const coordSet& points,
78  const wordList& valueSetNames,
79  const List<const Field<Type>*>& valueSets,
80  Ostream& os
81 ) const
82 {
83  os << "# JPlot file" << nl
84  << "# column 1: " << points.name() << nl;
85 
86  forAll(valueSets, i)
87  {
88  os << "# column " << i + 2 << ": " << valueSetNames[i] << nl;
89  }
90 
91  // Collect sets into columns
92  List<const List<Type>*> columns(valueSets.size());
93 
94  forAll(valueSets, i)
95  {
96  columns[i] = valueSets[i];
97  }
98 
99  this->writeTable(points, columns, os);
100 }
101 
102 
103 // ************************************************************************* //
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
coordSet.H
Foam::jplotSetWriter::~jplotSetWriter
virtual ~jplotSetWriter()
Destructor.
Definition: jplotSetWriter.C:57
Foam::jplotSetWriter::jplotSetWriter
jplotSetWriter()
Construct null.
Definition: jplotSetWriter.C:48
Foam::jplotSetWriter::writeHeader
Ostream & writeHeader(Ostream &) const
Write header.
Definition: jplotSetWriter.C:36
OFstream.H
Foam::Field< Type >
Foam::nl
static const char nl
Definition: Ostream.H:260
jplotSetWriter.H
clock.H
fileName.H
Foam::jplotSetWriter::write
virtual void write(const coordSet &, const wordList &, const List< const Field< Type > * > &, Ostream &) const
General entry point for writing.
Definition: jplotSetWriter.C:76
Foam::writer
Base class for graphics format writing. Entry points are.
Definition: writer.H:78
Foam::coordSet
Holds list of sampling positions.
Definition: coordSet.H:49
Foam::jplotSetWriter::getFileName
virtual fileName getFileName(const coordSet &, const wordList &) const
Generate file name with correct extension.
Definition: jplotSetWriter.C:65
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53