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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2013-2017 OpenFOAM Foundation
9  Copyright (C) 2016-2024 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::MPPICParcel
29 
30 Group
31  grpLagrangianIntermediateParcels
32 
33 Description
34  Wrapper around kinematic parcel types to add MPPIC modelling
35 
36 SourceFiles
37  MPPICParcelI.H
38  MPPICParcelTrackingDataI.H
39  MPPICParcel.C
40  MPPICParcelIO.C
41 
42 \*---------------------------------------------------------------------------*/
43 
44 #ifndef MPPICParcel_H
45 #define MPPICParcel_H
46 
47 #include "particle.H"
48 #include "labelFieldIOField.H"
49 #include "vectorFieldIOField.H"
50 
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 
53 namespace Foam
54 {
55 
56 // Forward declaration of classes
57 
58 template<class ParcelType>
59 class MPPICParcel;
60 
61 template<class Type>
62 class AveragingMethod;
63 
64 // Forward declaration of friend functions
65 
66 template<class ParcelType>
67 Ostream& operator<<
68 (
69  Ostream&,
71 );
72 
73 /*---------------------------------------------------------------------------*\
74  Class MPPICParcel Declaration
75 \*---------------------------------------------------------------------------*/
76 
77 template<class ParcelType>
78 class MPPICParcel
79 :
80  public ParcelType
81 {
82 public:
83 
84  //- Size in bytes of the fields
85  static const std::size_t sizeofFields;
86 
87 
88  class trackingData
89  :
90  public ParcelType::trackingData
91  {
92 
93  public:
94 
95  enum trackPart
96  {
101  };
102 
103 
104  private:
105 
106  // Private data
107 
108  // MPPIC Averages
109 
110  //- Volume average
111  autoPtr<AveragingMethod<scalar>> volumeAverage_;
112 
113  //- Radius average [ volume^(1/3) ]
114  autoPtr<AveragingMethod<scalar>> radiusAverage_;
115 
116  //- Density average
117  autoPtr<AveragingMethod<scalar>> rhoAverage_;
118 
119  //- Velocity average
121 
122  //- Magnitude velocity squared average
123  autoPtr<AveragingMethod<scalar>> uSqrAverage_;
124 
125  //- Frequency average
126  autoPtr<AveragingMethod<scalar>> frequencyAverage_;
127 
128  //- Mass average
129  autoPtr<AveragingMethod<scalar>> massAverage_;
130 
131 
132  //- Label specifying the current part of the tracking process
133  trackPart part_;
134 
135 
136  public:
137 
138  //- Constructors
139 
140  //- Construct from components
141  template<class TrackCloudType>
142  inline trackingData
143  (
144  const TrackCloudType& cloud,
146  );
147 
148 
149  //- Update the MPPIC averages
150  template<class TrackCloudType>
151  inline void updateAverages(const TrackCloudType& cloud);
152 
153 
154  //- Access
155 
156  //- Const access to the tracking part label
157  inline trackPart part() const;
158 
159  //- Non const access to the tracking part label
160  inline trackPart& part();
161  };
162 
163 
164 protected:
165 
166  // Protected data
167 
168  //- Velocity correction due to collisions [m/s]
170 
171 
172 public:
173 
174  // Static data members
175 
176  //- Runtime type information
177  TypeName("MPPICParcel");
178 
179  //- String representation of properties
181  (
182  ParcelType,
183  " (UCorrectx UCorrecty UCorrectz)"
184  );
185 
186 
187  // Constructors
188 
189  //- Construct from mesh, coordinates and topology
190  // Other properties initialised as null
191  inline MPPICParcel
192  (
193  const polyMesh& mesh,
194  const barycentric& coordinates,
195  const label celli,
196  const label tetFacei,
197  const label tetPti
198  );
199 
200  //- Construct from a position and a cell, searching for the rest of the
201  // required topology. Other properties are initialised as null.
202  inline MPPICParcel
203  (
204  const polyMesh& mesh,
205  const vector& position,
206  const label celli
207  );
208 
209  //- Construct from components
210  inline MPPICParcel
211  (
212  const polyMesh& mesh,
213  const barycentric& coordinates,
214  const label celli,
215  const label tetFacei,
216  const label tetPti,
217  const label typeId,
218  const scalar nParticle0,
219  const scalar d0,
220  const scalar dTarget0,
221  const vector& U0,
222  const vector& UCorrect0,
223  const typename ParcelType::constantProperties& constProps
224  );
225 
226  //- Construct from Istream
228  (
229  const polyMesh& mesh,
230  Istream& is,
231  bool readFields = true,
232  bool newFormat = true
233  );
234 
235  //- Construct as a copy
236  MPPICParcel(const MPPICParcel& p);
237 
238  //- Construct as a copy
239  MPPICParcel(const MPPICParcel& p, const polyMesh& mesh);
240 
241  //- Return a (basic particle) clone
242  virtual autoPtr<particle> clone() const
243  {
244  return particle::Clone(*this);
245  }
246 
247  //- Return a (basic particle) clone
248  virtual autoPtr<particle> clone(const polyMesh& mesh) const
249  {
250  return particle::Clone(*this, mesh);
251  }
252 
253  //- Factory class to read-construct particles (for parallel transfer)
254  class iNew
255  {
256  const polyMesh& mesh_;
257 
258  public:
259 
260  iNew(const polyMesh& mesh)
261  :
262  mesh_(mesh)
263  {}
264 
265  autoPtr<MPPICParcel<ParcelType>> operator()(Istream& is) const
266  {
267  return autoPtr<MPPICParcel<ParcelType>>
268  (
269  new MPPICParcel<ParcelType>(mesh_, is, true)
270  );
271  }
272  };
273 
274 
275  // Member Functions
276 
277  // Access
278 
279  //- Return const access to correction velocity
280  inline const vector& UCorrect() const;
281 
282  //- Return access to correction velocity
283  inline vector& UCorrect();
284 
285 
286  // Tracking
287 
288  //- Move the parcel
289  template<class TrackCloudType>
290  bool move
291  (
292  TrackCloudType& cloud,
293  trackingData& td,
294  const scalar trackTime
295  );
296 
298  // Friend Functions
299 
300  // I-O
301 
302  //- Read
303  template<class CloudType>
304  static void readFields(CloudType& c);
306  //- Write
307  template<class CloudType>
308  static void writeFields(const CloudType& c);
309 
310  //- Write individual parcel properties to stream
312  (
313  Ostream& os,
314  const wordRes& filters,
315  const word& delim,
316  const bool namesOnly = false
317  ) const;
318 
319  //- Read particle fields as objects from the obr registry
320  template<class CloudType>
321  static void readObjects(CloudType& c, const objectRegistry& obr);
322 
323  //- Write particle fields as objects into the obr registry
324  template<class CloudType>
325  static void writeObjects(const CloudType& c, objectRegistry& obr);
326 
327 
328  // Ostream operator
329 
330  friend Ostream& operator<< <ParcelType>
331  (
332  Ostream&,
334  );
335 };
336 
337 
338 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
339 
340 } // End namespace Foam
341 
342 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
343 
344 #include "MPPICParcelI.H"
346 
347 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
348 
349 #ifdef NoRepository
350  #include "MPPICParcel.C"
351 #endif
352 
353 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
354 
355 #endif
356 
357 // ************************************************************************* //
bool move(TrackCloudType &cloud, trackingData &td, const scalar trackTime)
Move the parcel.
Definition: MPPICParcel.C:53
trackingData(const TrackCloudType &cloud, trackPart part=tpLinearTrack)
Constructors.
virtual autoPtr< particle > clone() const
Return a (basic particle) clone.
Definition: MPPICParcel.H:289
wallPoints::trackData td(isBlockedFace, regionToBlockSize)
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
iNew(const polyMesh &mesh)
Definition: MPPICParcel.H:311
static void readObjects(CloudType &c, const objectRegistry &obr)
Read particle fields as objects from the obr registry.
dynamicFvMesh & mesh
A class for handling words, derived from Foam::string.
Definition: word.H:63
Wrapper around kinematic parcel types to add MPPIC modelling.
Definition: MPPICParcel.H:54
A cloud is a registry collection of lagrangian particles.
Definition: cloud.H:53
Base class for lagrangian averaging methods.
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:53
Vector< scalar > vector
Definition: vector.H:57
void updateAverages(const TrackCloudType &cloud)
Update the MPPIC averages.
const vector & UCorrect() const
Return const access to correction velocity.
Definition: MPPICParcelI.H:89
static autoPtr< particle > Clone(const Derived &p)
Clone a particle.
Definition: particle.H:552
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
OBJstream os(runTime.globalPath()/outputName)
static void writeFields(const CloudType &c)
Write.
static const std::size_t sizeofFields
Size in bytes of the fields.
Definition: MPPICParcel.H:82
PtrList< coordinateSystem > coordinates(solidRegions.size())
vector UCorrect_
Velocity correction due to collisions [m/s].
Definition: MPPICParcel.H:196
MPPICParcel(const polyMesh &mesh, const barycentric &coordinates, const label celli, const label tetFacei, const label tetPti)
Construct from mesh, coordinates and topology.
Definition: MPPICParcelI.H:25
autoPtr< MPPICParcel< ParcelType > > operator()(Istream &is) const
Definition: MPPICParcel.H:316
const dimensionedScalar c
Speed of light in a vacuum.
static void readFields(CloudType &c)
Read.
Definition: MPPICParcelIO.C:82
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:75
volScalarField & p
Registry of regIOobjects.
TypeName("MPPICParcel")
Runtime type information.
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:67
void writeProperties(Ostream &os, const wordRes &filters, const word &delim, const bool namesOnly=false) const
Write individual parcel properties to stream.
static void writeObjects(const CloudType &c, objectRegistry &obr)
Write particle fields as objects into the obr registry.
AddToPropertyList(ParcelType, " (UCorrectx UCorrecty UCorrectz)")
String representation of properties.
Namespace for OpenFOAM.