boundaryDataSurfaceWriter.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) 2015-2022 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::surfaceWriters::boundaryDataWriter
28
29Description
30 A surfaceWriter for outputting to a form usable for the
31 timeVaryingMapped boundary condition. This reads the data from
32 constant/boundaryData/<patch> directory.
33
34 \verbatim
35 formatOptions
36 {
37 boundaryData
38 {
39 header false;
40 format ascii;
41 compression false;
42 }
43 }
44 \endverbatim
45
46 Format options:
47 \table
48 Property | Description | Required | Default
49 header | Generate files with FoamFile header | no | true
50 format | ascii/binary | no | ascii
51 compression | Use file compression | no | false
52 scale | Output geometry scaling | no | 1
53 transform | Output coordinate transform | no |
54 fieldLevel | Subtract field level before scaling | no | empty dict
55 fieldScale | Output field scaling | no | empty dict
56 \endtable
57
58 Typical way of working:
59 - use a sampledSurface of type 'patch' (to sample a patch):
60 \verbatim
61 surfaces
62 {
63 type surfaces;
64 fields ( p );
65 surfaceFormat boundaryData;
66 formatOptions
67 {
68 boundaryData
69 {
70 format binary;
71 fieldLevel
72 {
73 p 1e5; // Absolute -> gauge [Pa]
74 }
75 fieldScale
76 {
77 "p.*" 0.01; // [Pa] -> [mbar]
78 }
79 }
80 }
81 surfaces
82 {
83 outlet
84 {
85 type patch;
86 patches (outlet);
87 interpolate false;
88 }
89 }
90 }
91 \endverbatim
92
93 - write using this writer.
94 - move postProcessing/surfaces/outlet to constant/boundaryData/outlet
95 in your destination case.
96 - use a timeVaryingMappedFixedValue condition to read and interpolate
97 the profile:
98 type timeVaryingMappedFixedValue;
99 setAverage false; // do not use read average
100 offset 0; // do not apply offset to values
101
102 Note:
103 - with 'interpolate false' the data is on the face centres of the
104 patch. Take care that a 2D geometry will only have a single row
105 of face centres so might not provide a valid triangulation
106 (this is what timeVaryingMappedFixedValue uses to do interpolation)
107 (Alternatively use timeVaryingMappedFixedValue with mapMethod 'nearest')
108
109 \heading Output file locations
110
111 The \c rootdir normally corresponds to something like
112 \c postProcessing/<name>
113
114 where the geometry is written as:
115 \verbatim
116 rootdir
117 `-- surfaceName
118 `-- "points"
119 \endverbatim
120
121 and field data:
122 \verbatim
123 rootdir
124 `-- surfaceName
125 |-- "points"
126 `-- timeName
127 `-- field
128 \endverbatim
129
130SourceFiles
131 boundaryDataSurfaceWriter.C
132
133\*---------------------------------------------------------------------------*/
134
135#ifndef Foam_surfaceWriters_boundaryDataWriter_H
136#define Foam_surfaceWriters_boundaryDataWriter_H
137
138#include "surfaceWriter.H"
139
140// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141
142namespace Foam
143{
144
145// Forward Declarations
146class regIOobject;
147
148namespace surfaceWriters
149{
150
151/*---------------------------------------------------------------------------*\
152 Class boundaryDataWriter Declaration
153\*---------------------------------------------------------------------------*/
154
155class boundaryDataWriter
156:
157 public surfaceWriter
158{
159 // Private Data
160
161 //- Output files with FoamFile header
162 bool header_;
163
164 //- Output stream option
165 IOstreamOption streamOpt_;
166
167
168 // Private Member Functions
169
170 //- Write serial surface geometry to "points" file.
171 void serialWriteGeometry(const regIOobject&, const meshedSurf& surf);
172
173 //- Templated write field operation
174 template<class Type>
175 fileName writeTemplate
176 (
177 const word& fieldName,
178 const Field<Type>& localValues
179 );
180
181
182public:
183
184 //- Declare type-name, virtual type (without debug switch)
185 TypeNameNoDebug("boundaryData");
186
187
188 // Constructors
189
190 //- Default construct
192
193 //- Construct with some output options
194 explicit boundaryDataWriter(const dictionary& options);
195
196 //- Construct from components
198 (
199 const meshedSurf& surf,
200 const fileName& outputPath,
201 bool parallel = Pstream::parRun(),
202 const dictionary& options = dictionary()
203 );
204
205 //- Construct from components
207 (
208 const pointField& points,
209 const faceList& faces,
210 const fileName& outputPath,
211 bool parallel = Pstream::parRun(),
212 const dictionary& options = dictionary()
213 );
214
215
216 //- Destructor
217 virtual ~boundaryDataWriter() = default;
218
219
220 // Member Functions
221
222 //- Write surface geometry to file.
223 virtual fileName write(); // override
231};
232
233
234// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
235
236} // End namespace surfaceWriters
237} // End namespace Foam
238
239// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
240
241#endif
242
243// ************************************************************************* //
Generic templated field type.
Definition: Field.H:82
The IOstreamOption is a simple container for options an IOstream can normally have.
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:433
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A class for handling file names.
Definition: fileName.H:76
Abstract definition of a meshed surface defined by faces and points.
Definition: meshedSurf.H:50
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:76
Base class for surface writers.
A surfaceWriter for outputting to a form usable for the timeVaryingMapped boundary condition....
virtual ~boundaryDataWriter()=default
Destructor.
TypeNameNoDebug("boundaryData")
Declare type-name, virtual type (without debug switch)
virtual fileName write()
Write surface geometry to file.
A class for handling words, derived from Foam::string.
Definition: word.H:68
const pointField & points
Namespace for OpenFOAM.
#define declareSurfaceWriterWriteMethod(Type)
#define TypeNameNoDebug(TypeNameString)
Declare a ClassNameNoDebug() with extra virtual type info.
Definition: typeInfo.H:68