-
Notifications
You must be signed in to change notification settings - Fork 1
/
KinematicCloud.H
631 lines (429 loc) · 18.3 KB
/
KinematicCloud.H
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::KinematicCloud
Description
Templated base class for kinematic cloud
- cloud function objects
- particle forces, e.g.
- buoyancy
- drag
- pressure gradient
- ...
- sub-models:
- dispersion model
- injection model
- patch interaction model
- stochastic collision model
- surface film model
SourceFiles
KinematicCloudI.H
KinematicCloud.C
\*---------------------------------------------------------------------------*/
#ifndef KinematicCloud_H
#define KinematicCloud_H
#include "particle.H"
#include "Cloud.H"
#include "kinematicCloud.H"
#include "IOdictionary.H"
#include "autoPtr.H"
#include "cachedRandom.H"
#include "fvMesh.H"
#include "volFields.H"
#include "fvMatrices.H"
#include "IntegrationSchemesFwd.H"
#include "cloudSolution.H"
#include "ParticleForceList.H"
#include "CloudFunctionObjectList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
template<class CloudType>
class InjectionModelList;
template<class CloudType>
class DispersionModel;
template<class CloudType>
class PatchInteractionModel;
template<class CloudType>
class SurfaceFilmModel;
template<class CloudType>
class StochasticCollisionModel;
/*---------------------------------------------------------------------------*\
Class KinematicCloud Declaration
\*---------------------------------------------------------------------------*/
template<class CloudType>
class KinematicCloud
:
public CloudType,
public kinematicCloud
{
public:
// Public typedefs
//- Type of cloud this cloud was instantiated for
typedef CloudType cloudType;
//- Type of parcel the cloud was instantiated for
typedef typename CloudType::particleType parcelType;
//- Convenience typedef for this cloud type
typedef KinematicCloud<CloudType> kinematicCloudType;
//- Force models type
typedef ParticleForceList<KinematicCloud<CloudType>> forceType;
//- Function object type
typedef CloudFunctionObjectList<KinematicCloud<CloudType>>
functionType;
private:
// Private data
//- Cloud copy pointer
autoPtr<KinematicCloud<CloudType>> cloudCopyPtr_;
// Private Member Functions
//- Disallow default bitwise copy construct
KinematicCloud(const KinematicCloud&);
//- Disallow default bitwise assignment
void operator=(const KinematicCloud&);
protected:
// Protected data
//- References to the mesh and time databases
const fvMesh& mesh_;
//- Dictionary of particle properties
IOdictionary particleProperties_;
//- Dictionary of output properties
IOdictionary outputProperties_;
//- Solution properties
cloudSolution solution_;
//- Parcel constant properties
typename parcelType::constantProperties constProps_;
//- Sub-models dictionary
const dictionary subModelProperties_;
//- Random number generator - used by some injection routines
mutable cachedRandom rndGen_;
//- Cell occupancy information for each parcel, (demand driven)
autoPtr<List<DynamicList<parcelType*>>> cellOccupancyPtr_;
//- Cell length scale
scalarField cellLengthScale_;
// References to the carrier gas fields
//- Density [kg/m3]
const volScalarField& rho_;
//- Velocity [m/s]
const volVectorField& U_;
//- Dynamic viscosity [Pa.s]
const volScalarField& mu_;
// Environmental properties
//- Gravity
const dimensionedVector& g_;
//- Averaged ambient domain pressure
scalar pAmbient_;
//- Optional particle forces
forceType forces_;
//- Optional cloud function objects
functionType functions_;
// References to the cloud sub-models
//- Injector models
InjectionModelList<KinematicCloud<CloudType>> injectors_;
//- Dispersion model
autoPtr<DispersionModel<KinematicCloud<CloudType>>>
dispersionModel_;
//- Patch interaction model
autoPtr<PatchInteractionModel<KinematicCloud<CloudType>>>
patchInteractionModel_;
//- Stochastic collision model
autoPtr<StochasticCollisionModel<KinematicCloud<CloudType>>>
stochasticCollisionModel_;
//- Surface film model
autoPtr<SurfaceFilmModel<KinematicCloud<CloudType>>>
surfaceFilmModel_;
// Reference to the particle integration schemes
//- Velocity integration
autoPtr<vectorIntegrationScheme> UIntegrator_;
// Sources
//- Momentum
autoPtr<volVectorField::Internal> UTrans_;
//- Coefficient for carrier phase U equation
autoPtr<volScalarField::Internal> UCoeff_;
// Initialisation
//- Set cloud sub-models
void setModels();
// Cloud evolution functions
//- Solve the cloud - calls all evolution functions
template<class TrackData>
void solve(TrackData& td);
//- Build the cellOccupancy
void buildCellOccupancy();
//- Update (i.e. build) the cellOccupancy if it has
// already been used
void updateCellOccupancy();
//- Evolve the cloud
template<class TrackData>
void evolveCloud(TrackData& td);
//- Post-evolve
void postEvolve();
//- Reset state of cloud
void cloudReset(KinematicCloud<CloudType>& c);
public:
// Constructors
//- Construct given carrier gas fields
KinematicCloud
(
const word& cloudName,
const volScalarField& rho,
const volVectorField& U,
const volScalarField& mu,
const dimensionedVector& g,
bool readFields = true
);
//- Copy constructor with new name
KinematicCloud
(
KinematicCloud<CloudType>& c,
const word& name
);
//- Copy constructor with new name - creates bare cloud
KinematicCloud
(
const fvMesh& mesh,
const word& name,
const KinematicCloud<CloudType>& c
);
//- Construct and return clone based on (this) with new name
virtual autoPtr<Cloud<parcelType>> clone(const word& name)
{
return autoPtr<Cloud<parcelType>>
(
new KinematicCloud(*this, name)
);
}
//- Construct and return bare clone based on (this) with new name
virtual autoPtr<Cloud<parcelType>> cloneBare(const word& name) const
{
return autoPtr<Cloud<parcelType>>
(
new KinematicCloud(this->mesh(), name, *this)
);
}
//- Destructor
virtual ~KinematicCloud();
// Member Functions
// Access
//- Return a reference to the cloud copy
inline const KinematicCloud& cloudCopy() const;
//- Switch to specify if particles of the cloud can return
// non-zero wall distance values - true for kinematic parcels
bool hasWallImpactDistance() const;
// References to the mesh and databases
//- Return reference to the mesh
inline const fvMesh& mesh() const;
//- Return particle properties dictionary
inline const IOdictionary& particleProperties() const;
//- Return output properties dictionary
inline const IOdictionary& outputProperties() const;
//- Return non-const access to the output properties dictionary
inline IOdictionary& outputProperties();
//- Return const access to the solution properties
inline const cloudSolution& solution() const;
//- Return access to the solution properties
inline cloudSolution& solution();
//- Return the constant properties
inline const typename parcelType::constantProperties&
constProps() const;
//- Return access to the constant properties
inline typename parcelType::constantProperties& constProps();
//- Return reference to the sub-models dictionary
inline const dictionary& subModelProperties() const;
// Cloud data
//- Return reference to the random object
inline cachedRandom& rndGen() const;
//- Return the cell occupancy information for each
// parcel, non-const access, the caller is
// responsible for updating it for its own purposes
// if particles are removed or created.
inline List<DynamicList<parcelType*>>& cellOccupancy();
//- Return the cell length scale
inline const scalarField& cellLengthScale() const;
// References to the carrier gas fields
//- Return carrier gas velocity
inline const volVectorField& U() const;
//- Return carrier gas density
inline const volScalarField& rho() const;
//- Return carrier gas dynamic viscosity
inline const volScalarField& mu() const;
// Environmental properties
//- Gravity
inline const dimensionedVector& g() const;
//- Return const-access to the ambient pressure
inline scalar pAmbient() const;
//- Return reference to the ambient pressure
inline scalar& pAmbient();
//- Optional particle forces
inline const forceType& forces() const;
//- Return the optional particle forces
inline forceType& forces();
//- Optional cloud function objects
inline functionType& functions();
// Sub-models
//- Return const access to the injection model
inline const InjectionModelList<KinematicCloud<CloudType>>&
injectors() const;
//- Return reference to the injection model
inline InjectionModelList<KinematicCloud<CloudType>>&
injectors();
//- Return const-access to the dispersion model
inline const DispersionModel<KinematicCloud<CloudType>>&
dispersion() const;
//- Return reference to the dispersion model
inline DispersionModel<KinematicCloud<CloudType>>&
dispersion();
//- Return const-access to the patch interaction model
inline const PatchInteractionModel<KinematicCloud<CloudType>>&
patchInteraction() const;
//- Return reference to the patch interaction model
inline PatchInteractionModel<KinematicCloud<CloudType>>&
patchInteraction();
//- Return const-access to the stochastic collision model
inline const
StochasticCollisionModel<KinematicCloud<CloudType>>&
stochasticCollision() const;
//- Return reference to the stochastic collision model
inline StochasticCollisionModel<KinematicCloud<CloudType>>&
stochasticCollision();
//- Return const-access to the surface film model
inline const SurfaceFilmModel<KinematicCloud<CloudType>>&
surfaceFilm() const;
//- Return reference to the surface film model
inline SurfaceFilmModel<KinematicCloud<CloudType>>&
surfaceFilm();
// Integration schemes
//-Return reference to velocity integration
inline const vectorIntegrationScheme& UIntegrator() const;
// Sources
// Momentum
//- Return reference to momentum source
inline volVectorField::Internal& UTrans();
//- Return const reference to momentum source
inline const volVectorField::Internal&
UTrans() const;
//- Return coefficient for carrier phase U equation
inline volScalarField::Internal& UCoeff();
//- Return const coefficient for carrier phase U equation
inline const volScalarField::Internal&
UCoeff() const;
//- Return tmp momentum source term
inline tmp<fvVectorMatrix> SU(volVectorField& U) const;
// Check
//- Total number of parcels
inline label nParcels() const;
//- Total mass in system
inline scalar massInSystem() const;
//- Total linear momentum of the system
inline vector linearMomentumOfSystem() const;
//- Total linear kinetic energy in the system
inline scalar linearKineticEnergyOfSystem() const;
//- Total rotational kinetic energy in the system
inline scalar rotationalKineticEnergyOfSystem() const;
//- Mean diameter Dij
inline scalar Dij(const label i, const label j) const;
//- Max diameter
inline scalar Dmax() const;
// Fields
//- Volume swept rate of parcels per cell
inline const tmp<volScalarField> vDotSweep() const;
//- Return the particle volume fraction field
// Note: for particles belonging to this cloud only
inline const tmp<volScalarField> theta() const;
//- Return the particle mass fraction field
// Note: for particles belonging to this cloud only
inline const tmp<volScalarField> alpha() const;
//- Return the particle effective density field
// Note: for particles belonging to this cloud only
inline const tmp<volScalarField> rhoEff() const;
// Cloud evolution functions
//- Set parcel thermo properties
void setParcelThermoProperties
(
parcelType& parcel,
const scalar lagrangianDt
);
//- Check parcel properties
void checkParcelProperties
(
parcelType& parcel,
const scalar lagrangianDt,
const bool fullyDescribed
);
//- Store the current cloud state
void storeState();
//- Reset the current cloud to the previously stored state
void restoreState();
//- Reset the cloud source terms
void resetSourceTerms();
//- Relax field
template<class Type>
void relax
(
DimensionedField<Type, volMesh>& field,
const DimensionedField<Type, volMesh>& field0,
const word& name
) const;
//- Scale field
template<class Type>
void scale
(
DimensionedField<Type, volMesh>& field,
const word& name
) const;
//- Apply relaxation to (steady state) cloud sources
void relaxSources(const KinematicCloud<CloudType>& cloudOldTime);
//- Apply scaling to (transient) cloud sources
void scaleSources();
//- Pre-evolve
void preEvolve();
//- Evolve the cloud
void evolve();
//- Particle motion
template<class TrackData>
void motion(TrackData& td);
//- Calculate the patch normal and velocity to interact with,
// accounting for patch motion if required.
void patchData
(
const parcelType& p,
const polyPatch& pp,
vector& normal,
vector& Up
) const;
// Mapping
//- Update mesh
void updateMesh();
//- Remap the cells of particles corresponding to the
// mesh topology change with a default tracking data object
virtual void autoMap(const mapPolyMesh&);
// I-O
//- Print cloud information
void info();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "KinematicCloudI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "KinematicCloud.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //