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 -------------------------------------------------------------------------------
10 License
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 
26 Class
27  Foam::surfaceWriters::boundaryDataWriter
28 
29 Description
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 
133 SourceFiles
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 
145 namespace Foam
146 {
147 
148 // Forward Declarations
149 class regIOobject;
150 
151 namespace surfaceWriters
152 {
153 
154 /*---------------------------------------------------------------------------*\
155  Class boundaryDataWriter Declaration
156 \*---------------------------------------------------------------------------*/
157 
158 class boundaryDataWriter
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 
188 public:
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 // ************************************************************************* //
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
TypeNameNoDebug("boundaryData")
Declare type-name, virtual type (without debug switch)
virtual fileName write()
Write surface geometry to file.
const pointField & points
virtual ~boundaryDataWriter()=default
Destructor.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
Tensor of scalars, i.e. Tensor<scalar>.
Namespace for OpenFOAM.