Loading...
Searching...
No Matches
particleDistribution.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-------------------------------------------------------------------------------
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::particleDistribution
28
29Group
30 grpFieldFunctionObjects
31
32Description
33 Generates a particle distribution for lagrangian data at a given time.
34
35 Operands:
36 \table
37 Operand | Type | Location
38 input | - | -
39 output file | dat | postProcessing/<FO>/<time>/file
40 output field | - | -
41 \endtable
42
43Usage
44 Minimal example by using \c system/controlDict.functions:
45 \verbatim
46 particleDistributionFO
47 {
48 // Mandatory entries
49 type particleDistribution;
50 libs (fieldFunctionObjects);
51 cloud <word>;
52 nameVsBinWidth
53 (
54 (d 0.1)
55 (U 10)
56 );
57 setFormat <word>; // ensight, vtk, raw
58
59 // Optional entries
60 tagField <word>;
61
62 // Inherited entries
63 ...
64 }
65 \endverbatim
66
67 where the entries mean:
68 \table
69 Property | Description | Type | Reqd | Deflt
70 type | Type name: particleDistribution | word | yes | -
71 libs | Library name: fieldFunctionObjects | word | yes | -
72 cloud | Name of cloud to process | word | yes | -
73 nameVsBinWidth | List of cloud field-bin width | wordHashTable | yes | -
74 setFormat | Output format | word | yes | -
75 tagField | Name of cloud field to use group particles | word | no | none
76 \endtable
77
78 The inherited entries are elaborated in:
79 - \link functionObject.H \endlink
80 - \link writeFile.H \endlink
81
82SourceFiles
83 particleDistribution.C
84 particleDistributionTemplates.C
85
86\*---------------------------------------------------------------------------*/
87
88#ifndef Foam_functionObjects_particleDistribution_H
89#define Foam_functionObjects_particleDistribution_H
90
92#include "writeFile.H"
93#include "scalarField.H"
94#include "Random.H"
95#include "Tuple2.H"
96#include "coordSetWriter.H"
97
98// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
99
100namespace Foam
101{
102namespace functionObjects
103{
104
105/*---------------------------------------------------------------------------*\
106 Class particleDistribution Declaration
107\*---------------------------------------------------------------------------*/
108
110:
111 public functionObjects::fvMeshFunctionObject,
112 public writeFile
113{
114protected:
115
116 // Protected Data
117
118 //- Cloud name
119 word cloudName_;
120
121 //- Tag field name - used to filter the particles into groups
122 word tagFieldName_;
123
124 //- Random number generator - used by distribution models
125 Random rndGen_;
126
127 //- List of field name vs. bin width
128 List<Tuple2<word, scalar>> nameVsBinWidth_;
129
130 //- Writer
131 mutable autoPtr<coordSetWriter> writerPtr_;
132
133
134 // Protected Member Functions
135
136 //- Generate the distribution
138 (
139 const word& fieldName,
140 const scalarField& field,
141 const scalar binWidth,
142 const label tag = -1
143 );
144
145 // Helper function to retrieve the particle data
146 template<class Type>
147 bool processField
148 (
149 const objectRegistry& obr,
150 const label fieldi,
151 const List<DynamicList<label>>& addr
152 );
153
154
155public:
156
157 //- Runtime type information
158 TypeName("particleDistribution");
159
160
161 // Constructors
163 //- Construct from name, Time and dictionary
165 (
166 const word& name,
167 const Time& runTime,
168 const dictionary& dict
169 );
170
171 //- No copy construct
173
174 //- No copy assignment
175 void operator=(const particleDistribution&) = delete;
176
177
178 //- Destructor
179 virtual ~particleDistribution() = default;
180
181
182 // Member Functions
183
184 //- Read the function-object dictionary
185 virtual bool read(const dictionary& dict);
186
187 //- Execute the function-object operations
188 virtual bool execute();
190 //- Write the function-object results
191 virtual bool write();
192};
193
195// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196
197} // End namespace functionObjects
198} // End namespace Foam
199
200// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201
202#ifdef NoRepository
204#endif
205
206// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207
208#endif
209
210// ************************************************************************* //
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition DynamicList.H:68
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
Random number generator.
Definition Random.H:56
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
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Generates a particle distribution for lagrangian data at a given time.
List< Tuple2< word, scalar > > nameVsBinWidth_
List of field name vs. bin width.
particleDistribution(const particleDistribution &)=delete
No copy construct.
void operator=(const particleDistribution &)=delete
No copy assignment.
virtual bool read(const dictionary &dict)
Read the function-object dictionary.
bool processField(const objectRegistry &obr, const label fieldi, const List< DynamicList< label > > &addr)
void generateDistribution(const word &fieldName, const scalarField &field, const scalar binWidth, const label tag=-1)
Generate the distribution.
autoPtr< coordSetWriter > writerPtr_
Writer.
virtual ~particleDistribution()=default
Destructor.
Random rndGen_
Random number generator - used by distribution models.
TypeName("particleDistribution")
Runtime type information.
virtual bool execute()
Execute the function-object operations.
virtual bool write()
Write the function-object results.
word tagFieldName_
Tag field name - used to filter the particles into groups.
particleDistribution(const word &name, const Time &runTime, const dictionary &dict)
Construct from name, Time and dictionary.
virtual const objectRegistry & obr() const
The region or sub-region registry being used.
Base class for writing single files from the function objects.
Definition writeFile.H:113
writeFile(const objectRegistry &obr, const fileName &prefix, const word &name="undefined", const bool writeToFile=true, const string &ext=".dat")
Construct from objectRegistry, prefix, fileName.
Definition writeFile.C:200
Registry of regIOobjects.
A class for handling words, derived from Foam::string.
Definition word.H:66
rDeltaTY field()
engineTime & runTime
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
Namespace for OpenFOAM.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68