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-2020 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 namespace surfaceWriters
138 {
139 
140 /*---------------------------------------------------------------------------*\
141  Class boundaryDataWriter Declaration
142 \*---------------------------------------------------------------------------*/
143 
144 class boundaryDataWriter
145 :
146  public surfaceWriter
147 {
148  // Private Data
149 
150  //- Output files with FoamFile header
151  bool header_;
152 
153  //- Output stream option
154  IOstreamOption streamOpt_;
155 
156  //- Output field scaling
157  const dictionary fieldScale_;
158 
159 
160  // Private Member Functions
161 
162  //- Templated write field operation
163  template<class Type>
164  fileName writeTemplate
165  (
166  const word& fieldName,
167  const Field<Type>& localValues
168  );
169 
170 
171 public:
172 
173  //- Declare type-name, virtual type (without debug switch)
174  TypeNameNoDebug("boundaryData");
175 
176 
177  // Constructors
178 
179  //- Default construct
181 
182  //- Construct with some output options
183  explicit boundaryDataWriter(const dictionary& options);
184 
185  //- Construct from components
187  (
188  const meshedSurf& surf,
189  const fileName& outputPath,
190  bool parallel = Pstream::parRun(),
191  const dictionary& options = dictionary()
192  );
193 
194  //- Construct from components
196  (
197  const pointField& points,
198  const faceList& faces,
199  const fileName& outputPath,
200  bool parallel = Pstream::parRun(),
201  const dictionary& options = dictionary()
202  );
203 
204 
205  //- Destructor
206  virtual ~boundaryDataWriter() = default;
207 
208 
209  // Member Functions
210 
211  //- Write surface geometry to file.
212  virtual fileName write(); // override
213 
220 };
221 
222 
223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
224 
225 } // End namespace surfaceWriters
226 } // End namespace Foam
227 
228 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
229 
230 #endif
231 
232 // ************************************************************************* //
Foam::Tensor< scalar >
Foam::SymmTensor< scalar >
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::surfaceWriter
Base class for surface writers.
Definition: surfaceWriter.H:111
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::surfaceWriters::boundaryDataWriter
A surfaceWriter for outputting to a form usable for the timeVaryingMapped boundary condition....
Definition: boundaryDataSurfaceWriter.H:168
Foam::UPstream::parRun
static bool & parRun()
Test if this a parallel run, or allow modify access.
Definition: UPstream.H:434
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:121
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:111
Foam::Vector< scalar >
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.