PatchParticleHistogram.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) 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::PatchParticleHistogram
28 
29 Description
30  Computes a histogram for the distribution of particle diameters
31  and corresponding number of particles hitting on a given list of patches.
32 
33  Operands:
34  \table
35  Operand | Type | Location
36  input | - | -
37  output file | dat | $FOAM_CASE/postProcessing/<FO>/<time>/<file>
38  output field | - | -
39  \endtable
40 
41  The output file contains two columns, the first is the bin edges of
42  the particle diameter (i.e. \c d), and the second is the number of
43  particles whose diameter falling into the corresponding bin
44  (i.e. \c nParticles).
45 
46 Usage
47  Minimal example by using
48  \c constant/reactingCloud1Properties.cloudFunctions:
49  \verbatim
50  patchParticleHistogram1
51  {
52  // Mandatory entries (unmodifiable)
53  type patchParticleHistogram;
54  patches (<patch1> <patch2> ... <patchN>);
55  nBins 10;
56  min 0.1;
57  max 10.0;
58  maxStoredParcels 20;
59  }
60  \endverbatim
61 
62  where the entries mean:
63  \table
64  Property | Description | Type | Reqd | Dflt
65  type | Type name: patchParticleHistogram | word | yes | -
66  patches | Names of operand patches | wordList | yes | -
67  nBins | Number of histogram bins | label | yes | -
68  max | Maximum value of histogram data | scalar | yes | -
69  min | Minimum value of histogram data | scalar | yes | -
70  maxStoredParcels | Maximum number of parcels to process | label | yes | -
71  \endtable
72 
73 Note
74  - The underlying type of \c maxStoredParcels is set as a scalar for I/O.
75 
76 SourceFiles
77  PatchParticleHistogram.C
78 
79 \*---------------------------------------------------------------------------*/
80 
81 #ifndef PatchParticleHistogram_H
82 #define PatchParticleHistogram_H
83 
84 #include "CloudFunctionObject.H"
85 
86 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
87 
88 namespace Foam
89 {
90 
91 /*---------------------------------------------------------------------------*\
92  Class PatchParticleHistogram Declaration
93 \*---------------------------------------------------------------------------*/
94 
95 template<class CloudType>
96 class PatchParticleHistogram
97 :
98  public CloudFunctionObject<CloudType>
99 {
100  // Private Data
101 
102  //- Convenience typedef for parcel type
103  typedef typename CloudType::particleType parcelType;
104 
105  //- Number of data bins
106  const label nBins_;
107 
108  //- Minimum value of histogram data
109  const scalar min_;
110 
111  //- Maximum value of histogram data
112  const scalar max_;
113 
114  //- Bin width of histogram
115  const scalar delta_;
116 
117  //- Maximum number of parcels to store - set as a scalar for I/O
118  const scalar maxStoredParcels_;
119 
120  //- Bin edges of histogram
121  scalarField binEdges_;
122 
123  //- List of patch indices to post-process
124  labelList patchIDs_;
125 
126  //- Accumulated number of particles per patch
127  //- binned according to the histogram settings
128  List<List<scalar>> nParticlesCumulative_;
129 
130  //- List of time for each data record
131  List<DynamicList<scalar>> times_;
132 
133  // List of patch-hit particle diameters
134  List<DynamicList<scalar>> patchDiameters_;
135 
136  // List of number of patch-hit particles
137  List<DynamicList<scalar>> patchParticles_;
138 
139 
140  // Private Member Functions
141 
142  //- Return local patchi if patch is in patchIds_ list
143  label applyToPatch(const label globalPatchi) const;
144 
145 
146 protected:
147 
148  // Protected Member Functions
149 
150  //- Write post-processing info
151  void write();
152 
153 
154 public:
155 
156  //- Runtime type information
157  TypeName("patchParticleHistogram");
158 
159 
160  // Constructors
161 
162  //- No default construct
163  PatchParticleHistogram() = delete;
164 
165  //- Construct from dictionary
167  (
168  const dictionary& dict,
169  CloudType& owner,
170  const word& modelName
171  );
172 
173  //- Copy construct
175 
176  //- No copy assignment
177  void operator=(const PatchParticleHistogram<CloudType>&) = delete;
178 
179  //- Construct and return a clone
181  {
183  (
185  );
186  }
187 
188 
189  //- Destructor
190  virtual ~PatchParticleHistogram() = default;
191 
192 
193  // Member Functions
194 
195  // Evaluation
196 
197  //- Post-patch hook
198  virtual void postPatch
199  (
200  const parcelType& p,
201  const polyPatch& pp,
202  bool& keepParticle
203  );
204 };
205 
206 
207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208 
209 } // End namespace Foam
210 
211 
212 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
213 
214 #ifdef NoRepository
215  #include "PatchParticleHistogram.C"
216 #endif
217 
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 
220 #endif
221 
222 // ************************************************************************* //
Foam::PatchParticleHistogram::postPatch
virtual void postPatch(const parcelType &p, const polyPatch &pp, bool &keepParticle)
Post-patch hook.
Definition: PatchParticleHistogram.C:236
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:67
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::PatchParticleHistogram::PatchParticleHistogram
PatchParticleHistogram()=delete
No default construct.
Foam::PatchParticleHistogram::write
void write()
Write post-processing info.
Definition: PatchParticleHistogram.C:49
Foam::subModelBase::modelName
const word & modelName() const
Return const access to the name of the sub-model.
Definition: subModelBase.C:107
CloudFunctionObject.H
Foam::PatchParticleHistogram::~PatchParticleHistogram
virtual ~PatchParticleHistogram()=default
Destructor.
Foam::PatchParticleHistogram
Computes a histogram for the distribution of particle diameters and corresponding number of particles...
Definition: PatchParticleHistogram.H:153
Foam::PatchParticleHistogram::TypeName
TypeName("patchParticleHistogram")
Runtime type information.
Foam::Field< scalar >
Foam::subModelBase::dict
const dictionary & dict() const
Return const access to the cloud dictionary.
Definition: subModelBase.C:113
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:68
Foam::CloudSubModelBase::owner
const CloudType & owner() const
Return const access to the owner cloud.
Definition: CloudSubModelBase.C:106
Foam::DSMCCloud
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:71
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::Cloud::particleType
ParticleType particleType
Definition: Cloud.H:114
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::PatchParticleHistogram::operator=
void operator=(const PatchParticleHistogram< CloudType > &)=delete
No copy assignment.
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::PatchParticleHistogram::clone
virtual autoPtr< CloudFunctionObject< CloudType > > clone() const
Construct and return a clone.
Definition: PatchParticleHistogram.H:237
Foam::List< label >
Foam::CloudFunctionObject
Templated cloud function object base class.
Definition: CloudFunctionObject.H:62
PatchParticleHistogram.C