Loading...
Searching...
No Matches
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 true;
40 format ascii;
41 compression false;
42 normal false;
43 }
44 }
45 \endverbatim
46
47 Format options:
48 \table
49 Property | Description | Required | Default
50 header | Generate files with FoamFile header | no | true
51 format | ascii/binary | no | ascii
52 compression | Use file compression | no | false
53 scale | Output geometry scaling | no | 1
54 transform | Output coordinate transform | no |
55 fieldLevel | Subtract field level before scaling | no | empty dict
56 fieldScale | Output field scaling | no | empty dict
57 normal | Write face area normal in output | no | false
58 \endtable
59
60 Typical way of working:
61 - use a sampledSurface of type 'patch' (to sample a patch):
62 \verbatim
63 surfaces
64 {
65 type surfaces;
66 fields ( p );
67 surfaceFormat boundaryData;
68 formatOptions
69 {
70 boundaryData
71 {
72 format binary;
73 normal yes;
74 fieldLevel
75 {
76 p 1e5; // Absolute -> gauge [Pa]
77 }
78 fieldScale
79 {
80 "p.*" 0.01; // [Pa] -> [mbar]
81 }
82 }
83 }
84 surfaces
85 {
86 outlet
87 {
88 type patch;
89 patches (outlet);
90 interpolate false;
91 }
92 }
93 }
94 \endverbatim
95
96 - write using this writer.
97 - move postProcessing/surfaces/outlet to constant/boundaryData/outlet
98 in your destination case.
99 - use a timeVaryingMappedFixedValue condition to read and interpolate
100 the profile:
101 type timeVaryingMappedFixedValue;
102 setAverage false; // do not use read average
103 offset 0; // do not apply offset to values
104
105 Note:
106 - with 'interpolate false' the data is on the face centres of the
107 patch. Take care that a 2D geometry will only have a single row
108 of face centres so might not provide a valid triangulation
109 (this is what timeVaryingMappedFixedValue uses to do interpolation)
110 (Alternatively use timeVaryingMappedFixedValue with mapMethod 'nearest')
111
112 \heading Output file locations
113
114 The \c rootdir normally corresponds to something like
115 \c postProcessing/<name>
116
117 where the geometry is written as:
118 \verbatim
119 rootdir
120 `-- surfaceName
121 `-- "points"
122 \endverbatim
123
124 and field data:
125 \verbatim
126 rootdir
127 `-- surfaceName
128 |-- "points"
129 `-- timeName
130 `-- field
131 \endverbatim
132
133SourceFiles
134 boundaryDataSurfaceWriter.C
135
136\*---------------------------------------------------------------------------*/
137
138#ifndef Foam_surfaceWriters_boundaryDataWriter_H
139#define Foam_surfaceWriters_boundaryDataWriter_H
140
141#include "surfaceWriter.H"
142
143// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
144
145namespace Foam
146{
147
148// Forward Declarations
149class regIOobject;
150
151namespace surfaceWriters
152{
153
154/*---------------------------------------------------------------------------*\
155 Class boundaryDataWriter Declaration
156\*---------------------------------------------------------------------------*/
157
159:
160 public surfaceWriter
161{
162 // Private Data
163
164 //- Output stream option
165 IOstreamOption streamOpt_;
166
167 //- Output files with FoamFile header
168 bool header_;
169
170 //- Output face area normal
171 const bool writeNormal_;
172
173
174 // Private Member Functions
175
176 //- Write serial surface geometry to "points" file.
177 void serialWriteGeometry(const regIOobject&, const meshedSurf& surf);
178
179 //- Templated write field operation
180 template<class Type>
181 fileName writeTemplate
182 (
183 const word& fieldName,
184 const Field<Type>& localValues
185 );
186
187
188public:
189
190 //- Declare type-name, virtual type (without debug switch)
191 TypeNameNoDebug("boundaryData");
192
193
194 // Constructors
195
196 //- Default construct
199 //- Construct with some output options
200 explicit boundaryDataWriter(const dictionary& options);
201
202 //- Construct from components
204 (
205 const meshedSurf& surf,
206 const fileName& outputPath,
207 bool parallel = UPstream::parRun(),
208 const dictionary& options = dictionary()
209 );
210
211 //- Construct from components
213 (
214 const pointField& points,
215 const faceList& faces,
216 const fileName& outputPath,
217 bool parallel = UPstream::parRun(),
218 const dictionary& options = dictionary()
219 );
220
221
222 //- Destructor
223 virtual ~boundaryDataWriter() = default;
224
225
226 // Member Functions
227
228 //- Write surface geometry to file.
229 virtual fileName write(); // override
230
237};
238
239
240// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
241
242} // End namespace surfaceWriters
243} // End namespace Foam
244
245// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246
247#endif
248
249// ************************************************************************* //
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
A simple container for options an IOstream can normally have.
static bool parRun(const bool on) noexcept
Set as parallel run on/off.
Definition UPstream.H:1669
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
A class for handling file names.
Definition fileName.H:75
Abstract definition of a meshed surface defined by faces and points.
Definition meshedSurf.H:44
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition regIOobject.H:71
surfaceWriter()
Default construct.
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:66
const pointField & points
Namespace for surface writers.
Namespace for OpenFOAM.
List< face > faceList
List of faces.
Definition faceListFwd.H:41
Tensor< scalar > tensor
Definition symmTensor.H:57
vectorField pointField
pointField is a vectorField.
Vector< scalar > vector
Definition vector.H:57
SphericalTensor< scalar > sphericalTensor
SphericalTensor of scalars, i.e. SphericalTensor<scalar>.
SymmTensor< scalar > symmTensor
SymmTensor of scalars, i.e. SymmTensor<scalar>.
Definition symmTensor.H:55
#define declareSurfaceWriterWriteMethod(Type)
#define TypeNameNoDebug(TypeNameString)
Declare a ClassNameNoDebug() with extra virtual type info.
Definition typeInfo.H:61