ParticlePostProcessing.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) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2019-2023 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::ParticlePostProcessing
29 
30 Description
31  Writes out various standard Lagrangian data elements of
32  particles hitting on a given list of patches or face zones.
33 
34  Operands:
35  \table
36  Operand | Type | Location
37  input | - | -
38  output file | dat | <case>/postProcessing/<FO>/<time>/<file>
39  output field | - | -
40  \endtable
41 
42  The output file contains columns depending on the \c fields entry.
43 
44 Usage
45  Minimal example by using
46  \c constant/reactingCloud1Properties.cloudFunctions:
47  \verbatim
48  ParticlePostProcessing1
49  {
50  // Mandatory entries
51  type particlePostProcessing;
52  maxStoredParcels <scalar>;
53 
54  // Optional entries
55  fields (<wordRes>);
56 
57  // Conditional entries
58 
59  // Option-1
60  patches (<wordRes>);
61 
62  // Option-2
63  faceZones (<wordRes>);
64 
65  // Inherited entries
66  ...
67  }
68  \endverbatim
69 
70  where the entries mean:
71  \table
72  Property | Description | Type | Reqd | Deflt
73  type | Type name: particlePostProcessing | word | yes | -
74  maxStoredParcels | Maximum number of parcels to process | label | yes | -
75  fields | Names of standard Lagrangian fields | wordRes | no | all
76  patches | Names of operand patches | wordRes | choice | -
77  faceZones | Names of operand face zones | wordRes | choice | -
78  \endtable
79 
80  The inherited entries are elaborated in:
81  - \link CloudFunctionObject.H \endlink
82  - \link writeFile.H \endlink
83 
84 Note
85  - The underlying type of \c maxStoredParcels is set as a scalar for I/O.
86  - Empty files indicate that no particles hit selected surfaces.
87 
88 SourceFiles
89  ParticlePostProcessing.C
90 
91 \*---------------------------------------------------------------------------*/
92 
93 #ifndef Foam_ParticlePostProcessing_H
94 #define Foam_ParticlePostProcessing_H
95 
96 #include "CloudFunctionObject.H"
97 #include "writeFile.H"
99 
100 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
101 
102 namespace Foam
103 {
104 
105 /*---------------------------------------------------------------------------*\
106  Class ParticlePostProcessing Declaration
107 \*---------------------------------------------------------------------------*/
108 
109 template<class CloudType>
110 class ParticlePostProcessing
111 :
112  public CloudFunctionObject<CloudType>,
113  public functionObjects::writeFile
114 {
115  // Private Data
116 
117  // Typedefs
118 
119  //- Convenience typedef for parcel type
120  typedef typename CloudType::particleType parcelType;
121 
122  //- Collector surfaces
123  cloudFunctionObjectTools::collector collector_;
124 
125  //- Maximum number of parcels to store - set as a scalar for I/O
126  scalar maxStoredParcels_;
127 
128  //- Field header
129  string header_;
130 
131  //- Field name filters
132  wordRes fields_;
133 
134  //- List of times for each data record
135  List<DynamicList<scalar>> times_;
136 
137  //- List of output data per surface
138  List<DynamicList<string>> data_;
139 
140 
141  // Private Member Functions
142 
143  //- Write output file header
144  void writeFileHeader(Ostream& os) const;
145 
146 
147 public:
148 
149  //- Runtime type information
150  TypeName("particlePostProcessing");
151 
152 
153  // Constructors
154 
155  //- Construct from dictionary
157  (
158  const dictionary& dict,
159  CloudType& owner,
160  const word& modelName
161  );
162 
163  //- Copy construct
165 
166  //- No copy assignment
167  void operator=(const ParticlePostProcessing<CloudType>&) = delete;
168 
169  //- Construct and return a clone
171  {
173  (
175  );
176  }
177 
178 
179  //- Destructor
180  virtual ~ParticlePostProcessing() = default;
181 
182 
183  // Member Functions
184 
185  // Access
186 
187  //- Return maximum number of parcels to store per surface
188  label maxStoredParcels() const noexcept { return maxStoredParcels_; }
189 
190 
191  // Evaluation
192 
193  //- Post-patch hook
194  virtual bool postPatch
195  (
196  const parcelType& p,
197  const polyPatch& pp,
198  const typename parcelType::trackingData& td
199  );
200 
201  //- Post-face hook
202  virtual bool postFace
203  (
204  const parcelType& p,
205  const typename parcelType::trackingData& td
206  );
207 
208 
209  // I-O
210 
211  //- Write post-processing info
212  virtual void write();
213 };
214 
215 
216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 
218 } // End namespace Foam
219 
220 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
221 
222 #ifdef NoRepository
223  #include "ParticlePostProcessing.C"
224 #endif
225 
226 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
227 
228 #endif
229 
230 // ************************************************************************* //
ParcelType particleType
Definition: Cloud.H:130
TypeName("particlePostProcessing")
Runtime type information.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
const word & modelName() const
Return const access to the name of the sub-model.
Definition: subModelBase.C:98
const dictionary & dict() const
Return const access to the cloud dictionary.
Definition: subModelBase.C:104
ParticlePostProcessing(const dictionary &dict, CloudType &owner, const word &modelName)
Construct from dictionary.
const CloudType & owner() const
Return const access to the owner cloud.
void operator=(const ParticlePostProcessing< CloudType > &)=delete
No copy assignment.
virtual bool postPatch(const parcelType &p, const polyPatch &pp, const typename parcelType::trackingData &td)
Post-patch hook.
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual autoPtr< CloudFunctionObject< CloudType > > clone() const
Construct and return a clone.
label maxStoredParcels() const noexcept
Return maximum number of parcels to store per surface.
Writes out various standard Lagrangian data elements of particles hitting on a given list of patches ...
const direction noexcept
Definition: Scalar.H:258
OBJstream os(runTime.globalPath()/outputName)
virtual void write()
Write post-processing info.
virtual bool postFace(const parcelType &p, const typename parcelType::trackingData &td)
Post-face hook.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
volScalarField & p
virtual ~ParticlePostProcessing()=default
Destructor.
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:67
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
Namespace for OpenFOAM.