phaseSystem.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2015-2019 OpenFOAM Foundation
9  Copyright (C) 2022 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::phaseSystem
29 
30 Description
31  Class to represent a system of phases and model interfacial transfers
32  between them.
33 
34 SourceFiles
35  phaseSystem.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef phaseSystem_H
40 #define phaseSystem_H
41 
42 #include "IOdictionary.H"
43 
44 #include "phaseModel.H"
45 #include "phasePair.H"
46 #include "orderedPhasePair.H"
47 #include "HashPtrTable.H"
48 #include "PtrListDictionary.H"
49 
50 #include "IOMRFZoneList.H"
51 #include "fvOptions.H"
52 
53 #include "volFields.H"
54 #include "surfaceFields.H"
55 #include "fvMatricesFwd.H"
56 
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 
59 namespace Foam
60 {
61 
62 class blendingMethod;
63 template<class modelType> class BlendedInterfacialModel;
64 class aspectRatioModel;
65 
66 namespace reactingMultiphaseEuler
67 {
68  class surfaceTensionModel;
69 }
70 /*---------------------------------------------------------------------------*\
71  Class phaseSystem Declaration
72 \*---------------------------------------------------------------------------*/
73 
74 class phaseSystem
75 :
76  public IOdictionary
77 {
78 public:
79 
80  // Public typedefs
81 
83 
85 
87 
89 
91 
92  typedef
95 
96 
97 protected:
98 
99  // Protected typedefs
100 
101  typedef
103  dictTable;
104 
105  typedef
107 
108  typedef
109  HashTable
110  <
112  phasePairKey,
114  >
116 
117  typedef
118  HashTable
119  <
121  phasePairKey,
123  >
125 
126 
127  // Protected data
128 
129  //- Reference to the mesh
130  const fvMesh& mesh_;
131 
132  //- Phase models
134 
135  //- Moving phase models
138  //- Stationary phase models
140 
141  //- Anisothermal phase models
143 
144  //- Multi-component phase models
146 
147  //- Phase pairs
149 
150  //- Total volumetric flux
153  //- Rate of change of pressure
155 
156  //- Optional MRF zones
158 
159  //- Blending methods
161 
163  // Sub Models
164 
165  //- Surface tension models
168  //- Aspect ratio models
170 
171 
172  // Protected member functions
173 
174  //- Calculate and return the mixture flux
176  (
177  const phaseModelList& phaseModels
178  ) const;
179 
180  //- Generate pairs
181  void generatePairs
182  (
183  const dictTable& modelDicts
184  );
186  //- Generate pairs and sub-model tables
187  template<class modelType>
188  void createSubModels
189  (
190  const dictTable& modelDicts,
191  HashTable
192  <
194  phasePairKey,
196  >& models
197  );
198 
199  //- Generate pairs and sub-model tables
200  template<class modelType>
202  (
203  const word& modelName,
204  HashTable
205  <
207  phasePairKey,
209  >& models
210  );
211 
212  //- Generate pairs and blended sub-model tables
213  template<class modelType>
215  (
216  const word& modelName,
217  HashTable
218  <
220  phasePairKey,
222  >& models,
223  const bool correctFixedFluxBCs = true
224  );
225 
226  //- Generate pairs and two-sided sub-model tables
227  template<class modelType>
229  (
230  const word& modelName,
231  HashTable
232  <
234  phasePairKey,
236  >& models,
237  const bool correctFixedFluxBCs = true
238  );
239 
240  //- Add the field to a phase-indexed list, with the given name,
241  // constructing if necessary
242  template<class GeoField>
243  void addField
244  (
245  const phaseModel& phase,
246  const word& fieldName,
248  PtrList<GeoField>& fieldList
249  ) const;
250 
251  //- Add the field to a phase-indexed list, with the given name,
252  // constructing if necessary
253  template<class GeoField>
254  void addField
255  (
256  const phaseModel& phase,
257  const word& fieldName,
258  const GeoField& field,
259  PtrList<GeoField>& fieldList
260  ) const;
261 
262  //- Add the field to a phase-indexed table, with the given name,
263  // constructing if necessary
264  template<class GeoField>
265  void addField
266  (
267  const phaseModel& phase,
268  const word& fieldName,
270  HashPtrTable<GeoField>& fieldTable
271  ) const;
272 
273  //- Add the field to a phase-indexed table, with the given name,
274  // constructing if necessary
275  template<class GeoField>
276  void addField
277  (
278  const phaseModel& phase,
279  const word& fieldName,
280  const GeoField& field,
281  HashPtrTable<GeoField>& fieldTable
282  ) const;
283 
284 
285 public:
286 
287  //- Runtime type information
288  TypeName("phaseSystem");
289 
290  //- Default name of the phase properties dictionary
291  static const word propertiesName;
292 
293 
294  // Constructors
295 
296  //- Construct from fvMesh
297  phaseSystem(const fvMesh& mesh);
298 
299 
300  //- Destructor
301  virtual ~phaseSystem();
302 
303 
304  // Member Functions
305 
306  // Access
307 
308  //- Return the mesh
309  inline const fvMesh& mesh() const;
310 
311  //- Return the phase models
312  inline const phaseModelList& phases() const;
313 
314  //- Access the phase models
315  inline phaseModelList& phases();
316 
317  //- Return the models for phases that are moving
318  inline const phaseModelPartialList& movingPhases() const;
319 
320  //- Access the models for phases that are moving
322 
323  //- Return the models for phases that are stationary
324  inline const phaseModelPartialList& stationaryPhases() const;
325 
326  //- Access the models for phases that are stationary
328 
329  //- Return the models for phases that have variable temperature
330  inline const phaseModelPartialList& anisothermalPhases() const;
331 
332  //- Access the models for phases that have variable temperature
334 
335  //- Return the models for phases that have multiple species
336  inline const phaseModelPartialList& multiComponentPhases() const;
337 
338  //- Access the models for phases that have multiple species
341  //- Return the phase pairs
342  inline const phasePairTable& phasePairs() const;
343 
344  //- Return the mixture flux
345  inline const surfaceScalarField& phi() const;
346 
347  //- Access the mixture flux
348  inline surfaceScalarField& phi();
349 
350  //- Return the rate of change of the pressure
351  inline const volScalarField& dpdt() const;
352 
353  //- Access the rate of change of the pressure
354  inline volScalarField& dpdt();
355 
356  //- Return MRF zones
357  inline const IOMRFZoneList& MRF() const;
358 
359  //- Access the fvOptions
360  inline fv::options& fvOptions() const;
361 
362 
363  // Sub-model lookup
364 
365  //- Check availability of a sub model for a given phase pair
366  template<class modelType>
367  bool foundSubModel(const phasePair& key) const;
368 
369  //- Return a sub model between a phase pair
370  template<class modelType>
371  const modelType& lookupSubModel(const phasePair& key) const;
372 
373  //- Check availability of a sub model between two phases
374  template<class modelType>
375  bool foundSubModel
376  (
377  const phaseModel& dispersed,
378  const phaseModel& continuous
379  ) const;
380 
381  //- Return a sub model between two phases
382  template<class modelType>
383  const modelType& lookupSubModel
384  (
385  const phaseModel& dispersed,
386  const phaseModel& continuous
387  ) const;
388 
389  //- Check availability of a blended sub model for a given phase pair
390  template<class modelType>
391  bool foundBlendedSubModel(const phasePair& key) const;
392 
393  //- Return a blended sub model between a phase pair
394  template<class modelType>
396  lookupBlendedSubModel(const phasePair& key) const;
397 
398 
399  // Field construction
400 
401  //- Fill up gaps in a phase-indexed list of fields with zeros
402  template
403  <
404  class Type,
405  template<class> class PatchField,
406  class GeoMesh
407  >
408  void fillFields
409  (
410  const word& name,
411  const dimensionSet& dims,
413  ) const;
414 
415  //- Fill up gaps in a phase-indexed table of fields with zeros
416  template
417  <
418  class Type,
419  template<class> class PatchField,
420  class GeoMesh
421  >
422  void fillFields
423  (
424  const word& name,
425  const dimensionSet& dims,
427  fieldTable
428  ) const;
429 
430 
431  // Properties
432 
433  //- Return the mixture density
434  tmp<volScalarField> rho() const;
435 
436  //- Return the mixture velocity
437  tmp<volVectorField> U() const;
438 
439  //- Return the aspect-ratio for a pair
440  tmp<volScalarField> E(const phasePairKey& key) const;
441 
442  //- Return the surface tension coefficient for a pair
444 
445  //- Return the mass transfer rate for a pair
446  virtual tmp<volScalarField> dmdt(const phasePairKey& key) const;
447 
448  //- Return the mass transfer rates for each phase
449  virtual PtrList<volScalarField> dmdts() const;
450 
451 
452  // Transfers
453 
454  //- Return the momentum transfer matrices for the cell-based
455  // algorithm
457 
458  //- Return the momentum transfer matrices for the face-based
459  // algorithm
461 
462  //- Return the implicit force coefficients for the face-based
463  // algorithm
464  virtual PtrList<surfaceScalarField> AFfs() const = 0;
465 
466  //- Return the force fluxes for the cell-based algorithm
468  (
470  ) = 0;
471 
472  //- Return the force fluxes for the face-based algorithm
474  (
476  ) = 0;
477 
478  //- Return the force fluxes for the cell-based algorithm
480  (
482  ) const = 0;
483 
484  //- Return the force fluxes for the face-based algorithm
486  (
488  ) const = 0;
489 
490  //- Return the explicit part of the drag force
492  (
494  ) const = 0;
495 
496  //- Solve the drag system for the new velocities and fluxes
497  virtual void partialElimination
498  (
500  ) = 0;
501 
502  //- Solve the drag system for the new fluxes
503  virtual void partialEliminationf
504  (
506  ) = 0;
507 
508  //- Return the flux corrections for the cell-based algorithm
510  (
512  const bool includeVirtualMass = false
513  ) const = 0;
514 
515  //- Return the phase diffusivities divided by the momentum
516  // coefficients
517  virtual const HashPtrTable<surfaceScalarField>& DByAfs() const = 0;
518 
519  //- Return the heat transfer matrices
520  virtual autoPtr<heatTransferTable> heatTransfer() const = 0;
521 
522  //- Return the mass transfer matrices
523  virtual autoPtr<massTransferTable> massTransfer() const = 0;
524 
525 
526  // Evolution
527 
528  //- Solve for the phase fractions
529  virtual void solve();
530 
531  //- Correct the fluid properties other than those listed below
532  virtual void correct();
533 
534  //- Correct the kinematics
535  virtual void correctKinematics();
536 
537  //- Correct the thermodynamics
538  virtual void correctThermo();
539 
540  //- Correct the turbulence
541  virtual void correctTurbulence();
542 
543  //- Correct the energy transport e.g. alphat
544  virtual void correctEnergyTransport();
545 
546 
547  // IO
548 
549  //- Read base phaseProperties dictionary
550  virtual bool read();
551 };
552 
553 
554 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
555 
558 
559 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
560 
561 } // End namespace Foam
562 
563 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
564 
565 #include "phaseSystemI.H"
566 
567 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
568 
569 #ifdef NoRepository
570  #include "phaseSystemTemplates.C"
571 #endif
572 
573 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
574 
575 #endif
576 
577 // ************************************************************************* //
Foam::surfaceFields.
virtual void correctKinematics()
Correct the kinematics.
Definition: phaseSystem.C:369
const BlendedInterfacialModel< modelType > & lookupBlendedSubModel(const phasePair &key) const
Return a blended sub model between a phase pair.
virtual PtrList< surfaceScalarField > AFfs() const =0
Return the implicit force coefficients for the face-based.
virtual void correctEnergyTransport()
Correct the energy transport e.g. alphat.
Definition: phaseSystem.C:406
void generatePairs(const dictTable &modelDicts)
Generate pairs.
Definition: phaseSystem.C:69
fv::options & fvOptions() const
Access the fvOptions.
Definition: phaseSystemI.H:136
const phaseModelPartialList & movingPhases() const
Return the models for phases that are moving.
Definition: phaseSystemI.H:44
surfaceTensionModelTable surfaceTensionModels_
Surface tension models.
Definition: phaseSystem.H:185
rDeltaTY field()
virtual PtrList< surfaceScalarField > phiFfs(const PtrList< surfaceScalarField > &rAUfs)=0
Return the force fluxes for the face-based algorithm.
HashPtrTable< fvScalarMatrix > massTransferTable
Definition: phaseSystem.H:81
HashTable< autoPtr< phasePair >, phasePairKey, phasePairKey::hash > phasePairTable
Definition: phaseSystem.H:89
virtual tmp< volScalarField > dmdt(const phasePairKey &key) const
Return the mass transfer rate for a pair.
Definition: phaseSystem.C:335
HashPtrTable< fvVectorMatrix > momentumTransferTable
Definition: phaseSystem.H:77
phasePairTable phasePairs_
Phase pairs.
Definition: phaseSystem.H:157
virtual void partialElimination(const PtrList< volScalarField > &rAUs)=0
Solve the drag system for the new velocities and fluxes.
bool foundBlendedSubModel(const phasePair &key) const
Check availability of a blended sub model for a given phase pair.
virtual autoPtr< heatTransferTable > heatTransfer() const =0
Return the heat transfer matrices.
volScalarField dpdt_
Rate of change of pressure.
Definition: phaseSystem.H:167
TypeName("phaseSystem")
Runtime type information.
virtual autoPtr< momentumTransferTable > momentumTransferf()=0
Return the momentum transfer matrices for the face-based.
HashPtrTable< fvScalarMatrix > heatTransferTable
Definition: phaseSystem.H:79
phaseModelPartialList stationaryPhaseModels_
Stationary phase models.
Definition: phaseSystem.H:142
virtual PtrList< surfaceScalarField > ddtCorrByAs(const PtrList< volScalarField > &rAUs, const bool includeVirtualMass=false) const =0
Return the flux corrections for the cell-based algorithm.
A HashTable of pointers to objects of type <T>, with deallocation management of the pointers...
Definition: HashPtrTable.H:51
void createSubModels(const dictTable &modelDicts, HashTable< autoPtr< modelType >, phasePairKey, phasePairKey::hash > &models)
Generate pairs and sub-model tables.
Finite-volume options.
Definition: fvOptions.H:51
virtual autoPtr< momentumTransferTable > momentumTransfer()=0
Return the momentum transfer matrices for the cell-based.
phaseModelList phaseModels_
Phase models.
Definition: phaseSystem.H:132
Hashing functor for phasePairKey.
Definition: phasePairKey.H:138
virtual void correctTurbulence()
Correct the turbulence.
Definition: phaseSystem.C:397
phaseModelPartialList multiComponentPhaseModels_
Multi-component phase models.
Definition: phaseSystem.H:152
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:50
const phaseModelPartialList & stationaryPhases() const
Return the models for phases that are stationary.
Definition: phaseSystemI.H:58
tmp< volScalarField > rho() const
Return the mixture density.
Definition: phaseSystem.C:235
virtual void correctThermo()
Correct the thermodynamics.
Definition: phaseSystem.C:388
const phasePairTable & phasePairs() const
Return the phase pairs.
Definition: phaseSystemI.H:100
tmp< volScalarField > sigma(const phasePairKey &key) const
Return the surface tension coefficient for a pair.
Definition: phaseSystem.C:312
const phaseModelList & phases() const
Return the phase models.
Definition: phaseSystemI.H:30
virtual PtrList< volVectorField > KdUByAs(const PtrList< volScalarField > &rAUs) const =0
Return the explicit part of the drag force.
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
Definition: dimensionSet.H:105
An ordered pair of two objects of type <T> with first() and second() elements.
Definition: instant.H:46
phaseSystem(const fvMesh &mesh)
Construct from fvMesh.
Definition: phaseSystem.C:121
virtual bool read()
Read base phaseProperties dictionary.
Definition: phaseSystem.C:415
Class to represent a system of phases and model interfacial transfers between them.
Definition: phaseSystem.H:69
virtual void partialEliminationf(const PtrList< surfaceScalarField > &rAUfs)=0
Solve the drag system for the new fluxes.
A class for handling words, derived from Foam::string.
Definition: word.H:63
const IOMRFZoneList & MRF() const
Return MRF zones.
Definition: phaseSystemI.H:130
PtrList< surfaceScalarField > rAUfs
Definition: pEqn.H:30
const phaseModelPartialList & anisothermalPhases() const
Return the models for phases that have variable temperature.
Definition: phaseSystemI.H:72
PtrListDictionary< phaseModel > phaseModelList
Definition: phaseSystem.H:83
tmp< volScalarField > E(const phasePairKey &key) const
Return the aspect-ratio for a pair.
Definition: phaseSystem.C:293
tmp< volScalarField > byDt(const volScalarField &vf)
Definition: phaseSystem.C:435
UPtrList< phaseModel > phaseModelPartialList
Definition: phaseSystem.H:85
const fvMesh & mesh_
Reference to the mesh.
Definition: phaseSystem.H:127
virtual PtrList< surfaceScalarField > phiFs(const PtrList< volScalarField > &rAUs)=0
Return the force fluxes for the cell-based algorithm.
bool foundSubModel(const phasePair &key) const
Check availability of a sub model for a given phase pair.
const word & name() const
Name function is needed to disambiguate those inherited from regIOobject and dictionary.
A HashTable similar to std::unordered_map.
Definition: HashTable.H:108
phaseModelPartialList anisothermalPhaseModels_
Anisothermal phase models.
Definition: phaseSystem.H:147
virtual void solve()
Solve for the phase fractions.
Definition: phaseSystem.C:356
const modelType & lookupSubModel(const phasePair &key) const
Return a sub model between a phase pair.
An ordered or unorder pair of phase names. Typically specified as follows.
Definition: phasePairKey.H:61
phaseModelPartialList movingPhaseModels_
Moving phase models.
Definition: phaseSystem.H:137
aspectRatioModelTable aspectRatioModels_
Aspect ratio models.
Definition: phaseSystem.H:190
IOMRFZoneList MRF_
Optional MRF zones.
Definition: phaseSystem.H:172
static const word propertiesName
Default name of the phase properties dictionary.
Definition: phaseSystem.H:340
const volScalarField & dpdt() const
Return the rate of change of the pressure.
Definition: phaseSystemI.H:118
HashTable< autoPtr< reactingMultiphaseEuler::surfaceTensionModel >, phasePairKey, phasePairKey::hash > surfaceTensionModelTable
Definition: phaseSystem.H:110
void fillFields(const word &name, const dimensionSet &dims, PtrList< GeometricField< Type, PatchField, GeoMesh >> &fieldList) const
Fill up gaps in a phase-indexed list of fields with zeros.
void generatePairsAndSubModels(const word &modelName, HashTable< autoPtr< modelType >, phasePairKey, phasePairKey::hash > &models)
Generate pairs and sub-model tables.
Forward declarations of fvMatrix specializations.
PtrList< volScalarField > rAUs
Definition: pEqn.H:4
const surfaceScalarField & phi() const
Return the mixture flux.
Definition: phaseSystemI.H:106
void addField(const phaseModel &phase, const word &fieldName, tmp< GeoField > field, PtrList< GeoField > &fieldList) const
Add the field to a phase-indexed list, with the given name,.
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
Definition: foamGltfBase.H:103
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: List.H:55
virtual void correct()
Correct the fluid properties other than those listed below.
Definition: phaseSystem.C:360
blendingMethodTable blendingMethods_
Blending methods.
Definition: phaseSystem.H:177
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
HashTable< autoPtr< blendingMethod > > blendingMethodTable
Definition: phaseSystem.H:101
tmp< volVectorField > U() const
Return the mixture velocity.
Definition: phaseSystem.C:263
tmp< surfaceScalarField > calcPhi(const phaseModelList &phaseModels) const
Calculate and return the mixture flux.
Definition: phaseSystem.C:45
Single incompressible phase derived from the phase-fraction. Used as part of the multiPhaseMixture fo...
Definition: phase.H:50
virtual autoPtr< massTransferTable > massTransfer() const =0
Return the mass transfer matrices.
virtual ~phaseSystem()
Destructor.
Definition: phaseSystem.C:229
virtual PtrList< volScalarField > dmdts() const
Return the mass transfer rates for each phase.
Definition: phaseSystem.C:348
HashTable< autoPtr< aspectRatioModel >, phasePairKey, phasePairKey::hash > aspectRatioModelTable
Definition: phaseSystem.H:119
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
surfaceScalarField phi_
Total volumetric flux.
Definition: phaseSystem.H:162
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
Definition: GeoMesh.H:42
virtual PtrList< surfaceScalarField > phiKdPhifs(const PtrList< surfaceScalarField > &rAUfs) const =0
Return the force fluxes for the face-based algorithm.
A class for managing temporary objects.
Definition: HashPtrTable.H:50
virtual PtrList< surfaceScalarField > phiKdPhis(const PtrList< volScalarField > &rAUs) const =0
Return the force fluxes for the cell-based algorithm.
const phaseModelPartialList & multiComponentPhases() const
Return the models for phases that have multiple species.
Definition: phaseSystemI.H:86
const fvMesh & mesh() const
Return the mesh.
Definition: phaseSystemI.H:23
Single incompressible phase derived from the phase-fraction. Used as part of the multiPhaseMixture fo...
Definition: phaseModel.H:53
Description for mass transfer between a pair of phases. The direction of the mass transfer is from th...
Definition: phasePair.H:49
List of MRF zones with IO functionality. MRF zones are specified by a list of dictionary entries...
Definition: IOMRFZoneList.H:67
HashTable< dictionary, phasePairKey, phasePairKey::hash > dictTable
Definition: phaseSystem.H:98
virtual const HashPtrTable< surfaceScalarField > & DByAfs() const =0
Return the phase diffusivities divided by the momentum.
Namespace for OpenFOAM.