KinematicCloudI.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-2017 OpenFOAM Foundation
9  Copyright (C) 2019-2020 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 "fvmSup.H"
30 #include "SortableList.H"
31 
32 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
33 
34 template<class CloudType>
37 {
38  return *cloudCopyPtr_;
39 }
40 
41 
42 template<class CloudType>
44 {
45  return mesh_;
46 }
47 
48 
49 template<class CloudType>
50 inline const Foam::IOdictionary&
52 {
53  return particleProperties_;
54 }
55 
56 
57 template<class CloudType>
58 inline const Foam::IOdictionary&
60 {
61  return outputProperties_;
62 }
63 
64 
65 template<class CloudType>
67 {
68  return outputProperties_;
69 }
70 
71 
72 template<class CloudType>
73 inline const Foam::cloudSolution&
75 {
76  return solution_;
77 }
78 
79 
80 template<class CloudType>
82 {
83  return solution_;
84 }
85 
86 
87 template<class CloudType>
88 inline const typename CloudType::particleType::constantProperties&
90 {
91  return constProps_;
92 }
93 
94 
95 template<class CloudType>
96 inline typename CloudType::particleType::constantProperties&
98 {
99  return constProps_;
100 }
101 
102 
103 template<class CloudType>
104 inline const Foam::dictionary&
106 {
107  return subModelProperties_;
108 }
109 
110 
111 template<class CloudType>
113 {
114  return rho_;
115 }
116 
117 
118 template<class CloudType>
120 {
121  return U_;
122 }
123 
124 
125 template<class CloudType>
127 {
128  return mu_;
129 }
130 
131 
132 template<class CloudType>
134 {
135  return g_;
136 }
137 
138 
139 template<class CloudType>
140 inline Foam::scalar Foam::KinematicCloud<CloudType>::pAmbient() const
141 {
142  return pAmbient_;
143 }
144 
145 
146 template<class CloudType>
148 {
149  return pAmbient_;
150 }
151 
152 
153 template<class CloudType>
154 //inline const typename CloudType::parcelType::forceType&
155 inline const typename Foam::KinematicCloud<CloudType>::forceType&
157 {
158  return forces_;
159 }
160 
161 
162 template<class CloudType>
165 {
166  return forces_;
167 }
168 
169 
170 template<class CloudType>
173 {
174  return functions_;
175 }
176 
177 
178 template<class CloudType>
181 {
182  return injectors_;
183 }
184 
185 
186 template<class CloudType>
189 {
190  return injectors_;
191 }
192 
193 
194 template<class CloudType>
197 {
198  return *dispersionModel_;
199 }
200 
201 
202 template<class CloudType>
205 {
206  return *dispersionModel_;
207 }
208 
209 
210 template<class CloudType>
213 {
214  return *patchInteractionModel_;
215 }
216 
217 
218 template<class CloudType>
221 {
222  return *patchInteractionModel_;
223 }
224 
225 
226 template<class CloudType>
229 {
230  return *stochasticCollisionModel_;
231 }
232 
233 
234 template<class CloudType>
237 {
238  return *stochasticCollisionModel_;
239 }
240 
241 
242 template<class CloudType>
245 {
246  return *surfaceFilmModel_;
247 }
248 
249 
250 template<class CloudType>
253 {
254  return *surfaceFilmModel_;
255 }
256 
257 
258 template<class CloudType>
261 {
262  return *packingModel_;
263 }
264 
265 
266 template<class CloudType>
269 {
270  return *packingModel_;
271 }
272 
273 
274 template<class CloudType>
277 {
278  return *dampingModel_;
279 }
280 
281 
282 template<class CloudType>
285 {
286  return *dampingModel_;
287 }
288 
289 
290 template<class CloudType>
293 {
294  return *isotropyModel_;
295 }
296 
297 
298 template<class CloudType>
301 {
302  return *isotropyModel_;
303 }
304 
305 
306 template<class CloudType>
307 inline const Foam::integrationScheme&
309 {
310  return *UIntegrator_;
311 }
312 
313 
314 template<class CloudType>
316 {
317  scalar sysMass = 0.0;
318  for (const parcelType& p : *this)
319  {
320  sysMass += p.nParticle()*p.mass();
321  }
322 
323  return sysMass;
324 }
325 
326 
327 template<class CloudType>
328 inline Foam::vector
330 {
331  vector linearMomentum(Zero);
332 
333  for (const parcelType& p : *this)
334  {
335  linearMomentum += p.nParticle()*p.mass()*p.U();
336  }
337 
338  return linearMomentum;
339 }
340 
341 
342 template<class CloudType>
343 inline Foam::scalar
345 {
346  scalar parPerParcel = 0;
347 
348  for (const parcelType& p : *this)
349  {
350  parPerParcel += p.nParticle();
351  }
352 
353  return parPerParcel;
354 }
355 
356 
357 template<class CloudType>
358 inline Foam::scalar
360 {
361  scalar linearKineticEnergy = 0;
362 
363  for (const parcelType& p : *this)
364  {
365  linearKineticEnergy += p.nParticle()*0.5*p.mass()*(p.U() & p.U());
366  }
367 
368  return linearKineticEnergy;
369 }
370 
371 
372 template<class CloudType>
373 inline Foam::scalar Foam::KinematicCloud<CloudType>::Dij
374 (
375  const label i,
376  const label j
377 ) const
378 {
379  scalar si = 0.0;
380  scalar sj = 0.0;
381  for (const parcelType& p : *this)
382  {
383  si += p.nParticle()*pow(p.d(), i);
384  sj += p.nParticle()*pow(p.d(), j);
385  }
386 
387  reduce(si, sumOp<scalar>());
388  reduce(sj, sumOp<scalar>());
389  sj = max(sj, VSMALL);
390 
391  return si/sj;
392 }
393 
394 
395 template<class CloudType>
396 inline Foam::scalar Foam::KinematicCloud<CloudType>::Dmax() const
397 {
398  scalar d = -GREAT;
399  for (const parcelType& p : *this)
400  {
401  d = max(d, p.d());
402  }
403 
404  reduce(d, maxOp<scalar>());
405 
406  return max(0.0, d);
407 }
408 
409 
410 template<class CloudType>
412 {
413  return rndGen_;
414 }
415 
416 
417 template<class CloudType>
420 {
421  if (!cellOccupancyPtr_)
422  {
423  buildCellOccupancy();
424  }
425 
426  return *cellOccupancyPtr_;
427 }
428 
429 
430 template<class CloudType>
431 inline const Foam::scalarField&
433 {
434  return cellLengthScale_;
435 }
436 
437 
438 template<class CloudType>
441 {
442  return *UTrans_;
443 }
444 
445 
446 template<class CloudType>
449 {
450  return *UTrans_;
451 }
452 
453 
454 template<class CloudType>
457 {
458  return *UCoeff_;
459 }
460 
461 
462 template<class CloudType>
465 {
466  return *UCoeff_;
467 }
468 
469 
470 template<class CloudType>
473 {
474  if (debug)
475  {
476  Pout<< "UTrans min/max = " << min(UTrans()).value() << ", "
477  << max(UTrans()).value() << nl
478  << "UCoeff min/max = " << min(UCoeff()).value() << ", "
479  << max(UCoeff()).value() << endl;
480  }
481 
482  if (solution_.coupled())
483  {
484  if (solution_.semiImplicit("U"))
485  {
487  Vdt(mesh_.V()*this->db().time().deltaT());
488 
489  return UTrans()/Vdt - fvm::Sp(UCoeff()/Vdt, U) + UCoeff()/Vdt*U;
490  }
491  else
492  {
494  fvVectorMatrix& fvm = tfvm.ref();
495 
496  fvm.source() = -UTrans()/(this->db().time().deltaT());
497 
498  return tfvm;
499  }
500  }
501 
503 }
504 
505 
506 template<class CloudType>
509 {
510  tmp<volScalarField> tvDotSweep
511  (
512  new volScalarField
513  (
514  IOobject
515  (
516  this->name() + ":vDotSweep",
517  this->db().time().timeName(),
518  this->db(),
519  IOobject::NO_READ,
520  IOobject::NO_WRITE,
521  false
522  ),
523  mesh_,
525  extrapolatedCalculatedFvPatchScalarField::typeName
526  )
527  );
528 
529  volScalarField& vDotSweep = tvDotSweep.ref();
530  for (const parcelType& p : *this)
531  {
532  const label celli = p.cell();
533 
534  vDotSweep[celli] += p.nParticle()*p.areaP()*mag(p.U() - U_[celli]);
535  }
536 
537  vDotSweep.primitiveFieldRef() /= mesh_.V();
538  vDotSweep.correctBoundaryConditions();
539 
540  return tvDotSweep;
541 }
542 
543 
544 template<class CloudType>
547 {
548  tmp<volScalarField> ttheta
549  (
550  new volScalarField
551  (
552  IOobject
553  (
554  this->name() + ":theta",
555  this->db().time().timeName(),
556  this->db(),
557  IOobject::NO_READ,
558  IOobject::NO_WRITE,
559  false
560  ),
561  mesh_,
563  extrapolatedCalculatedFvPatchScalarField::typeName
564  )
565  );
566 
567  volScalarField& theta = ttheta.ref();
568  for (const parcelType& p : *this)
569  {
570  const label celli = p.cell();
571 
572  theta[celli] += p.nParticle()*p.volume();
573  }
574 
575  theta.primitiveFieldRef() /= mesh_.V();
577 
578  return ttheta;
579 }
580 
581 
582 template<class CloudType>
585 {
586  tmp<volScalarField> talpha
587  (
588  new volScalarField
589  (
590  IOobject
591  (
592  this->name() + ":alpha",
593  this->db().time().timeName(),
594  this->db(),
595  IOobject::NO_READ,
596  IOobject::NO_WRITE,
597  false
598  ),
599  mesh_,
601  )
602  );
603 
604  scalarField& alpha = talpha.ref().primitiveFieldRef();
605  for (const parcelType& p : *this)
606  {
607  const label celli = p.cell();
608 
609  alpha[celli] += p.nParticle()*p.mass();
610  }
611 
612  alpha /= (mesh_.V()*rho_);
613 
614  return talpha;
615 }
616 
617 
618 template<class CloudType>
621 {
622  tmp<volScalarField> trhoEff
623  (
624  new volScalarField
625  (
626  IOobject
627  (
628  this->name() + ":rhoEff",
629  this->db().time().timeName(),
630  this->db(),
631  IOobject::NO_READ,
632  IOobject::NO_WRITE,
633  false
634  ),
635  mesh_,
637  )
638  );
639 
640  scalarField& rhoEff = trhoEff.ref().primitiveFieldRef();
641  for (const parcelType& p : *this)
642  {
643  const label celli = p.cell();
644 
645  rhoEff[celli] += p.nParticle()*p.mass();
646  }
647 
648  rhoEff /= mesh_.V();
649 
650  return trhoEff;
651 }
652 
653 
654 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:54
Foam::KinematicCloud::dispersion
const DispersionModel< KinematicCloud< CloudType > > & dispersion() const
Return const-access to the dispersion model.
Definition: KinematicCloudI.H:196
Foam::Random
Random number generator.
Definition: Random.H:59
Foam::maxOp
Definition: ops.H:223
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
Foam::KinematicCloud::UIntegrator
const integrationScheme & UIntegrator() const
Return reference to velocity integration.
Definition: KinematicCloudI.H:308
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::KinematicCloud::outputProperties
const IOdictionary & outputProperties() const
Return output properties dictionary.
Definition: KinematicCloudI.H:59
Foam::dimless
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Dimensionless.
Definition: dimensionSets.H:50
Foam::KinematicCloud::functions
functionType & functions()
Optional cloud function objects.
Definition: KinematicCloudI.H:172
Foam::KinematicCloud::pAmbient
scalar pAmbient() const
Return const-access to the ambient pressure.
Definition: KinematicCloudI.H:140
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::DispersionModel
Base class for dispersion modelling.
Definition: KinematicCloud.H:86
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::dimDensity
const dimensionSet dimDensity
Foam::KinematicCloud::totalParticlePerParcel
scalar totalParticlePerParcel() const
Average particle per parcel.
Definition: KinematicCloudI.H:344
Foam::KinematicCloud::mesh
const fvMesh & mesh() const
Return reference to the mesh.
Definition: KinematicCloudI.H:43
Foam::KinematicCloud::SU
tmp< fvVectorMatrix > SU(volVectorField &U) const
Return tmp momentum source term.
Definition: KinematicCloudI.H:472
Foam::constant::atomic::alpha
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Definition: readThermalProperties.H:212
Foam::KinematicCloud::mu
const volScalarField & mu() const
Return carrier gas dynamic viscosity.
Definition: KinematicCloudI.H:126
Foam::KinematicCloud::massInSystem
scalar massInSystem() const
Total mass in system.
Definition: KinematicCloudI.H:315
Foam::KinematicCloud::rhoEff
const tmp< volScalarField > rhoEff() const
Return the particle effective density field.
Definition: KinematicCloudI.H:620
Foam::KinematicCloud::dampingModel
const DampingModel< KinematicCloud< CloudType > > & dampingModel() const
Return const access to the damping model.
Definition: KinematicCloudI.H:276
Sp
zeroField Sp
Definition: alphaSuSp.H:2
Foam::KinematicCloud::UCoeff
volScalarField::Internal & UCoeff()
Return coefficient for carrier phase U equation.
Definition: KinematicCloudI.H:456
Foam::KinematicCloud::cloudCopy
const KinematicCloud & cloudCopy() const
Return a reference to the cloud copy.
Definition: KinematicCloudI.H:36
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
Foam::KinematicCloud::UTrans
volVectorField::Internal & UTrans()
Return reference to momentum source.
Definition: KinematicCloudI.H:440
Foam::DampingModel
Base class for collisional damping models.
Definition: KinematicCloud.H:101
Foam::Pout
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
Foam::dimForce
const dimensionSet dimForce
Foam::integrationScheme
Base for a set of schemes which integrate simple ODEs which arise from semi-implcit rate expressions.
Definition: integrationScheme.H:90
Foam::min
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
Foam::sumOp
Definition: ops.H:213
Foam::KinematicCloud::forces
const forceType & forces() const
Optional particle forces.
Definition: KinematicCloudI.H:156
Foam::KinematicCloud::stochasticCollision
const StochasticCollisionModel< KinematicCloud< CloudType > > & stochasticCollision() const
Return const-access to the stochastic collision model.
Definition: KinematicCloudI.H:228
Foam::KinematicCloud::constProps
const parcelType::constantProperties & constProps() const
Return the constant properties.
Definition: KinematicCloudI.H:89
Foam::KinematicCloud::vDotSweep
const tmp< volScalarField > vDotSweep() const
Volume swept rate of parcels per cell.
Definition: KinematicCloudI.H:508
SortableList.H
Foam::dimTime
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:54
Foam::KinematicCloud
Templated base class for kinematic cloud.
Definition: KinematicCloud.H:112
Foam::PatchInteractionModel
Templated patch interaction model class.
Definition: KinematicCloud.H:89
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:228
Foam::fvVectorMatrix
fvMatrix< vector > fvVectorMatrix
Definition: fvMatricesFwd.H:47
Foam::StochasticCollisionModel
Templated stochastic collision model class.
Definition: KinematicCloud.H:95
Foam::Field< scalar >
Foam::KinematicCloud::cellOccupancy
List< DynamicList< parcelType * > > & cellOccupancy()
Return the cell occupancy information for each.
Definition: KinematicCloudI.H:419
Foam::SurfaceFilmModel
Templated wall surface film model class.
Definition: KinematicCloud.H:92
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
Foam::cloudSolution
Stores all relevant solution info for cloud.
Definition: cloudSolution.H:53
Foam::CollidingParcel
Wrapper around kinematic parcel types to add collision modelling.
Definition: CollidingParcel.H:61
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:43
Foam::KinematicCloud::packingModel
const PackingModel< KinematicCloud< CloudType > > & packingModel() const
Return const access to the packing model.
Definition: KinematicCloudI.H:260
Foam::pow
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Definition: dimensionedScalar.C:75
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
timeName
word timeName
Definition: getTimeIndex.H:3
Foam::PackingModel
Base class for packing models.
Definition: KinematicCloud.H:98
Foam::KinematicCloud::solution
const cloudSolution & solution() const
Return const access to the solution properties.
Definition: KinematicCloudI.H:74
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
reduce
reduce(hasMovingMesh, orOp< bool >())
Foam::dimensioned< vector >
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:83
Foam::KinematicCloud::particleProperties
const IOdictionary & particleProperties() const
Return particle properties dictionary.
Definition: KinematicCloudI.H:51
fvmSup.H
Calculate the matrix for implicit and explicit sources.
Foam::CloudFunctionObjectList< KinematicCloud< CloudType > >
Foam::GeometricField::primitiveFieldRef
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field.
Definition: GeometricField.C:766
Foam::GeometricField::correctBoundaryConditions
void correctBoundaryConditions()
Correct boundary field.
Definition: GeometricField.C:940
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
Foam::KinematicCloud::rndGen
Random & rndGen() const
Return reference to the random object.
Definition: KinematicCloudI.H:411
U
U
Definition: pEqn.H:72
Foam::KinematicCloud::isotropyModel
const IsotropyModel< KinematicCloud< CloudType > > & isotropyModel() const
Return const access to the isotropy model.
Definition: KinematicCloudI.H:292
Foam::KinematicCloud::patchInteraction
const PatchInteractionModel< KinematicCloud< CloudType > > & patchInteraction() const
Return const-access to the patch interaction model.
Definition: KinematicCloudI.H:212
Foam::nl
constexpr char nl
Definition: Ostream.H:385
Foam::Vector< scalar >
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::KinematicCloud::g
const dimensionedVector & g() const
Gravity.
Definition: KinematicCloudI.H:133
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::fvMatrix::source
Field< Type > & source()
Definition: fvMatrix.H:297
Foam::KinematicCloud::theta
const tmp< volScalarField > theta() const
Return the particle volume fraction field.
Definition: KinematicCloudI.H:546
Foam::KinematicCloud::injectors
const InjectionModelList< KinematicCloud< CloudType > > & injectors() const
Return const access to the injection model.
Definition: KinematicCloudI.H:180
Foam::fvMatrix
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvPatchField.H:76
Foam::KinematicCloud::Dij
scalar Dij(const label i, const label j) const
Mean diameter Dij.
Definition: KinematicCloudI.H:374
Foam::KinematicCloud::subModelProperties
const dictionary & subModelProperties() const
Return reference to the sub-models dictionary.
Definition: KinematicCloudI.H:105
Foam::IsotropyModel
Base class for collisional return-to-isotropy models.
Definition: KinematicCloud.H:104
Foam::KinematicCloud::U
const volVectorField & U() const
Return carrier gas velocity.
Definition: KinematicCloudI.H:119
Foam::KinematicCloud::linearKineticEnergyOfSystem
scalar linearKineticEnergyOfSystem() const
Total linear kinetic energy in the system.
Definition: KinematicCloudI.H:359
Foam::GeometricField< scalar, fvPatchField, volMesh >
Foam::KinematicCloud::linearMomentumOfSystem
vector linearMomentumOfSystem() const
Total linear momentum of the system.
Definition: KinematicCloudI.H:329
Foam::KinematicCloud::Dmax
scalar Dmax() const
Max diameter.
Definition: KinematicCloudI.H:396
Foam::KinematicCloud::surfaceFilm
const SurfaceFilmModel< KinematicCloud< CloudType > > & surfaceFilm() const
Return const-access to the surface film model.
Definition: KinematicCloudI.H:244
Foam::ParticleForceList< KinematicCloud< CloudType > >
Foam::InjectionModelList
List of injection models.
Definition: KinematicCloud.H:83
Foam::KinematicCloud::alpha
const tmp< volScalarField > alpha() const
Return the particle mass fraction field.
Definition: KinematicCloudI.H:584
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54
Foam::KinematicCloud::rho
const volScalarField & rho() const
Return carrier gas density.
Definition: KinematicCloudI.H:112
Foam::KinematicCloud::cellLengthScale
const scalarField & cellLengthScale() const
Return the cell length scale.
Definition: KinematicCloudI.H:432