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 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>
259 inline const Foam::integrationScheme&
261 {
262  return *UIntegrator_;
263 }
264 
265 
266 template<class CloudType>
268 {
269  scalar sysMass = 0.0;
270  for (const parcelType& p : *this)
271  {
272  sysMass += p.nParticle()*p.mass();
273  }
274 
275  return sysMass;
276 }
277 
278 
279 template<class CloudType>
280 inline Foam::vector
282 {
283  vector linearMomentum(Zero);
284 
285  for (const parcelType& p : *this)
286  {
287  linearMomentum += p.nParticle()*p.mass()*p.U();
288  }
289 
290  return linearMomentum;
291 }
292 
293 
294 template<class CloudType>
295 inline Foam::scalar
297 {
298  scalar parPerParcel = 0;
299 
300  for (const parcelType& p : *this)
301  {
302  parPerParcel += p.nParticle();
303  }
304 
305  return parPerParcel;
306 }
307 
308 
309 template<class CloudType>
310 inline Foam::scalar
312 {
313  scalar linearKineticEnergy = 0;
314 
315  for (const parcelType& p : *this)
316  {
317  linearKineticEnergy += p.nParticle()*0.5*p.mass()*(p.U() & p.U());
318  }
319 
320  return linearKineticEnergy;
321 }
322 
323 
324 template<class CloudType>
325 inline Foam::scalar Foam::KinematicCloud<CloudType>::Dij
326 (
327  const label i,
328  const label j
329 ) const
330 {
331  scalar si = 0.0;
332  scalar sj = 0.0;
333  for (const parcelType& p : *this)
334  {
335  si += p.nParticle()*pow(p.d(), i);
336  sj += p.nParticle()*pow(p.d(), j);
337  }
338 
339  reduce(si, sumOp<scalar>());
340  reduce(sj, sumOp<scalar>());
341  sj = max(sj, VSMALL);
342 
343  return si/sj;
344 }
345 
346 
347 template<class CloudType>
348 inline Foam::scalar Foam::KinematicCloud<CloudType>::Dmax() const
349 {
350  scalar d = -GREAT;
351  for (const parcelType& p : *this)
352  {
353  d = max(d, p.d());
354  }
355 
356  reduce(d, maxOp<scalar>());
357 
358  return max(0.0, d);
359 }
360 
361 
362 template<class CloudType>
364 {
365  return rndGen_;
366 }
367 
368 
369 template<class CloudType>
372 {
373  if (cellOccupancyPtr_.empty())
374  {
375  buildCellOccupancy();
376  }
377 
378  return *cellOccupancyPtr_;
379 }
380 
381 
382 template<class CloudType>
383 inline const Foam::scalarField&
385 {
386  return cellLengthScale_;
387 }
388 
389 
390 template<class CloudType>
393 {
394  return *UTrans_;
395 }
396 
397 
398 template<class CloudType>
401 {
402  return *UTrans_;
403 }
404 
405 
406 template<class CloudType>
409 {
410  return *UCoeff_;
411 }
412 
413 
414 template<class CloudType>
417 {
418  return *UCoeff_;
419 }
420 
421 
422 template<class CloudType>
425 {
426  if (debug)
427  {
428  Info<< "UTrans min/max = " << min(UTrans()).value() << ", "
429  << max(UTrans()).value() << nl
430  << "UCoeff min/max = " << min(UCoeff()).value() << ", "
431  << max(UCoeff()).value() << endl;
432  }
433 
434  if (solution_.coupled())
435  {
436  if (solution_.semiImplicit("U"))
437  {
439  Vdt(mesh_.V()*this->db().time().deltaT());
440 
441  return UTrans()/Vdt - fvm::Sp(UCoeff()/Vdt, U) + UCoeff()/Vdt*U;
442  }
443  else
444  {
446  fvVectorMatrix& fvm = tfvm.ref();
447 
448  fvm.source() = -UTrans()/(this->db().time().deltaT());
449 
450  return tfvm;
451  }
452  }
453 
455 }
456 
457 
458 template<class CloudType>
461 {
462  tmp<volScalarField> tvDotSweep
463  (
464  new volScalarField
465  (
466  IOobject
467  (
468  this->name() + ":vDotSweep",
469  this->db().time().timeName(),
470  this->db(),
471  IOobject::NO_READ,
472  IOobject::NO_WRITE,
473  false
474  ),
475  mesh_,
477  extrapolatedCalculatedFvPatchScalarField::typeName
478  )
479  );
480 
481  volScalarField& vDotSweep = tvDotSweep.ref();
482  for (const parcelType& p : *this)
483  {
484  const label celli = p.cell();
485 
486  vDotSweep[celli] += p.nParticle()*p.areaP()*mag(p.U() - U_[celli]);
487  }
488 
489  vDotSweep.primitiveFieldRef() /= mesh_.V();
490  vDotSweep.correctBoundaryConditions();
491 
492  return tvDotSweep;
493 }
494 
495 
496 template<class CloudType>
499 {
500  tmp<volScalarField> ttheta
501  (
502  new volScalarField
503  (
504  IOobject
505  (
506  this->name() + ":theta",
507  this->db().time().timeName(),
508  this->db(),
509  IOobject::NO_READ,
510  IOobject::NO_WRITE,
511  false
512  ),
513  mesh_,
515  extrapolatedCalculatedFvPatchScalarField::typeName
516  )
517  );
518 
519  volScalarField& theta = ttheta.ref();
520  for (const parcelType& p : *this)
521  {
522  const label celli = p.cell();
523 
524  theta[celli] += p.nParticle()*p.volume();
525  }
526 
527  theta.primitiveFieldRef() /= mesh_.V();
529 
530  return ttheta;
531 }
532 
533 
534 template<class CloudType>
537 {
538  tmp<volScalarField> talpha
539  (
540  new volScalarField
541  (
542  IOobject
543  (
544  this->name() + ":alpha",
545  this->db().time().timeName(),
546  this->db(),
547  IOobject::NO_READ,
548  IOobject::NO_WRITE,
549  false
550  ),
551  mesh_,
553  )
554  );
555 
556  scalarField& alpha = talpha.ref().primitiveFieldRef();
557  for (const parcelType& p : *this)
558  {
559  const label celli = p.cell();
560 
561  alpha[celli] += p.nParticle()*p.mass();
562  }
563 
564  alpha /= (mesh_.V()*rho_);
565 
566  return talpha;
567 }
568 
569 
570 template<class CloudType>
573 {
574  tmp<volScalarField> trhoEff
575  (
576  new volScalarField
577  (
578  IOobject
579  (
580  this->name() + ":rhoEff",
581  this->db().time().timeName(),
582  this->db(),
583  IOobject::NO_READ,
584  IOobject::NO_WRITE,
585  false
586  ),
587  mesh_,
589  )
590  );
591 
592  scalarField& rhoEff = trhoEff.ref().primitiveFieldRef();
593  for (const parcelType& p : *this)
594  {
595  const label celli = p.cell();
596 
597  rhoEff[celli] += p.nParticle()*p.mass();
598  }
599 
600  rhoEff /= mesh_.V();
601 
602  return trhoEff;
603 }
604 
605 
606 // ************************************************************************* //
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:260
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:59
Foam::DispersionModel
Base class for dispersion modelling.
Definition: KinematicCloud.H:86
Foam::Zero
static constexpr const zero Zero
Global zero.
Definition: zero.H:128
Foam::dimDensity
const dimensionSet dimDensity
Foam::KinematicCloud::totalParticlePerParcel
scalar totalParticlePerParcel() const
Average particle per parcel.
Definition: KinematicCloudI.H:296
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:424
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:267
Foam::KinematicCloud::rhoEff
const tmp< volScalarField > rhoEff() const
Return the particle effective density field.
Definition: KinematicCloudI.H:572
Sp
zeroField Sp
Definition: alphaSuSp.H:2
Foam::KinematicCloud::UCoeff
volScalarField::Internal & UCoeff()
Return coefficient for carrier phase U equation.
Definition: KinematicCloudI.H:408
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:337
Foam::KinematicCloud::UTrans
volVectorField::Internal & UTrans()
Return reference to momentum source.
Definition: KinematicCloudI.H:392
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:460
SortableList.H
Foam::dimTime
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:54
Foam::reduce
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
Definition: PstreamReduceOps.H:51
Foam::KinematicCloud
Templated base class for kinematic cloud.
Definition: KinematicCloud.H:103
Foam::PatchInteractionModel
Templated patch interaction model class.
Definition: KinematicCloud.H:89
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:258
Foam::fvVectorMatrix
fvMatrix< vector > fvVectorMatrix
Definition: fvMatricesFwd.H:47
Foam::StochasticCollisionModel
Templated stochastic collision model class.
Definition: KinematicCloud.H:95
Foam::label
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:62
Foam::Field< scalar >
Foam::KinematicCloud::cellOccupancy
List< DynamicList< parcelType * > > & cellOccupancy()
Return the cell occupancy information for each.
Definition: KinematicCloudI.H:371
Foam::SurfaceFilmModel
Templated wall surface film model class.
Definition: KinematicCloud.H:92
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
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::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::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
Foam::dimensioned< vector >
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:84
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:735
Foam::GeometricField::correctBoundaryConditions
void correctBoundaryConditions()
Correct boundary field.
Definition: GeometricField.C:909
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:363
U
U
Definition: pEqn.H:72
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:372
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: HashTable.H:102
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:295
Foam::KinematicCloud::theta
const tmp< volScalarField > theta() const
Return the particle volume fraction field.
Definition: KinematicCloudI.H:498
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:326
Foam::KinematicCloud::subModelProperties
const dictionary & subModelProperties() const
Return reference to the sub-models dictionary.
Definition: KinematicCloudI.H:105
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:311
Foam::GeometricField< scalar, fvPatchField, volMesh >
Foam::KinematicCloud::linearMomentumOfSystem
vector linearMomentumOfSystem() const
Total linear momentum of the system.
Definition: KinematicCloudI.H:281
Foam::KinematicCloud::Dmax
scalar Dmax() const
Max diameter.
Definition: KinematicCloudI.H:348
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:536
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:384