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-2023 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  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(this->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  (
465  (
466  this->name() + ":vDotSweep",
467  this->mesh(),
469  extrapolatedCalculatedFvPatchScalarField::typeName
470  )
471  );
472 
473  volScalarField& vDotSweep = tvDotSweep.ref();
474  forAllConstIter(typename MomentumCloud<CloudType>, *this, iter)
475  {
476  const parcelType& p = iter();
477  const label celli = p.cell();
478 
479  vDotSweep[celli] += p.nParticle()*p.areaP()*mag(p.U() - U_[celli]);
480  }
481 
482  vDotSweep.primitiveFieldRef() /= this->mesh().V();
483  vDotSweep.correctBoundaryConditions();
484 
485  return tvDotSweep;
486 }
487 
488 
489 template<class CloudType>
492 {
493  tmp<volScalarField> ttheta
494  (
496  (
497  this->name() + ":theta",
498  this->mesh(),
500  extrapolatedCalculatedFvPatchScalarField::typeName
501  )
502  );
503 
504  volScalarField& theta = ttheta.ref();
505  forAllConstIter(typename MomentumCloud<CloudType>, *this, iter)
506  {
507  const parcelType& p = iter();
508  const label celli = p.cell();
509 
510  theta[celli] += p.nParticle()*p.volume();
511  }
512 
513  theta.primitiveFieldRef() /= this->mesh().V();
515 
516  return ttheta;
517 }
518 
519 
520 template<class CloudType>
523 {
524  tmp<volScalarField> talpha
525  (
527  (
528  this->name() + ":alpha",
529  this->mesh(),
531  )
532  );
533 
534  scalarField& alpha = talpha.ref().primitiveFieldRef();
535  forAllConstIter(typename MomentumCloud<CloudType>, *this, iter)
536  {
537  const parcelType& p = iter();
538  const label celli = p.cell();
539 
540  alpha[celli] += p.nParticle()*p.mass();
541  }
542 
543  alpha /= (this->mesh().V()*rho_);
544 
545  return talpha;
546 }
547 
548 
549 template<class CloudType>
552 {
553  tmp<volScalarField> trhoEff
554  (
556  (
557  this->name() + ":rhoEff",
558  this->mesh(),
560  )
561  );
562 
563  scalarField& rhoEff = trhoEff.ref().primitiveFieldRef();
564  forAllConstIter(typename MomentumCloud<CloudType>, *this, iter)
565  {
566  const parcelType& p = iter();
567  const label celli = p.cell();
568 
569  rhoEff[celli] += p.nParticle()*p.mass();
570  }
571 
572  rhoEff /= this->mesh().V();
573 
574  return trhoEff;
575 }
576 
577 
578 // ************************************************************************* //
#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:221
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 internal 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 > theta() const
Return the particle volume fraction field.
const tmp< volScalarField > alpha() const
Return the particle mass 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.
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.
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.
Random & rndGen() const
Return reference to the random object.
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.
const volScalarField & mu() const
Return carrier gas dynamic viscosity.
Templated patch interaction model class.
Random number generator.
Definition: Random.H:58
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:160
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...
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
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
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:251
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)
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
static const char nl
Definition: Ostream.H:260
volScalarField & p