rawSurfaceWriter.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-2021 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::rawWriter
29 
30 Description
31  A surfaceWriter for raw output.
32 
33  The formatOptions for raw:
34  \table
35  Property | Description | Required | Default
36  compression | Use file compression | no | false
37  precision | Write precision in ascii | no | same as IOstream
38  scale | output geometry scaling | no | 1
39  fieldScale | output field scaling (dictionary) | no | empty
40  normal | Write face area normal in output | no | false
41  \endtable
42 
43  For example,
44  \verbatim
45  formatOptions
46  {
47  raw
48  {
49  compression on;
50 
51  scale 1000; // [m] -> [mm]
52  normal yes;
53  precision 10;
54  fieldScale
55  {
56  "p.*" 0.01; // [Pa] -> [mbar]
57  }
58  }
59  }
60  \endverbatim
61 
62  \section Output file locations
63 
64  The \c rootdir normally corresponds to something like
65  \c postProcessing/<name>
66 
67  \subsection Geometry
68  \verbatim
69  rootdir
70  `-- timeName
71  `-- surfaceName.{raw}
72  \endverbatim
73 
74  \subsection Fields
75  \verbatim
76  rootdir
77  `-- timeName
78  |-- <field0>_surfaceName.{raw}
79  `-- <field1>_surfaceName.{raw}
80  \endverbatim
81 
82 SourceFiles
83  rawSurfaceWriter.C
84 
85 \*---------------------------------------------------------------------------*/
86 
87 #ifndef rawSurfaceWriter_H
88 #define rawSurfaceWriter_H
89 
90 #include "surfaceWriter.H"
91 
92 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
93 
94 namespace Foam
95 {
96 namespace surfaceWriters
97 {
98 
99 /*---------------------------------------------------------------------------*\
100  Class rawWriter Declaration
101 \*---------------------------------------------------------------------------*/
102 
103 class rawWriter
104 :
105  public surfaceWriter
106 {
107  // Private Data
108 
109  //- Output stream option
110  IOstreamOption streamOpt_;
111 
112  //- ASCII write precision
113  unsigned precision_;
114 
115  //- Output face area normal
116  const bool writeNormal_;
117 
118  //- Output geometry scaling
119  const scalar geometryScale_;
120 
121  //- Output field scaling
122  const dictionary fieldScale_;
123 
124 
125  // Private Member Functions
126 
127  //- Templated write operation
128  template<class Type>
129  fileName writeTemplate
130  (
131  const word& fieldName,
132  const Field<Type>& localValues
133  );
134 
135 
136 public:
137 
138  //- Declare type-name, virtual type (without debug switch)
139  TypeNameNoDebug("raw");
140 
141 
142  // Constructors
143 
144  //- Default construct
145  rawWriter();
146 
147  //- Construct with some output options
148  explicit rawWriter(const dictionary& options);
149 
150  //- Construct from components
151  rawWriter
152  (
153  const meshedSurf& surf,
154  const fileName& outputPath,
155  bool parallel = Pstream::parRun(),
156  const dictionary& options = dictionary()
157  );
158 
159  //- Construct from components
160  rawWriter
161  (
162  const pointField& points,
163  const faceList& faces,
164  const fileName& outputPath,
165  bool parallel = Pstream::parRun(),
166  const dictionary& options = dictionary()
167  );
168 
169 
170  //- Destructor
171  virtual ~rawWriter() = default;
172 
173 
174  // Member Functions
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::Tensor< scalar >
Foam::SymmTensor< scalar >
Foam::surfaceWriters::rawWriter::~rawWriter
virtual ~rawWriter()=default
Destructor.
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::rawWriter::TypeNameNoDebug
TypeNameNoDebug("raw")
Declare type-name, virtual type (without debug switch)
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::IOstreamOption
The IOstreamOption is a simple container for options an IOstream can normally have.
Definition: IOstreamOption.H:63
Foam::surfaceWriters::rawWriter
A surfaceWriter for raw output.
Definition: rawSurfaceWriter.H:132
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::rawWriter::declareSurfaceWriterWriteMethod
declareSurfaceWriterWriteMethod(label)
Foam::surfaceWriters::rawWriter::rawWriter
rawWriter()
Default construct.
Definition: rawSurfaceWriter.C:59
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::rawWriter::write
virtual fileName write()
Write surface geometry to file.
Definition: rawSurfaceWriter.C:122