Home
Downloads
Documentation
Installation
User Guide
man-pages
API Documentation
README
Release Notes
Changes
License
Support
SourceForge Project
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
sampling
sampledSet
writers
jplot
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) 1991-2010 OpenCFD Ltd.
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 <
OpenFOAM/clock.H
>
28
#include <
sampling/coordSet.H
>
29
#include <
OpenFOAM/fileName.H
>
30
#include <
OpenFOAM/OFstream.H
>
31
32
33
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
34
35
template
<
class
Type>
36
Foam::Ostream
&
Foam::jplotSetWriter<Type>::writeHeader
(Ostream& os)
const
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>
48
Foam::jplotSetWriter<Type>::jplotSetWriter
()
49
:
50
writer
<Type>()
51
{}
52
53
54
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
55
56
template
<
class
Type>
57
Foam::jplotSetWriter<Type>::~jplotSetWriter
()
58
{}
59
60
61
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
62
63
template
<
class
Type>
64
Foam::fileName
Foam::jplotSetWriter<Type>::getFileName
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>
75
void
Foam::jplotSetWriter<Type>::write
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
writeTable(points, columns, os);
100
}
101
102
103
// ************************ vim: set sw=4 sts=4 et: ************************ //