Loading...
Searching...
No Matches
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-2024 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::vtkCloud
28
29Group
30 grpLagrangianFunctionObjects
31
32Description
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 |
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
115Note
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
124See also
125 Foam::Detail::parcelSelection
126 Foam::functionObjects::ensightWrite
127 Foam::functionObjects::vtkWrite
128 Foam::functionObjects::fvMeshFunctionObject
129 Foam::functionObjects::timeControl
130
131SourceFiles
132 vtkCloud.cxx
133 vtkCloudImpl.cxx
134
135\*---------------------------------------------------------------------------*/
136
137#ifndef Foam_functionObjects_vtkCloud_H
138#define Foam_functionObjects_vtkCloud_H
139
140#include "fvMeshFunctionObject.H"
142#include "foamVtkOutputOptions.H"
143#include "foamVtkSeriesWriter.H"
144#include "wordRes.H"
145#include "HashTable.H"
146
147// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
148
149namespace Foam
150{
151namespace functionObjects
152{
153
154/*---------------------------------------------------------------------------*\
155 Class vtkCloud Declaration
156\*---------------------------------------------------------------------------*/
157
158class vtkCloud
159:
161 public Foam::Detail::parcelSelection
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& obr,
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
224public:
225
226 //- Runtime type information
227 TypeName("vtkCloud");
228
229
230 // Constructors
231
232 //- Construct from name, 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 function-object dictionary
248 virtual bool read(const dictionary& dict);
249
250 //- Execute the function-object operations (no-op)
251 virtual bool execute();
252
253 //- Write the function-object results
254 virtual bool write();
255};
256
257
258// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
259
260} // End namespace functionObjects
261} // End namespace Foam
262
263// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
264
265#endif
266
267// ************************************************************************* //
const word cloudName(propsDict.get< word >("cloud"))
Selection of parcels based on their objectRegistry entries. Normally accessed via a dictionary entry.
A HashTable similar to std::unordered_map.
Definition HashTable.H:124
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition Time.H:75
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
A class for handling file names.
Definition fileName.H:75
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
fvMeshFunctionObject(const fvMeshFunctionObject &)=delete
No copy construct.
virtual const objectRegistry & obr() const
The region or sub-region registry being used.
This functionObject writes cloud(s) in VTK PolyData format (.vtp extension) with the time information...
Definition vtkCloud.H:227
virtual bool read(const dictionary &dict)
Read the function-object dictionary.
virtual bool execute()
Execute the function-object operations (no-op).
virtual bool write()
Write the function-object results.
virtual ~vtkCloud()=default
Destructor.
vtkCloud(const word &name, const Time &runTime, const dictionary &dict)
Construct from name, Time and dictionary.
TypeName("vtkCloud")
Runtime type information.
Registry of regIOobjects.
Encapsulated combinations of output format options. This is primarily useful when defining the output...
A List of wordRe with additional matching capabilities.
Definition wordRes.H:56
A class for handling words, derived from Foam::string.
Definition word.H:66
engineTime & runTime
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
Namespace for OpenFOAM.
List< word > wordList
List of word.
Definition fileName.H:60
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
word format(conversionProperties.get< word >("format"))
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68