ParticleTracks.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-2020 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::ParticleTracks
29 
30 Group
31  grpLagrangianIntermediateFunctionObjects
32 
33 Description
34  Records particle state (all variables) on each call to postFace
35 
36 SourceFiles
37  ParticleTracks.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef ParticleTracks_H
42 #define ParticleTracks_H
43 
44 #include "CloudFunctionObject.H"
45 #include "labelPairHashes.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 /*---------------------------------------------------------------------------*\
53  Class ParticleTracks Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 template<class CloudType>
57 class ParticleTracks
58 :
59  public CloudFunctionObject<CloudType>
60 {
61  //- Convenience typedef for parcel type
62  typedef typename CloudType::parcelType parcelType;
63 
64 
65  // Private Data
66 
67  //- Number of face-hit intervals between storing parcel data
68  label trackInterval_;
69 
70  //- Maximum number of particles to store per track
71  label maxSamples_;
72 
73  //- Should data should be reset/cleared on writing?
74  bool resetOnWrite_;
75 
76  //- Table of number of times a particle has hit a face
77  labelPairLookup faceHitCounter_;
78 
79  //- Pointer to the cloud storage
80  autoPtr<Cloud<parcelType>> cloudPtr_;
81 
82 
83 protected:
84 
85  // Protected Member Functions
86 
87  //- Write post-processing info
88  void write();
89 
90 
91 public:
92 
93  //- Runtime type information
94  TypeName("particleTracks");
95 
96 
97  // Constructors
98 
99  //- Construct from dictionary
101  (
102  const dictionary& dict,
103  CloudType& owner,
104  const word& modelName
105  );
106 
107  //- Construct copy
109 
110  //- Construct and return a clone
112  {
114  (
115  new ParticleTracks<CloudType>(*this)
116  );
117  }
118 
119 
120  //- Destructor
121  virtual ~ParticleTracks() = default;
122 
123 
124  // Member Functions
125 
126  // Access
127 
128  //- Return const access to the track interval
129  inline label trackInterval() const;
130 
131  //- Return const access to the max samples
132  inline label maxSamples() const;
133 
134  //- Should data be reset on write?
135  inline bool resetOnWrite() const;
136 
137  //- Return the table of number of times a particle has hit a face
138  inline const labelPairLookup& faceHitCounter() const;
139 
140  //- Return const access to the cloud
141  inline const Cloud<parcelType>& cloud() const;
142 
143 
144  // Evaluation
145 
146  //- Pre-evolve hook
147  virtual void preEvolve
148  (
149  const typename parcelType::trackingData& td
150  );
151 
152  //- Post-face hook
153  virtual bool postFace
154  (
155  const parcelType& p,
156  const typename parcelType::trackingData& td
157  );
158 };
159 
160 
161 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162 
163 } // End namespace Foam
164 
165 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166 
167 #include "ParticleTracksI.H"
168 
169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 
171 #ifdef NoRepository
172  #include "ParticleTracks.C"
173 #endif
174 
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 
177 #endif
178 
179 // ************************************************************************* //
const Cloud< parcelType > & cloud() const
Return const access to the cloud.
label maxSamples() const
Return const access to the max samples.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
bool resetOnWrite() const
Should data be reset on write?
Records particle state (all variables) on each call to postFace.
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
const CloudType & owner() const
Return const access to the owner cloud.
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual ~ParticleTracks()=default
Destructor.
A HashTable to objects of type <T> with a labelPair key. The hashing is based on labelPair (FixedList...
void write()
Write post-processing info.
virtual void preEvolve(const typename parcelType::trackingData &td)
Pre-evolve hook.
ParcelType parcelType
Type of parcel the cloud was instantiated for.
Definition: DSMCCloud.H:290
ParticleTracks(const dictionary &dict, CloudType &owner, const word &modelName)
Construct from dictionary.
virtual autoPtr< CloudFunctionObject< CloudType > > clone() const
Construct and return a clone.
virtual bool postFace(const parcelType &p, const typename parcelType::trackingData &td)
Post-face hook.
label trackInterval() const
Return const access to the track interval.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
volScalarField & p
const labelPairLookup & faceHitCounter() const
Return the table of number of times a particle has hit a face.
TypeName("particleTracks")
Runtime type information.
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:67
Templated cloud function object base class.
Namespace for OpenFOAM.