rawSurfaceWriter.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
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::rawSurfaceWriter
26 
27 Description
28  A surfaceWriter for raw output.
29 
30 SourceFiles
31  rawSurfaceWriter.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef rawSurfaceWriter_H
36 #define rawSurfaceWriter_H
37 
38 #include "surfaceWriter.H"
39 
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 /*---------------------------------------------------------------------------*\
47  Class rawSurfaceWriter Declaration
48 \*---------------------------------------------------------------------------*/
49 
50 class rawSurfaceWriter
51 :
52  public surfaceWriter
53 {
54  // Private Data
55 
56  //- Output compression, defaults to uncompressed
57  IOstream::compressionType writeCompression_;
58 
59 
60  // Private Member Functions
61 
62  static inline void writeLocation
63  (
64  Ostream&,
65  const pointField&,
66  const label pointi
67  );
68 
69  static inline void writeLocation
70  (
71  Ostream&,
72  const pointField&,
73  const faceList&,
74  const label facei
75  );
76 
77  template<class Type>
78  static void writeHeader
79  (
80  Ostream&,
81  const word& fieldName,
82  const Field<Type>&
83  );
84 
85  template<class Type>
86  static inline void writeData(Ostream&, const Type&);
87 
88 
89  //- Templated write operation
90  template<class Type>
91  void Write
92  (
93  const fileName& outputDir,
94  const fileName& surfaceName,
95  const pointField& points,
96  const faceList& faces,
97  const word& fieldName,
98  const Field<Type>& values,
99  const bool isNodeValues
100  ) const;
101 
102 
103 public:
104 
105  //- Runtime type information
106  TypeName("raw");
107 
108 
109  // Constructors
110 
111  //- Construct given write format
112  rawSurfaceWriter(const IOstream::streamFormat writeFormat);
113 
114  //- Construct with output options
115  rawSurfaceWriter(const dictionary& optDict);
116 
117 
118  //- Destructor
119  virtual ~rawSurfaceWriter();
120 
121 
122  // Member Functions
123 
124  //- Write single surface geometry to file.
125  virtual void write
126  (
127  const fileName& outputDir,
128  const fileName& surfaceName,
129  const pointField& points,
130  const faceList& faces
131  ) const;
132 
133 
134  //- Write scalarField for a single surface to file.
135  // One value per face or vertex (isNodeValues = true)
136  virtual void write
137  (
138  const fileName& outputDir, // <case>/surface/TIME
139  const fileName& surfaceName, // name of surface
140  const pointField& points,
141  const faceList& faces,
142  const word& fieldName, // name of field
143  const Field<scalar>& values,
144  const bool isNodeValues
145  ) const;
146 
147  //- Write vectorField for a single surface to file.
148  // One value per face or vertex (isNodeValues = true)
149  virtual void write
150  (
151  const fileName& outputDir, // <case>/surface/TIME
152  const fileName& surfaceName, // name of surface
153  const pointField& points,
154  const faceList& faces,
155  const word& fieldName, // name of field
156  const Field<vector>& values,
157  const bool isNodeValues
158  ) const;
159 
160  //- Write sphericalTensorField for a single surface to file.
161  // One value per face or vertex (isNodeValues = true)
162  virtual void write
163  (
164  const fileName& outputDir, // <case>/surface/TIME
165  const fileName& surfaceName, // name of surface
166  const pointField& points,
167  const faceList& faces,
168  const word& fieldName, // name of field
169  const Field<sphericalTensor>& values,
170  const bool isNodeValues
171  ) const;
172 
173  //- Write symmTensorField for a single surface to file.
174  // One value per face or vertex (isNodeValues = true)
175  virtual void write
176  (
177  const fileName& outputDir, // <case>/surface/TIME
178  const fileName& surfaceName, // name of surface
179  const pointField& points,
180  const faceList& faces,
181  const word& fieldName, // name of field
182  const Field<symmTensor>& values,
183  const bool isNodeValues
184  ) const;
185 
186  //- Write tensorField for a single surface to file.
187  // One value per face or vertex (isNodeValues = true)
188  virtual void write
189  (
190  const fileName& outputDir, // <case>/surface/TIME
191  const fileName& surfaceName, // name of surface
192  const pointField& points,
193  const faceList& faces,
194  const word& fieldName, // name of field
195  const Field<tensor>& values,
196  const bool isNodeValues
197  ) const;
198 };
199 
200 
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 
203 } // End namespace Foam
204 
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206 
207 #endif
208 
209 // ************************************************************************* //
A surfaceWriter for raw output.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
A class for handling file names.
Definition: fileName.H:79
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
virtual void write(const fileName &outputDir, const fileName &surfaceName, const pointField &points, const faceList &faces) const
Write single surface geometry to file.
TypeName("raw")
Runtime type information.
virtual ~rawSurfaceWriter()
Destructor.
const pointField & points
A class for handling words, derived from string.
Definition: word.H:59
streamFormat
Enumeration for the format of data in the stream.
Definition: IOstream.H:86
compressionType
Enumeration for the format of data in the stream.
Definition: IOstream.H:193
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
rawSurfaceWriter(const IOstream::streamFormat writeFormat)
Construct given write format.
Base class for surface writers.
Definition: surfaceWriter.H:54
Namespace for OpenFOAM.