MultiComponentPhaseModel.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) 2015-2018 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 
30 
31 #include "phaseSystem.H"
32 
33 #include "fvmDdt.H"
34 #include "fvmDiv.H"
35 #include "fvmSup.H"
36 #include "fvmLaplacian.H"
37 #include "fvcDdt.H"
38 #include "fvcDiv.H"
39 #include "fvMatrix.H"
40 
41 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42 
43 template<class BasePhaseModel>
45 (
46  const phaseSystem& fluid,
47  const word& phaseName,
48  const label index
49 )
50 :
51  BasePhaseModel(fluid, phaseName, index),
52  Sct_
53  (
54  "Sct",
55  dimless,
56  fluid.subDict(phaseName)
57  ),
58  residualAlpha_
59  (
60  "residualAlpha",
61  dimless,
62  fluid.mesh().solverDict("Yi")
63  ),
64  inertIndex_(-1)
65 {
66  const word inertSpecie
67  (
68  this->thermo_->getOrDefault("inertSpecie", word::null)
69  );
70 
71  if (inertSpecie != word::null)
72  {
73  inertIndex_ = this->thermo_->composition().species()[inertSpecie];
74  }
75 
76  PtrList<volScalarField>& Y = this->thermo_->composition().Y();
77 
78  forAll(Y, i)
79  {
80  if (i != inertIndex_ && this->thermo_->composition().active(i))
81  {
82  const label j = YActive_.size();
83  YActive_.resize(j + 1);
84  YActive_.set(j, &Y[i]);
85  }
86  }
87 }
88 
89 
90 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
91 
92 template<class BasePhaseModel>
94 {}
95 
96 
97 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
98 
99 template<class BasePhaseModel>
101 {
103  (
104  IOobject
105  (
106  IOobject::groupName("Yt", this->name()),
107  this->fluid().mesh().time().timeName(),
108  this->fluid().mesh()
109  ),
110  this->fluid().mesh(),
112  );
113 
114  PtrList<volScalarField>& Yi = YRef();
115 
116  forAll(Yi, i)
117  {
118  if (i != inertIndex_)
119  {
120  Yt += Yi[i];
121  }
122  }
123 
124  if (inertIndex_ != -1)
125  {
126  Yi[inertIndex_] = scalar(1) - Yt;
127  Yi[inertIndex_].max(0);
128  }
129  else
130  {
131  forAll(Yi, i)
132  {
133  Yi[i] /= Yt;
134  Yi[i].max(0);
135  }
136  }
137 
139 }
140 
141 
142 template<class BasePhaseModel>
144 {
145  return false;
146 }
147 
148 
149 template<class BasePhaseModel>
152 {
153  const volScalarField& alpha = *this;
154  const surfaceScalarField alphaRhoPhi(this->alphaRhoPhi());
155  const volScalarField& rho = this->thermo().rho();
156 
157  return
158  (
159  fvm::ddt(alpha, rho, Yi)
160  + fvm::div(alphaRhoPhi, Yi, "div(" + alphaRhoPhi.name() + ",Yi)")
161 
163  (
165  *fvc::interpolate(this->muEff()/Sct_),
166  Yi
167  )
168  ==
169  alpha*this->R(Yi)
170 
171  + fvc::ddt(residualAlpha_*rho, Yi)
172  - fvm::ddt(residualAlpha_*rho, Yi)
173  );
174 }
175 
176 
177 template<class BasePhaseModel>
180 {
181  return this->thermo_->composition().Y();
182 }
183 
184 
185 template<class BasePhaseModel>
188 {
189  return this->thermo_->composition().Y(name);
190 }
191 
192 
193 template<class BasePhaseModel>
196 {
197  return this->thermo_->composition().Y();
198 }
199 
200 
201 template<class BasePhaseModel>
204 {
205  return YActive_;
206 }
207 
208 
209 template<class BasePhaseModel>
212 {
213  return YActive_;
214 }
215 
216 
217 // ************************************************************************* //
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::constant::atomic::alpha
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Definition: readThermalProperties.H:212
thermo
psiReactionThermo & thermo
Definition: createFields.H:28
fvcDiv.H
Calculate the divergence of the given field.
fvMatrix.H
Foam::MultiComponentPhaseModel::~MultiComponentPhaseModel
virtual ~MultiComponentPhaseModel()=default
Destructor.
Definition: MultiComponentPhaseModel.C:93
fluid
twoPhaseSystem & fluid
Definition: setRegionFluidFields.H:3
Foam::fac::div
tmp< GeometricField< Type, faPatchField, areaMesh > > div(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Definition: facDiv.C:50
rho
rho
Definition: readInitialConditions.H:88
Foam::MultiComponentPhaseModel::Y
virtual const PtrList< volScalarField > & Y() const
Constant access the species mass fractions.
Definition: MultiComponentPhaseModel.C:412
fvmDiv.H
Calculate the matrix for the divergence of the given field and flux.
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::MultiComponentPhaseModel::YRef
virtual PtrList< volScalarField > & YRef()
Access the species mass fractions.
Definition: MultiComponentPhaseModel.C:195
Foam::MultiComponentPhaseModel::MultiComponentPhaseModel
MultiComponentPhaseModel(const phaseSystem &fluid, const word &phaseName)
Definition: MultiComponentPhaseModel.C:49
R
#define R(A, B, C, D, E, F, K, M)
Yt
volScalarField Yt(0.0 *Y[0])
fvmLaplacian.H
Calculate the matrix for the laplacian of the field.
Foam::MultiComponentPhaseModel::pure
virtual bool pure() const
Return whether the phase is pure (i.e., not multi-component)
Definition: MultiComponentPhaseModel.C:143
Foam::UPtrList
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: UPtrList.H:62
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:42
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:59
timeName
word timeName
Definition: getTimeIndex.H:3
inertSpecie
const word inertSpecie(thermo.get< word >("inertSpecie"))
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
correctThermo
mixture correctThermo()
Y
PtrList< volScalarField > & Y
Definition: createFieldRefs.H:7
MultiComponentPhaseModel.H
fvmSup.H
Calculate the matrix for implicit and explicit sources.
Foam::MultiComponentPhaseModel::YActive
virtual const UPtrList< volScalarField > & YActive() const
Return the active species mass fractions.
Definition: MultiComponentPhaseModel.C:203
Foam::MultiComponentPhaseModel::YiEqn
virtual tmp< fvScalarMatrix > YiEqn(volScalarField &Yi)
Return the species fraction equation.
Definition: MultiComponentPhaseModel.C:151
Foam::fac::ddt
tmp< GeometricField< Type, faPatchField, areaMesh > > ddt(const dimensioned< Type > dt, const faMesh &mesh)
Definition: facDdt.C:47
Foam::MultiComponentPhaseModel::correctThermo
virtual void correctThermo()
Correct the thermodynamics.
Definition: MultiComponentPhaseModel.C:100
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::MultiComponentPhaseModel::YActiveRef
virtual UPtrList< volScalarField > & YActiveRef()
Access the active species mass fractions.
Definition: MultiComponentPhaseModel.C:211
fvcDdt.H
Calculate the first temporal derivative.
Foam::phaseSystem
Class to represent a system of phases and model interfacial transfers between them.
Definition: phaseSystem.H:66
Foam::fac::laplacian
tmp< GeometricField< Type, faPatchField, areaMesh > > laplacian(const GeometricField< Type, faPatchField, areaMesh > &vf, const word &name)
Definition: facLaplacian.C:47
Foam::GeometricField< scalar, fvPatchField, volMesh >
Foam::fac::interpolate
static tmp< GeometricField< Type, faePatchField, edgeMesh > > interpolate(const GeometricField< Type, faPatchField, areaMesh > &tvf, const edgeScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
fvmDdt.H
Calculate the matrix for the first temporal derivative.
Foam::dimless
const dimensionSet dimless
Dimensionless.
Definition: dimensionSets.C:189