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-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::particleDistribution
28 
29 Group
30  grpFieldFunctionObjects
31 
32 Description
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 
43 Usage
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 
86 See also
87  - Foam::functionObject
88  - Foam::functionObjects::fvMeshFunctionObject
89  - Foam::functionObjects::writeFile
90  - ExtendedCodeGuide::functionObjects::field::particleDistribution
91 
92 SourceFiles
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 "writer.H"
107 
108 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
109 
110 namespace Foam
111 {
112 namespace functionObjects
113 {
114 
115 /*---------------------------------------------------------------------------*\
116  Class particleDistribution Declaration
117 \*---------------------------------------------------------------------------*/
118 
119 class particleDistribution
120 :
121  public fvMeshFunctionObject,
122  public writeFile
123 {
124 protected:
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  autoPtr<writer<scalar>> 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 
165 public:
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;
186 
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 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::Random
Random number generator.
Definition: Random.H:59
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
writeFile.H
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::functionObjects::particleDistribution::operator=
void operator=(const particleDistribution &)=delete
No copy assignment.
Foam::functionObjects::particleDistribution::read
virtual bool read(const dictionary &)
Read the particleDistribution data.
Definition: particleDistribution.C:74
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
fvMeshFunctionObject.H
Tuple2.H
scalarField.H
Foam::functionObjects::particleDistribution::cloudName_
word cloudName_
Cloud name.
Definition: particleDistribution.H:186
Foam::DynamicList< label >
Foam::functionObjects::particleDistribution::write
virtual bool write()
Write the particleDistribution.
Definition: particleDistribution.C:101
particleDistributionTemplates.C
Foam::functionObjects::particleDistribution::~particleDistribution
virtual ~particleDistribution()=default
Destructor.
Foam::functionObjects::fvMeshFunctionObject
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Definition: fvMeshFunctionObject.H:64
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
Foam::functionObjects::particleDistribution::writerPtr_
autoPtr< writer< scalar > > writerPtr_
Writer.
Definition: particleDistribution.H:198
Foam::Field< scalar >
Foam::functionObjects::particleDistribution
Generates a particle distribution for lagrangian data at a given time.
Definition: particleDistribution.H:176
Foam::functionObjects::particleDistribution::processField
bool processField(const objectRegistry &obr, const label fieldi, const List< DynamicList< label >> &addr)
Definition: particleDistributionTemplates.C:32
Foam::functionObjects::particleDistribution::rndGen_
Random rndGen_
Random number generator - used by distribution models.
Definition: particleDistribution.H:192
field
rDeltaTY field()
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:121
Foam::functionObjects::particleDistribution::particleDistribution
particleDistribution(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: particleDistribution.C:54
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Random.H
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
Return the name of this functionObject.
Definition: functionObject.C:131
Foam::functionObjects::particleDistribution::execute
virtual bool execute()
Execute, currently does nothing.
Definition: particleDistribution.C:95
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:102
Foam::functionObjects::regionFunctionObject::obr
virtual const objectRegistry & obr() const
The region or sub-region registry being used.
Definition: regionFunctionObject.C:47
Foam::functionObjects::particleDistribution::tagFieldName_
word tagFieldName_
Tag field name - used to filter the particles into groups.
Definition: particleDistribution.H:189
Foam::functionObjects::writeFile
Base class for writing single files from the function objects.
Definition: writeFile.H:106
Foam::functionObjects::particleDistribution::TypeName
TypeName("particleDistribution")
Runtime type information.
writer.H
Foam::functionObjects::particleDistribution::generateDistribution
void generateDistribution(const word &fieldName, const scalarField &field, const scalar binWidth, const label tag=-1)
Generate the distribution.
Definition: particleDistribution.C:180
Foam::functionObjects::particleDistribution::nameVsBinWidth_
List< Tuple2< word, scalar > > nameVsBinWidth_
List of field name vs. bin width.
Definition: particleDistribution.H:195