csvCoordSetWriter.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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2021-2022 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::coordSetWriters::csvWriter
28
29Description
30 Write coordSet(s) in csv format
31
32 The formatOptions for csv:
33 \table
34 Property | Description | Required | Default
35 buffer | Use buffered output | no | true
36 compression | Use file compression | no | false
37 precision | Write precision in ascii | no | same as IOstream
38 \endtable
39
40 When called with a single coordSet, will buffer the output of
41 all fields and output together in the order of label/scalar/vector/...
42 each of which is sorted alphabetically according to the field name.
43
44 When called as a track writer (eg, with multiple coordSets),
45 will emit one file per field.
46
47SourceFiles
48 csvCoorSetWriter.C
49 csvCoorSetWriterImpl.C
50
51\*---------------------------------------------------------------------------*/
52
53#ifndef Foam_coordSetWriters_csvWriter_H
54#define Foam_coordSetWriters_csvWriter_H
55
56#include "coordSetWriter.H"
57
58// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
59
60namespace Foam
61{
62namespace coordSetWriters
63{
64
65/*---------------------------------------------------------------------------*\
66 Class csvWriter Declaration
67\*---------------------------------------------------------------------------*/
68
69class csvWriter
70:
71 public coordSetWriter
72{
73 // Private Data
74
75 //- Output stream option
76 IOstreamOption streamOpt_;
77
78 //- ASCII write precision
79 unsigned precision_;
80
81
82 // Private Member Functions
83
84 //- Templated write operation
85 template<class Type>
86 fileName writeTemplate
87 (
88 const word& fieldName,
89 const UPtrList<const Field<Type>>& fieldPtrs
90 );
91
92 //- Templated write operation
93 template<class Type>
94 fileName writeTemplate
95 (
96 const word& fieldName,
97 const Field<Type>& vals
98 );
99
100 //- Templated write operation
101 template<class Type>
102 fileName writeTemplate
103 (
104 const word& fieldName,
105 const List<Field<Type>>& fieldValues
106 );
107
108
109protected:
110
111 // Protected Member Functions
112
113 //- Write buffered data
114 virtual bool writeBuffered();
115
116
117public:
118
119 //- Runtime type information (no debug)
120 TypeNameNoDebug("csv");
121
122
123 // Constructors
124
125 //- Default construct
126 csvWriter();
127
128 //- Default construct with specified options
129 explicit csvWriter(const dictionary& options);
130
131 //- Construct from components
133 (
134 const coordSet& coords,
135 const fileName& outputPath,
136 const dictionary& options = dictionary()
137 );
138
139 //- Construct from components
141 (
142 const UPtrList<coordSet>& tracks,
143 const fileName& outputPath,
144 const dictionary& options = dictionary()
145 );
146
147
148 //- Destructor. Calls close()
149 virtual ~csvWriter();
150
151
152 // Member Functions
153
154 //- Enable/disable internal buffering
155 virtual bool buffering(const bool on); // override
156
157 //- Characteristic output file name - information only
158 // \warning incorrect for unbuffered or track output!
159 virtual fileName path() const; // override
160
167};
168
169
170// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
171
172} // End namespace coordSetWriters
173} // End namespace Foam
174
175// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176
177#endif
178
179// ************************************************************************* //
Generic templated field type.
Definition: Field.H:82
The IOstreamOption is a simple container for options an IOstream can normally have.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: UPtrList.H:71
Base class for writing coordSet(s) and tracks with fields.
virtual bool buffering() const
True if the format uses internal buffering (eg, column output)
Write coordSet(s) in csv format.
virtual ~csvWriter()
Destructor. Calls close()
TypeNameNoDebug("csv")
Runtime type information (no debug)
virtual bool writeBuffered()
Write buffered data.
declareCoordSetWriterWriteMethod(sphericalTensor)
declareCoordSetWriterWriteMethod(symmTensor)
virtual fileName path() const
Characteristic output file name - information only.
Holds list of sampling positions.
Definition: coordSet.H:56
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A class for handling file names.
Definition: fileName.H:76
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define declareCoordSetWriterWriteMethod(Type)
Namespace for OpenFOAM.
#define TypeNameNoDebug(TypeNameString)
Declare a ClassNameNoDebug() with extra virtual type info.
Definition: typeInfo.H:68