surfaceWriter.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::surfaceWriter
26 
27 Description
28  Base class for surface writers
29 
30 SourceFiles
31  surfaceWriter.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef surfaceWriter_H
36 #define surfaceWriter_H
37 
38 #include "typeInfo.H"
39 #include "autoPtr.H"
40 #include "pointField.H"
41 #include "faceList.H"
42 #include "fileName.H"
43 
44 #include "runTimeSelectionTables.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 /*---------------------------------------------------------------------------*\
52  Class surfaceWriter Declaration
53 \*---------------------------------------------------------------------------*/
54 
55 class surfaceWriter
56 {
57 
58 protected:
59 
60  // Protected Data
61 
62  //- Write format
64 
65 
66 public:
67 
68  //- Runtime type information
69  TypeName("surfaceWriter");
70 
71  // Declare run-time constructor selection table
72 
74  (
75  autoPtr,
77  word,
78  (
79  const IOstream::streamFormat writeFormat
80  ),
81  (writeFormat)
82  );
83 
85  (
86  autoPtr,
88  wordDict,
89  (
90  const dictionary& optDict
91  ),
92  (optDict)
93  );
94 
95 
96  // Selectors
97 
98  //- Return a reference to the selected surfaceWriter
100  (
101  const word& writeType,
102  const IOstream::streamFormat writeFormat
103  );
104 
105  //- Return a reference to the selected surfaceWriter
106  // Select with extra write option
108  (
109  const word& writeType,
110  const dictionary& optDict
111  );
112 
113 
114  // Constructors
115 
116  //- Construct given write format
117  surfaceWriter(const IOstream::streamFormat writeFormat);
118 
119  //- Construct with output options
120  surfaceWriter(const dictionary& optDict);
121 
122 
123  //- Destructor
124  virtual ~surfaceWriter();
125 
126 
127  // Member Functions
128 
129  //- True if the surface format supports geometry in a separate file.
130  // False if geometry and field must be in a single file
131  virtual bool separateGeometry()
132  {
133  return false;
134  }
135 
136  //- Write single surface geometry to file.
137  virtual void write
138  (
139  const fileName& outputDir, // <case>/surface/TIME
140  const fileName& surfaceName, // name of surface
141  const pointField& points,
142  const faceList& faces
143  ) const = 0;
144 
145  //- Write scalarField for a single surface to file.
146  // One value per face or vertex (isNodeValues = true)
147  virtual void write
148  (
149  const fileName& outputDir, // <case>/surface/TIME
150  const fileName& surfaceName, // name of surface
151  const pointField& points,
152  const faceList& faces,
153  const word& fieldName, // name of field
154  const Field<scalar>& values,
155  const bool isNodeValues
156  ) const = 0;
157 
158  //- Write vectorField for a single surface to file.
159  // One value per face or vertex (isNodeValues = true)
160  virtual void write
161  (
162  const fileName& outputDir, // <case>/surface/TIME
163  const fileName& surfaceName, // name of surface
164  const pointField& points,
165  const faceList& faces,
166  const word& fieldName, // name of field
167  const Field<vector>& values,
168  const bool isNodeValues
169  ) const = 0;
170 
171  //- Write sphericalTensorField for a single surface to file.
172  // One value per face or vertex (isNodeValues = true)
173  virtual void write
174  (
175  const fileName& outputDir, // <case>/surface/TIME
176  const fileName& surfaceName, // name of surface
177  const pointField& points,
178  const faceList& faces,
179  const word& fieldName, // name of field
180  const Field<sphericalTensor>& values,
181  const bool isNodeValues
182  ) const = 0;
183 
184  //- Write symmTensorField for a single surface to file.
185  // One value per face or vertex (isNodeValues = true)
186  virtual void write
187  (
188  const fileName& outputDir, // <case>/surface/TIME
189  const fileName& surfaceName, // name of surface
190  const pointField& points,
191  const faceList& faces,
192  const word& fieldName, // name of field
193  const Field<symmTensor>& values,
194  const bool isNodeValues
195  ) const = 0;
196 
197  //- Write tensorField for a single surface to file.
198  // One value per face or vertex (isNodeValues = true)
199  virtual void write
200  (
201  const fileName& outputDir, // <case>/surface/TIME
202  const fileName& surfaceName, // name of surface
203  const pointField& points,
204  const faceList& faces,
205  const word& fieldName, // name of field
206  const Field<tensor>& values,
207  const bool isNodeValues
208  ) const = 0;
209 };
210 
211 
212 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
213 
214 } // End namespace Foam
215 
216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 
218 #endif
219 
220 // ************************************************************************* //
virtual bool separateGeometry()
True if the surface format supports geometry in a separate file.
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:156
static autoPtr< surfaceWriter > New(const word &writeType, const IOstream::streamFormat writeFormat)
Return a reference to the selected surfaceWriter.
Definition: surfaceWriter.C:45
virtual void write(const fileName &outputDir, const fileName &surfaceName, const pointField &points, const faceList &faces) const =0
Write single surface geometry to file.
virtual ~surfaceWriter()
Destructor.
IOstream::streamFormat writeFormat_
Write format.
Definition: surfaceWriter.H:62
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
declareRunTimeSelectionTable(autoPtr, surfaceWriter, word,(const IOstream::streamFormat writeFormat),(writeFormat))
TypeName("surfaceWriter")
Runtime type information.
surfaceWriter(const IOstream::streamFormat writeFormat)
Construct given write format.
Base class for surface writers.
Definition: surfaceWriter.H:54
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Macros to ease declaration of run-time selection tables.
Namespace for OpenFOAM.