phaseChange.C
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) 2018-2019 OpenFOAM Foundation
9  Copyright (C) 2020 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 \*---------------------------------------------------------------------------*/
28 
29 #include "phaseChange.H"
31 #include "phaseSystem.H"
32 #include "phasePairKey.H"
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 namespace diameterModels
39 {
40 namespace driftModels
41 {
42  defineTypeNameAndDebug(phaseChange, 0);
43  addToRunTimeSelectionTable(driftModel, phaseChange, dictionary);
44 }
45 }
46 }
47 
48 
49 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 
52 (
53  const populationBalanceModel& popBal,
54  const dictionary& dict
55 )
56 :
57  driftModel(popBal, dict),
58  pairKeys_(dict.lookup("pairs")),
59  numberWeighted_(dict.getOrDefault<Switch>("numberWeighted", false)),
60  W_(pairKeys_.size())
61 {
62  const phaseSystem& fluid = popBal_.fluid();
63 
64  forAll(pairKeys_, i)
65  {
66  const phasePair& pair = fluid.phasePairs()[pairKeys_[i]];
67 
68  W_.set
69  (
70  i,
71  new volScalarField
72  (
73  IOobject
74  (
76  popBal_.mesh().time().timeName(),
77  popBal_.mesh()
78  ),
79  popBal_.mesh(),
81  (
82  inv(numberWeighted_ ? dimVolume : dimLength),
83  Zero
84  )
85  )
86  );
87  }
88 }
89 
90 
91 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
92 
94 {
95  const phaseSystem& fluid = popBal_.fluid();
96 
97  forAll(pairKeys_, i)
98  {
99  W_[i] *= 0.0;
100  }
101 
102  forAll(pairKeys_, k)
103  {
104  if (fluid.phasePairs().found(pairKeys_[k]))
105  {
106  const phasePair& pair = fluid.phasePairs()[pairKeys_[k]];
107 
108  forAll(popBal_.velocityGroups(), j)
109  {
110  const velocityGroup& vgj = popBal_.velocityGroups()[j];
111  if (pair.contains(vgj.phase()))
112  {
113  forAll(vgj.sizeGroups(), i)
114  {
115  const sizeGroup& fi = vgj.sizeGroups()[i];
116 
117  W_[k] +=
118  fi*max(fi.phase(), SMALL)
119  /(numberWeighted_ ? fi.x() : fi.d());
120  }
121  }
122  }
123  }
124  }
125 }
126 
127 
129 (
130  volScalarField& driftRate,
131  const label i
132 )
133 {
134  const velocityGroup& vg = popBal_.sizeGroups()[i].VelocityGroup();
135 
136  forAll(pairKeys_, k)
137  {
138  const phasePair& pair =
139  popBal_.fluid().phasePairs()[pairKeys_[k]];
140 
141  if (pair.contains(vg.phase()))
142  {
143  const volScalarField& iDmdt =
144  popBal_.mesh().lookupObject<volScalarField>
145  (
146  IOobject::groupName("iDmdt", pair.name())
147  );
148 
149  const scalar iDmdtSign =
150  vg.phase().name() == pair.first() ? +1 : -1;
151 
152  const sizeGroup& fi = popBal_.sizeGroups()[i];
153 
154  tmp<volScalarField> dDriftRate
155  (
156  iDmdtSign*iDmdt/(fi.phase().rho()*W_[k])
157  );
158 
159  if (!numberWeighted_)
160  {
161  dDriftRate.ref() *= fi.x()/fi.d();
162  }
163 
164  driftRate += dDriftRate;
165  }
166  }
167 }
168 
169 
170 // ************************************************************************* //
twoPhaseSystem & fluid
dictionary dict
Base class for drift models.
Definition: driftModel.H:48
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
Class that solves the univariate population balance equation by means of a class method (also called ...
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:40
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
const populationBalanceModel & popBal_
Reference to the populationBalanceModel.
Definition: driftModel.H:57
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, any/none. Also accepts 0/1 as a string and shortcuts t/f, y/n.
Definition: Switch.H:77
label k
Boltzmann constant.
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:360
Lookup type of boundary radiation properties.
Definition: lookup.H:57
Macros for easy insertion into run-time selection tables.
phaseChange(const populationBalanceModel &popBal, const dictionary &dict)
Construct from a population balance model and a dictionary.
Definition: phaseChange.C:45
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:81
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: POSIX.C:799
const dimensionSet dimVolume(pow3(dimLength))
Definition: dimensionSets.H:58
static word groupName(StringType base, const word &group)
Create dot-delimited name.group string.
static word scopedName(const std::string &scope, const word &name)
Create scope:name or scope_name string.
Definition: IOobjectI.H:40
Class to represent a system of phases and model interfacial transfers between them.
Definition: phaseSystem.H:69
const phaseSystem & fluid() const
Return reference to the phaseSystem.
const Mesh & mesh() const noexcept
Return mesh.
virtual void addToDriftRate(volScalarField &driftRate, const label i)
Add to driftRate.
Definition: phaseChange.C:122
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
Definition: Time.C:714
virtual word name() const
Pair name.
Definition: phasePair.C:62
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:50
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
virtual void correct()
Correct diameter independent expressions.
Definition: phaseChange.C:86
bool contains(const phaseModel &phase) const
Return true if this phasePair contains the given phase.
Definition: phasePairI.H:35
const fvMesh & mesh() const
Return reference to the mesh.
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
addToRunTimeSelectionTable(driftModel, constantDrift, dictionary)
Description for mass transfer between a pair of phases. The direction of the mass transfer is from th...
Definition: phasePair.H:49
defineTypeNameAndDebug(constantDrift, 0)
Namespace for OpenFOAM.
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127