foamSurfaceWriter.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-2016 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::foamWriter
29 
30 Description
31  A surfaceWriter for OpenFOAM surfaces
32 
33  \verbatim
34  formatOptions
35  {
36  foam
37  {
38  format ascii;
39  compression true;
40 
41  fieldScale
42  {
43  "p.*" 0.01; // [Pa] -> [mbar]
44  }
45  }
46  }
47  \endverbatim
48 
49  Format options:
50  \table
51  Property | Description | Required | Default
52  format | ascii/binary | no | ascii
53  compression | output file compression | no | false
54  fieldScale | output field scaling (dictionary) | no | empty
55  \endtable
56 
57  \section Output file locations
58 
59  The \c rootdir normally corresponds to something like
60  \c postProcessing/<name>
61 
62  \subsection Geometry
63  \verbatim
64  rootdir
65  `-- timeName
66  `-- surfaceName
67  |-- "points"
68  |-- "faceCentres"
69  `-- "faces"
70  \endverbatim
71 
72  \subsection Fields
73  \verbatim
74  rootdir
75  `-- timeName
76  `-- surfaceName
77  |-- scalarField
78  | |-- field
79  | `-- field
80  |-- vectorField
81  |-- field
82  `-- field
83  \endverbatim
84 
85 SourceFiles
86  foamSurfaceWriter.C
87 
88 \*---------------------------------------------------------------------------*/
89 
90 #ifndef foamSurfaceWriter_H
91 #define foamSurfaceWriter_H
92 
93 #include "surfaceWriter.H"
94 
95 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
96 
97 namespace Foam
98 {
99 namespace surfaceWriters
100 {
101 
102 /*---------------------------------------------------------------------------*\
103  Class foamWriter Declaration
104 \*---------------------------------------------------------------------------*/
105 
106 class foamWriter
107 :
108  public surfaceWriter
109 {
110  // Private Data
111 
112  //- Output stream option (default: IOstream::ASCII, uncompressed)
113  IOstreamOption streamOpt_;
114 
115  //- Output field scaling
116  const dictionary fieldScale_;
117 
118 
119  // Private Member Functions
120 
121  //- Templated write operation
122  template<class Type>
123  fileName writeTemplate
124  (
125  const word& fieldName,
126  const Field<Type>& localValues
127  );
128 
129 
130 public:
131 
132  //- Declare type-name, virtual type (without debug switch)
133  TypeNameNoDebug("foam");
134 
135 
136  // Constructors
137 
138  //- Default construct
139  foamWriter();
140 
141  //- Construct with some output options
142  explicit foamWriter(const dictionary& options);
143 
144  //- Construct from components
145  foamWriter
146  (
147  const meshedSurf& surf,
148  const fileName& outputPath,
149  bool parallel = Pstream::parRun(),
150  const dictionary& options = dictionary()
151  );
152 
153  //- Construct from components
154  foamWriter
155  (
156  const pointField& points,
157  const faceList& faces,
158  const fileName& outputPath,
159  bool parallel = Pstream::parRun(),
160  const dictionary& options = dictionary()
161  );
162 
163 
164  //- Destructor
165  virtual ~foamWriter() = default;
166 
167 
168  // Member Functions
169 
170  //- The surface format has geometry in a separate file.
171  virtual bool separateGeometry() const
172  {
173  return true;
174  }
175 
176  //- Write surface geometry to file.
177  virtual fileName write(); // override
178 
185 };
186 
187 
188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189 
190 } // End namespace surfaceWriters
191 } // End namespace Foam
192 
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 
195 #endif
196 
197 // ************************************************************************* //
Foam::surfaceWriters::foamWriter::separateGeometry
virtual bool separateGeometry() const
The surface format has geometry in a separate file.
Definition: foamSurfaceWriter.H:190
Foam::Tensor< scalar >
Foam::SymmTensor< scalar >
Foam::surfaceWriters::foamWriter::write
virtual fileName write()
Write surface geometry to file.
Definition: foamSurfaceWriter.C:104
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::meshedSurf
Abstract definition of a meshed surface defined by faces and points.
Definition: meshedSurf.H:49
Foam::surfaceWriters::foamWriter::TypeNameNoDebug
TypeNameNoDebug("foam")
Declare type-name, virtual type (without debug switch)
surfaceWriter.H
Foam::surfaceWriters::foamWriter
A surfaceWriter for OpenFOAM surfaces.
Definition: foamSurfaceWriter.H:125
Foam::surfaceWriters::foamWriter::foamWriter
foamWriter()
Default construct.
Definition: foamSurfaceWriter.C:50
Foam::Field
Generic templated field type.
Definition: Field.H:63
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::foamWriter::declareSurfaceWriterWriteMethod
declareSurfaceWriterWriteMethod(label)
Foam::Vector< scalar >
Foam::UPstream::parRun
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:433
Foam::List< face >
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::surfaceWriters::foamWriter::~foamWriter
virtual ~foamWriter()=default
Destructor.