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 -------------------------------------------------------------------------------
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 
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  nodeValues | Write values at nodes | no | false
102  \endtable
103 
104  \heading Output Selection
105  \table
106  Property | Description | Required | Default
107  region | Name for a single region | no | region0
108  faceZones | Select faceZones to write | no |
109  patches | Limit to listed patches (wordRe list) | no |
110  selection | Cell selection (topoSet actions) | no | empty dict
111  \endtable
112 
113 Note
114  The region of interest is defined by the selection dictionary
115  as a set of actions (use,add,subtract,subset,invert).
116  Omitting the selection dictionary is the same as specifying the
117  conversion of all cells (in the selected regions).
118  Omitting the patches entry is the same as specifying the conversion of all
119  patches.
120 
121  Consecutive output numbering can be used in conjunction with \c overwrite.
122 
123 See also
124  Foam::functionObjects::vtkWrite
125  Foam::functionObjects::fvMeshFunctionObject
126  Foam::functionObjects::timeControl
127 
128 SourceFiles
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 
149 namespace Foam
150 {
151 
152 // Forward declarations
153 class dictionary;
154 
155 namespace functionObjects
156 {
157 
158 /*---------------------------------------------------------------------------*\
159  Class ensightWrite Declaration
160 \*---------------------------------------------------------------------------*/
161 
162 class 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 
249 public:
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 // ************************************************************************* //
volFields.H
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::ensightMesh
Encapsulation of volume meshes for writing in ensight format. It manages cellZones,...
Definition: ensightMesh.H:82
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
ensightCase.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::functionObjects::ensightWrite
Writes fields in ensight format.
Definition: ensightWrite.H:251
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
fvMeshFunctionObject.H
Foam::fvMeshSubset
Given the original mesh and the list of selected cells, it creates the mesh consisting only of the de...
Definition: fvMeshSubset.H:73
Foam::functionObjects::ensightWrite::end
virtual bool end()
Do nothing at the final time-loop.
Definition: ensightWrite.C:238
Foam::functionObjects::ensightWrite::write
virtual bool write()
Write fields, flush case file.
Definition: ensightWrite.C:190
Foam::functionObjects::ensightWrite::read
virtual bool read(const dictionary &dict)
Read the ensightWrite specification.
Definition: ensightWrite.C:110
surfaceFields.H
Foam::surfaceFields.
interpolation.H
Foam::HashSet< word, Hash< word > >
Foam::functionObjects::fvMeshFunctionObject
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Definition: fvMeshFunctionObject.H:64
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
searchableSurfaces.H
ensightMesh.H
ensightWriteTemplates.C
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::functionObjects::ensightWrite::updateMesh
virtual void updateMesh(const mapPolyMesh &mpm)
Update for changes of mesh.
Definition: ensightWriteUpdate.C:194
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
fvMeshSubsetProxy.H
Foam::functionObjects::ensightWrite::execute
virtual bool execute()
Do nothing.
Definition: ensightWrite.C:184
Foam::polyMesh::readUpdateState
readUpdateState
Enumeration defining the state of the mesh after a read update.
Definition: polyMesh.H:90
Foam::ensightCase
Supports writing of ensight cases as well as providing common factory methods to open new files.
Definition: ensightCase.H:67
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::functionObject::name
const word & name() const noexcept
Return the name of this functionObject.
Definition: functionObject.C:143
Foam::functionObjects::ensightWrite::~ensightWrite
virtual ~ensightWrite()=default
Destructor.
Foam::ensightMesh::options
Configuration options for the ensightMesh.
Definition: ensightMesh.H:228
Foam::wordRes
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:51
Foam::ensightCase::options
Configuration options for the ensightCase.
Definition: ensightCase.H:328
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:161
Foam::wordHashSet
HashSet< word, Hash< word > > wordHashSet
A HashSet of words, uses string hasher.
Definition: HashSet.H:77
Foam::functionObjects::ensightWrite::TypeName
TypeName("ensightWrite")
Runtime type information.
Foam::functionObjects::ensightWrite::movePoints
virtual void movePoints(const polyMesh &mpm)
Update for mesh point-motion.
Definition: ensightWriteUpdate.C:200