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-2021 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 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  fieldScale | output field scaling (dictionary) | no | empty
53  \endtable
54 
55  Typical way of working:
56  - use a sampledSurface of type 'patch' (to sample a patch):
57  \verbatim
58  surfaces
59  {
60  type surfaces;
61  fields ( p );
62  surfaceFormat boundaryData;
63  formatOptions
64  {
65  boundaryData
66  {
67  format binary;
68  fieldScale
69  {
70  "p.*" 0.01; // [Pa] -> [mbar]
71  }
72  }
73  }
74  surfaces
75  {
76  outlet
77  {
78  type patch;
79  patches (outlet);
80  interpolate false;
81  }
82  }
83  }
84  \endverbatim
85 
86  - write using this writer.
87  - move postProcessing/surfaces/outlet to constant/boundaryData/outlet
88  in your destination case.
89  - use a timeVaryingMappedFixedValue condition to read and interpolate
90  the profile:
91  type timeVaryingMappedFixedValue;
92  setAverage false; // do not use read average
93  offset 0; // do not apply offset to values
94 
95  Note:
96  - with 'interpolate false' the data is on the face centres of the
97  patch. Take care that a 2D geometry will only have a single row
98  of face centres so might not provide a valid triangulation
99  (this is what timeVaryingMappedFixedValue uses to do interpolation)
100  (Alternatively use timeVaryingMappedFixedValue with mapMethod 'nearest')
101 
102  \heading Output file locations
103 
104  The \c rootdir normally corresponds to something like
105  \c postProcessing/<name>
106 
107  where the geometry is written as:
108  \verbatim
109  rootdir
110  `-- surfaceName
111  `-- "points"
112  \endverbatim
113 
114  and field data:
115  \verbatim
116  rootdir
117  `-- surfaceName
118  |-- "points"
119  `-- timeName
120  `-- field
121  \endverbatim
122 
123 SourceFiles
124  boundaryDataSurfaceWriter.C
125 
126 \*---------------------------------------------------------------------------*/
127 
128 #ifndef boundaryDataSurfaceWriter_H
129 #define boundaryDataSurfaceWriter_H
130 
131 #include "surfaceWriter.H"
132 
133 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
134 
135 namespace Foam
136 {
137 
138 // Forward Declarations
139 class regIOobject;
140 
141 namespace surfaceWriters
142 {
143 
144 /*---------------------------------------------------------------------------*\
145  Class boundaryDataWriter Declaration
146 \*---------------------------------------------------------------------------*/
147 
148 class boundaryDataWriter
149 :
150  public surfaceWriter
151 {
152  // Private Data
153 
154  //- Output files with FoamFile header
155  bool header_;
156 
157  //- Output stream option
158  IOstreamOption streamOpt_;
159 
160  //- Output field scaling
161  const dictionary fieldScale_;
162 
163 
164  // Private Member Functions
165 
166  //- Write serial surface geometry to "points" file.
167  void serialWriteGeometry(const regIOobject&, const meshedSurf& surf);
168 
169  //- Templated write field operation
170  template<class Type>
171  fileName writeTemplate
172  (
173  const word& fieldName,
174  const Field<Type>& localValues
175  );
176 
177 
178 public:
179 
180  //- Declare type-name, virtual type (without debug switch)
181  TypeNameNoDebug("boundaryData");
182 
183 
184  // Constructors
185 
186  //- Default construct
188 
189  //- Construct with some output options
190  explicit boundaryDataWriter(const dictionary& options);
191 
192  //- Construct from components
194  (
195  const meshedSurf& surf,
196  const fileName& outputPath,
197  bool parallel = Pstream::parRun(),
198  const dictionary& options = dictionary()
199  );
200 
201  //- Construct from components
203  (
204  const pointField& points,
205  const faceList& faces,
206  const fileName& outputPath,
207  bool parallel = Pstream::parRun(),
208  const dictionary& options = dictionary()
209  );
210 
211 
212  //- Destructor
213  virtual ~boundaryDataWriter() = default;
214 
215 
216  // Member Functions
217 
218  //- Write surface geometry to file.
219  virtual fileName write(); // override
220 
227 };
228 
229 
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
231 
232 } // End namespace surfaceWriters
233 } // End namespace Foam
234 
235 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
236 
237 #endif
238 
239 // ************************************************************************* //
Foam::Tensor< scalar >
Foam::SymmTensor< scalar >
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::boundaryDataWriter
A surfaceWriter for outputting to a form usable for the timeVaryingMapped boundary condition....
Definition: boundaryDataSurfaceWriter.H:172
Foam::meshedSurf
Abstract definition of a meshed surface defined by faces and points.
Definition: meshedSurf.H:49
Foam::surfaceWriters::boundaryDataWriter::declareSurfaceWriterWriteMethod
declareSurfaceWriterWriteMethod(label)
surfaceWriter.H
Foam::surfaceWriters::boundaryDataWriter::boundaryDataWriter
boundaryDataWriter()
Default construct.
Definition: boundaryDataSurfaceWriter.C:55
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::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::boundaryDataWriter::write
virtual fileName write()
Write surface geometry to file.
Definition: boundaryDataSurfaceWriter.C:162
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:73
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::boundaryDataWriter::TypeNameNoDebug
TypeNameNoDebug("boundaryData")
Declare type-name, virtual type (without debug switch)
Foam::surfaceWriters::boundaryDataWriter::~boundaryDataWriter
virtual ~boundaryDataWriter()=default
Destructor.