MPPICParcel.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 | Copyright (C) 2013-2016 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::MPPICParcel
26 
27 Description
28  Wrapper around kinematic parcel types to add MPPIC modelling
29 
30 SourceFiles
31  MPPICParcelI.H
32  MPPICParcelTrackingDataI.H
33  MPPICParcel.C
34  MPPICParcelIO.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef MPPICParcel_H
39 #define MPPICParcel_H
40 
41 #include "particle.H"
42 #include "labelFieldIOField.H"
43 #include "vectorFieldIOField.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 // Forward declaration of clases
51 
52 template<class ParcelType>
53 class MPPICParcel;
54 
55 template<class Type>
56 class AveragingMethod;
57 
58 // Forward declaration of friend functions
59 
60 template<class ParcelType>
61 Ostream& operator<<
62 (
63  Ostream&,
65 );
66 
67 /*---------------------------------------------------------------------------*\
68  Class MPPICParcel Declaration
69 \*---------------------------------------------------------------------------*/
70 
71 template<class ParcelType>
72 class MPPICParcel
73 :
74  public ParcelType
75 {
76  // Private data
77 
78  //- Size in bytes of the fields
79  static const std::size_t sizeofFields_;
80 
81 
82 public:
83 
84  template<class CloudType>
85  class TrackingData
86  :
87  public ParcelType::template TrackingData<CloudType>
88  {
89 
90  public:
91 
92  enum trackPart
93  {
98  };
99 
100 
101  private:
102 
103  // Private data
104 
105  // MPPIC Averages
106 
107  //- Volume average
108  autoPtr<AveragingMethod<scalar>> volumeAverage_;
109 
110  //- Radius average [ volume^(1/3) ]
111  autoPtr<AveragingMethod<scalar>> radiusAverage_;
112 
113  //- Density average
114  autoPtr<AveragingMethod<scalar>> rhoAverage_;
115 
116  //- Velocity average
118 
119  //- Magnitude velocity sqyuared average
120  autoPtr<AveragingMethod<scalar>> uSqrAverage_;
121 
122  //- Frequency average
123  autoPtr<AveragingMethod<scalar>> frequencyAverage_;
124 
125  //- Mass average
126  autoPtr<AveragingMethod<scalar>> massAverage_;
127 
128 
129  //- Label specifying the current part of the tracking process
130  trackPart part_;
131 
132 
133  public:
134 
135  //- Constructors
136 
137  //- Construct from components
138  inline TrackingData
139  (
140  CloudType& cloud,
142  );
143 
144 
145  //- Update the MPPIC averages
146  inline void updateAverages(CloudType& cloud);
147 
148 
149  //- Access
150 
151  //- Const access to the tracking part label
152  inline trackPart part() const;
153 
154  //- Non const access to the tracking part label
155  inline trackPart& part();
156  };
157 
158 
159 protected:
160 
161  // Protected data
162 
163  //- Velocity correction due to collisions [m/s]
165 
166 
167 public:
168 
169  // Static data members
170 
171  //- Runtime type information
172  TypeName("MPPICParcel");
173 
174  //- String representation of properties
176  (
177  ParcelType,
178  "(UCorrectx UCorrecty UCorrectz)"
179  );
180 
181 
182  // Constructors
183 
184  //- Construct from owner, position, and cloud owner
185  // Other properties initialised as null
186  inline MPPICParcel
187  (
188  const polyMesh& mesh,
189  const vector& position,
190  const label celli,
191  const label tetFacei,
192  const label tetPtI
193  );
194 
195  //- Construct from components
196  inline MPPICParcel
197  (
198  const polyMesh& mesh,
199  const vector& position,
200  const label celli,
201  const label tetFacei,
202  const label tetPtI,
203  const label typeId,
204  const scalar nParticle0,
205  const scalar d0,
206  const scalar dTarget0,
207  const vector& U0,
208  const vector& UCorrect0,
209  const typename ParcelType::constantProperties& constProps
210  );
211 
212  //- Construct from Istream
214  (
215  const polyMesh& mesh,
216  Istream& is,
217  bool readFields = true
218  );
219 
220  //- Construct as a copy
221  MPPICParcel(const MPPICParcel& p);
222 
223  //- Construct as a copy
224  MPPICParcel(const MPPICParcel& p, const polyMesh& mesh);
225 
226  //- Construct and return a (basic particle) clone
227  virtual autoPtr<particle> clone() const
228  {
229  return autoPtr<particle>(new MPPICParcel(*this));
230  }
231 
232  //- Construct and return a (basic particle) clone
233  virtual autoPtr<particle> clone(const polyMesh& mesh) const
234  {
235  return autoPtr<particle>(new MPPICParcel(*this, mesh));
236  }
237 
238  //- Factory class to read-construct particles used for
239  // parallel transfer
240  class iNew
241  {
242  const polyMesh& mesh_;
243 
244  public:
246  iNew(const polyMesh& mesh)
247  :
248  mesh_(mesh)
249  {}
251  autoPtr<MPPICParcel<ParcelType>> operator()(Istream& is) const
252  {
254  (
255  new MPPICParcel<ParcelType>(mesh_, is, true)
256  );
257  }
258  };
259 
260 
261  // Member Functions
262 
263  // Access
264 
265  //- Return const access to correction velocity
266  inline const vector& UCorrect() const;
267 
268  //- Return access to correction velocity
269  inline vector& UCorrect();
270 
271 
272  // Tracking
273 
274  //- Move the parcel
275  template<class TrackData>
276  bool move(TrackData& td, const scalar trackTime);
277 
278 
279  // Friend Functions
280 
281  // I-O
282 
283  //- Read
284  template<class CloudType>
285  static void readFields(CloudType& c);
286 
287  //- Write
288  template<class CloudType>
289  static void writeFields(const CloudType& c);
290 
291 
292  // Ostream operator
293 
294  friend Ostream& operator<< <ParcelType>
295  (
296  Ostream&,
298  );
299 };
300 
301 
302 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
303 
304 } // End namespace Foam
305 
306 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
307 
308 #include "MPPICParcelI.H"
310 
311 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
312 
313 #ifdef NoRepository
314  #include "MPPICParcel.C"
315 #endif
316 
317 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
318 
319 #endif
320 
321 // ************************************************************************* //
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
virtual autoPtr< particle > clone() const
Construct and return a (basic particle) clone.
Definition: MPPICParcel.H:226
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
TrackingData(CloudType &cloud, trackPart part=tpLinearTrack)
Constructors.
AddToPropertyList(ParcelType,"(UCorrectx UCorrecty UCorrectz)")
String representation of properties.
dynamicFvMesh & mesh
bool move(TrackData &td, const scalar trackTime)
Move the parcel.
Definition: MPPICParcel.C:58
Wrapper around kinematic parcel types to add MPPIC modelling.
Definition: MPPICParcel.H:52
A cloud is a collection of lagrangian particles.
Definition: cloud.H:51
Base class for lagrangian averaging methods.
Definition: MPPICParcel.H:55
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
static void writeFields(const CloudType &c)
Write.
MPPICParcel(const polyMesh &mesh, const vector &position, const label celli, const label tetFacei, const label tetPtI)
Construct from owner, position, and cloud owner.
Definition: MPPICParcelI.H:30
void updateAverages(CloudType &cloud)
Update the MPPIC averages.
vector UCorrect_
Velocity correction due to collisions [m/s].
Definition: MPPICParcel.H:163
const dimensionedScalar c
Speed of light in a vacuum.
const vector & UCorrect() const
Return const access to correction velocity.
Definition: MPPICParcelI.H:81
static void readFields(CloudType &c)
Read.
Definition: MPPICParcelIO.C:78
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:53
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
volScalarField & p
Factory class to read-construct particles used for.
Definition: MPPICParcel.H:239
TypeName("MPPICParcel")
Runtime type information.
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:68
Namespace for OpenFOAM.