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