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-2022 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>
85 
86 template<class CloudType>
87 class SurfaceFilmModel;
88 
89 template<class CloudType>
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
190  forceType forces_;
191 
192  //- Optional cloud function objects
193  functionType functions_;
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  //- Surface film model
216 
217 
218  // Reference to the particle integration schemes
219 
220  //- Velocity integration
222 
223 
224  // Sources
225 
226  //- Momentum
228 
229  //- Coefficient for carrier phase U equation
231 
232 
233  // Initialisation
234 
235  //- Set cloud sub-models
236  void setModels();
237 
238 
239  // Cloud evolution functions
240 
241  //- Solve the cloud - calls all evolution functions
242  template<class TrackCloudType>
243  void solve
244  (
245  TrackCloudType& cloud,
246  typename parcelType::trackingData& td
247  );
248 
249  //- Build the cellOccupancy
250  void buildCellOccupancy();
251 
252  //- Update (i.e. build) the cellOccupancy if it has
253  // already been used
254  void updateCellOccupancy();
255 
256  //- Evolve the cloud
257  template<class TrackCloudType>
258  void evolveCloud
259  (
260  TrackCloudType& cloud,
261  typename parcelType::trackingData& td
262  );
263 
264  //- Post-evolve
265  void postEvolve();
266 
267  //- Reset state of cloud
269 
270 
271 public:
272 
273  // Constructors
274 
275  //- Construct given carrier fields
277  (
278  const word& cloudName,
279  const volScalarField& rho,
280  const volVectorField& U,
281  const volScalarField& mu,
282  const dimensionedVector& g,
283  const bool readFields = true
284  );
285 
286  //- Construct given carrier fields and thermo
288  (
289  const word& cloudName,
290  const volScalarField& rho,
291  const volVectorField& U,
292  const dimensionedVector& g,
293  const fluidThermo& carrierThermo,
294  const bool readFields = true
295  );
296 
297  //- Copy constructor with new name
299  (
301  const word& name
302  );
303 
304  //- Copy constructor with new name - creates bare cloud
306  (
307  const fvMesh& mesh,
308  const word& name,
310  );
311 
312  //- Disallow default bitwise copy construction
313  MomentumCloud(const MomentumCloud&) = delete;
314 
315  //- Construct and return clone based on (this) with new name
316  virtual autoPtr<Cloud<parcelType>> clone(const word& name)
317  {
319  (
320  new MomentumCloud(*this, name)
321  );
322  }
323 
324  //- Construct and return bare clone based on (this) with new name
325  virtual autoPtr<Cloud<parcelType>> cloneBare(const word& name) const
326  {
328  (
329  new MomentumCloud(this->mesh(), name, *this)
330  );
331  }
332 
333 
334  //- Destructor
335  virtual ~MomentumCloud();
336 
337 
338  // Member Functions
339 
340  // Access
341 
342  //- Return a reference to the cloud copy
343  inline const MomentumCloud& cloudCopy() const;
344 
345 
346  // References to the mesh and databases
347 
348  //- Return particle properties dictionary
349  inline const IOdictionary& particleProperties() const;
350 
351  //- Return output properties dictionary
352  inline const IOdictionary& outputProperties() const;
353 
354  //- Return non-const access to the output properties dictionary
355  inline IOdictionary& outputProperties();
356 
357  //- Return const access to the solution properties
358  inline const cloudSolution& solution() const;
359 
360  //- Return access to the solution properties
361  inline cloudSolution& solution();
362 
363  //- Return the constant properties
364  inline const typename parcelType::constantProperties&
365  constProps() const;
366 
367  //- Return access to the constant properties
368  inline typename parcelType::constantProperties& constProps();
369 
370  //- Return reference to the sub-models dictionary
371  inline const dictionary& subModelProperties() const;
372 
373 
374  // Cloud data
375 
376  //- Return reference to the random object
377  inline Random& rndGen() const;
378 
379  //- Return the cell occupancy information for each
380  // parcel, non-const access, the caller is
381  // responsible for updating it for its own purposes
382  // if particles are removed or created.
384 
385  //- Return the cell length scale
386  inline const scalarField& cellLengthScale() const;
387 
388 
389  // References to the carrier gas fields
390 
391  //- Return carrier gas velocity
392  inline const volVectorField& U() const;
393 
394  //- Return carrier gas density
395  inline const volScalarField& rho() const;
396 
397  //- Return carrier gas dynamic viscosity
398  inline const volScalarField& mu() const;
399 
400 
401  // Environmental properties
402 
403  //- Gravity
404  inline const dimensionedVector& g() const;
405 
406  //- Return const-access to the ambient pressure
407  inline scalar pAmbient() const;
408 
409  //- Return reference to the ambient pressure
410  inline scalar& pAmbient();
411 
412 
413  //- Optional particle forces
414  inline const forceType& forces() const;
415 
416  //- Return the optional particle forces
417  inline forceType& forces();
418 
419  //- Optional cloud function objects
420  inline functionType& functions();
421 
422 
423  // Sub-models
424 
425  //- Return const access to the injection model
427  injectors() const;
428 
429  //- Return reference to the injection model
431  injectors();
432 
433  //- Return const-access to the dispersion model
435  dispersion() const;
436 
437  //- Return reference to the dispersion model
439  dispersion();
440 
441  //- Return const-access to the patch interaction model
443  patchInteraction() const;
444 
445  //- Return reference to the patch interaction model
448 
449  //- Return const-access to the stochastic collision model
450  inline const
452  stochasticCollision() const;
453 
454  //- Return reference to the stochastic collision model
457 
458  //- Return const-access to the surface film model
460  surfaceFilm() const;
461 
462  //- Return reference to the surface film model
464  surfaceFilm();
465 
466 
467  // Integration schemes
468 
469  //-Return reference to velocity integration
470  inline const integrationScheme& UIntegrator() const;
471 
472 
473  // Sources
474 
475  // Momentum
476 
477  //- Return momentum source
478  inline tmp<volVectorField::Internal> UTrans() const;
479 
480  //- Access momentum source
482 
483  //- Return coefficient for carrier phase U equation
484  inline tmp<volScalarField::Internal> UCoeff() const;
485 
486  //- Access coefficient for carrier phase U equation
488 
489  //- Return tmp momentum source term
490  inline tmp<fvVectorMatrix> SU
491  (
492  const volVectorField& U
493  ) const;
494 
495 
496  // Check
497 
498  //- Total number of parcels
499  inline label nParcels() const;
500 
501  //- Total mass in system
502  inline scalar massInSystem() const;
503 
504  //- Total linear momentum of the system
505  inline vector linearMomentumOfSystem() const;
506 
507  //- Total linear kinetic energy in the system
508  inline scalar linearKineticEnergyOfSystem() const;
509 
510  //- Total rotational kinetic energy in the system
511  inline scalar rotationalKineticEnergyOfSystem() const;
512 
513  //- Mean diameter Dij
514  inline scalar Dij(const label i, const label j) const;
515 
516  //- Max diameter
517  inline scalar Dmax() const;
518 
519 
520  // Fields
521 
522  //- Volume swept rate of parcels per cell
523  inline const tmp<volScalarField> vDotSweep() const;
524 
525  //- Return the particle volume fraction field
526  // Note: for particles belonging to this cloud only
527  inline const tmp<volScalarField> theta() const;
528 
529  //- Return the particle mass fraction field
530  // Note: for particles belonging to this cloud only
531  inline const tmp<volScalarField> alpha() const;
532 
533  //- Return the particle effective density field
534  // Note: for particles belonging to this cloud only
535  inline const tmp<volScalarField> rhoEff() const;
536 
537 
538  // Cloud evolution functions
539 
540  //- Set parcel thermo properties
542  (
543  parcelType& parcel,
544  const scalar lagrangianDt
545  );
546 
547  //- Check parcel properties
549  (
550  parcelType& parcel,
551  const scalar lagrangianDt,
552  const bool fullyDescribed
553  );
554 
555  //- Store the current cloud state
556  void storeState();
557 
558  //- Reset the current cloud to the previously stored state
559  void restoreState();
560 
561  //- Reset the cloud source terms
562  void resetSourceTerms();
563 
564  //- Relax field
565  template<class Type>
566  void relax
567  (
569  const DimensionedField<Type, volMesh>& field0,
570  const word& name
571  ) const;
572 
573  //- Scale field
574  template<class Type>
575  void scale
576  (
578  const word& name
579  ) const;
580 
581  //- Apply relaxation to (steady state) cloud sources
582  void relaxSources(const MomentumCloud<CloudType>& cloudOldTime);
583 
584  //- Apply scaling to (transient) cloud sources
585  void scaleSources();
586 
587  //- Pre-evolve
588  void preEvolve();
589 
590  //- Evolve the cloud
591  void evolve();
592 
593  //- Particle motion
594  template<class TrackCloudType>
595  void motion
596  (
597  TrackCloudType& cloud,
598  typename parcelType::trackingData& td
599  );
600 
601  //- Calculate the patch normal and velocity to interact with,
602  // accounting for patch motion if required.
603  void patchData
604  (
605  const parcelType& p,
606  const polyPatch& pp,
607  vector& normal,
608  vector& Up
609  ) const;
610 
611 
612  // Mapping
613 
614  //- Update mesh
615  void topoChange();
616 
617  //- Remap the cells of particles corresponding to the
618  // mesh topology change with a default tracking data object
619  virtual void autoMap(const polyTopoChangeMap&);
620 
621 
622  // I-O
623 
624  //- Print cloud information
625  void info();
626 
627 
628  // Member Operators
629 
630  //- Disallow default bitwise assignment
631  void operator=(const MomentumCloud&) = delete;
632 };
633 
634 
635 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
636 
637 } // End namespace Foam
638 
639 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
640 
641 #include "MomentumCloudI.H"
642 
643 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
644 
645 #ifdef NoRepository
646  #include "MomentumCloud.C"
647 #endif
648 
649 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
650 
651 #endif
652 
653 // ************************************************************************* //
ParcelType particleType
Definition: Cloud.H:128
CloudFunctionObjectList< MomentumCloud< CloudType > > functionType
Function object type.
tmp< fvVectorMatrix > SU(const volVectorField &U) const
Return tmp momentum source term.
scalar linearKineticEnergyOfSystem() const
Total linear kinetic energy in the system.
autoPtr< StochasticCollisionModel< MomentumCloud< CloudType > > > stochasticCollisionModel_
Stochastic collision model.
const volVectorField & U_
Velocity [m/s].
void preEvolve()
Pre-evolve.
void scaleSources()
Apply scaling to (transient) cloud sources.
autoPtr< IOobject > clone() const
Clone.
Definition: IOobject.H:288
void updateCellOccupancy()
Update (i.e. build) the cellOccupancy if it has.
IOdictionary particleProperties_
Dictionary of particle properties.
void postEvolve()
Post-evolve.
void solve(TrackCloudType &cloud, typename parcelType::trackingData &td)
Solve the cloud - calls all evolution functions.
Definition: MomentumCloud.C:92
const word & name() const
Return name.
Definition: IOobject.H:315
void setModels()
Set cloud sub-models.
Definition: MomentumCloud.C:40
const SurfaceFilmModel< MomentumCloud< CloudType > > & surfaceFilm() const
Return const-access to the surface film model.
timeIOdictionary outputProperties_
Dictionary of output properties.
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
void operator=(const MomentumCloud &)=delete
Disallow default bitwise assignment.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
const word & cloudName() const
Return the cloud type.
Definition: DSMCCloudI.H:34
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
cloudSolution solution_
Solution properties.
functionType & functions()
Optional cloud function objects.
tmp< volVectorField::Internal > UTrans() const
Return momentum source.
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 PatchInteractionModel< MomentumCloud< CloudType > > & patchInteraction() const
Return const-access to the patch interaction model.
void storeState()
Store the current cloud state.
const tmp< volScalarField > alpha() const
Return the particle mass fraction field.
scalar Dij(const label i, const label j) const
Mean diameter Dij.
autoPtr< PatchInteractionModel< MomentumCloud< CloudType > > > patchInteractionModel_
Patch interaction model.
void topoChange()
Update mesh.
virtual autoPtr< Cloud< parcelType > > cloneBare(const word &name) const
Construct and return bare clone based on (this) with new name.
void buildCellOccupancy()
Build the cellOccupancy.
void scale(DimensionedField< Type, volMesh > &field, const word &name) const
Scale field.
void resetSourceTerms()
Reset the cloud source terms.
MomentumCloud< CloudType > momentumCloudType
Convenience typedef for this cloud type.
const parcelType::constantProperties & constProps() const
Return the constant properties.
CloudType::particleType parcelType
Type of parcel the cloud was instantiated for.
const dimensionedScalar c
Speed of light in a vacuum.
Random rndGen_
Random number generator - used by some injection routines.
InjectionModelList< MomentumCloud< CloudType > > injectors_
Injector models.
autoPtr< SurfaceFilmModel< MomentumCloud< CloudType > > > surfaceFilmModel_
Surface film model.
const dimensionedVector & g_
Gravity.
Templated patch interaction model class.
Definition: MomentumCloud.H:83
void info()
Print cloud information.
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.
autoPtr< volScalarField::Internal > UCoeff_
Coefficient for carrier phase U equation.
const volScalarField & rho_
Density [kg/m^3].
const volScalarField & rho() const
Return carrier gas density.
void cloudReset(MomentumCloud< CloudType > &c)
Reset state of cloud.
volScalarField::Internal & UCoeffRef()
Access coefficient for carrier phase U equation.
ParticleForceList< MomentumCloud< CloudType > > forceType
Force models type.
parcelType::constantProperties constProps_
Parcel constant properties.
A class for handling words, derived from string.
Definition: word.H:59
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Base-class for fluid thermodynamic properties.
Definition: fluidThermo.H:53
const integrationScheme & UIntegrator() const
Return reference to velocity integration.
forceType forces_
Optional particle forces.
const StochasticCollisionModel< MomentumCloud< CloudType > > & stochasticCollision() const
Return const-access to the stochastic collision model.
A cloud is a collection of lagrangian particles.
Definition: cloud.H:51
const volScalarField & mu() const
Return carrier gas dynamic viscosity.
void evolveCloud(TrackCloudType &cloud, typename parcelType::trackingData &td)
Evolve the cloud.
const tmp< volScalarField > rhoEff() const
Return the particle effective density field.
List of injection models.
Definition: MomentumCloud.H:77
TemplateName(FvFaceCellWave)
const InjectionModelList< MomentumCloud< CloudType > > & injectors() const
Return const access to the injection model.
void relax(DimensionedField< Type, volMesh > &field, const DimensionedField< Type, volMesh > &field0, const word &name) const
Relax field.
const IOdictionary & outputProperties() const
Return output properties dictionary.
autoPtr< DispersionModel< MomentumCloud< CloudType > > > dispersionModel_
Dispersion model.
const tmp< volScalarField > theta() const
Return the particle volume fraction field.
const dictionary subModelProperties_
Sub-models dictionary.
void motion(TrackCloudType &cloud, typename parcelType::trackingData &td)
Particle motion.
scalar massInSystem() const
Total mass in system.
Random number generator.
Definition: Random.H:57
autoPtr< integrationScheme > UIntegrator_
Velocity integration.
virtual void autoMap(const polyTopoChangeMap &)
Remap the cells of particles corresponding to the.
autoPtr< volVectorField::Internal > UTrans_
Momentum.
void checkParcelProperties(parcelType &parcel, const scalar lagrangianDt, const bool fullyDescribed)
Check parcel properties.
scalar Dmax() const
Max diameter.
const volScalarField & mu_
Dynamic viscosity [Pa.s].
const scalarField & cellLengthScale() const
Return the cell length scale.
const IOdictionary & particleProperties() const
Return particle properties dictionary.
virtual ~MomentumCloud()
Destructor.
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.
void relaxSources(const MomentumCloud< CloudType > &cloudOldTime)
Apply relaxation to (steady state) cloud sources.
void setParcelThermoProperties(parcelType &parcel, const scalar lagrangianDt)
Set parcel thermo properties.
label nParcels() const
Total number of parcels.
timeIOdictionary derived from IOdictionary with globalFile set false to enable writing to processor t...
const fvMesh & mesh() const
Return references to the mesh.
Definition: DSMCCloudI.H:41
scalar rotationalKineticEnergyOfSystem() const
Total rotational kinetic energy in the system.
Random & rndGen() const
Return reference to the random object.
Stores all relevant solution info for cloud.
Definition: cloudSolution.H:51
CloudType cloudType
Type of cloud this cloud was instantiated for.
tmp< volScalarField::Internal > UCoeff() const
Return coefficient for carrier phase U equation.
void patchData(const parcelType &p, const polyPatch &pp, vector &normal, vector &Up) const
Calculate the patch normal and velocity to interact with,.
Templated stochastic collision model class.
Definition: MomentumCloud.H:89
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:95
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
A special matrix type and solver, designed for finite volume solutions of scalar equations.
const volVectorField & U() const
Return carrier gas velocity.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
List of cloud function objects.
const dimensionedVector & g() const
Gravity.
rDeltaTY field()
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
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
const forceType & forces() const
Optional particle forces.
const MomentumCloud & cloudCopy() const
Return a reference to the cloud copy.
autoPtr< List< DynamicList< parcelType * > > > cellOccupancyPtr_
Cell occupancy information for each parcel, (demand driven)
scalarField cellLengthScale_
Cell length scale.
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:75
scalar pAmbient_
Averaged ambient domain pressure.
void restoreState()
Reset the current cloud to the previously stored state.
List< DynamicList< parcelType * > > & cellOccupancy()
Return the cell occupancy information for each.
vector linearMomentumOfSystem() const
Total linear momentum of the system.
List of particle forces.
Namespace for OpenFOAM.
void evolve()
Evolve the cloud.
functionType functions_
Optional cloud function objects.