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
writer.H
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-2011 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
Class
25
Foam::writer
26
27
Description
28
Base class for graphics format writing. Entry points are
29
- write(..). \n
30
Write to an Ostream a table of points with corresponding values.
31
- write(scalar/vector/sphericalTensor/symmTensor/tensor). \n
32
Write single scalar/vector/sphericalTensor/symmTensor/tensor.
33
Default is to write space separated components.
34
35
Example:
36
@verbatim
37
// Construct writer of xmgr type
38
autoPtr<writer<scalar> > scalarFormatter(writer<scalar>::New("xmgr"));
39
40
// Output list of points and corresponding values
41
scalarFormatter().write
42
(
43
coordSet
44
(
45
points, // sample coordinates
46
"someLine", // name of coordSet
47
"distance", // write coordinates as distance to refPoint
48
points[0] // reference point
49
),
50
"U.component(0)", // name of values
51
vals // values
52
);
53
@endverbatim
54
55
SourceFiles
56
writer.C
57
58
\*---------------------------------------------------------------------------*/
59
60
#ifndef writer_H
61
#define writer_H
62
63
#include <
OpenFOAM/fileName.H
>
64
#include <
OpenFOAM/wordList.H
>
65
#include <
OpenFOAM/vector.H
>
66
#include <
OpenFOAM/tensor.H
>
67
#include <
OpenFOAM/typeInfo.H
>
68
#include <
OpenFOAM/runTimeSelectionTables.H
>
69
#include <
OpenFOAM/autoPtr.H
>
70
#include <
OpenFOAM/Field.H
>
71
72
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
73
74
namespace
Foam
75
{
76
77
// Forward declaration of classes
78
class
coordSet;
79
80
/*---------------------------------------------------------------------------*\
81
Class writer Declaration
82
\*---------------------------------------------------------------------------*/
83
84
template
<
class
Type>
85
class
writer
86
{
87
88
protected
:
89
90
//- Generates filename from coordSet and sampled fields
91
fileName
getBaseName
(
const
coordSet
&,
const
wordList
&)
const
;
92
93
void
writeCoord
(
const
coordSet
&,
const
label sampleI,
Ostream
&)
const
;
94
95
//- Writes single-column ascii write. Column 1 is coordSet coordinate,
96
// columns 2 is the value. Uses write() function
97
// to write coordinate in correct format.
98
void
writeTable
(
const
coordSet
&,
const
List<Type>
&,
Ostream
&)
const
;
99
100
//- Writes multi-column ascii write. Column 1 is coordSet coordinate,
101
// columns 2..n are the values. Uses write() function
102
// to write coordinate in correct format.
103
void
writeTable
104
(
105
const
coordSet
&,
106
const
List
<
const
List<Type>
*>&,
107
Ostream
& os
108
)
const
;
109
110
//- Writes a separator. Used by write functions.
111
virtual
void
writeSeparator
(
Ostream
& os)
const
;
112
113
public
:
114
115
//- Runtime type information
116
TypeName
(
"writer"
);
117
118
// Declare run-time constructor selection table
119
120
declareRunTimeSelectionTable
121
(
122
autoPtr
,
123
writer
,
124
word
,
125
(),
126
()
127
);
128
129
130
// Selectors
131
132
//- Return a reference to the selected writer
133
static
autoPtr<writer>
New
(
const
word
& writeFormat);
134
135
136
// Constructors
137
138
//- Construct null
139
writer
();
140
141
142
//- Destructor
143
virtual
~writer
() = 0;
144
145
146
// Member Functions
147
148
//- Generate file name with correct extension
149
virtual
fileName
getFileName
150
(
151
const
coordSet
&,
152
const
wordList
&
153
)
const
= 0;
154
155
//- General entry point for writing.
156
// The data is organized in a set of point with one or more values
157
// per point
158
virtual
void
write
159
(
160
const
coordSet
&,
161
const
wordList
&,
162
const
List
<
const
Field<Type>
*>&,
163
Ostream
&
164
)
const
= 0;
165
166
//- General entry point for writing of multiple coordSets.
167
// Each coordSet (track) has same data variables.
168
// The data is per variable, per track, per point of track.
169
// If writeTracks adds connecting lines (wherever applicable)
170
virtual
void
write
171
(
172
const
bool
writeTracks,
173
const
PtrList<coordSet>
&,
174
const
wordList
& valueSetNames,
175
const
List
<
List
<
Field<Type>
> >&,
176
Ostream
&
177
)
const
= 0;
178
179
//- Write scalar as ascii
180
virtual
Ostream
&
write
(
const
scalar,
Ostream
&)
const
;
181
182
template
<
class
VSType>
183
Ostream
&
writeVS
(
const
VSType&,
Ostream
&)
const
;
184
185
//- Write vector. Tab separated ascii
186
virtual
Ostream
&
write
(
const
vector
&,
Ostream
&)
const
;
187
188
//- Write sphericalTensor. Tab separated ascii
189
virtual
Ostream
&
write
(
const
sphericalTensor
&,
Ostream
&)
const
;
190
191
//- Write symmTensor. Tab separated ascii
192
virtual
Ostream
&
write
(
const
symmTensor
&,
Ostream
&)
const
;
193
194
//- Write tensor. Tab separated ascii
195
virtual
Ostream
&
write
(
const
tensor
&,
Ostream
&)
const
;
196
};
197
198
199
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200
201
}
// End namespace Foam
202
203
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204
205
#ifdef NoRepository
206
# include <
sampling/writer.C
>
207
#endif
208
209
210
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211
212
#endif
213
214
// ************************ vim: set sw=4 sts=4 et: ************************ //