starcdSurfaceWriter.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 OpenFOAM Foundation
9  Copyright (C) 2015-2020 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::surfaceWriters::starcdWriter
29 
30 Description
31  A surfaceWriter for STARCD files.
32 
33  The formatOptions for starcd:
34  \table
35  Property | Description | Required | Default
36  compression | Use file compression | no | false
37  fieldScale | output field scaling (dictionary) | no | empty
38  \endtable
39 
40  The geometry is written via the MeshedSurfaceProxy, the fields
41  are written in a trivial ASCII format with ID and VALUE as
42  so-called user data. These \c .usr files can be read into proSTAR
43  with these types of commands. For element data:
44  \verbatim
45  getuser FILENAME.usr cell scalar free
46  getuser FILENAME.usr cell vector free
47  \endverbatim
48  and for vertex data:
49  \verbatim
50  getuser FILENAME.usr vertex scalar free
51  getuser FILENAME.usr vertex vector free
52  \endverbatim
53 
54  \section Output file locations
55 
56  The \c rootdir normally corresponds to something like
57  \c postProcessing/<name>
58 
59  \subsection Geometry
60  \verbatim
61  rootdir
62  `-- timeName
63  `-- surfaceName.{cel,vrt,inp}
64  \endverbatim
65 
66  \subsection Fields
67  \verbatim
68  rootdir
69  `-- timeName
70  |-- <field0>_surfaceName.{usr}
71  `-- <field1>_surfaceName.{usr}
72  \endverbatim
73 
74 SourceFiles
75  starcdSurfaceWriter.C
76 
77 \*---------------------------------------------------------------------------*/
78 
79 #ifndef starcdSurfaceWriter_H
80 #define starcdSurfaceWriter_H
81 
82 #include "surfaceWriter.H"
83 
84 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
85 
86 namespace Foam
87 {
88 namespace surfaceWriters
89 {
90 
91 /*---------------------------------------------------------------------------*\
92  Class starcdWriter Declaration
93 \*---------------------------------------------------------------------------*/
94 
95 class starcdWriter
96 :
97  public surfaceWriter
98 {
99  // Private Data
100 
101  //- Output stream option
102  IOstreamOption streamOpt_;
103 
104  //- Output field scaling
105  const dictionary fieldScale_;
106 
107 
108  // Private Member Functions
109 
110  //- Templated write operation
111  template<class Type>
112  fileName writeTemplate
113  (
114  const word& fieldName,
115  const Field<Type>& localValues
116  );
117 
118 
119 public:
120 
121  //- Declare type-name, virtual type (without debug switch)
122  TypeNameNoDebug("starcd");
123 
124 
125  // Constructors
126 
127  //- Default construct
128  starcdWriter();
129 
130  //- Construct with some output options
131  explicit starcdWriter(const dictionary& options);
132 
133  //- Construct from components
135  (
136  const meshedSurf& surf,
137  const fileName& outputPath,
138  bool parallel = Pstream::parRun(),
139  const dictionary& options = dictionary()
140  );
141 
142  //- Construct from components
144  (
145  const pointField& points,
146  const faceList& faces,
147  const fileName& outputPath,
148  bool parallel = Pstream::parRun(),
149  const dictionary& options = dictionary()
150  );
151 
152 
153  //- Destructor
154  virtual ~starcdWriter() = default;
155 
156 
157  // Member Functions
158 
159  //- True if the surface format supports geometry in a separate file.
160  // False if geometry and field must be in a single file
161  virtual bool separateGeometry() const
162  {
163  return true;
164  }
165 
166  //- Format uses faceIds as part of its output
167  virtual bool usesFaceIds() const // override
168  {
169  return true;
170  }
171 
172  //- Write surface geometry to file.
173  virtual fileName write(); // override
174 
181 };
182 
183 
184 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 
186 } // End namespace surfaceWriters
187 } // End namespace Foam
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 #endif
192 
193 // ************************************************************************* //
Foam::Tensor< scalar >
Foam::surfaceWriters::starcdWriter::write
virtual fileName write()
Write surface geometry to file.
Definition: starcdSurfaceWriter.C:123
Foam::SymmTensor< scalar >
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::surfaceWriter
Base class for surface writers.
Definition: surfaceWriter.H:114
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
Foam::surfaceWriters::starcdWriter::declareSurfaceWriterWriteMethod
declareSurfaceWriterWriteMethod(label)
Foam::meshedSurf
Abstract definition of a meshed surface defined by faces and points.
Definition: meshedSurf.H:49
surfaceWriter.H
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::surfaceWriters::starcdWriter::~starcdWriter
virtual ~starcdWriter()=default
Destructor.
Foam::IOstreamOption
The IOstreamOption is a simple container for options an IOstream can normally have.
Definition: IOstreamOption.H:63
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::SphericalTensor< scalar >
Foam::surfaceWriters::starcdWriter::starcdWriter
starcdWriter()
Default construct.
Definition: starcdSurfaceWriter.C:69
Foam::surfaceWriters::starcdWriter::separateGeometry
virtual bool separateGeometry() const
True if the surface format supports geometry in a separate file.
Definition: starcdSurfaceWriter.H:175
Foam::surfaceWriters::starcdWriter::TypeNameNoDebug
TypeNameNoDebug("starcd")
Declare type-name, virtual type (without debug switch)
Foam::Vector< scalar >
Foam::UPstream::parRun
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:433
Foam::List< face >
Foam::surfaceWriters::starcdWriter
A surfaceWriter for STARCD files.
Definition: starcdSurfaceWriter.H:109
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::surfaceWriters::starcdWriter::usesFaceIds
virtual bool usesFaceIds() const
Format uses faceIds as part of its output.
Definition: starcdSurfaceWriter.H:181