MulticomponentPhaseModel.C
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) 2015-2023 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 \*---------------------------------------------------------------------------*/
25 
27 
28 #include "phaseSystem.H"
29 
30 #include "fvmDdt.H"
31 #include "fvmDiv.H"
32 #include "fvmSup.H"
33 #include "fvmLaplacian.H"
34 #include "fvcDdt.H"
35 #include "fvcDiv.H"
36 #include "fvMatrix.H"
37 
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 
40 template<class BasePhaseModel>
42 (
43  const phaseSystem& fluid,
44  const word& phaseName,
45  const bool referencePhase,
46  const label index
47 )
48 :
49  BasePhaseModel(fluid, phaseName, referencePhase, index)
50 {
51  PtrList<volScalarField>& Y = this->thermo_->composition().Y();
52 
53  forAll(Y, i)
54  {
55  if (this->thermo_->composition().solve(i))
56  {
57  const label j = YActive_.size();
58  YActive_.resize(j + 1);
59  YActive_.set(j, &Y[i]);
60  }
61  }
62 }
63 
64 
65 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
66 
67 template<class BasePhaseModel>
69 {}
70 
71 
72 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
73 
74 template<class BasePhaseModel>
76 {
77  this->thermo_->composition().normalise();
78  BasePhaseModel::correctSpecies();
79 }
80 
81 
82 template<class BasePhaseModel>
84 {
85  return false;
86 }
87 
88 
89 template<class BasePhaseModel>
92 {
93  const volScalarField& alpha = *this;
94  const volScalarField& rho = this->rho();
95 
96  const tmp<surfaceScalarField> talphaRhoPhi(this->alphaRhoPhi());
97  const surfaceScalarField& alphaRhoPhi(talphaRhoPhi());
98 
99  return
100  (
101  fvm::ddt(alpha, rho, Yi)
102  + fvm::div(alphaRhoPhi, Yi, "div(" + alphaRhoPhi.name() + ",Yi)")
103  + this->divj(Yi)
104  ==
105  alpha*this->R(Yi)
106 
107  - correction
108  (
109  fvm::Sp
110  (
111  max(this->residualAlpha() - alpha, scalar(0))*rho
112  /this->mesh().time().deltaT(),
113  Yi
114  )
115  )
116  );
117 }
118 
119 
120 template<class BasePhaseModel>
123 {
124  return this->thermo_->composition().Y();
125 }
126 
127 
128 template<class BasePhaseModel>
131 {
132  return this->thermo_->composition().Y(name);
133 }
134 
135 
136 template<class BasePhaseModel>
139 {
140  return this->thermo_->composition().Y();
141 }
142 
143 
144 template<class BasePhaseModel>
147 {
148  return YActive_;
149 }
150 
151 
152 template<class BasePhaseModel>
155 {
156  return YActive_;
157 }
158 
159 
160 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
Generic GeometricField class.
const word & name() const
Return name.
Definition: IOobject.H:310
virtual void correctSpecies()
Correct the species fractions.
MulticomponentPhaseModel(const phaseSystem &fluid, const word &phaseName, const bool referencePhase, const label index)
virtual const UPtrList< volScalarField > & YActive() const
Return the active species mass fractions.
virtual PtrList< volScalarField > & YRef()
Access the species mass fractions.
virtual tmp< fvScalarMatrix > YiEqn(volScalarField &Yi)
Return the species fraction equation.
virtual bool pure() const
Return whether the phase is pure (i.e., not multi-component)
UPtrList< volScalarField > YActive_
Pointer list to active species.
virtual ~MulticomponentPhaseModel()
Destructor.
virtual UPtrList< volScalarField > & YActiveRef()
Access the active species mass fractions.
virtual const PtrList< volScalarField > & Y() const
Return the species mass fractions.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: PtrList.H:75
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: UPtrList.H:66
Class to represent a system of phases and model interfacial transfers between them.
Definition: phaseSystem.H:73
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:62
Calculate the first temporal derivative.
Calculate the divergence of the given field.
Calculate the matrix for the first temporal derivative.
Calculate the matrix for the divergence of the given field and flux.
Calculate the matrix for the laplacian of the field.
Calculate the matrix for implicit and explicit sources.
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
tmp< fvMatrix< Type > > Sp(const volScalarField::Internal &, const VolField< Type > &)
tmp< fvMatrix< Type > > div(const surfaceScalarField &flux, const VolField< Type > &vf, const word &name)
Definition: fvmDiv.C:48
tmp< fvMatrix< Type > > ddt(const VolField< Type > &vf)
Definition: fvmDdt.C:46
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
tmp< fvMatrix< Type > > correction(const fvMatrix< Type > &)
Return the correction form of the given matrix.
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47