DSMCParcel.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) 2011-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::DSMCParcel
26 
27 Description
28  DSMC parcel class
29 
30 SourceFiles
31  DSMCParcelI.H
32  DSMCParcel.C
33  DSMCParcelIO.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef DSMCParcel_H
38 #define DSMCParcel_H
39 
40 #include "particle.H"
41 #include "IOstream.H"
42 #include "autoPtr.H"
43 #include "contiguous.H"
44 #include "DSMCCloud.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 template<class ParcelType>
52 class DSMCParcel;
53 
54 // Forward declaration of friend functions
55 
56 template<class ParcelType>
57 Ostream& operator<<
58 (
59  Ostream&,
61 );
62 
63 /*---------------------------------------------------------------------------*\
64  Class DSMCParcel Declaration
65 \*---------------------------------------------------------------------------*/
66 
67 template<class ParcelType>
68 class DSMCParcel
69 :
70  public ParcelType
71 {
72  // Private member data
73 
74  //- Size in bytes of the fields
75  static const std::size_t sizeofFields_;
76 
77 
78 public:
79 
80  //- Class to hold DSMC particle constant properties
81  class constantProperties
82  {
83  // Private data
84 
85  //- Particle mass [kg] (constant)
86  scalar mass_;
87 
88  //- Particle hard sphere diameter [m] (constant)
89  scalar d_;
90 
91  //- Internal degrees of freedom
92  direction internalDegreesOfFreedom_;
93 
94  //- Viscosity index
95  scalar omega_;
96 
97 
98  public:
99 
100  // Constructors
101 
102  //- Null constructor, allows List of constantProperties to be
103  // created before the contents is initialised
104  inline constantProperties();
105 
106  //- Constructor from dictionary
107  inline constantProperties(const dictionary& dict);
108 
109 
110  // Member functions
111 
112  //- Return const access to the particle mass [kg]
113  inline scalar mass() const;
114 
115  //- Return const access to the hard sphere diameter [m]
116  inline scalar d() const;
117 
118  //- Return the reference total collision cross section
119  inline scalar sigmaT() const;
120 
121  //- Return the internalDegreesOfFreedom
122  inline direction internalDegreesOfFreedom() const;
123 
124  //- Return the viscosity index
125  inline scalar omega() const;
126 
127  };
128 
129 
130  //- Class used to pass kinematic tracking data to the trackToFace function
131  class trackingData
132  :
133  public particle::TrackingData<DSMCCloud<DSMCParcel<ParcelType>>>
134  {
135  public:
136 
137  // Constructors
138 
139  //- Construct from components
141  :
142  particle::TrackingData<DSMCCloud<DSMCParcel<ParcelType>>>
143  (
144  cloud
145  )
146  {}
147  };
148 
149 
150 protected:
151 
152  // Protected member data
153 
154  // Parcel properties
155 
156  //- Velocity of Parcel [m/s]
157  vector U_;
158 
159  //- Internal energy of the Parcel, covering all non-translational
160  // degrees of freedom [J]
161  scalar Ei_;
162 
163  //- Parcel type id
164  label typeId_;
165 
166 
167 public:
168 
169  //- Runtime type information
170  TypeName("DSMCParcel");
172  friend class Cloud<ParcelType>;
173 
174 
175  // Constructors
176 
177  //- Construct from components
178  inline DSMCParcel
179  (
180  const polyMesh& mesh,
181  const vector& position,
182  const vector& U,
183  const scalar Ei,
184  const label celli,
185  const label tetFacei,
186  const label tetPtI,
187  const label typeId
188  );
189 
190  //- Construct from Istream
191  DSMCParcel
192  (
193  const polyMesh& mesh,
194  Istream& is,
195  bool readFields = true
196  );
197 
198  //- Construct and return a clone
199  virtual autoPtr<particle> clone() const
200  {
201  return autoPtr<particle>(new DSMCParcel<ParcelType>(*this));
202  }
203 
204  //- Factory class to read-construct particles used for
205  // parallel transfer
206  class iNew
207  {
208  const polyMesh& mesh_;
209 
210  public:
212  iNew(const polyMesh& mesh)
213  :
214  mesh_(mesh)
215  {}
217  autoPtr<DSMCParcel<ParcelType>> operator()(Istream& is) const
218  {
220  (
221  new DSMCParcel<ParcelType>(mesh_, is, true)
222  );
223  }
224  };
225 
226 
227  // Member Functions
228 
229  // Access
230 
231  //- Return type id
232  inline label typeId() const;
233 
234  //- Return const access to velocity
235  inline const vector& U() const;
236 
237  //- Return const access to internal energy
238  inline scalar Ei() const;
239 
240 
241  // Edit
242 
243  //- Return access to velocity
244  inline vector& U();
245 
246  //- Return access to internal energy
247  inline scalar& Ei();
248 
249 
250  // Main calculation loop
251 
252  // Tracking
253 
254  //- Move the parcel
255  template<class TrackData>
256  bool move(TrackData& td, const scalar trackTime);
257 
258 
259  // Patch interactions
260 
261  //- Overridable function to handle the particle hitting a patch
262  // Executed before other patch-hitting functions
263  template<class TrackData>
264  bool hitPatch
265  (
266  const polyPatch&,
267  TrackData& td,
268  const label patchi,
269  const scalar trackFraction,
270  const tetIndices& tetIs
271  );
272 
273  //- Overridable function to handle the particle hitting a
274  // processorPatch
275  template<class TrackData>
276  void hitProcessorPatch
277  (
278  const processorPolyPatch&,
279  TrackData& td
280  );
281 
282  //- Overridable function to handle the particle hitting a wallPatch
283  template<class TrackData>
284  void hitWallPatch
285  (
286  const wallPolyPatch&,
287  TrackData& td,
288  const tetIndices&
289  );
290 
291  //- Overridable function to handle the particle hitting a polyPatch
292  template<class TrackData>
293  void hitPatch
294  (
295  const polyPatch&,
296  TrackData& td
297  );
298 
299  //- Transform the physical properties of the particle
300  // according to the given transformation tensor
301  virtual void transformProperties(const tensor& T);
302 
303  //- Transform the physical properties of the particle
304  // according to the given separation vector
305  virtual void transformProperties(const vector& separation);
306 
307 
308  // I-O
309 
310  static void readFields(Cloud<DSMCParcel<ParcelType>>& c);
311 
312  static void writeFields(const Cloud<DSMCParcel<ParcelType>>& c);
313 
314 
315  // Ostream Operator
316 
317  friend Ostream& operator<< <ParcelType>
318  (
319  Ostream&,
321  );
322 };
323 
324 
325 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
326 
327 } // End namespace Foam
328 
329 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
330 
331 #include "DSMCParcelI.H"
332 
333 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
334 
335 #ifdef NoRepository
336  #include "DSMCParcel.C"
337 #endif
338 
339 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
340 
341 #endif
342 
343 // ************************************************************************* //
TypeName("DSMCParcel")
Runtime type information.
dictionary dict
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
uint8_t direction
Definition: direction.H:46
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
void hitWallPatch(const wallPolyPatch &, TrackData &td, const tetIndices &)
Overridable function to handle the particle hitting a wallPatch.
Definition: DSMCParcel.C:116
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
bool move(TrackData &td, const scalar trackTime)
Move the parcel.
Definition: DSMCParcel.C:33
label typeId_
Parcel type id.
Definition: DSMCParcel.H:163
Template function to specify if the data of a type are contiguous.
DSMC parcel class.
Definition: DSMCParcel.H:51
scalar sigmaT() const
Return the reference total collision cross section.
Definition: DSMCParcelI.H:93
Class used to pass kinematic tracking data to the trackToFace function.
Definition: DSMCParcel.H:130
void hitProcessorPatch(const processorPolyPatch &, TrackData &td)
Overridable function to handle the particle hitting a.
Definition: DSMCParcel.C:104
bool hitPatch(const polyPatch &, TrackData &td, const label patchi, const scalar trackFraction, const tetIndices &tetIs)
Overridable function to handle the particle hitting a patch.
Definition: DSMCParcel.C:89
DSMCParcel(const polyMesh &mesh, const vector &position, const vector &U, const scalar Ei, const label celli, const label tetFacei, const label tetPtI, const label typeId)
Construct from components.
Definition: DSMCParcelI.H:56
scalar omega() const
Return the viscosity index.
Definition: DSMCParcelI.H:110
label typeId() const
Return type id.
Definition: DSMCParcelI.H:119
Base particle class.
Definition: particle.H:78
Neighbour processor patch.
static void readFields(Cloud< DSMCParcel< ParcelType >> &c)
Definition: DSMCParcelIO.C:79
scalar d() const
Return const access to the hard sphere diameter [m].
Definition: DSMCParcelI.H:85
static void writeFields(const Cloud< DSMCParcel< ParcelType >> &c)
Definition: DSMCParcelIO.C:112
constantProperties()
Null constructor, allows List of constantProperties to be.
Definition: DSMCParcelI.H:31
dynamicFvMesh & mesh
Class to hold DSMC particle constant properties.
Definition: DSMCParcel.H:80
Factory class to read-construct particles used for.
Definition: DSMCParcel.H:205
A cloud is a collection of lagrangian particles.
Definition: cloud.H:51
Foam::wallPolyPatch.
Definition: wallPolyPatch.H:48
Storage and named access for the indices of a tet which is part of the decomposition of a cell...
Definition: tetIndices.H:81
Base cloud calls templated on particle type.
Definition: Cloud.H:52
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
direction internalDegreesOfFreedom() const
Return the internalDegreesOfFreedom.
Definition: DSMCParcelI.H:101
const vector & U() const
Return const access to velocity.
Definition: DSMCParcelI.H:126
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
scalar Ei() const
Return const access to internal energy.
Definition: DSMCParcelI.H:133
virtual void transformProperties(const tensor &T)
Transform the physical properties of the particle.
Definition: DSMCParcel.C:215
virtual autoPtr< particle > clone() const
Construct and return a clone.
Definition: DSMCParcel.H:198
label patchi
const dimensionedScalar c
Speed of light in a vacuum.
scalar Ei_
Internal energy of the Parcel, covering all non-translational.
Definition: DSMCParcel.H:160
scalar mass() const
Return const access to the particle mass [kg].
Definition: DSMCParcelI.H: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
vector U_
Velocity of Parcel [m/s].
Definition: DSMCParcel.H:156
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:68
Namespace for OpenFOAM.