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