starcdSurfaceWriter.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::starcdSurfaceWriter
26 
27 Description
28  A surfaceWriter for STARCD files.
29 
30  The geometry is written via the MeshedSurfaceProxy, the fields
31  are written in a trivial ASCII format with ID and VALUE as
32  so-called user data. These \c .usr files can be read into proSTAR
33  with these types of commands. For element data:
34  \verbatim
35  getuser FILENAME.usr cell scalar free
36  getuser FILENAME.usr cell vector free
37  \endverbatim
38  and for vertex data:
39  \verbatim
40  getuser FILENAME.usr vertex scalar free
41  getuser FILENAME.usr vertex vector free
42  \endverbatim
43 
44 Note
45  Only scalar and vector fields are supported directly.
46  A sphericalTensor is written as a scalar.
47  Other field types are not written.
48 
49 SourceFiles
50  starcdSurfaceWriter.C
51 
52 \*---------------------------------------------------------------------------*/
53 
54 #ifndef starcdSurfaceWriter_H
55 #define starcdSurfaceWriter_H
56 
57 #include "surfaceWriter.H"
58 
59 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
60 
61 namespace Foam
62 {
63 
64 /*---------------------------------------------------------------------------*\
65  Class starcdSurfaceWriter Declaration
66 \*---------------------------------------------------------------------------*/
67 
69 :
70  public surfaceWriter
71 {
72  // Private Member Functions
73 
74  template<class Type>
75  static inline void writeData(Ostream&, const Type&);
76 
77 
78  //- Templated write operation
79  template<class Type>
80  void Write
81  (
82  const fileName& outputDir,
83  const fileName& surfaceName,
84  const pointField& points,
85  const faceList& faces,
86  const word& fieldName,
87  const Field<Type>& values,
88  const bool isNodeValues
89  ) const;
90 
91 
92 public:
93 
94  //- Runtime type information
95  TypeName("starcd");
96 
97 
98  // Constructors
99 
100  //- Construct given write format
101  starcdSurfaceWriter(const IOstream::streamFormat writeFormat);
102 
103 
104  //- Destructor
105  virtual ~starcdSurfaceWriter();
106 
107 
108  // Member Functions
109 
110  //- True if the surface format supports geometry in a separate file.
111  // False if geometry and field must be in a single file
112  virtual bool separateGeometry()
113  {
114  return true;
115  }
116 
117  //- Write single surface geometry to file.
118  virtual void write
119  (
120  const fileName& outputDir,
121  const fileName& surfaceName,
122  const pointField& points,
123  const faceList& faces
124  ) const;
125 
126  //- Write scalarField for a single surface to file.
127  // One value per face or vertex (isNodeValues = true)
128  virtual void write
129  (
130  const fileName& outputDir, // <case>/surface/TIME
131  const fileName& surfaceName, // name of surface
132  const pointField& points,
133  const faceList& faces,
134  const word& fieldName, // name of field
135  const Field<scalar>& values,
136  const bool isNodeValues
137  ) const;
138 
139  //- Write vectorField for a single surface to file.
140  // One value per face or vertex (isNodeValues = true)
141  virtual void write
142  (
143  const fileName& outputDir, // <case>/surface/TIME
144  const fileName& surfaceName, // name of surface
145  const pointField& points,
146  const faceList& faces,
147  const word& fieldName, // name of field
148  const Field<vector>& values,
149  const bool isNodeValues
150  ) const;
151 
152  //- Write sphericalTensorField for a single surface to file.
153  // One value per face or vertex (isNodeValues = true)
154  virtual void write
155  (
156  const fileName& outputDir, // <case>/surface/TIME
157  const fileName& surfaceName, // name of surface
158  const pointField& points,
159  const faceList& faces,
160  const word& fieldName, // name of field
161  const Field<sphericalTensor>& values,
162  const bool isNodeValues
163  ) const;
164 
165  //- Write symmTensorField for a single surface to file.
166  // One value per face or vertex (isNodeValues = true)
167  virtual void write
168  (
169  const fileName& outputDir, // <case>/surface/TIME
170  const fileName& surfaceName, // name of surface
171  const pointField& points,
172  const faceList& faces,
173  const word& fieldName, // name of field
174  const Field<symmTensor>& values,
175  const bool isNodeValues
176  ) const
177  {}
178 
179  //- Write tensorField for a single surface to file.
180  // One value per face or vertex (isNodeValues = true)
181  virtual void write
182  (
183  const fileName& outputDir, // <case>/surface/TIME
184  const fileName& surfaceName, // name of surface
185  const pointField& points,
186  const faceList& faces,
187  const word& fieldName, // name of field
188  const Field<tensor>& values,
189  const bool isNodeValues
190  ) const
191  {}
192 };
193 
194 
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 
197 } // End namespace Foam
198 
199 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200 
201 #endif
202 
203 // ************************************************************************* //
starcdSurfaceWriter(const IOstream::streamFormat writeFormat)
Construct given write format.
A class for handling file names.
Definition: fileName.H:79
virtual ~starcdSurfaceWriter()
Destructor.
virtual bool separateGeometry()
True if the surface format supports geometry in a separate file.
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
TypeName("starcd")
Runtime type information.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
virtual void write(const fileName &outputDir, const fileName &surfaceName, const pointField &points, const faceList &faces) const
Write single surface geometry to file.
A surfaceWriter for STARCD files.
Base class for surface writers.
Definition: surfaceWriter.H:54
Namespace for OpenFOAM.