ensightWrite.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) 2016-2020 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::functionObjects::ensightWrite
28
29Group
30 grpUtilitiesFunctionObjects
31
32Description
33 Writes fields in ensight format.
34
35 Example of function object specification:
36 \verbatim
37 ensight
38 {
39 type ensightWrite;
40 libs (utilityFunctionObjects);
41 writeControl writeTime;
42 writeInterval 1;
43 format binary;
44
45 overwrite true;
46 width 12;
47
48 fields (U p);
49
50 selection
51 {
52 box
53 {
54 action use;
55 source box;
56 box (-0.1 -0.01 -0.1) (0.1 0.30 0.1);
57 }
58 dome
59 {
60 action add;
61 shape sphere;
62 origin (-0.1 -0.01 -0.1);
63 radius 0.25;
64 }
65 centre
66 {
67 action subtract;
68 source sphere;
69 origin (-0.1 -0.01 -0.1);
70 radius 0.1;
71 }
72 blob
73 {
74 action add;
75 source surface;
76 surface triSurfaceMesh;
77 name blob.stl;
78 }
79 }
80 }
81 \endverbatim
82
83 \heading Basic Usage
84 \table
85 Property | Description | Required | Default
86 type | Type name: ensightWrite | yes |
87 fields | Fields to output | yes |
88 boundary | Convert boundary fields | no | true
89 internal | Convert internal fields | no | true
90 nodeValues | Write values at nodes | no | false
91 \endtable
92
93 \heading Ensight Output Options
94 \table
95 Property | Description | Required | Default
96 format | ascii or binary format | no | same as simulation
97 width | Mask width for \c data/XXXX | no | 8
98 directory | The output directory name | no | postProcessing/NAME
99 overwrite | Remove existing directory | no | false
100 consecutive | Consecutive output numbering | no | false
101 \endtable
102
103 \heading Output Selection
104 \table
105 Property | Description | Required | Default
106 region | Name for a single region | no | region0
107 faceZones | Select faceZones to write | no |
108 patches | Limit to listed patches (wordRe list) | no |
109 selection | Cell selection (topoSet actions) | no | empty dict
110 \endtable
111
112Note
113 The region of interest is defined by the selection dictionary
114 as a set of actions (use,add,subtract,subset,invert).
115 Omitting the selection dictionary is the same as specifying the
116 conversion of all cells (in the selected regions).
117 Omitting the patches entry is the same as specifying the conversion of all
118 patches.
119
120 Consecutive output numbering can be used in conjunction with \c overwrite.
121
122See also
123 Foam::functionObjects::vtkWrite
124 Foam::functionObjects::fvMeshFunctionObject
125 Foam::functionObjects::timeControl
126 Foam::cellBitSet::select
127
128SourceFiles
129 ensightWrite.C
130 ensightWriteTemplates.C
131
132\*---------------------------------------------------------------------------*/
133
134#ifndef functionObjects_ensightWrite_H
135#define functionObjects_ensightWrite_H
136
137#include "fvMeshFunctionObject.H"
138#include "ensightCase.H"
139#include "ensightMesh.H"
140
141#include "interpolation.H"
142#include "volFields.H"
143#include "surfaceFields.H"
144#include "fvMeshSubsetProxy.H"
145#include "searchableSurfaces.H"
146
147// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
148
149namespace Foam
150{
151
152// Forward Declarations
153class dictionary;
154
155namespace functionObjects
156{
157
158/*---------------------------------------------------------------------------*\
159 Class ensightWrite Declaration
160\*---------------------------------------------------------------------------*/
161
162class ensightWrite
163:
164 public fvMeshFunctionObject
165{
166 // Private data
167
168 //- Ensight writer options
169 ensightMesh::options writeOpts_;
170
171 //- Ensight case options
172 ensightCase::options caseOpts_;
173
174 //- The output directory
175 fileName outputDir_;
176
177 //- Consecutive output numbering
178 bool consecutive_;
179
180 //- Track changes in mesh geometry
181 enum polyMesh::readUpdateState meshState_;
182
183 //- Requested names of fields to process
184 wordRes selectFields_;
185
186 //- Dictionary of volume selections
187 dictionary selection_;
188
189 //- Mesh subset handler
190 fvMeshSubset meshSubset_;
191
192 //- Ensight case handler
193 autoPtr<ensightCase> ensCase_;
194
195 //- Ensight mesh handler
196 autoPtr<ensightMesh> ensMesh_;
197
198
199 // Private Member Functions
200
201 //- Ensight case handler
202 ensightCase& ensCase()
203 {
204 return *ensCase_;
205 }
206
207 //- Ensight mesh handler
208 ensightMesh& ensMesh()
209 {
210 return *ensMesh_;
211 }
212
213
214 //- Update mesh subset according to zones, geometry, bounds
215 bool updateSubset(fvMeshSubset& subsetter) const;
216
217 //- Read information for selections
218 bool readSelection(const dictionary& dict);
219
220 //- Update meshes, subMeshes etc.
221 bool update();
222
223
224 // Write
225
226 //- Write all volume fields
227 label writeAllVolFields
228 (
229 const fvMeshSubset& proxy,
230 const wordHashSet& acceptField
231 );
232
233 //- Write selected volume fields.
234 template<class Type>
235 label writeVolFields
236 (
237 const fvMeshSubset& proxy,
238 const wordHashSet& acceptField
239 );
240
241
242 //- No copy construct
243 ensightWrite(const ensightWrite&) = delete;
244
245 //- No copy assignment
246 void operator=(const ensightWrite&) = delete;
247
248
249public:
250
251 //- Runtime type information
252 TypeName("ensightWrite");
253
254
255 // Constructors
256
257 //- Construct from runTime and dictionary.
259 (
260 const word& name,
261 const Time& runTime,
262 const dictionary& dict
263 );
264
265
266 //- Destructor
267 virtual ~ensightWrite() = default;
268
269
270 // Member Functions
271
272 //- Read the ensightWrite specification
273 virtual bool read(const dictionary& dict);
274
275 //- Do nothing
276 virtual bool execute();
277
278 //- Write fields, flush case file
279 virtual bool write();
280
281 //- Do nothing at the final time-loop
282 virtual bool end();
283
284 //- Update for changes of mesh
285 virtual void updateMesh(const mapPolyMesh& mpm);
286
287 //- Update for mesh point-motion
288 virtual void movePoints(const polyMesh& mpm);
289};
290
291
292// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
293
294} // End namespace functionObjects
295} // End namespace Foam
296
297// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
298
299#ifdef NoRepository
300 #include "ensightWriteTemplates.C"
301#endif
302
303// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
304
305#endif
306
307// ************************************************************************* //
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Configuration options for the ensightCase.
Definition: ensightCase.H:381
Supports writing of ensight cases as well as providing common factory methods to open new files.
Definition: ensightCase.H:69
Configuration options for the ensightMesh.
Definition: ensightMesh.H:240
Encapsulation of volume meshes for writing in ensight format. It manages cellZones,...
Definition: ensightMesh.H:83
A class for handling file names.
Definition: fileName.H:76
const word & name() const noexcept
Return the name of this functionObject.
Writes fields in ensight format.
Definition: ensightWrite.H:249
virtual void movePoints(const polyMesh &mpm)
Update for mesh point-motion.
TypeName("ensightWrite")
Runtime type information.
virtual bool read(const dictionary &dict)
Read the ensightWrite specification.
Definition: ensightWrite.C:110
virtual ~ensightWrite()=default
Destructor.
virtual void updateMesh(const mapPolyMesh &mpm)
Update for changes of mesh.
virtual bool execute()
Do nothing.
Definition: ensightWrite.C:184
virtual bool write()
Write fields, flush case file.
Definition: ensightWrite.C:190
virtual bool end()
Do nothing at the final time-loop.
Definition: ensightWrite.C:238
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Holds a reference to the original mesh (the baseMesh) and optionally to a subset of that mesh (the su...
Definition: fvMeshSubset.H:80
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:162
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
readUpdateState
Enumeration defining the state of the mesh after a read update.
Definition: polyMesh.H:91
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:54
A class for handling words, derived from Foam::string.
Definition: word.H:68
engineTime & runTime
Namespace for OpenFOAM.
HashSet< word, Hash< word > > wordHashSet
A HashSet of words, uses string hasher.
Definition: HashSet.H:82
dictionary dict
Foam::surfaceFields.
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73