rawCoordSetWriter.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) 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::rawWriter
28
29Description
30 A coordSet(s) in raw format.
31
32 The formatOptions for raw:
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 rawCoordSetWriter.C
49
50\*---------------------------------------------------------------------------*/
51
52#ifndef Foam_coordSetWriters_rawWriter_H
53#define Foam_coordSetWriters_rawWriter_H
54
55#include "coordSetWriter.H"
56
57// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58
59namespace Foam
60{
61namespace coordSetWriters
62{
63
64/*---------------------------------------------------------------------------*\
65 Class rawWriter Declaration
66\*---------------------------------------------------------------------------*/
67
68class rawWriter
69:
70 public coordSetWriter
71{
72 // Private Data
73
74 //- Output stream option
75 IOstreamOption streamOpt_;
76
77 //- ASCII write precision
78 unsigned precision_;
79
80
81 // Private Member Functions
82
83 //- Templated write operation
84 template<class Type>
85 fileName writeTemplate
86 (
87 const word& fieldName,
88 const UPtrList<const Field<Type>>& fieldPtrs
89 );
90
91 //- Templated write operation
92 template<class Type>
93 fileName writeTemplate
94 (
95 const word& fieldName,
96 const Field<Type>& vals
97 );
98
99 //- Templated write operation
100 template<class Type>
101 fileName writeTemplate
102 (
103 const word& fieldName,
104 const List<Field<Type>>& fieldValues
105 );
106
107
108protected:
109
110 // Protected Member Functions
111
112 //- Write buffered data
113 virtual bool writeBuffered();
114
115
116public:
117
118 //- Runtime type information (no debug)
119 TypeNameNoDebug("raw");
120
121
122 // Constructors
123
124 //- Default construct
125 rawWriter();
126
127 //- Default construct with specified options
128 explicit rawWriter(const dictionary& options);
129
130 //- Construct from components
132 (
133 const coordSet& coords,
134 const fileName& outputPath,
135 const dictionary& options = dictionary()
136 );
137
138 //- Construct from components
140 (
141 const UPtrList<coordSet>& tracks,
142 const fileName& outputPath,
143 const dictionary& options = dictionary()
144 );
145
146
147 //- Destructor. Calls close()
148 virtual ~rawWriter();
149
150
151 // Member Functions
152
153 //- Enable/disable internal buffering
154 virtual bool buffering(const bool on); // override
155
156 //- Characteristic output file name - information only
157 // \warning incorrect for unbuffered or track output!
158 virtual fileName path() const; // override
159
166};
167
168
169// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170
171} // End namespace coordSetWriters
172} // End namespace Foam
173
174// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175
176#endif
177
178// ************************************************************************* //
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)
A coordSet(s) in raw format.
virtual ~rawWriter()
Destructor. Calls close()
virtual bool writeBuffered()
Write buffered data.
declareCoordSetWriterWriteMethod(sphericalTensor)
declareCoordSetWriterWriteMethod(symmTensor)
virtual fileName path() const
Characteristic output file name - information only.
TypeNameNoDebug("raw")
Runtime type information (no debug)
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