MomentumCloud.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 Class
25  Foam::MomentumCloud
26 
27 Description
28  Templated base class for momentum cloud
29 
30  - cloud function objects
31 
32  - particle forces, e.g.
33  - buoyancy
34  - drag
35  - pressure gradient
36  - ...
37 
38  - sub-models:
39  - dispersion model
40  - injection model
41  - patch interaction model
42  - stochastic collision model
43  - surface film model
44 
45 SourceFiles
46  MomentumCloudI.H
47  MomentumCloud.C
48 
49 \*---------------------------------------------------------------------------*/
50 
51 #ifndef MomentumCloud_H
52 #define MomentumCloud_H
53 
54 #include "particle.H"
55 #include "Cloud.H"
56 #include "timeIOdictionary.H"
57 #include "autoPtr.H"
58 #include "Random.H"
59 #include "fvMesh.H"
60 #include "volFields.H"
61 #include "fvMatrices.H"
62 #include "cloudSolution.H"
63 #include "fluidThermo.H"
64 
65 #include "ParticleForceList.H"
67 
68 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
69 
70 namespace Foam
71 {
72 
73 // Forward declaration of classes
74 
75 class integrationScheme;
76 
77 template<class CloudType>
78 class InjectionModelList;
79 
80 template<class CloudType>
81 class DispersionModel;
82 
83 template<class CloudType>
84 class PatchInteractionModel;
85 
86 template<class CloudType>
87 class SurfaceFilmModel;
88 
89 template<class CloudType>
90 class StochasticCollisionModel;
91 
92 
93 /*---------------------------------------------------------------------------*\
94  Class MomentumCloudName Declaration
95 \*---------------------------------------------------------------------------*/
96 
98 
99 
100 /*---------------------------------------------------------------------------*\
101  Class MomentumCloud Declaration
102 \*---------------------------------------------------------------------------*/
103 
104 template<class CloudType>
105 class MomentumCloud
106 :
107  public CloudType,
108  public MomentumCloudName
109 {
110 public:
111 
112  // Public Typedefs
113 
114  //- Type of cloud this cloud was instantiated for
115  typedef CloudType cloudType;
116 
117  //- Type of parcel the cloud was instantiated for
118  typedef typename CloudType::particleType parcelType;
119 
120  //- Convenience typedef for this cloud type
122 
123  //- Force models type
125 
126  //- Function object type
128  functionType;
129 
130 
131 private:
132 
133  // Private Data
134 
135  //- Cloud copy pointer
136  autoPtr<MomentumCloud<CloudType>> cloudCopyPtr_;
137 
138 
139 protected:
140 
141  // Protected data
142 
143  //- Dictionary of particle properties
145 
146  //- Dictionary of output properties
148 
149  //- Solution properties
151 
152  //- Parcel constant properties
153  typename parcelType::constantProperties constProps_;
154 
155  //- Sub-models dictionary
157 
158  //- Random number generator - used by some injection routines
159  mutable Random rndGen_;
160 
161  //- Cell occupancy information for each parcel, (demand driven)
163 
164  //- Cell length scale
166 
167 
168  // References to the carrier gas fields
169 
170  //- Density [kg/m^3]
171  const volScalarField& rho_;
172 
173  //- Velocity [m/s]
174  const volVectorField& U_;
175 
176  //- Dynamic viscosity [Pa.s]
177  const volScalarField& mu_;
178 
179 
180  // Environmental properties
181 
182  //- Gravity
183  const dimensionedVector& g_;
184 
185  //- Averaged ambient domain pressure
186  scalar pAmbient_;
187 
188 
189  //- Optional particle forces
191 
192  //- Optional cloud function objects
194 
195 
196  // References to the cloud sub-models
197 
198  //- Injector models
200 
201  //- Dispersion model
204 
205  //- Patch interaction model
208 
209  //- Stochastic collision model
212 
213  //- Optional film model
215 
216 
217  // Reference to the particle integration schemes
218 
219  //- Velocity integration
221 
222 
223  // Sources
224 
225  //- Momentum
227 
228  //- Coefficient for carrier phase U equation
230 
231 
232  // Initialisation
233 
234  //- Set cloud sub-models
235  void setModels();
236 
237 
238  // Cloud evolution functions
239 
240  //- Solve the cloud - calls all evolution functions
241  template<class TrackCloudType>
242  void solve
243  (
244  TrackCloudType& cloud,
245  typename parcelType::trackingData& td
246  );
247 
248  //- Build the cellOccupancy
249  void buildCellOccupancy();
250 
251  //- Update (i.e. build) the cellOccupancy if it has
252  // already been used
253  void updateCellOccupancy();
254 
255  //- Post-evolve
256  void postEvolve();
257 
258  //- Reset state of cloud
260 
261 
262 public:
263 
264  // Constructors
265 
266  //- Construct given carrier fields
268  (
269  const word& cloudName,
270  const volScalarField& rho,
271  const volVectorField& U,
272  const volScalarField& mu,
273  const dimensionedVector& g,
274  const bool readFields = true
275  );
276 
277  //- Construct given carrier fields and thermo
279  (
280  const word& cloudName,
281  const volScalarField& rho,
282  const volVectorField& U,
283  const dimensionedVector& g,
284  const fluidThermo& carrierThermo,
285  const bool readFields = true
286  );
287 
288  //- Copy constructor with new name
290  (
292  const word& name
293  );
294 
295  //- Copy constructor with new name - creates bare cloud
297  (
298  const fvMesh& mesh,
299  const word& name,
301  );
302 
303  //- Disallow default bitwise copy construction
304  MomentumCloud(const MomentumCloud&) = delete;
305 
306  //- Construct and return clone based on (this) with new name
307  virtual autoPtr<Cloud<parcelType>> clone(const word& name)
308  {
310  (
311  new MomentumCloud(*this, name)
312  );
313  }
314 
315  //- Construct and return bare clone based on (this) with new name
316  virtual autoPtr<Cloud<parcelType>> cloneBare(const word& name) const
317  {
319  (
320  new MomentumCloud(this->mesh(), name, *this)
321  );
322  }
323 
324 
325  //- Destructor
326  virtual ~MomentumCloud();
327 
328 
329  // Member Functions
330 
331  // Access
332 
333  //- Return a reference to the cloud copy
334  inline const MomentumCloud& cloudCopy() const;
335 
336 
337  // References to the mesh and databases
338 
339  //- Return particle properties dictionary
340  inline const IOdictionary& particleProperties() const;
341 
342  //- Return output properties dictionary
343  inline const IOdictionary& outputProperties() const;
344 
345  //- Return non-const access to the output properties dictionary
346  inline IOdictionary& outputProperties();
347 
348  //- Return const access to the solution properties
349  inline const cloudSolution& solution() const;
350 
351  //- Return access to the solution properties
352  inline cloudSolution& solution();
353 
354  //- Return the constant properties
355  inline const typename parcelType::constantProperties&
356  constProps() const;
357 
358  //- Return access to the constant properties
359  inline typename parcelType::constantProperties& constProps();
360 
361  //- Return reference to the sub-models dictionary
362  inline const dictionary& subModelProperties() const;
363 
364 
365  // Cloud data
366 
367  //- Return reference to the random object
368  inline Random& rndGen() const;
369 
370  //- Return the cell occupancy information for each
371  // parcel, non-const access, the caller is
372  // responsible for updating it for its own purposes
373  // if particles are removed or created.
375 
376  //- Return the cell length scale
377  inline const scalarField& cellLengthScale() const;
378 
379 
380  // References to the carrier gas fields
381 
382  //- Return carrier gas velocity
383  inline const volVectorField& U() const;
384 
385  //- Return carrier gas density
386  inline const volScalarField& rho() const;
387 
388  //- Return carrier gas dynamic viscosity
389  inline const volScalarField& mu() const;
390 
391 
392  // Environmental properties
393 
394  //- Gravity
395  inline const dimensionedVector& g() const;
396 
397  //- Return const-access to the ambient pressure
398  inline scalar pAmbient() const;
399 
400  //- Return reference to the ambient pressure
401  inline scalar& pAmbient();
402 
403 
404  //- Optional particle forces
405  inline const forceType& forces() const;
406 
407  //- Return the optional particle forces
408  inline forceType& forces();
409 
410  //- Optional cloud function objects
411  inline functionType& functions();
412 
413 
414  // Sub-models
415 
416  //- Return const access to the injection model
418  injectors() const;
419 
420  //- Return reference to the injection model
422  injectors();
423 
424  //- Return const-access to the dispersion model
426  dispersion() const;
427 
428  //- Return reference to the dispersion model
430  dispersion();
431 
432  //- Return const-access to the patch interaction model
434  patchInteraction() const;
435 
436  //- Return reference to the patch interaction model
439 
440  //- Return const-access to the stochastic collision model
441  inline const
443  stochasticCollision() const;
444 
445  //- Return reference to the stochastic collision model
448 
449  //- Return const-access to the surface film model
451  surfaceFilm() const;
452 
453  //- Return reference to the surface film model
455  surfaceFilm();
456 
457 
458  // Integration schemes
459 
460  //-Return reference to velocity integration
461  inline const integrationScheme& UIntegrator() const;
462 
463 
464  // Sources
465 
466  // Momentum
467 
468  //- Return momentum source
469  inline tmp<volVectorField::Internal> UTrans() const;
470 
471  //- Access momentum source
473 
474  //- Return coefficient for carrier phase U equation
475  inline tmp<volScalarField::Internal> UCoeff() const;
476 
477  //- Access coefficient for carrier phase U equation
479 
480  //- Return tmp momentum source term
481  inline tmp<fvVectorMatrix> SU
482  (
483  const volVectorField& U
484  ) const;
485 
486 
487  // Check
488 
489  //- Total number of parcels
490  inline label nParcels() const;
491 
492  //- Total mass in system
493  inline scalar massInSystem() const;
494 
495  //- Total linear momentum of the system
496  inline vector linearMomentumOfSystem() const;
497 
498  //- Total linear kinetic energy in the system
499  inline scalar linearKineticEnergyOfSystem() const;
500 
501  //- Total rotational kinetic energy in the system
502  inline scalar rotationalKineticEnergyOfSystem() const;
503 
504  //- Mean diameter Dij
505  inline scalar Dij(const label i, const label j) const;
506 
507  //- Min diameter
508  inline scalar Dmin() const;
509 
510  //- Max diameter
511  inline scalar Dmax() const;
512 
513 
514  // Fields
515 
516  //- Volume swept rate of parcels per cell
517  inline const tmp<volScalarField> vDotSweep() const;
518 
519  //- Return the particle volume fraction field
520  // Note: for particles belonging to this cloud only
521  inline const tmp<volScalarField> theta() const;
522 
523  //- Return the particle mass fraction field
524  // Note: for particles belonging to this cloud only
525  inline const tmp<volScalarField> alpha() const;
526 
527  //- Return the particle effective density field
528  // Note: for particles belonging to this cloud only
529  inline const tmp<volScalarField> rhoEff() const;
530 
531 
532  // Cloud evolution functions
533 
534  //- Set parcel thermo properties
536 
537  //- Check parcel properties
539  (
540  parcelType& parcel,
541  const label injectori
542  );
543 
544  //- Store the current cloud state
545  void storeState();
546 
547  //- Reset the current cloud to the previously stored state
548  void restoreState();
549 
550  //- Reset the cloud source terms
551  void resetSourceTerms();
552 
553  //- Relax field
554  template<class Type>
555  void relax
556  (
558  const DimensionedField<Type, volMesh>& field0,
559  const word& name
560  ) const;
561 
562  //- Scale field
563  template<class Type>
564  void scale
565  (
567  const word& name
568  ) const;
569 
570  //- Apply relaxation to (steady state) cloud sources
571  void relaxSources(const MomentumCloud<CloudType>& cloudOldTime);
572 
573  //- Apply scaling to (transient) cloud sources
574  void scaleSources();
575 
576  //- Pre-evolve
577  void preEvolve();
578 
579  //- Evolve the cloud
580  void evolve();
581 
582  //- Particle motion
583  template<class TrackCloudType>
584  void motion
585  (
586  TrackCloudType& cloud,
587  typename parcelType::trackingData& td
588  );
589 
590  //- Calculate the patch normal and velocity to interact with,
591  // accounting for patch motion if required.
592  void patchData
593  (
594  const parcelType& p,
595  const polyPatch& pp,
596  vector& normal,
597  vector& Up
598  ) const;
599 
600 
601  // Mapping
602 
603  //- Update topology using the given map
604  virtual void topoChange(const polyTopoChangeMap&);
605 
606  //- Update from another mesh using the given map
607  virtual void mapMesh(const polyMeshMap&);
608 
609  //- Redistribute or update using the given distribution map
610  virtual void distribute(const polyDistributionMap&);
611 
612 
613  // I-O
614 
615  //- Print cloud information
616  void info();
617 
618 
619  // Member Operators
620 
621  //- Disallow default bitwise assignment
622  void operator=(const MomentumCloud&) = delete;
623 };
624 
625 
626 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
627 
628 } // End namespace Foam
629 
630 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
631 
632 #include "MomentumCloudI.H"
633 
634 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
635 
636 #ifdef NoRepository
637  #include "MomentumCloud.C"
638 #endif
639 
640 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
641 
642 #endif
643 
644 // ************************************************************************* //
List of cloud function objects.
ParcelType particleType
Definition: Cloud.H:128
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:79
const word & cloudName() const
Return the cloud type.
Definition: DSMCCloudI.H:34
ParcelType parcelType
Type of parcel the cloud was instantiated for.
Definition: DSMCCloud.H:221
const fvMesh & mesh() const
Return references to the mesh.
Definition: DSMCCloudI.H:41
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Generic GeometricField class.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:57
autoPtr< IOobject > clone() const
Clone.
Definition: IOobject.H:283
const word & name() const
Return name.
Definition: IOobject.H:310
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.
void postEvolve()
Post-evolve.
functionType & functions()
Optional cloud function objects.
cloudSolution solution_
Solution properties.
const InjectionModelList< MomentumCloud< CloudType > > & injectors() const
Return const access to the injection model.
autoPtr< volVectorField::Internal > UTrans_
Momentum.
void setModels()
Set cloud sub-models.
Definition: MomentumCloud.C:40
scalar massInSystem() const
Total mass in system.
const DispersionModel< MomentumCloud< CloudType > > & dispersion() const
Return const-access to the dispersion model.
scalar rotationalKineticEnergyOfSystem() const
Total rotational kinetic energy in the system.
const PatchInteractionModel< MomentumCloud< CloudType > > & patchInteraction() const
Return const-access to the patch interaction model.
void operator=(const MomentumCloud &)=delete
Disallow default bitwise assignment.
void motion(TrackCloudType &cloud, typename parcelType::trackingData &td)
Particle motion.
forceType forces_
Optional particle forces.
virtual ~MomentumCloud()
Destructor.
void scale(DimensionedField< Type, volMesh > &field, const word &name) const
Scale field.
const tmp< volScalarField > theta() const
Return the particle volume fraction field.
void storeState()
Store the current cloud state.
MomentumCloud< CloudType > momentumCloudType
Convenience typedef for this cloud type.
const tmp< volScalarField > alpha() const
Return the particle mass fraction field.
void patchData(const parcelType &p, const polyPatch &pp, vector &normal, vector &Up) const
Calculate the patch normal and velocity to interact with,.
CloudFunctionObjectList< MomentumCloud< CloudType > > functionType
Function object type.
const scalarField & cellLengthScale() const
Return the cell length scale.
autoPtr< SurfaceFilmModel< MomentumCloud< CloudType > > > filmModel_
Optional film model.
scalar pAmbient_
Averaged ambient domain pressure.
scalarField cellLengthScale_
Cell length scale.
tmp< volVectorField::Internal > UTrans() const
Return momentum source.
InjectionModelList< MomentumCloud< CloudType > > injectors_
Injector models.
autoPtr< integrationScheme > UIntegrator_
Velocity integration.
vector linearMomentumOfSystem() const
Total linear momentum of the system.
ParticleForceList< MomentumCloud< CloudType > > forceType
Force models type.
const volVectorField & U() const
Return carrier gas velocity.
scalar pAmbient() const
Return const-access to the ambient pressure.
virtual autoPtr< Cloud< parcelType > > cloneBare(const word &name) const
Construct and return bare clone based on (this) with new name.
const SurfaceFilmModel< MomentumCloud< CloudType > > & surfaceFilm() const
Return const-access to the surface film model.
void relax(DimensionedField< Type, volMesh > &field, const DimensionedField< Type, volMesh > &field0, const word &name) const
Relax field.
const volScalarField & rho() const
Return carrier gas density.
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
void scaleSources()
Apply scaling to (transient) cloud sources.
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
MomentumCloud(const word &cloudName, const volScalarField &rho, const volVectorField &U, const volScalarField &mu, const dimensionedVector &g, const bool readFields=true)
Construct given carrier fields.
const volVectorField & U_
Velocity [m/s].
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.
const volScalarField & mu_
Dynamic viscosity [Pa.s].
label nParcels() const
Total number of parcels.
const dimensionedVector & g_
Gravity.
timeIOdictionary outputProperties_
Dictionary of output properties.
CloudType::particleType parcelType
Type of parcel the cloud was instantiated for.
const tmp< volScalarField > rhoEff() const
Return the particle effective density field.
const cloudSolution & solution() const
Return const access to the solution properties.
void updateCellOccupancy()
Update (i.e. build) the cellOccupancy if it has.
scalar Dmin() const
Min diameter.
const dictionary subModelProperties_
Sub-models dictionary.
const tmp< volScalarField > vDotSweep() const
Volume swept rate of parcels per cell.
CloudType cloudType
Type of cloud this cloud was instantiated for.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
const StochasticCollisionModel< MomentumCloud< CloudType > > & stochasticCollision() const
Return const-access to the stochastic collision model.
autoPtr< DispersionModel< MomentumCloud< CloudType > > > dispersionModel_
Dispersion model.
void evolve()
Evolve the cloud.
volVectorField::Internal & UTransRef()
Access momentum source.
functionType functions_
Optional cloud function objects.
const forceType & forces() const
Optional particle forces.
parcelType::constantProperties constProps_
Parcel constant properties.
const MomentumCloud & cloudCopy() const
Return a reference to the cloud copy.
scalar Dmax() const
Max diameter.
autoPtr< PatchInteractionModel< MomentumCloud< CloudType > > > patchInteractionModel_
Patch interaction model.
autoPtr< List< DynamicList< parcelType * > > > cellOccupancyPtr_
Cell occupancy information for each parcel, (demand driven)
const volScalarField & rho_
Density [kg/m^3].
scalar Dij(const label i, const label j) const
Mean diameter Dij.
IOdictionary particleProperties_
Dictionary of particle properties.
void cloudReset(MomentumCloud< CloudType > &c)
Reset state of cloud.
const IOdictionary & particleProperties() const
Return particle properties dictionary.
void info()
Print cloud information.
void restoreState()
Reset the current cloud to the previously stored state.
const dimensionedVector & g() const
Gravity.
void checkParcelProperties(parcelType &parcel, const label injectori)
Check parcel properties.
void preEvolve()
Pre-evolve.
Random rndGen_
Random number generator - used by some injection routines.
Random & rndGen() const
Return reference to the random object.
void resetSourceTerms()
Reset the cloud source terms.
tmp< fvVectorMatrix > SU(const volVectorField &U) const
Return tmp momentum source term.
const IOdictionary & outputProperties() const
Return output properties dictionary.
void buildCellOccupancy()
Build the cellOccupancy.
autoPtr< volScalarField::Internal > UCoeff_
Coefficient for carrier phase U equation.
scalar linearKineticEnergyOfSystem() const
Total linear kinetic energy in the system.
autoPtr< StochasticCollisionModel< MomentumCloud< CloudType > > > stochasticCollisionModel_
Stochastic collision model.
void setParcelThermoProperties(parcelType &parcel)
Set parcel thermo properties.
void relaxSources(const MomentumCloud< CloudType > &cloudOldTime)
Apply relaxation to (steady state) cloud sources.
const volScalarField & mu() const
Return carrier gas dynamic viscosity.
void solve(TrackCloudType &cloud, typename parcelType::trackingData &td)
Solve the cloud - calls all evolution functions.
Definition: MomentumCloud.C:92
List of particle forces.
Templated patch interaction model class.
Random number generator.
Definition: Random.H:58
Templated stochastic collision model class.
Templated wall surface film model class.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
Stores all relevant solution info for cloud.
Definition: cloudSolution.H:52
A cloud is a collection of lagrangian particles.
Definition: cloud.H:55
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
Base-class for fluid thermodynamic properties.
Definition: fluidThermo.H:57
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:101
Base for a set of schemes which integrate simple ODEs which arise from semi-implicit rate expressions...
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:70
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
timeIOdictionary derived from IOdictionary with globalFile set false to enable writing to processor t...
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:62
A special matrix type and solver, designed for finite volume solutions of scalar equations.
const dimensionedScalar c
Speed of light in a vacuum.
Namespace for OpenFOAM.
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
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const HashSet< word > &selectedFields, LIFOStack< regIOobject * > &storedObjects)
Read the selected GeometricFields of the specified type.
Definition: ReadFields.C:244
TemplateName(FvFaceCellWave)
volScalarField & p