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-2021 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 surfaceFilmModel_();
236 }
237 
238 
239 template<class CloudType>
242 {
243  return surfaceFilmModel_();
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>
311 inline Foam::scalar Foam::MomentumCloud<CloudType>::Dij
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>::Dmax() const
336 {
337  scalar d = -great;
338  forAllConstIter(typename MomentumCloud<CloudType>, *this, iter)
339  {
340  const parcelType& p = iter();
341  d = max(d, p.d());
342  }
343 
344  reduce(d, maxOp<scalar>());
345 
346  return max(0.0, d);
347 }
348 
349 
350 template<class CloudType>
352 {
353  return rndGen_;
354 }
355 
356 
357 template<class CloudType>
360 {
361  if (cellOccupancyPtr_.empty())
362  {
363  buildCellOccupancy();
364  }
365 
366  return cellOccupancyPtr_();
367 }
368 
369 
370 template<class CloudType>
371 inline const Foam::scalarField&
373 {
374  return cellLengthScale_;
375 }
376 
377 
378 template<class CloudType>
381 {
382  return UTrans_();
383 }
384 
385 
386 template<class CloudType>
389 {
390  return UTrans_();
391 }
392 
393 
394 template<class CloudType>
397 {
398  return UCoeff_();
399 }
400 
401 
402 template<class CloudType>
405 {
406  return UCoeff_();
407 }
408 
409 
410 template<class CloudType>
413 {
414  if (debug)
415  {
416  Info<< "UTrans min/max = " << min(UTrans()).value() << ", "
417  << max(UTrans()).value() << nl
418  << "UCoeff min/max = " << min(UCoeff()).value() << ", "
419  << max(UCoeff()).value() << endl;
420  }
421 
422  if (solution_.coupled())
423  {
424  if (solution_.semiImplicit("U"))
425  {
427  Vdt(this->mesh().V()*this->db().time().deltaT());
428 
429  return UTrans()/Vdt - fvm::Sp(UCoeff()/Vdt, U) + UCoeff()/Vdt*U;
430  }
431  else
432  {
434  fvVectorMatrix& fvm = tfvm.ref();
435 
436  fvm.source() = -UTrans()/(this->db().time().deltaT());
437 
438  return tfvm;
439  }
440  }
441 
443 }
444 
445 
446 template<class CloudType>
449 {
450  tmp<volScalarField> tvDotSweep
451  (
453  (
454  this->name() + ":vDotSweep",
455  this->mesh(),
457  extrapolatedCalculatedFvPatchScalarField::typeName
458  )
459  );
460 
461  volScalarField& vDotSweep = tvDotSweep.ref();
462  forAllConstIter(typename MomentumCloud<CloudType>, *this, iter)
463  {
464  const parcelType& p = iter();
465  const label celli = p.cell();
466 
467  vDotSweep[celli] += p.nParticle()*p.areaP()*mag(p.U() - U_[celli]);
468  }
469 
470  vDotSweep.primitiveFieldRef() /= this->mesh().V();
471  vDotSweep.correctBoundaryConditions();
472 
473  return tvDotSweep;
474 }
475 
476 
477 template<class CloudType>
480 {
481  tmp<volScalarField> ttheta
482  (
484  (
485  this->name() + ":theta",
486  this->mesh(),
488  extrapolatedCalculatedFvPatchScalarField::typeName
489  )
490  );
491 
492  volScalarField& theta = ttheta.ref();
493  forAllConstIter(typename MomentumCloud<CloudType>, *this, iter)
494  {
495  const parcelType& p = iter();
496  const label celli = p.cell();
497 
498  theta[celli] += p.nParticle()*p.volume();
499  }
500 
501  theta.primitiveFieldRef() /= this->mesh().V();
503 
504  return ttheta;
505 }
506 
507 
508 template<class CloudType>
511 {
512  tmp<volScalarField> talpha
513  (
515  (
516  this->name() + ":alpha",
517  this->mesh(),
519  )
520  );
521 
522  scalarField& alpha = talpha.ref().primitiveFieldRef();
523  forAllConstIter(typename MomentumCloud<CloudType>, *this, iter)
524  {
525  const parcelType& p = iter();
526  const label celli = p.cell();
527 
528  alpha[celli] += p.nParticle()*p.mass();
529  }
530 
531  alpha /= (this->mesh().V()*rho_);
532 
533  return talpha;
534 }
535 
536 
537 template<class CloudType>
540 {
541  tmp<volScalarField> trhoEff
542  (
544  (
545  this->name() + ":rhoEff",
546  this->mesh(),
548  )
549  );
550 
551  scalarField& rhoEff = trhoEff.ref().primitiveFieldRef();
552  forAllConstIter(typename MomentumCloud<CloudType>, *this, iter)
553  {
554  const parcelType& p = iter();
555  const label celli = p.cell();
556 
557  rhoEff[celli] += p.nParticle()*p.mass();
558  }
559 
560  rhoEff /= this->mesh().V();
561 
562  return trhoEff;
563 }
564 
565 
566 // ************************************************************************* //
tmp< fvVectorMatrix > SU(const volVectorField &U) const
Return tmp momentum source term.
scalar linearKineticEnergyOfSystem() const
Total linear kinetic energy in the system.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
autoPtr< CompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const viscosity &viscosity)
const SurfaceFilmModel< MomentumCloud< CloudType > > & surfaceFilm() const
Return const-access to the surface film model.
U
Definition: pEqn.H:72
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:477
const dictionary & subModelProperties() const
Return reference to the sub-models dictionary.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:181
functionType & functions()
Optional cloud function objects.
tmp< volVectorField::Internal > UTrans() const
Return momentum source.
volScalarField alpha(IOobject("alpha", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
const PatchInteractionModel< MomentumCloud< CloudType > > & patchInteraction() const
Return const-access to the patch interaction model.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
const tmp< volScalarField > alpha() const
Return the particle mass fraction field.
scalar Dij(const label i, const label j) const
Mean diameter Dij.
const dimensionSet dimless
fvMesh & mesh
const parcelType::constantProperties & constProps() const
Return the constant properties.
Templated patch interaction model class.
Definition: MomentumCloud.H:83
volVectorField::Internal & UTransRef()
Access momentum source.
const cloudSolution & solution() const
Return const access to the solution properties.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:53
Templated base class for momentum cloud.
const volScalarField & rho() const
Return carrier gas density.
const dimensionSet dimTime
volScalarField::Internal & UCoeffRef()
Access coefficient for carrier phase U equation.
const integrationScheme & UIntegrator() const
Return reference to velocity integration.
const StochasticCollisionModel< MomentumCloud< CloudType > > & stochasticCollision() const
Return const-access to the stochastic collision model.
const volScalarField & mu() const
Return carrier gas dynamic viscosity.
const dimensionSet dimDensity
const tmp< volScalarField > rhoEff() const
Return the particle effective density field.
List of injection models.
Definition: MomentumCloud.H:77
const InjectionModelList< MomentumCloud< CloudType > > & injectors() const
Return const access to the injection model.
const IOdictionary & outputProperties() const
Return output properties dictionary.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
A special matrix type and solver, designed for finite volume solutions of scalar equations. Face addressing is used to make all matrix assembly and solution loops vectorise.
Definition: fvPatchField.H:72
const tmp< volScalarField > theta() const
Return the particle volume fraction field.
static const zero Zero
Definition: zero.H:97
const dimensionSet dimForce
scalar massInSystem() const
Total mass in system.
Random number generator.
Definition: Random.H:57
ParcelType parcelType
Type of parcel the cloud was instantiated for.
Definition: DSMCCloud.H:221
Internal::FieldType & primitiveFieldRef()
Return a reference to the internal field.
static const char nl
Definition: Ostream.H:260
Field< Type > & source()
Definition: fvMatrix.H:300
scalar Dmax() const
Max diameter.
const scalarField & cellLengthScale() const
Return the cell length scale.
const IOdictionary & particleProperties() const
Return particle properties dictionary.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
const tmp< volScalarField::Internal > & Sp
Definition: alphaSuSp.H:7
scalar pAmbient() const
Return const-access to the ambient pressure.
Base for a set of schemes which integrate simple ODEs which arise from semi-implcit rate expressions...
const tmp< volScalarField > vDotSweep() const
Volume swept rate of parcels per cell.
label nParcels() const
Total number of parcels.
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Random & rndGen() const
Return reference to the random object.
Stores all relevant solution info for cloud.
Definition: cloudSolution.H:51
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
tmp< volScalarField::Internal > UCoeff() const
Return coefficient for carrier phase U equation.
Templated stochastic collision model class.
Definition: MomentumCloud.H:89
fvMatrix< vector > fvVectorMatrix
Definition: fvMatricesFwd.H:45
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
void correctBoundaryConditions()
Correct boundary field.
messageStream Info
dimensioned< scalar > mag(const dimensioned< Type > &)
const volVectorField & U() const
Return carrier gas velocity.
const dimensionedVector & g() const
Gravity.
const DispersionModel< MomentumCloud< CloudType > > & dispersion() const
Return const-access to the dispersion model.
volScalarField & p
A class for managing temporary objects.
Definition: PtrList.H:53
const forceType & forces() const
Optional particle forces.
const MomentumCloud & cloudCopy() const
Return a reference to the cloud copy.
List< DynamicList< parcelType * > > & cellOccupancy()
Return the cell occupancy information for each.
vector linearMomentumOfSystem() const
Total linear momentum of the system.
Calculate the matrix for implicit and explicit sources.