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 | $FOAM_CASE/postProcessing/<FO>/<time>/<file>
40 output field | - | -
41 \endtable
42
43Usage
44 Minimal example by using \c system/controlDict.functions:
45 \verbatim
46 particleDistribution1
47 {
48 // Mandatory entries (unmodifiable)
49 type particleDistribution;
50 libs (fieldFunctionObjects);
51
52 // Mandatory entries (runtime modifiable)
53 cloud <cloudName>;
54 nameVsBinWidth
55 (
56 (d 0.1)
57 (U 10)
58 );
59 setFormat raw;
60
61 // Optional entries (runtime modifiable)
62 tagField none;
63
64 // Optional (inherited) entries
65 ...
66 }
67 \endverbatim
68
69 where the entries mean:
70 \table
71 Property | Description | Type | Req'd | Dflt
72 type | Type name: particleDistribution | word | yes | -
73 libs | Library name: fieldFunctionObjects | word | yes | -
74 cloud | Name of cloud to process | word | yes | -
75 nameVsBinWidth | List of cloud field-bin width | wordHashTable | yes | -
76 setFormat | Output format | word | yes | -
77 tagField | Name of cloud field to use group particles | word | no | none
78 \endtable
79
80 The inherited entries are elaborated in:
81 - \link functionObject.H \endlink
82 - \link writeFile.H \endlink
83
84 Usage by the \c postProcess utility is not available.
85
86See also
87 - Foam::functionObject
88 - Foam::functionObjects::fvMeshFunctionObject
89 - Foam::functionObjects::writeFile
90 - ExtendedCodeGuide::functionObjects::field::particleDistribution
91
92SourceFiles
93 particleDistribution.C
94 particleDistributionTemplates.C
95
96\*---------------------------------------------------------------------------*/
97
98#ifndef functionObjects_particleDistribution_H
99#define functionObjects_particleDistribution_H
100
101#include "fvMeshFunctionObject.H"
102#include "writeFile.H"
103#include "scalarField.H"
104#include "Random.H"
105#include "Tuple2.H"
106#include "coordSetWriter.H"
107
108// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
109
110namespace Foam
111{
112namespace functionObjects
113{
114
115/*---------------------------------------------------------------------------*\
116 Class particleDistribution Declaration
117\*---------------------------------------------------------------------------*/
118
119class particleDistribution
120:
121 public functionObjects::fvMeshFunctionObject,
122 public writeFile
123{
124protected:
125
126 // Protected Data
127
128 //- Cloud name
129 word cloudName_;
130
131 //- Tag field name - used to filter the particles into groups
132 word tagFieldName_;
133
134 //- Random number generator - used by distribution models
135 Random rndGen_;
136
137 //- List of field name vs. bin width
138 List<Tuple2<word, scalar>> nameVsBinWidth_;
139
140 //- Writer
141 mutable autoPtr<coordSetWriter> writerPtr_;
142
143
144 // Protected Member Functions
145
146 //- Generate the distribution
148 (
149 const word& fieldName,
150 const scalarField& field,
151 const scalar binWidth,
152 const label tag = -1
153 );
154
155 // Helper function to retrieve the particle data
156 template<class Type>
157 bool processField
158 (
159 const objectRegistry& obr,
160 const label fieldi,
161 const List<DynamicList<label>>& addr
162 );
163
164
165public:
166
167 //- Runtime type information
168 TypeName("particleDistribution");
169
170
171 // Constructors
172
173 //- Construct from Time and dictionary
175 (
176 const word& name,
177 const Time& runTime,
178 const dictionary& dict
179 );
180
181 //- No copy construct
183
184 //- No copy assignment
185 void operator=(const particleDistribution&) = delete;
187
188 //- Destructor
189 virtual ~particleDistribution() = default;
190
191
192 // Member Functions
193
194 //- Read the particleDistribution data
195 virtual bool read(const dictionary&);
196
197 //- Execute, currently does nothing
198 virtual bool execute();
199
200 //- Write the particleDistribution
201 virtual bool write();
202};
203
204
205// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206
207} // End namespace functionObjects
208} // End namespace Foam
209
210// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211
212#ifdef NoRepository
214#endif
215
216// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217
218#endif
219
220// ************************************************************************* //
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:72
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
Random number generator.
Definition: Random.H:60
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
const word & name() const noexcept
Return the name of this functionObject.
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.
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, currently does nothing.
virtual bool write()
Write the particleDistribution.
word tagFieldName_
Tag field name - used to filter the particles into groups.
particleDistribution(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
virtual bool read(const dictionary &)
Read the particleDistribution data.
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:120
Registry of regIOobjects.
A class for handling words, derived from Foam::string.
Definition: word.H:68
rDeltaTY field()
engineTime & runTime
Namespace for OpenFOAM.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73