vtkCloud.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) 2018-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::vtkCloud
28 
29 Group
30  grpLagrangianFunctionObjects
31 
32 Description
33  This functionObject writes cloud(s) in VTK PolyData format
34  (.vtp extension) with the time information saved in a '.series' file.
35 
36  Example of function object specification:
37  \verbatim
38  cloudWrite1
39  {
40  type vtkCloud;
41  libs (lagrangianFunctionObjects);
42  writeControl writeTime;
43  writeInterval 1;
44  format ascii;
45 
46  cloud myCloud;
47  fields (T U rho);
48  width 4; // file-padding
49 
50  selection
51  {
52  stride
53  {
54  // every 10th parcelId
55  action add;
56  source stride;
57  stride 10;
58  }
59  Umin
60  {
61  // Remove slow parcels
62  action subtract;
63  source field;
64  field U;
65  accept (less 1e-3);
66  }
67  diam
68  {
69  // Only particular diameter ranges
70  action subset;
71  source field;
72  field d;
73  accept (greater 1e-3) and (less 1e-3);
74  }
75  }
76  }
77  \endverbatim
78 
79  \heading Basic Usage
80  \table
81  Property | Description | Required | Default
82  type | Type name: vtkCloud | yes |
83  clouds | List of clouds (name or regex) | no |
84  cloud | Cloud name | no | defaultCloud
85  fields | List of fields (name or regex) | no |
86  selection | Parcel selection control | no | empty-dict
87  \endtable
88 
89  \heading Output Options
90  \table
91  Property | Description | Required | Default
92  format | Format as ascii or binary | no | binary
93  precision | Write precision in ascii | no | same as IOstream
94  directory | The output directory name | no | postProcessing/NAME
95  width | Padding width for file name | no | 8
96  cellData | Emit cellData instead of pointData | no | false
97  prune | Suppress writing of empty clouds | no | false
98  writeControl | Output control | recommended | timeStep
99  \endtable
100 
101  The output filename and fields are added to the functionObjectProperties
102  information. For the previous example specification:
103 
104  \verbatim
105  cloudWrite1
106  {
107  myCloud
108  {
109  file "<case>/VTK/myCloud_0001.vtp";
110  fields (T U rho);
111  }
112  }
113  \endverbatim
114 
115 Note
116  The selection dictionary can be used for finer control of the parcel
117  output. It contains a set of (add,subtract,subset,clear,invert)
118  selection actions and sources.
119  Omitting the selection dictionary is the same as specifying the
120  conversion of all parcels (in the selected clouds).
121  More syntax details are to be found in the corresponding
122  Foam::Detail::parcelSelection class.
123 
124 See also
125  Foam::Detail::parcelSelection
126  Foam::functionObjects::ensightWrite
127  Foam::functionObjects::vtkWrite
128  Foam::functionObjects::fvMeshFunctionObject
129  Foam::functionObjects::timeControl
130 
131 SourceFiles
132  vtkCloud.C
133  vtkCloudTemplates.C
134 
135 \*---------------------------------------------------------------------------*/
136 
137 #ifndef functionObjects_vtkCloud_H
138 #define functionObjects_vtkCloud_H
139 
140 #include "fvMeshFunctionObject.H"
141 #include "parcelSelectionDetail.H"
142 #include "foamVtkOutputOptions.H"
143 #include "foamVtkSeriesWriter.H"
144 #include "wordRes.H"
145 #include "HashTable.H"
146 
147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
148 
149 namespace Foam
150 {
151 namespace functionObjects
152 {
153 
154 /*---------------------------------------------------------------------------*\
155  Class vtkCloud Declaration
156 \*---------------------------------------------------------------------------*/
157 
158 class vtkCloud
159 :
160  public fvMeshFunctionObject,
162 {
163  // Private data
164 
165  //- Writer options
166  vtk::outputOptions writeOpts_;
167 
168  //- The printf format for zero-padding names
169  string printf_;
170 
171  //- Write lagrangian as cell data (verts) instead of point data
172  bool useVerts_;
173 
174  //- Suppress writing of empty clouds
175  bool pruneEmpty_;
176 
177  //- Apply output filter (for the current cloud)
178  bool applyFilter_;
179 
180  //- Requested names of clouds to process
181  wordRes selectClouds_;
182 
183  //- Subset of cloud fields to process
184  wordRes selectFields_;
185 
186  //- Output directory
187  fileName directory_;
188 
189  //- Per cloud output for file series
190  HashTable<vtk::seriesWriter, fileName> series_;
191 
192 
193  // Private Member Functions
194 
195  //- Write a cloud to disk (creates parent directory),
196  //- and record on the cloud OutputProperties.
197  // \param file is the output file name, with extension.
198  bool writeCloud(const fileName& file, const word& cloudName);
199 
200  //- Write vertex (cells) - callable on master only
201  void writeVerts
202  (
203  autoPtr<vtk::formatter>& format,
204  const label nTotParcels
205  ) const;
206 
207  //- Write fields of IOField<Type>
208  template<class Type>
209  wordList writeFields
210  (
211  autoPtr<vtk::formatter>& format,
212  const objectRegistry& obrTmp,
213  const label nTotParcels
214  ) const;
215 
216 
217  //- No copy construct
218  vtkCloud(const vtkCloud&) = delete;
219 
220  //- No copy assignment
221  void operator=(const vtkCloud&) = delete;
222 
223 
224 public:
225 
226  //- Runtime type information
227  TypeName("vtkCloud");
228 
229 
230  // Constructors
231 
232  //- Construct from Time and dictionary
233  vtkCloud
234  (
235  const word& name,
236  const Time& runTime,
237  const dictionary& dict
238  );
239 
240 
241  //- Destructor
242  virtual ~vtkCloud() = default;
243 
244 
245  // Member Functions
246 
247  //- Read the vtkCloud specification
248  virtual bool read(const dictionary& dict);
249 
250  //- Execute, currently does nothing
251  virtual bool execute();
252 
253  //- Write fields
254  virtual bool write();
255 };
256 
257 
258 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
259 
260 } // End namespace functionObjects
261 } // End namespace Foam
262 
263 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
264 
265 #ifdef NoRepository
266  #include "vtkCloudTemplates.C"
267 #endif
268 
269 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
270 
271 #endif
272 
273 // ************************************************************************* //
Foam::vtk::outputOptions
Encapsulated combinations of output format options. This is primarily useful when defining the output...
Definition: foamVtkOutputOptions.H:59
runTime
engineTime & runTime
Definition: createEngineTime.H:13
wordRes.H
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
cloudName
const word cloudName(propsDict.get< word >("cloud"))
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
HashTable.H
fvMeshFunctionObject.H
Foam::functionObjects::vtkCloud::TypeName
TypeName("vtkCloud")
Runtime type information.
Foam::Detail::parcelSelection
Selection of parcels based on their objectRegistry entries. Normally accessed via a dictionary entry.
Definition: parcelSelectionDetail.H:180
Foam::functionObjects::vtkCloud::read
virtual bool read(const dictionary &dict)
Read the vtkCloud specification.
Definition: vtkCloud.C:370
Foam::functionObjects::vtkCloud
This functionObject writes cloud(s) in VTK PolyData format (.vtp extension) with the time information...
Definition: vtkCloud.H:227
Foam::functionObjects::vtkCloud::execute
virtual bool execute()
Execute, currently does nothing.
Definition: vtkCloud.C:458
parcelSelectionDetail.H
Foam::functionObjects::fvMeshFunctionObject
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Definition: fvMeshFunctionObject.H:64
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:62
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
format
word format(conversionProperties.get< word >("format"))
vtkCloudTemplates.C
Foam::functionObjects::vtkCloud::write
virtual bool write()
Write fields.
Definition: vtkCloud.C:464
foamVtkSeriesWriter.H
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::vtkCloud::~vtkCloud
virtual ~vtkCloud()=default
Destructor.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
foamVtkOutputOptions.H
Foam::HashTable
A HashTable similar to std::unordered_map.
Definition: HashTable.H:105
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::List< word >
Foam::wordRes
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:51