gnuplotCoordSetWriter.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) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2021-2022 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 Class
28  Foam::coordSetWriters::gnuplotWriter
29 
30 Description
31  A coordSet(s) writer in gnuplot format.
32 
33  The formatOptions for gnuplot:
34  \table
35  Property | Description | Required | Default
36  buffer | Use buffered output | no | true
37  compression | Use file compression | no | false
38  precision | Write precision in ascii | no | same as IOstream
39  \endtable
40 
41  When called with a single coordSet, will buffer the output of
42  all fields and output together in the order of label/scalar/vector/...
43  each of which is sorted alphabetically according to the field name.
44 
45  When called as a track writer (eg, with multiple coordSets),
46  will emit one file per field.
47 
48 SourceFiles
49  gnuplotCoordSetWriter.C
50  gnuplotCoordSetWriterImpl.C
51 
52 \*---------------------------------------------------------------------------*/
53 
54 #ifndef Foam_coordSetWriters_gnuplotWriter_H
55 #define Foam_coordSetWriters_gnuplotWriter_H
56 
57 #include "coordSetWriter.H"
58 
59 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
60 
61 namespace Foam
62 {
63 namespace coordSetWriters
64 {
65 
66 /*---------------------------------------------------------------------------*\
67  Class gnuplotWriter Declaration
68 \*---------------------------------------------------------------------------*/
69 
70 class gnuplotWriter
71 :
72  public coordSetWriter
73 {
74  // Private Data
75 
76  //- Output stream option
77  IOstreamOption streamOpt_;
78 
79  //- ASCII write precision
80  unsigned precision_;
81 
82 
83  // Private Member Functions
84 
85  //- Templated write operation
86  template<class Type>
87  fileName writeTemplate
88  (
89  const word& fieldName,
90  const UPtrList<const Field<Type>>& fieldPtrs
91  );
92 
93  //- Templated write operation
94  template<class Type>
95  fileName writeTemplate
96  (
97  const word& fieldName,
98  const Field<Type>& vals
99  );
100 
101  //- Templated write operation
102  template<class Type>
103  fileName writeTemplate
104  (
105  const word& fieldName,
106  const List<Field<Type>>& fieldValues
107  );
108 
109 
110 protected:
111 
112  // Protected Member Functions
113 
114  //- Write buffered data
115  virtual bool writeBuffered();
116 
117 
118 public:
119 
120  //- Runtime type information (no debug)
121  TypeNameNoDebug("gnuplot");
122 
123 
124  // Constructors
125 
126  //- Default construct
127  gnuplotWriter();
128 
129  //- Default construct with specified options
130  explicit gnuplotWriter(const dictionary& options);
131 
132  //- Construct from components
134  (
135  const coordSet& coords,
136  const fileName& outputPath,
137  const dictionary& options = dictionary()
138  );
139 
140  //- Construct from components
142  (
143  const UPtrList<coordSet>& tracks,
144  const fileName& outputPath,
145  const dictionary& options = dictionary()
146  );
147 
148 
149  //- Destructor. Calls close()
150  virtual ~gnuplotWriter();
151 
152 
153  // Member Functions
154 
155  //- Enable/disable internal buffering
156  virtual bool buffering(const bool on); // override
157 
158  //- Characteristic output file name - information only
159  virtual fileName path() const; // override
160 
167 };
168 
169 
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
171 
172 } // Endnamespace coordSetWriters
173 } // End namespace Foam
174 
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 
177 #endif
178 
179 // ************************************************************************* //
virtual ~gnuplotWriter()
Destructor. Calls close()
A class for handling file names.
Definition: fileName.H:72
virtual fileName path() const
Characteristic output file name - information only.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:56
virtual bool buffering() const
True if the format uses internal buffering (eg, column output)
Holds list of sampling positions.
Definition: coordSet.H:49
TypeNameNoDebug("gnuplot")
Runtime type information (no debug)
Generic templated field type.
Definition: Field.H:62
A class for handling words, derived from Foam::string.
Definition: word.H:63
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: HashTable.H:106
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
virtual bool writeBuffered()
Write buffered data.
Tensor of scalars, i.e. Tensor<scalar>.
Namespace for OpenFOAM.