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-2018 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 writeTemplate
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 bool verbose
90  ) const;
91 
92 
93 public:
94 
95  //- Runtime type information
96  TypeName("starcd");
97 
98 
99  // Constructors
100 
101  //- Construct null
103 
104 
105  //- Destructor
106  virtual ~starcdSurfaceWriter();
107 
108 
109  // Member Functions
110 
111  //- True if the surface format supports geometry in a separate file.
112  // False if geometry and field must be in a single file
113  virtual bool separateGeometry()
114  {
115  return true;
116  }
117 
118  //- Write single surface geometry to file.
119  virtual void write
120  (
121  const fileName& outputDir,
122  const fileName& surfaceName,
123  const pointField& points,
124  const faceList& faces,
125  const bool verbose = false
126  ) const;
127 
128  //- Write scalarField for a single surface to file.
129  // One value per face or vertex (isNodeValues = true)
130  virtual void write
131  (
132  const fileName& outputDir, // <case>/surface/TIME
133  const fileName& surfaceName, // name of surface
134  const pointField& points,
135  const faceList& faces,
136  const word& fieldName, // name of field
137  const Field<scalar>& values,
138  const bool isNodeValues,
139  const bool verbose = false
140  ) const;
141 
142  //- Write vectorField for a single surface to file.
143  // One value per face or vertex (isNodeValues = true)
144  virtual void write
145  (
146  const fileName& outputDir, // <case>/surface/TIME
147  const fileName& surfaceName, // name of surface
148  const pointField& points,
149  const faceList& faces,
150  const word& fieldName, // name of field
151  const Field<vector>& values,
152  const bool isNodeValues,
153  const bool verbose = false
154  ) const;
155 
156  //- Write sphericalTensorField for a single surface to file.
157  // One value per face or vertex (isNodeValues = true)
158  virtual void write
159  (
160  const fileName& outputDir, // <case>/surface/TIME
161  const fileName& surfaceName, // name of surface
162  const pointField& points,
163  const faceList& faces,
164  const word& fieldName, // name of field
165  const Field<sphericalTensor>& values,
166  const bool isNodeValues,
167  const bool verbose = false
168  ) const;
169 
170 };
171 
172 
173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174 
175 } // End namespace Foam
176 
177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178 
179 #endif
180 
181 // ************************************************************************* //
starcdSurfaceWriter()
Construct null.
A class for handling file names.
Definition: fileName.H:69
virtual ~starcdSurfaceWriter()
Destructor.
virtual bool separateGeometry()
True if the surface format supports geometry in a separate file.
const pointField & points
A class for handling words, derived from string.
Definition: word.H:59
TypeName("starcd")
Runtime type information.
virtual void write(const fileName &outputDir, const fileName &surfaceName, const pointField &points, const faceList &faces, const bool verbose=false) const
Write single surface geometry to file.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
A surfaceWriter for STARCD files.
Base class for surface writers.
Definition: surfaceWriter.H:54
Namespace for OpenFOAM.