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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2012 OpenFOAM Foundation
9  Copyright (C) 2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "jplotSetWriter.H"
30 #include "clock.H"
31 #include "coordSet.H"
32 #include "fileName.H"
33 #include "OFstream.H"
34 
35 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
36 
37 template<class Type>
39 {
40  return os
41  << "# JPlot input file" << nl
42  << "#" << nl << nl
43  << "# Generated by sample on " << clock::date().c_str() << nl;
44 }
45 
46 
47 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48 
49 template<class Type>
51 :
52  writer<Type>()
53 {}
54 
55 
56 template<class Type>
58 :
59  writer<Type>(dict)
60 {}
61 
62 
63 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
64 
65 template<class Type>
67 (
68  const coordSet& points,
69  const wordList& valueSetNames
70 ) const
71 {
72  return this->getBaseName(points, valueSetNames) + ".dat";
73 }
74 
75 
76 template<class Type>
78 (
79  const coordSet& points,
80  const wordList& valueSetNames,
81  const List<const Field<Type>*>& valueSets,
82  Ostream& os
83 ) const
84 {
85  os << "# JPlot file" << nl
86  << "# column 1: " << points.name() << nl;
87 
88  forAll(valueSets, i)
89  {
90  os << "# column " << i + 2 << ": " << valueSetNames[i] << nl;
91  }
92 
93  // Collect sets into columns
94  List<const List<Type>*> columns(valueSets.size());
95 
96  forAll(valueSets, i)
97  {
98  columns[i] = valueSets[i];
99  }
100 
101  this->writeTable(points, columns, os);
102 }
103 
104 
105 // ************************************************************************* //
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
coordSet.H
Foam::jplotSetWriter
Definition: jplotSetWriter.H:50
Foam::jplotSetWriter::jplotSetWriter
jplotSetWriter()
Default construct.
Definition: jplotSetWriter.C:50
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
OFstream.H
Foam::Field
Generic templated field type.
Definition: Field.H:63
jplotSetWriter.H
clock.H
fileName.H
dict
dictionary dict
Definition: searchingEngine.H:14
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:78
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam::writer
Base class for graphics format writing. Entry points are.
Definition: writer.H:81
Foam::coordSet
Holds list of sampling positions.
Definition: coordSet.H:53
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::jplotSetWriter::getFileName
virtual fileName getFileName(const coordSet &, const wordList &) const
Generate file name with correct extension.
Definition: jplotSetWriter.C:67
Foam::List< word >
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:56