DSMCParcel.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2023 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  //- Use base tracking data
131  typedef typename ParcelType::trackingData trackingData;
132 
133 
134 protected:
135 
136  // Protected member data
137 
138  // Parcel properties
139 
140  //- Velocity of Parcel [m/s]
141  vector U_;
142 
143  //- Internal energy of the Parcel, covering all non-translational
144  // degrees of freedom [J]
145  scalar Ei_;
146 
147  //- Parcel type id
148  label typeId_;
149 
150 
151 public:
152 
153  //- Runtime type information
154  TypeName("DSMCParcel");
155 
156  friend class Cloud<ParcelType>;
157 
158 
159  // Constructors
160 
161  //- Construct from a position and a cell, searching for the rest of the
162  // required topology
163  inline DSMCParcel
164  (
165  const polyMesh& mesh,
166  const vector& position,
167  const label celli,
168  label& nLocateBoundaryHits,
169  const vector& U,
170  const scalar Ei,
171  const label typeId
172  );
173 
174  //- Construct from Istream
175  DSMCParcel(Istream& is, bool readFields = true);
176 
177  //- Construct and return a clone
178  virtual autoPtr<particle> clone() const
179  {
180  return autoPtr<particle>(new DSMCParcel<ParcelType>(*this));
181  }
182 
183  //- Construct from Istream and return
184  static autoPtr<DSMCParcel> New(Istream& is)
185  {
186  return autoPtr<DSMCParcel>(new DSMCParcel(is));
187  }
188 
189 
190  // Member Functions
191 
192  // Access
193 
194  //- Return type id
195  inline label typeId() const;
196 
197  //- Return const access to velocity
198  inline const vector& U() const;
199 
200  //- Return const access to internal energy
201  inline scalar Ei() const;
202 
203 
204  // Edit
205 
206  //- Return access to velocity
207  inline vector& U();
208 
209  //- Return access to internal energy
210  inline scalar& Ei();
211 
212 
213  // Main calculation loop
214 
215  // Tracking
216 
217  //- Move the parcel
218  template<class TrackCloudType>
219  bool move(TrackCloudType& cloud, trackingData& td);
220 
221 
222  // Patch interactions
223 
224  //- Overridable function to handle the particle hitting a wallPatch
225  template<class TrackCloudType>
226  void hitWallPatch(TrackCloudType&, trackingData&);
227 
228  //- Transform the physical properties of the particle
229  // according to the given transformation tensor
230  virtual void transformProperties(const transformer&);
231 
232 
233  // I-O
234 
235  static void readFields(Cloud<DSMCParcel<ParcelType>>& c);
236 
237  static void writeFields(const Cloud<DSMCParcel<ParcelType>>& c);
238 
239 
240  // Ostream Operator
241 
242  friend Ostream& operator<< <ParcelType>
243  (
244  Ostream&,
246  );
247 };
248 
249 
250 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
251 
252 } // End namespace Foam
253 
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 
256 #include "DSMCParcelI.H"
257 
258 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
259 
260 #ifdef NoRepository
261  #include "DSMCParcel.C"
262 #endif
263 
264 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
265 
266 #endif
267 
268 // ************************************************************************* //
Base cloud calls templated on particle type.
Definition: Cloud.H:74
Class to hold DSMC particle constant properties.
Definition: DSMCParcel.H:81
scalar d() const
Return const access to the hard sphere diameter [m].
Definition: DSMCParcelI.H:85
constantProperties()
Null constructor, allows List of constantProperties to be.
Definition: DSMCParcelI.H:32
scalar omega() const
Return the viscosity index.
Definition: DSMCParcelI.H:110
scalar mass() const
Return const access to the particle mass [kg].
Definition: DSMCParcelI.H:78
scalar sigmaT() const
Return the reference total collision cross section.
Definition: DSMCParcelI.H:93
direction internalDegreesOfFreedom() const
Return the internalDegreesOfFreedom.
Definition: DSMCParcelI.H:101
DSMC parcel class.
Definition: DSMCParcel.H:70
static void readFields(Cloud< DSMCParcel< ParcelType >> &c)
Definition: DSMCParcelIO.C:74
label typeId_
Parcel type id.
Definition: DSMCParcel.H:147
label typeId() const
Return type id.
Definition: DSMCParcelI.H:119
const vector & U() const
Return const access to velocity.
Definition: DSMCParcelI.H:126
bool move(TrackCloudType &cloud, trackingData &td)
Move the parcel.
Definition: DSMCParcel.C:34
scalar Ei() const
Return const access to internal energy.
Definition: DSMCParcelI.H:133
static autoPtr< DSMCParcel > New(Istream &is)
Construct from Istream and return.
Definition: DSMCParcel.H:183
ParcelType::trackingData trackingData
Use base tracking data.
Definition: DSMCParcel.H:130
virtual autoPtr< particle > clone() const
Construct and return a clone.
Definition: DSMCParcel.H:177
TypeName("DSMCParcel")
Runtime type information.
static void writeFields(const Cloud< DSMCParcel< ParcelType >> &c)
Definition: DSMCParcelIO.C:108
virtual void transformProperties(const transformer &)
Transform the physical properties of the particle.
Definition: DSMCParcel.C:169
void hitWallPatch(TrackCloudType &, trackingData &)
Overridable function to handle the particle hitting a wallPatch.
Definition: DSMCParcel.C:77
vector U_
Velocity of Parcel [m/s].
Definition: DSMCParcel.H:140
DSMCParcel(const polyMesh &mesh, const vector &position, const label celli, label &nLocateBoundaryHits, const vector &U, const scalar Ei, const label typeId)
Construct from a position and a cell, searching for the rest of the.
Definition: DSMCParcelI.H:57
scalar Ei_
Internal energy of the Parcel, covering all non-translational.
Definition: DSMCParcel.H:144
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A cloud is a collection of lagrangian particles.
Definition: cloud.H:55
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
Vector-tensor class used to perform translations, rotations and scaling operations in 3D space.
Definition: transformer.H:84
Template function to specify if the data of a type are contiguous.
const dimensionedScalar c
Speed of light in a vacuum.
Namespace for OpenFOAM.
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:45
dictionary dict