KinematicCloudI.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-2018 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 #include "SortableList.H"
28 
29 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
30 
31 template<class CloudType>
34 {
35  return cloudCopyPtr_();
36 }
37 
38 
39 template<class CloudType>
41 {
42  return mesh_;
43 }
44 
45 
46 template<class CloudType>
47 inline const Foam::IOdictionary&
49 {
50  return particleProperties_;
51 }
52 
53 
54 template<class CloudType>
55 inline const Foam::IOdictionary&
57 {
58  return outputProperties_;
59 }
60 
61 
62 template<class CloudType>
64 {
65  return outputProperties_;
66 }
67 
68 
69 template<class CloudType>
70 inline const Foam::cloudSolution&
72 {
73  return solution_;
74 }
75 
76 
77 template<class CloudType>
79 {
80  return solution_;
81 }
82 
83 
84 template<class CloudType>
85 inline const typename CloudType::particleType::constantProperties&
87 {
88  return constProps_;
89 }
90 
91 
92 template<class CloudType>
93 inline typename CloudType::particleType::constantProperties&
95 {
96  return constProps_;
97 }
98 
99 
100 template<class CloudType>
101 inline const Foam::dictionary&
103 {
104  return subModelProperties_;
105 }
106 
107 
108 template<class CloudType>
110 {
111  return rho_;
112 }
113 
114 
115 template<class CloudType>
117 {
118  return U_;
119 }
120 
121 
122 template<class CloudType>
124 {
125  return mu_;
126 }
127 
128 
129 template<class CloudType>
131 {
132  return g_;
133 }
134 
135 
136 template<class CloudType>
137 inline Foam::scalar Foam::KinematicCloud<CloudType>::pAmbient() const
138 {
139  return pAmbient_;
140 }
141 
142 
143 template<class CloudType>
145 {
146  return pAmbient_;
147 }
148 
149 
150 template<class CloudType>
151 //inline const typename CloudType::parcelType::forceType&
152 inline const typename Foam::KinematicCloud<CloudType>::forceType&
154 {
155  return forces_;
156 }
157 
158 
159 template<class CloudType>
162 {
163  return forces_;
164 }
165 
166 
167 template<class CloudType>
170 {
171  return functions_;
172 }
173 
174 
175 template<class CloudType>
178 {
179  return injectors_;
180 }
181 
182 
183 template<class CloudType>
186 {
187  return injectors_;
188 }
189 
190 
191 template<class CloudType>
194 {
195  return dispersionModel_;
196 }
197 
198 
199 template<class CloudType>
202 {
203  return dispersionModel_();
204 }
205 
206 
207 template<class CloudType>
210 {
211  return patchInteractionModel_;
212 }
213 
214 
215 template<class CloudType>
218 {
219  return patchInteractionModel_();
220 }
221 
222 
223 template<class CloudType>
226 {
227  return stochasticCollisionModel_();
228 }
229 
230 
231 template<class CloudType>
234 {
235  return stochasticCollisionModel_();
236 }
237 
238 
239 template<class CloudType>
242 {
243  return surfaceFilmModel_();
244 }
245 
246 
247 template<class CloudType>
250 {
251  return surfaceFilmModel_();
252 }
253 
254 
255 template<class CloudType>
256 inline const Foam::integrationScheme&
258 {
259  return UIntegrator_;
260 }
261 
262 
263 template<class CloudType>
265 {
266  return this->size();
267 }
268 
269 
270 template<class CloudType>
272 {
273  scalar sysMass = 0.0;
274  forAllConstIter(typename KinematicCloud<CloudType>, *this, iter)
275  {
276  const parcelType& p = iter();
277  sysMass += p.nParticle()*p.mass();
278  }
279 
280  return sysMass;
281 }
282 
283 
284 template<class CloudType>
285 inline Foam::vector
287 {
288  vector linearMomentum(Zero);
289 
290  forAllConstIter(typename KinematicCloud<CloudType>, *this, iter)
291  {
292  const parcelType& p = iter();
293 
294  linearMomentum += p.nParticle()*p.mass()*p.U();
295  }
296 
297  return linearMomentum;
298 }
299 
300 
301 template<class CloudType>
302 inline Foam::scalar
304 {
305  scalar linearKineticEnergy = 0.0;
306 
307  forAllConstIter(typename KinematicCloud<CloudType>, *this, iter)
308  {
309  const parcelType& p = iter();
310 
311  linearKineticEnergy += p.nParticle()*0.5*p.mass()*(p.U() & p.U());
312  }
313 
314  return linearKineticEnergy;
315 }
316 
317 
318 template<class CloudType>
319 inline Foam::scalar Foam::KinematicCloud<CloudType>::Dij
320 (
321  const label i,
322  const label j
323 ) const
324 {
325  scalar si = 0.0;
326  scalar sj = 0.0;
327  forAllConstIter(typename KinematicCloud<CloudType>, *this, iter)
328  {
329  const parcelType& p = iter();
330  si += p.nParticle()*pow(p.d(), i);
331  sj += p.nParticle()*pow(p.d(), j);
332  }
333 
334  reduce(si, sumOp<scalar>());
335  reduce(sj, sumOp<scalar>());
336  sj = max(sj, vSmall);
337 
338  return si/sj;
339 }
340 
341 
342 template<class CloudType>
343 inline Foam::scalar Foam::KinematicCloud<CloudType>::Dmax() const
344 {
345  scalar d = -great;
346  forAllConstIter(typename KinematicCloud<CloudType>, *this, iter)
347  {
348  const parcelType& p = iter();
349  d = max(d, p.d());
350  }
351 
352  reduce(d, maxOp<scalar>());
353 
354  return max(0.0, d);
355 }
356 
357 
358 template<class CloudType>
360 {
361  return rndGen_;
362 }
363 
364 
365 template<class CloudType>
368 {
369  if (cellOccupancyPtr_.empty())
370  {
371  buildCellOccupancy();
372  }
373 
374  return cellOccupancyPtr_();
375 }
376 
377 
378 template<class CloudType>
379 inline const Foam::scalarField&
381 {
382  return cellLengthScale_;
383 }
384 
385 
386 template<class CloudType>
389 {
390  return UTrans_();
391 }
392 
393 
394 template<class CloudType>
397 {
398  return UTrans_();
399 }
400 
401 
402 template<class CloudType>
405 {
406  return UCoeff_();
407 }
408 
409 
410 template<class CloudType>
413 {
414  return UCoeff_();
415 }
416 
417 
418 template<class CloudType>
421 {
422  if (debug)
423  {
424  Info<< "UTrans min/max = " << min(UTrans()).value() << ", "
425  << max(UTrans()).value() << nl
426  << "UCoeff min/max = " << min(UCoeff()).value() << ", "
427  << max(UCoeff()).value() << endl;
428  }
429 
430  if (solution_.coupled())
431  {
432  if (solution_.semiImplicit("U"))
433  {
435  Vdt(mesh_.V()*this->db().time().deltaT());
436 
437  return UTrans()/Vdt - fvm::Sp(UCoeff()/Vdt, U) + UCoeff()/Vdt*U;
438  }
439  else
440  {
442  fvVectorMatrix& fvm = tfvm.ref();
443 
444  fvm.source() = -UTrans()/(this->db().time().deltaT());
445 
446  return tfvm;
447  }
448  }
449 
451 }
452 
453 
454 template<class CloudType>
457 {
458  tmp<volScalarField> tvDotSweep
459  (
461  (
462  this->name() + ":vDotSweep",
463  mesh_,
465  extrapolatedCalculatedFvPatchScalarField::typeName
466  )
467  );
468 
469  volScalarField& vDotSweep = tvDotSweep.ref();
470  forAllConstIter(typename KinematicCloud<CloudType>, *this, iter)
471  {
472  const parcelType& p = iter();
473  const label celli = p.cell();
474 
475  vDotSweep[celli] += p.nParticle()*p.areaP()*mag(p.U() - U_[celli]);
476  }
477 
478  vDotSweep.primitiveFieldRef() /= mesh_.V();
479  vDotSweep.correctBoundaryConditions();
480 
481  return tvDotSweep;
482 }
483 
484 
485 template<class CloudType>
488 {
489  tmp<volScalarField> ttheta
490  (
492  (
493  this->name() + ":theta",
494  mesh_,
496  extrapolatedCalculatedFvPatchScalarField::typeName
497  )
498  );
499 
500  volScalarField& theta = ttheta.ref();
501  forAllConstIter(typename KinematicCloud<CloudType>, *this, iter)
502  {
503  const parcelType& p = iter();
504  const label celli = p.cell();
505 
506  theta[celli] += p.nParticle()*p.volume();
507  }
508 
509  theta.primitiveFieldRef() /= mesh_.V();
511 
512  return ttheta;
513 }
514 
515 
516 template<class CloudType>
519 {
520  tmp<volScalarField> talpha
521  (
523  (
524  this->name() + ":alpha",
525  mesh_,
527  )
528  );
529 
530  scalarField& alpha = talpha.ref().primitiveFieldRef();
531  forAllConstIter(typename KinematicCloud<CloudType>, *this, iter)
532  {
533  const parcelType& p = iter();
534  const label celli = p.cell();
535 
536  alpha[celli] += p.nParticle()*p.mass();
537  }
538 
539  alpha /= (mesh_.V()*rho_);
540 
541  return talpha;
542 }
543 
544 
545 template<class CloudType>
548 {
549  tmp<volScalarField> trhoEff
550  (
552  (
553  this->name() + ":rhoEff",
554  mesh_,
556  )
557  );
558 
559  scalarField& rhoEff = trhoEff.ref().primitiveFieldRef();
560  forAllConstIter(typename KinematicCloud<CloudType>, *this, iter)
561  {
562  const parcelType& p = iter();
563  const label celli = p.cell();
564 
565  rhoEff[celli] += p.nParticle()*p.mass();
566  }
567 
568  rhoEff /= mesh_.V();
569 
570  return trhoEff;
571 }
572 
573 
574 // ************************************************************************* //
const SurfaceFilmModel< KinematicCloud< CloudType > > & surfaceFilm() const
Return const-access to the surface film model.
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
const StochasticCollisionModel< KinematicCloud< CloudType > > & stochasticCollision() const
Return const-access to the stochastic collision model.
const scalarField & cellLengthScale() const
Return the cell length scale.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
const tmp< volScalarField > theta() const
Return the particle volume fraction field.
scalar Dmax() const
Max diameter.
Cloud< basicKinematicCollidingParcel > ::particleType parcelType
Type of parcel the cloud was instantiated for.
const InjectionModelList< KinematicCloud< CloudType > > & injectors() const
Return const access to the injection model.
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:174
const KinematicCloud & cloudCopy() const
Return a reference to the cloud copy.
const volScalarField & rho() const
Return carrier gas density.
const fvMesh & mesh() const
Return reference to the mesh.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:256
volVectorField::Internal & UTrans()
Return reference to momentum source.
const tmp< volScalarField > rhoEff() const
Return the particle effective density field.
List< DynamicList< parcelType * > > & cellOccupancy()
Return the cell occupancy information for each.
const parcelType::constantProperties & constProps() const
Return the constant properties.
Templated patch interaction model class.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
scalar massInSystem() const
Total mass in system.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:52
const forceType & forces() const
Optional particle forces.
volScalarField::Internal & UCoeff()
Return coefficient for carrier phase U equation.
List of injection models.
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
static const zero Zero
Definition: zero.H:97
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:29
Random number generator.
Definition: Random.H:57
scalar linearKineticEnergyOfSystem() const
Total linear kinetic energy in the system.
const dimensionSet dimForce
Internal::FieldType & primitiveFieldRef()
Return a reference to the internal field.
static const char nl
Definition: Ostream.H:265
Field< Type > & source()
Definition: fvMatrix.H:292
const tmp< volScalarField > vDotSweep() const
Volume swept rate of parcels per cell.
const DispersionModel< KinematicCloud< CloudType > > & dispersion() const
Return const-access to the dispersion model.
scalar pAmbient() const
Return const-access to the ambient pressure.
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
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 dimensionSet dimDensity
const cloudSolution & solution() const
Return const access to the solution properties.
Base for a set of schemes which integrate simple ODEs which arise from semi-implcit rate expressions...
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
const IOdictionary & particleProperties() const
Return particle properties dictionary.
Templated base class for kinematic cloud.
Stores all relevant solution info for cloud.
Definition: cloudSolution.H:51
U
Definition: pEqn.H:72
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:47
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
const integrationScheme & UIntegrator() const
Return reference to velocity integration.
Templated stochastic collision model class.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
fvMatrix< vector > fvVectorMatrix
Definition: fvMatricesFwd.H:45
vector linearMomentumOfSystem() const
Total linear momentum of the system.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const dimensionedVector & g() const
Gravity.
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:51
const IOdictionary & outputProperties() const
Return output properties dictionary.
void correctBoundaryConditions()
Correct boundary field.
const volVectorField & U() const
Return carrier gas velocity.
messageStream Info
dimensioned< scalar > mag(const dimensioned< Type > &)
const PatchInteractionModel< KinematicCloud< CloudType > > & patchInteraction() const
Return const-access to the patch interaction model.
volScalarField alpha(IOobject("alpha", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
volScalarField & p
A class for managing temporary objects.
Definition: PtrList.H:53
scalar Dij(const label i, const label j) const
Mean diameter Dij.
const volScalarField & mu() const
Return carrier gas dynamic viscosity.
const tmp< volScalarField > alpha() const
Return the particle mass fraction field.
tmp< fvVectorMatrix > SU(volVectorField &U) const
Return tmp momentum source term.
functionType & functions()
Optional cloud function objects.
Random & rndGen() const
Return reference to the random object.
Calculate the matrix for implicit and explicit sources.
label nParcels() const
Total number of parcels.
const dictionary & subModelProperties() const
Return reference to the sub-models dictionary.
zeroField Sp
Definition: alphaSuSp.H:2