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 // ************************************************************************* //
Holds list of sampling positions.
Definition: coordSet.H:49
const word & name() const
Definition: coordSet.H:111
virtual fileName getFileName(const coordSet &, const wordList &) const
Generate file name with correct extension.
fileName getBaseName(const coordSet &, const wordList &) const
Generates filename from coordSet and sampled fields.
Definition: writer.C:62
virtual ~jplotSetWriter()
Destructor.
static const char nl
Definition: Ostream.H:260
jplotSetWriter()
Construct null.
#define forAll(list, i)
Definition: UList.H:421
Base class for graphics format writing. Entry points are.
Definition: writer.H:78
Pre-declare SubField and related Field type.
Definition: Field.H:57
A class for handling file names.
Definition: fileName.H:69
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
void writeTable(const coordSet &, const List< Type > &, Ostream &) const
Writes single-column ascii write. Column 1 is coordSet coordinate,.
Definition: writer.C:99
virtual void write(const coordSet &, const wordList &, const List< const Field< Type > * > &, Ostream &) const
General entry point for writing.