MomentumCloudI.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-2024 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 \*---------------------------------------------------------------------------*/
25 
26 #include "fvmSup.H"
27 
28 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
29 
30 template<class CloudType>
33 {
34  return cloudCopyPtr_();
35 }
36 
37 
38 template<class CloudType>
39 inline const Foam::IOdictionary&
41 {
42  return particleProperties_;
43 }
44 
45 
46 template<class CloudType>
47 inline const Foam::IOdictionary&
49 {
50  return outputProperties_;
51 }
52 
53 
54 template<class CloudType>
56 {
57  return outputProperties_;
58 }
59 
60 
61 template<class CloudType>
62 inline const Foam::cloudSolution&
64 {
65  return solution_;
66 }
67 
68 
69 template<class CloudType>
71 {
72  return solution_;
73 }
74 
75 
76 template<class CloudType>
77 inline const typename CloudType::particleType::constantProperties&
79 {
80  return constProps_;
81 }
82 
83 
84 template<class CloudType>
85 inline typename CloudType::particleType::constantProperties&
87 {
88  return constProps_;
89 }
90 
91 
92 template<class CloudType>
93 inline const Foam::dictionary&
95 {
96  return subModelProperties_;
97 }
98 
99 
100 template<class CloudType>
102 {
103  return rho_;
104 }
105 
106 
107 template<class CloudType>
109 {
110  return U_;
111 }
112 
113 
114 template<class CloudType>
116 {
117  return mu_;
118 }
119 
120 
121 template<class CloudType>
123 {
124  return g_;
125 }
126 
127 
128 template<class CloudType>
129 inline Foam::scalar Foam::MomentumCloud<CloudType>::pAmbient() const
130 {
131  return pAmbient_;
132 }
133 
134 
135 template<class CloudType>
137 {
138  return pAmbient_;
139 }
140 
141 
142 template<class CloudType>
143 //inline const typename CloudType::parcelType::forceType&
144 inline const typename Foam::MomentumCloud<CloudType>::forceType&
146 {
147  return forces_;
148 }
149 
150 
151 template<class CloudType>
154 {
155  return forces_;
156 }
157 
158 
159 template<class CloudType>
162 {
163  return functions_;
164 }
165 
166 
167 template<class CloudType>
170 {
171  return injectors_;
172 }
173 
174 
175 template<class CloudType>
178 {
179  return injectors_;
180 }
181 
182 
183 template<class CloudType>
186 {
187  return dispersionModel_;
188 }
189 
190 
191 template<class CloudType>
194 {
195  return dispersionModel_();
196 }
197 
198 
199 template<class CloudType>
202 {
203  return patchInteractionModel_;
204 }
205 
206 
207 template<class CloudType>
210 {
211  return patchInteractionModel_();
212 }
213 
214 
215 template<class CloudType>
218 {
219  return stochasticCollisionModel_();
220 }
221 
222 
223 template<class CloudType>
226 {
227  return stochasticCollisionModel_();
228 }
229 
230 
231 template<class CloudType>
234 {
235  return filmModel_();
236 }
237 
238 
239 template<class CloudType>
242 {
243  return filmModel_();
244 }
245 
246 
247 template<class CloudType>
248 inline const Foam::integrationScheme&
250 {
251  return UIntegrator_;
252 }
253 
254 
255 template<class CloudType>
257 {
258  return this->size();
259 }
260 
261 
262 template<class CloudType>
264 {
265  scalar sysMass = 0.0;
266  forAllConstIter(typename MomentumCloud<CloudType>, *this, iter)
267  {
268  const parcelType& p = iter();
269  sysMass += p.nParticle()*p.mass();
270  }
271 
272  return sysMass;
273 }
274 
275 
276 template<class CloudType>
277 inline Foam::vector
279 {
280  vector linearMomentum(Zero);
281 
282  forAllConstIter(typename MomentumCloud<CloudType>, *this, iter)
283  {
284  const parcelType& p = iter();
285 
286  linearMomentum += p.nParticle()*p.mass()*p.U();
287  }
288 
289  return linearMomentum;
290 }
291 
292 
293 template<class CloudType>
294 inline Foam::scalar
296 {
297  scalar linearKineticEnergy = 0.0;
298 
299  forAllConstIter(typename MomentumCloud<CloudType>, *this, iter)
300  {
301  const parcelType& p = iter();
302 
303  linearKineticEnergy += p.nParticle()*0.5*p.mass()*(p.U() & p.U());
304  }
305 
306  return linearKineticEnergy;
307 }
308 
309 
310 template<class CloudType>
312 (
313  const label i,
314  const label j
315 ) const
316 {
317  scalar si = 0.0;
318  scalar sj = 0.0;
319  forAllConstIter(typename MomentumCloud<CloudType>, *this, iter)
320  {
321  const parcelType& p = iter();
322  si += p.nParticle()*pow(p.d(), i);
323  sj += p.nParticle()*pow(p.d(), j);
324  }
325 
326  reduce(si, sumOp<scalar>());
327  reduce(sj, sumOp<scalar>());
328  sj = max(sj, vSmall);
329 
330  return si/sj;
331 }
332 
333 
334 template<class CloudType>
335 inline Foam::scalar Foam::MomentumCloud<CloudType>::Dmin() const
336 {
337  scalar d = vGreat;
338 
339  forAllConstIter(typename MomentumCloud<CloudType>, *this, iter)
340  {
341  d = min(d, iter().d());
342  }
343 
344  return returnReduce(d, minOp<scalar>());
345 }
346 
347 
348 template<class CloudType>
349 inline Foam::scalar Foam::MomentumCloud<CloudType>::Dmax() const
350 {
351  scalar d = -vGreat;
352 
353  forAllConstIter(typename MomentumCloud<CloudType>, *this, iter)
354  {
355  d = max(d, iter().d());
356  }
357 
358  return returnReduce(d, maxOp<scalar>());
359 }
360 
361 
362 template<class CloudType>
364 {
365  return rndGen_;
366 }
367 
368 
369 template<class CloudType>
372 {
373  return stdNormal_;
374 }
375 
376 
377 template<class CloudType>
380 {
381  if (cellOccupancyPtr_.empty())
382  {
383  buildCellOccupancy();
384  }
385 
386  return cellOccupancyPtr_();
387 }
388 
389 
390 template<class CloudType>
391 inline const Foam::scalarField&
393 {
394  return cellLengthScale_;
395 }
396 
397 
398 template<class CloudType>
401 {
402  return UTrans_();
403 }
404 
405 
406 template<class CloudType>
409 {
410  return UTrans_();
411 }
412 
413 
414 template<class CloudType>
417 {
418  return UCoeff_();
419 }
420 
421 
422 template<class CloudType>
425 {
426  return UCoeff_();
427 }
428 
429 
430 template<class CloudType>
433 {
434  if (debug)
435  {
436  Info<< "UTrans min/max = " << min(UTrans()).value() << ", "
437  << max(UTrans()).value() << nl
438  << "UCoeff min/max = " << min(UCoeff()).value() << ", "
439  << max(UCoeff()).value() << endl;
440  }
441 
442  if (solution_.coupled())
443  {
444  if (solution_.semiImplicit("U"))
445  {
447  Vdt(this->mesh().V()*this->db().time().deltaT());
448 
449  return UTrans()/Vdt - fvm::Sp(UCoeff()/Vdt, U) + UCoeff()/Vdt*U;
450  }
451  else
452  {
454  fvVectorMatrix& fvm = tfvm.ref();
455 
456  fvm.source() = -UTrans()/(this->db().time().deltaT());
457 
458  return tfvm;
459  }
460  }
461 
463 }
464 
465 
466 template<class CloudType>
469 {
470  tmp<volScalarField> tvDotSweep
471  (
473  (
474  this->name() + ":vDotSweep",
475  this->mesh(),
477  extrapolatedCalculatedFvPatchScalarField::typeName
478  )
479  );
480 
481  volScalarField& vDotSweep = tvDotSweep.ref();
482  forAllConstIter(typename MomentumCloud<CloudType>, *this, iter)
483  {
484  const parcelType& p = iter();
485  const label celli = p.cell();
486 
487  vDotSweep[celli] += p.nParticle()*p.areaP()*mag(p.U() - U_[celli]);
488  }
489 
490  vDotSweep.primitiveFieldRef() /= this->mesh().V();
491  vDotSweep.correctBoundaryConditions();
492 
493  return tvDotSweep;
494 }
495 
496 
497 template<class CloudType>
500 {
501  tmp<volScalarField> ttheta
502  (
504  (
505  this->name() + ":alpha",
506  this->mesh(),
508  extrapolatedCalculatedFvPatchScalarField::typeName
509  )
510  );
511 
512  volScalarField& alpha = ttheta.ref();
513  forAllConstIter(typename MomentumCloud<CloudType>, *this, iter)
514  {
515  const parcelType& p = iter();
516  const label celli = p.cell();
517 
518  alpha[celli] += p.nParticle()*p.volume();
519  }
520 
521  alpha.primitiveFieldRef() /= this->mesh().V();
522  alpha.correctBoundaryConditions();
523 
524  return ttheta;
525 }
526 
527 
528 template<class CloudType>
531 {
533  (
535  (
536  this->name() + ":Y",
537  this->mesh(),
539  )
540  );
541 
542  scalarField& Y = tY.ref().primitiveFieldRef();
543  forAllConstIter(typename MomentumCloud<CloudType>, *this, iter)
544  {
545  const parcelType& p = iter();
546  const label celli = p.cell();
547 
548  Y[celli] += p.nParticle()*p.mass();
549  }
550 
551  Y /= (this->mesh().V()*rho_);
552 
553  return tY;
554 }
555 
556 
557 template<class CloudType>
560 {
561  tmp<volScalarField> trhoEff
562  (
564  (
565  this->name() + ":rhoEff",
566  this->mesh(),
568  )
569  );
570 
571  scalarField& rhoEff = trhoEff.ref().primitiveFieldRef();
572  forAllConstIter(typename MomentumCloud<CloudType>, *this, iter)
573  {
574  const parcelType& p = iter();
575  const label celli = p.cell();
576 
577  rhoEff[celli] += p.nParticle()*p.mass();
578  }
579 
580  rhoEff /= this->mesh().V();
581 
582  return trhoEff;
583 }
584 
585 
586 // ************************************************************************* //
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:477
ParcelType parcelType
Type of parcel the cloud was instantiated for.
Definition: DSMCCloud.H:225
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Generic GeometricField class.
Internal::FieldType & primitiveFieldRef()
Return a reference to the primitive field.
void correctBoundaryConditions()
Correct boundary field.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:57
List of injection models.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:91
Templated base class for momentum cloud.
volScalarField::Internal & UCoeffRef()
Access coefficient for carrier phase U equation.
const parcelType::constantProperties & constProps() const
Return the constant properties.
const dictionary & subModelProperties() const
Return reference to the sub-models dictionary.
functionType & functions()
Optional cloud function objects.
const InjectionModelList< MomentumCloud< CloudType > > & injectors() const
Return const access to the injection model.
scalar massInSystem() const
Total mass in system.
const DispersionModel< MomentumCloud< CloudType > > & dispersion() const
Return const-access to the dispersion model.
const PatchInteractionModel< MomentumCloud< CloudType > > & patchInteraction() const
Return const-access to the patch interaction model.
const tmp< volScalarField > alpha() const
Return the particle volume fraction field.
const scalarField & cellLengthScale() const
Return the cell length scale.
tmp< volVectorField::Internal > UTrans() const
Return momentum source.
vector linearMomentumOfSystem() const
Total linear momentum of the system.
const volVectorField & U() const
Return carrier gas velocity.
scalar pAmbient() const
Return const-access to the ambient pressure.
const SurfaceFilmModel< MomentumCloud< CloudType > > & surfaceFilm() const
Return const-access to the surface film model.
const volScalarField & rho() const
Return carrier gas density.
distributions::standardNormal & stdNormal() const
Return reference to the standard normal distribution.
const integrationScheme & UIntegrator() const
Return reference to velocity integration.
tmp< volScalarField::Internal > UCoeff() const
Return coefficient for carrier phase U equation.
List< DynamicList< parcelType * > > & cellOccupancy()
Return the cell occupancy information for each.
label nParcels() const
Total number of parcels.
const tmp< volScalarField > rhoEff() const
Return the particle effective density field.
const cloudSolution & solution() const
Return const access to the solution properties.
scalar Dmin() const
Min diameter.
const tmp< volScalarField > vDotSweep() const
Volume swept rate of parcels per cell.
const StochasticCollisionModel< MomentumCloud< CloudType > > & stochasticCollision() const
Return const-access to the stochastic collision model.
volVectorField::Internal & UTransRef()
Access momentum source.
const forceType & forces() const
Optional particle forces.
const MomentumCloud & cloudCopy() const
Return a reference to the cloud copy.
scalar Dmax() const
Max diameter.
const tmp< volScalarField > Y() const
Return the particle mass fraction field.
scalar Dij(const label i, const label j) const
Mean diameter Dij.
const IOdictionary & particleProperties() const
Return particle properties dictionary.
const dimensionedVector & g() const
Gravity.
tmp< fvVectorMatrix > SU(const volVectorField &U) const
Return tmp momentum source term.
const IOdictionary & outputProperties() const
Return output properties dictionary.
scalar linearKineticEnergyOfSystem() const
Total linear kinetic energy in the system.
randomGenerator & rndGen() const
Return reference to the random generator.
const volScalarField & mu() const
Return carrier gas dynamic viscosity.
Templated patch interaction model class.
Templated stochastic collision model class.
Templated wall surface film model class.
Stores all relevant solution info for cloud.
Definition: cloudSolution.H:52
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Standard normal distribution. Not selectable.
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:118
Field< Type > & source()
Definition: fvMatrix.H:307
Base for a set of schemes which integrate simple ODEs which arise from semi-implicit rate expressions...
Random number generator.
A class for managing temporary objects.
Definition: tmp.H:55
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:181
Calculate the matrix for implicit and explicit sources.
U
Definition: pEqn.H:72
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
autoPtr< CompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const viscosity &viscosity)
tmp< VolField< Type > > Sp(const volScalarField &sp, const VolField< Type > &vf)
Definition: fvcSup.C:67
static const zero Zero
Definition: zero.H:97
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
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:257
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
const dimensionSet dimless
messageStream Info
const dimensionSet dimForce
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
const dimensionSet dimTime
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
const dimensionSet dimDensity
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
fvMatrix< vector > fvVectorMatrix
Definition: fvMatricesFwd.H:45
dimensioned< scalar > mag(const dimensioned< Type > &)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
static const char nl
Definition: Ostream.H:266
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
volScalarField & p
PtrList< volScalarField > & Y