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