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-2019 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  //- Construct and return a (basic particle) clone
242  virtual autoPtr<particle> clone() const
243  {
244  return autoPtr<particle>(new MPPICParcel(*this));
245  }
246 
247  //- Construct and return a (basic particle) clone
248  virtual autoPtr<particle> clone(const polyMesh& mesh) const
249  {
250  return autoPtr<particle>(new MPPICParcel(*this, mesh));
251  }
252 
253  //- Factory class to read-construct particles used for
254  // parallel transfer
255  class iNew
256  {
257  const polyMesh& mesh_;
258 
259  public:
260 
261  iNew(const polyMesh& mesh)
262  :
263  mesh_(mesh)
264  {}
265 
267  {
269  (
270  new MPPICParcel<ParcelType>(mesh_, is, true)
271  );
272  }
273  };
274 
275 
276  // Member Functions
277 
278  // Access
279 
280  //- Return const access to correction velocity
281  inline const vector& UCorrect() const;
282 
283  //- Return access to correction velocity
284  inline vector& UCorrect();
285 
286 
287  // Tracking
288 
289  //- Move the parcel
290  template<class TrackCloudType>
291  bool move
292  (
293  TrackCloudType& cloud,
294  trackingData& td,
295  const scalar trackTime
296  );
297 
298 
299  // Friend Functions
300 
301  // I-O
302 
303  //- Read
304  template<class CloudType>
305  static void readFields(CloudType& c);
306 
307  //- Write
308  template<class CloudType>
309  static void writeFields(const CloudType& c);
310 
311  //- Write individual parcel properties to stream
312  void writeProperties
313  (
314  Ostream& os,
315  const wordRes& filters,
316  const word& delim,
317  const bool namesOnly = false
318  ) const;
319 
320  //- Read particle fields as objects from the obr registry
321  template<class CloudType>
322  static void readObjects(CloudType& c, const objectRegistry& obr);
323 
324  //- Write particle fields as objects into the obr registry
325  template<class CloudType>
326  static void writeObjects(const CloudType& c, objectRegistry& obr);
327 
328 
329  // Ostream operator
330 
331  friend Ostream& operator<< <ParcelType>
332  (
333  Ostream&,
335  );
336 };
337 
338 
339 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
340 
341 } // End namespace Foam
342 
343 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
344 
345 #include "MPPICParcelI.H"
347 
348 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
349 
350 #ifdef NoRepository
351  #include "MPPICParcel.C"
352 #endif
353 
354 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
355 
356 #endif
357 
358 // ************************************************************************* //
Foam::AveragingMethod
Base class for lagrangian averaging methods.
Definition: KinematicParcel.H:69
MPPICParcelI.H
MPPICParcelTrackingDataI.H
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::MPPICParcel::clone
virtual autoPtr< particle > clone(const polyMesh &mesh) const
Construct and return a (basic particle) clone.
Definition: MPPICParcel.H:247
Foam::MPPICParcel::trackingData::tpPackingNoTrack
Definition: MPPICParcel.H:98
Foam::MPPICParcel::iNew
Factory class to read-construct particles used for.
Definition: MPPICParcel.H:254
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::MPPICParcel::iNew::operator()
autoPtr< MPPICParcel< ParcelType > > operator()(Istream &is) const
Definition: MPPICParcel.H:265
Foam::MPPICParcel::UCorrect
const vector & UCorrect() const
Return const access to correction velocity.
Definition: MPPICParcelI.H:96
Foam::MPPICParcel::trackingData::tpLinearTrack
Definition: MPPICParcel.H:96
Foam::MPPICParcel::trackingData::trackingData
trackingData(const TrackCloudType &cloud, trackPart part=tpLinearTrack)
Constructors.
Definition: MPPICParcelTrackingDataI.H:36
Foam::MPPICParcel::TypeName
TypeName("MPPICParcel")
Runtime type information.
Foam::MPPICParcel::writeProperties
void writeProperties(Ostream &os, const wordRes &filters, const word &delim, const bool namesOnly=false) const
Write individual parcel properties to stream.
Definition: MPPICParcelIO.C:138
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::MPPICParcel::trackingData::updateAverages
void updateAverages(const TrackCloudType &cloud)
Update the MPPIC averages.
Definition: MPPICParcelTrackingDataI.H:147
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
Foam::MPPICParcel::trackingData::trackPart
trackPart
Definition: MPPICParcel.H:94
Foam::MPPICParcel::trackingData::part
trackPart part() const
Access.
Definition: MPPICParcelTrackingDataI.H:249
Foam::MPPICParcel::UCorrect_
vector UCorrect_
Velocity correction due to collisions [m/s].
Definition: MPPICParcel.H:168
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::MPPICParcel::readFields
static void readFields(CloudType &c)
Read.
Definition: MPPICParcelIO.C:89
vectorFieldIOField.H
Foam::MPPICParcel
Wrapper around kinematic parcel types to add MPPIC modelling.
Definition: MPPICParcel.H:58
coordinates
PtrList< coordinateSystem > coordinates(solidRegions.size())
Foam::MPPICParcel::writeFields
static void writeFields(const CloudType &c)
Write.
Definition: MPPICParcelIO.C:114
Foam::Barycentric< scalar >
Foam::MPPICParcel::sizeofFields
static const std::size_t sizeofFields
Size in bytes of the fields.
Definition: MPPICParcel.H:84
Foam::MPPICParcel::iNew::iNew
iNew(const polyMesh &mesh)
Definition: MPPICParcel.H:260
Foam::MPPICParcel::writeObjects
static void writeObjects(const CloudType &c, objectRegistry &obr)
Write particle fields as objects into the obr registry.
Definition: MPPICParcelIO.C:184
MPPICParcel.C
labelFieldIOField.H
Foam::DSMCCloud
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:71
Foam::MPPICParcel::trackingData
Definition: MPPICParcel.H:87
os
OBJstream os(runTime.globalPath()/outputName)
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::MPPICParcel::clone
virtual autoPtr< particle > clone() const
Construct and return a (basic particle) clone.
Definition: MPPICParcel.H:241
Foam::MPPICParcel::trackingData::tpDampingNoTrack
Definition: MPPICParcel.H:97
Foam::MPPICParcel::move
bool move(TrackCloudType &cloud, trackingData &td, const scalar trackTime)
Move the parcel.
Definition: MPPICParcel.C:60
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::cloud
A cloud is a registry collection of lagrangian particles.
Definition: cloud.H:57
Foam::Vector< scalar >
Foam::wordRes
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:51
particle.H
Foam::constant::universal::c
const dimensionedScalar c
Speed of light in a vacuum.
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::MPPICParcel::readObjects
static void readObjects(CloudType &c, const objectRegistry &obr)
Read particle fields as objects from the obr registry.
Definition: MPPICParcelIO.C:160
Foam::MPPICParcel::MPPICParcel
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:32
Foam::MPPICParcel::trackingData::tpCorrectTrack
Definition: MPPICParcel.H:99
Foam::MPPICParcel::AddToPropertyList
AddToPropertyList(ParcelType, " (UCorrectx UCorrecty UCorrectz)")
String representation of properties.