CollidingParcel.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-2018 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::CollidingParcel
26 
27 Description
28  Wrapper around kinematic parcel types to add collision modelling
29 
30 SourceFiles
31  CollidingParcelI.H
32  CollidingParcel.C
33  CollidingParcelIO.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef CollidingParcel_H
38 #define CollidingParcel_H
39 
40 #include "particle.H"
41 #include "CollisionRecordList.H"
42 #include "labelFieldIOField.H"
43 #include "vectorFieldIOField.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
53 
54 template<class ParcelType>
55 class CollidingParcel;
56 
57 // Forward declaration of friend functions
58 
59 template<class ParcelType>
60 Ostream& operator<<
61 (
62  Ostream&,
64 );
65 
66 /*---------------------------------------------------------------------------*\
67  Class CollidingParcel Declaration
68 \*---------------------------------------------------------------------------*/
69 
70 template<class ParcelType>
71 class CollidingParcel
72 :
73  public ParcelType
74 {
75  // Private member data
76 
77  //- Size in bytes of the fields
78  static const std::size_t sizeofFields_;
79 
80 
81 public:
82 
83  //- Class to hold thermo particle constant properties
84  class constantProperties
85  :
86  public ParcelType::constantProperties
87  {
88 
89  // Private data
90 
91  //- Young's modulus [N/m2]
92  demandDrivenEntry<scalar> youngsModulus_;
93 
94  //- Poisson's ratio
95  demandDrivenEntry<scalar> poissonsRatio_;
96 
97 
98  public:
99 
100  // Constructors
101 
102  //- Null constructor
104 
105  //- Copy constructor
107 
108  //- Construct from dictionary
109  constantProperties(const dictionary& parentDict);
110 
111 
112  // Member functions
113 
114  //- Return const access to Young's Modulus
115  inline scalar youngsModulus() const;
116 
117  //- Return const access to Poisson's ratio
118  inline scalar poissonsRatio() const;
119  };
120 
121 
122  //- Use base tracking data
123  typedef typename ParcelType::trackingData trackingData;
124 
125 
126 protected:
127 
128  // Protected data
129 
130  //- Force on particle due to collisions [N]
131  vector f_;
132 
133  //- Angular momentum of Parcel in global reference frame [kg m2/s]
135 
136  //- Torque on particle due to collisions in global
137  // reference frame [Nm]
138  vector torque_;
139 
140  //- Particle collision records
141  collisionRecordList collisionRecords_;
142 
143 
144 public:
145 
146  // Static data members
147 
148  //- Runtime type information
149  TypeName("CollidingParcel");
150 
151  //- String representation of properties
153  (
154  ParcelType,
155  " (fx fy fz)"
156  + " (angularMomentumx angularMomentumy angularMomentumz)"
157  + " (torquex torquey torquez)"
158  + " collisionRecordsPairAccessed"
159  + " collisionRecordsPairOrigProcOfOther"
160  + " collisionRecordsPairOrigIdOfOther"
161  + " (collisionRecordsPairData)"
162  + " collisionRecordsWallAccessed"
163  + " collisionRecordsWallPRel"
164  + " (collisionRecordsWallData)"
165  );
166 
167 
168  // Constructors
169 
170  //- Construct from mesh, coordinates and topology
171  // Other properties initialised as null
172  inline CollidingParcel
173  (
174  const polyMesh& mesh,
175  const barycentric& coordinates,
176  const label celli,
177  const label tetFacei,
178  const label tetPti
179  );
180 
181  //- Construct from a position and a cell, searching for the rest of the
182  // required topology. Other properties are initialised as null.
183  inline CollidingParcel
184  (
185  const polyMesh& mesh,
186  const vector& position,
187  const label celli
188  );
189 
190  //- Construct from components
191  inline CollidingParcel
192  (
193  const polyMesh& mesh,
194  const barycentric& coordinates,
195  const label celli,
196  const label tetFacei,
197  const label tetPti,
198  const label typeId,
199  const scalar nParticle0,
200  const scalar d0,
201  const scalar dTarget0,
202  const vector& U0,
203  const vector& f0,
204  const vector& angularMomentum0,
205  const vector& torque0,
206  const typename ParcelType::constantProperties& constProps
207  );
208 
209  //- Construct from Istream
211  (
212  const polyMesh& mesh,
213  Istream& is,
214  bool readFields = true
215  );
216 
217  //- Construct as a copy
219 
220  //- Construct as a copy
222 
223  //- Construct and return a (basic particle) clone
224  virtual autoPtr<particle> clone() const
225  {
226  return autoPtr<particle>(new CollidingParcel(*this));
227  }
228 
229  //- Construct and return a (basic particle) clone
230  virtual autoPtr<particle> clone(const polyMesh& mesh) const
231  {
232  return autoPtr<particle>(new CollidingParcel(*this, mesh));
233  }
234 
235  //- Factory class to read-construct particles used for
236  // parallel transfer
237  class iNew
238  {
239  const polyMesh& mesh_;
240 
241  public:
243  iNew(const polyMesh& mesh)
244  :
245  mesh_(mesh)
246  {}
248  autoPtr<CollidingParcel<ParcelType>> operator()(Istream& is) const
249  {
251  (
252  new CollidingParcel<ParcelType>(mesh_, is, true)
253  );
254  }
255  };
256 
257 
258  // Member Functions
259 
260  // Access
261 
262  //- Return const access to force
263  inline const vector& f() const;
264 
265  //- Return const access to angular momentum
266  inline const vector& angularMomentum() const;
267 
268  //- Return const access to torque
269  inline const vector& torque() const;
270 
271  //- Return const access to the collision records
272  inline const collisionRecordList& collisionRecords() const;
273 
274  //- Return access to force
275  inline vector& f();
276 
277  //- Return access to angular momentum
278  inline vector& angularMomentum();
279 
280  //- Return access to torque
281  inline vector& torque();
282 
283  //- Return access to collision records
284  inline collisionRecordList& collisionRecords();
285 
286  //- Particle angular velocity
287  inline vector omega() const;
288 
289 
290  // Tracking
291 
292  //- Move the parcel
293  template<class TrackCloudType>
294  bool move
295  (
296  TrackCloudType& cloud,
297  trackingData& td,
298  const scalar trackTime
299  );
300 
301  //- Transform the physical properties of the particle
302  // according to the given transformation tensor
303  virtual void transformProperties(const tensor& T);
304 
305  //- Transform the physical properties of the particle
306  // according to the given separation vector
307  virtual void transformProperties(const vector& separation);
308 
309 
310  // I-O
311 
312  //- Read
313  template<class CloudType>
314  static void readFields(CloudType& c);
315 
316  //- Write
317  template<class CloudType>
318  static void writeFields(const CloudType& c);
319 
320 
321  // Ostream Operator
322 
323  friend Ostream& operator<< <ParcelType>
324  (
325  Ostream&,
327  );
328 };
329 
330 
331 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
332 
333 } // End namespace Foam
334 
335 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
336 
337 #include "CollidingParcelI.H"
338 
339 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
340 
341 #ifdef NoRepository
342  #include "CollidingParcel.C"
343 #endif
344 
345 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
346 
347 #endif
348 
349 // ************************************************************************* //
ParcelType::trackingData trackingData
Use base tracking data.
vector f_
Force on particle due to collisions [N].
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
CollisionRecordList< vector, vector > collisionRecordList
vectorFieldCompactIOField pairDataFieldCompactIOField
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
Wrapper around kinematic parcel types to add collision modelling.
Class to hold thermo particle constant properties.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
const vector & f() const
Return const access to force.
bool cp(const fileName &src, const fileName &dst, const bool followLink=true)
Copy, recursively if necessary, the source to the destination.
Definition: POSIX.C:737
static void writeFields(const CloudType &c)
Write.
vectorFieldCompactIOField wallDataFieldCompactIOField
scalar poissonsRatio() const
Return const access to Poisson&#39;s ratio.
scalar youngsModulus() const
Return const access to Young&#39;s Modulus.
collisionRecordList collisionRecords_
Particle collision records.
dynamicFvMesh & mesh
AddToPropertyList(ParcelType, " (fx fy fz)"+" (angularMomentumx angularMomentumy angularMomentumz)"+" (torquex torquey torquez)"+" collisionRecordsPairAccessed"+" collisionRecordsPairOrigProcOfOther"+" collisionRecordsPairOrigIdOfOther"+" (collisionRecordsPairData)"+" collisionRecordsWallAccessed"+" collisionRecordsWallPRel"+" (collisionRecordsWallData)")
String representation of properties.
A cloud is a collection of lagrangian particles.
Definition: cloud.H:51
bool move(TrackCloudType &cloud, trackingData &td, const scalar trackTime)
Move the parcel.
const vector & torque() const
Return const access to torque.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
const vector & angularMomentum() const
Return const access to angular momentum.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
vector angularMomentum_
Angular momentum of Parcel in global reference frame [kg m2/s].
vector torque_
Torque on particle due to collisions in global.
vector omega() const
Particle angular velocity.
PtrList< coordinateSystem > coordinates(solidRegions.size())
A Field of objects of type <T> with automated input and output using a compact storage. Behaves like IOField except when binary output in case it writes a CompactListList.
const dimensionedScalar c
Speed of light in a vacuum.
CollidingParcel(const polyMesh &mesh, const barycentric &coordinates, const label celli, const label tetFacei, const label tetPti)
Construct from mesh, coordinates and topology.
TypeName("CollidingParcel")
Runtime type information.
Factory class to read-construct particles used for.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
volScalarField & p
const collisionRecordList & collisionRecords() const
Return const access to the collision records.
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:69
virtual void transformProperties(const tensor &T)
Transform the physical properties of the particle.
virtual autoPtr< particle > clone() const
Construct and return a (basic particle) clone.
Namespace for OpenFOAM.
static void readFields(CloudType &c)
Read.