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