DSMCCloudI.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) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 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 \*---------------------------------------------------------------------------*/
28 
29 #include "constants.H"
30 
31 using namespace Foam::constant;
32 using namespace Foam::constant::mathematical;
33 
34 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
35 
36 template<class ParcelType>
38 {
39  return cloudName_;
40 }
41 
42 
43 template<class ParcelType>
45 {
46  return mesh_;
47 }
48 
49 
50 template<class ParcelType>
51 inline const Foam::IOdictionary&
53 {
54  return particleProperties_;
55 }
56 
57 
58 template<class ParcelType>
59 inline const Foam::List<Foam::word>&
61 {
62  return typeIdList_;
63 }
64 
65 
66 template<class ParcelType>
67 inline Foam::scalar Foam::DSMCCloud<ParcelType>::nParticle() const
68 {
69  return nParticle_;
70 }
71 
72 
73 template<class ParcelType>
76 {
77  return cellOccupancy_;
78 }
79 
80 
81 template<class ParcelType>
83 {
84  return sigmaTcRMax_;
85 }
86 
87 
88 template<class ParcelType>
89 inline Foam::scalarField&
91 {
92  return collisionSelectionRemainder_;
93 }
94 
95 
96 template<class ParcelType>
99 {
100  return constProps_;
101 }
102 
103 
104 template<class ParcelType>
105 inline const typename ParcelType::constantProperties&
107 (
108  label typeId
109 ) const
110 {
111  if (typeId < 0 || typeId >= constProps_.size())
112  {
114  << "constantProperties for requested typeId index "
115  << typeId << " do not exist" << nl
116  << abort(FatalError);
117  }
118 
119  return constProps_[typeId];
120 }
121 
122 
123 template<class ParcelType>
125 {
126  return rndGen_;
127 }
128 
129 
130 template<class ParcelType>
133 {
134  return q_.boundaryFieldRef();
135 }
136 
137 
138 template<class ParcelType>
141 {
142  return fD_.boundaryFieldRef();
143 }
144 
145 
146 template<class ParcelType>
149 {
150  return rhoN_.boundaryFieldRef();
151 }
152 
153 
154 template<class ParcelType>
157 {
158  return rhoM_.boundaryFieldRef();
159 }
160 
161 
162 template<class ParcelType>
165 {
166  return linearKE_.boundaryFieldRef();
167 }
168 
169 
170 template<class ParcelType>
173 {
174  return internalE_.boundaryFieldRef();
175 }
176 
177 
178 template<class ParcelType>
181 {
182  return iDof_.boundaryFieldRef();
183 }
184 
185 
186 template<class ParcelType>
189 {
190  return momentum_.boundaryFieldRef();
191 }
192 
193 
194 template<class ParcelType>
195 inline const Foam::volScalarField&
197 {
198  return boundaryT_;
199 }
200 
201 
202 template<class ParcelType>
203 inline const Foam::volVectorField&
205 {
206  return boundaryU_;
207 }
208 
209 
210 template<class ParcelType>
213 {
214  return binaryCollisionModel_;
215 }
216 
217 
218 template<class ParcelType>
221 {
222  return *binaryCollisionModel_;
223 }
224 
225 
226 template<class ParcelType>
229 {
230  return *wallInteractionModel_;
231 }
232 
233 
234 template<class ParcelType>
237 {
238  return *wallInteractionModel_;
239 }
240 
241 
242 template<class ParcelType>
245 {
246  return *inflowBoundaryModel_;
247 }
248 
249 
250 template<class ParcelType>
253 {
254  return *inflowBoundaryModel_;
255 }
256 
257 
258 template<class ParcelType>
259 inline Foam::scalar Foam::DSMCCloud<ParcelType>::massInSystem() const
260 {
261  scalar sysMass = 0.0;
262 
263  for (const ParcelType& p : *this)
264  {
265  const typename ParcelType::constantProperties& cP = constProps
266  (
267  p.typeId()
268  );
269 
270  sysMass += cP.mass();
271  }
272 
273  return nParticle_*sysMass;
274 }
275 
276 
277 template<class ParcelType>
279 {
280  vector linearMomentum(Zero);
281 
282  for (const ParcelType& p : *this)
283  {
284  const typename ParcelType::constantProperties& cP = constProps
285  (
286  p.typeId()
287  );
288 
289  linearMomentum += cP.mass()*p.U();
290  }
292  return nParticle_*linearMomentum;
293 }
294 
295 
296 template<class ParcelType>
297 inline Foam::scalar
299 {
300  scalar linearKineticEnergy = 0.0;
301 
302  for (const ParcelType& p : *this)
303  {
304  const typename ParcelType::constantProperties& cP = constProps
305  (
306  p.typeId()
307  );
308 
309  linearKineticEnergy += 0.5*cP.mass()*(p.U() & p.U());
310  }
312  return nParticle_*linearKineticEnergy;
313 }
314 
315 
316 template<class ParcelType>
317 inline Foam::scalar
319 {
320  scalar internalEnergy = 0.0;
321 
322  for (const ParcelType& p : *this)
323  {
324  internalEnergy += p.Ei();
325  }
327  return nParticle_*internalEnergy;
328 }
329 
330 
331 template<class ParcelType>
333 (
334  scalar temperature,
335  scalar mass
336 ) const
337 {
338  return
339  2.0*sqrt(2.0*physicoChemical::k.value()*temperature/(pi*mass));
340 }
341 
342 
343 template<class ParcelType>
345 (
346  scalarField temperature,
347  scalar mass
348 ) const
349 {
350  tmp<scalarField> tfld =
351  2.0*sqrt(2.0*physicoChemical::k.value()*temperature/(pi*mass));
352  return tfld();
353 }
354 
355 
356 template<class ParcelType>
358 (
359  scalar temperature,
360  scalar mass
361 ) const
362 {
363  return sqrt(3.0*physicoChemical::k.value()*temperature/mass);
364 }
365 
366 
367 template<class ParcelType>
369 (
370  scalarField temperature,
371  scalar mass
372 ) const
373 {
374  tmp<scalarField> tfld =
375  sqrt(3.0*physicoChemical::k.value()*temperature/mass);
376  return tfld();
377 }
378 
379 
380 template<class ParcelType>
381 inline Foam::scalar
383 (
384  scalar temperature,
385  scalar mass
386 ) const
387 {
388  return sqrt(2.0*physicoChemical::k.value()*temperature/mass);
389 }
390 
391 
392 template<class ParcelType>
393 inline Foam::scalarField
395 (
396  scalarField temperature,
397  scalar mass
398 ) const
399 {
401  sqrt(2.0*physicoChemical::k.value()*temperature/mass);
402  return tfld();
403 }
404 
405 
406 template<class ParcelType>
408 {
409  return q_;
410 }
411 
412 
413 template<class ParcelType>
415 {
416  return fD_;
417 }
418 
419 
420 template<class ParcelType>
421 inline const Foam::volScalarField&
423 {
424  return rhoN_;
425 }
426 
427 
428 template<class ParcelType>
430 {
431  return rhoM_;
432 }
433 
434 
435 template<class ParcelType>
436 inline const Foam::volScalarField&
438 {
439  return dsmcRhoN_;
440 }
441 
442 
443 template<class ParcelType>
444 inline const Foam::volScalarField&
446 {
447  return linearKE_;
448 }
449 
450 
451 template<class ParcelType>
452 inline const Foam::volScalarField&
454 {
455  return internalE_;
456 }
457 
458 
459 template<class ParcelType>
460 inline const Foam::volScalarField&
462 {
463  return iDof_;
464 }
465 
466 
467 template<class ParcelType>
469 {
470  return momentum_;
471 }
472 
473 
474 template<class ParcelType>
476 {
478 }
479 
480 
481 // ************************************************************************* //
Different types of constants.
const volVectorField & momentum() const
Return the momentum density field.
Definition: DSMCCloudI.H:461
const volScalarField & boundaryT() const
Return macroscopic temperature.
Definition: DSMCCloudI.H:189
const volScalarField & linearKE() const
Return the total linear kinetic energy (translational and.
Definition: DSMCCloudI.H:438
const volScalarField & dsmcRhoN() const
Return the field of number of DSMC particles.
Definition: DSMCCloudI.H:430
const List< word > & typeIdList() const
Return the idList.
Definition: DSMCCloudI.H:53
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:598
vector linearMomentumOfSystem() const
Total linear momentum of the system.
Definition: DSMCCloudI.H:271
const word & cloudName() const
Return the cloud type.
Definition: DSMCCloudI.H:30
Templated inflow boundary model class.
Definition: DSMCCloud.H:60
const BinaryCollisionModel< DSMCCloud< ParcelType > > & binaryCollision() const
Return reference to binary elastic collision model.
Definition: DSMCCloudI.H:205
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
volScalarField::Boundary & rhoMBF()
Return non-const mass density boundary field reference.
Definition: DSMCCloudI.H:149
Templated DSMC particle collision class.
Definition: DSMCCloud.H:54
dimensionedScalar sqrt(const dimensionedScalar &ds)
scalar massInSystem() const
Total mass in system.
Definition: DSMCCloudI.H:252
volScalarField::Boundary & iDofBF()
Return non-const internal degree of freedom density boundary.
Definition: DSMCCloudI.H:173
const InflowBoundaryModel< DSMCCloud< ParcelType > > & inflowBoundary() const
Return reference to wall interaction model.
Definition: DSMCCloudI.H:237
scalar maxwellianRMSSpeed(scalar temperature, scalar mass) const
RMS particle speed.
Definition: DSMCCloudI.H:351
volScalarField::Boundary & qBF()
Return non-const heat flux boundary field reference.
Definition: DSMCCloudI.H:125
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:50
const volScalarField & internalE() const
Return the internal energy density field.
Definition: DSMCCloudI.H:446
const volVectorField & boundaryU() const
Return macroscopic velocity.
Definition: DSMCCloudI.H:197
Mathematical constants.
A class for handling words, derived from Foam::string.
Definition: word.H:63
Random & rndGen()
Return reference to the random object.
Definition: DSMCCloudI.H:117
const volScalarField & q() const
Return heat flux at surface field.
Definition: DSMCCloudI.H:400
void clear()
Clear the contents of the list.
Definition: ILList.C:93
volScalarField::Boundary & linearKEBF()
Return non-const linear kinetic energy density boundary.
Definition: DSMCCloudI.H:157
volVectorField::Boundary & fDBF()
Return non-const force density at boundary field reference.
Definition: DSMCCloudI.H:133
constexpr scalar pi(M_PI)
Vector< scalar > vector
Definition: vector.H:57
errorManip< error > abort(error &err)
Definition: errorManip.H:139
scalar maxwellianMostProbableSpeed(scalar temperature, scalar mass) const
Most probable speed.
Definition: DSMCCloudI.H:376
volScalarField::Boundary & internalEBF()
Return non-const internal energy density boundary field.
Definition: DSMCCloudI.H:165
Random number generator.
Definition: Random.H:55
const volScalarField & rhoM() const
Return the particle mass density field.
Definition: DSMCCloudI.H:422
void clear()
Clear the Cloud.
Definition: DSMCCloudI.H:468
const volScalarField & rhoN() const
Return the real particle number density field.
Definition: DSMCCloudI.H:415
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
scalar linearKineticEnergyOfSystem() const
Total linear kinetic energy in the system.
Definition: DSMCCloudI.H:291
scalar nParticle() const
Return the number of real particles represented by one.
Definition: DSMCCloudI.H:60
const volScalarField & iDof() const
Return the average internal degrees of freedom field.
Definition: DSMCCloudI.H:454
const fvMesh & mesh() const
Return reference to the mesh.
Definition: DSMCCloudI.H:37
const dimensionedScalar k
Boltzmann constant.
const volVectorField & fD() const
Return force density at surface field.
Definition: DSMCCloudI.H:407
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
scalar internalEnergyOfSystem() const
Total internal energy in the system.
Definition: DSMCCloudI.H:311
const List< DynamicList< ParcelType * > > & cellOccupancy() const
Return the cell occupancy addressing.
Definition: DSMCCloudI.H:68
volScalarField::Boundary & rhoNBF()
Return non-const number density boundary field reference.
Definition: DSMCCloudI.H:141
const WallInteractionModel< DSMCCloud< ParcelType > > & wallInteraction() const
Return reference to wall interaction model.
Definition: DSMCCloudI.H:221
const IOdictionary & particleProperties() const
Return particle properties dictionary.
Definition: DSMCCloudI.H:45
volScalarField & sigmaTcRMax()
Return the sigmaTcRMax field. non-const access to allow.
Definition: DSMCCloudI.H:75
volScalarField & p
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Templated wall interaction model class.
Definition: DSMCCloud.H:57
scalarField & collisionSelectionRemainder()
Return the collision selection remainder field. non-const.
Definition: DSMCCloudI.H:83
scalar maxwellianAverageSpeed(scalar temperature, scalar mass) const
Average particle speed.
Definition: DSMCCloudI.H:326
const List< typename ParcelType::constantProperties > & constProps() const
Return all of the constant properties.
Definition: DSMCCloudI.H:91
volVectorField::Boundary & momentumBF()
Return non-const momentum density boundary field reference.
Definition: DSMCCloudI.H:181
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127