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-2022 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();
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->thermo().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 // ************************************************************************* //
virtual PtrList< volScalarField > & YRef()
Access the species mass fractions.
virtual void correctSpecies()
Correct the species fractions.
tmp< fvMatrix< Type > > correction(const fvMatrix< Type > &)
Return the correction form of the given matrix.
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
FvWallInfoData< WallInfo, label > label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
fluidReactionThermo & thermo
Definition: createFields.H:28
virtual tmp< fvScalarMatrix > YiEqn(volScalarField &Yi)
Return the species fraction equation.
Calculate the matrix for the laplacian of the field.
virtual tmp< fvScalarMatrix > divj(volScalarField &Yi) const
Return the source term for the given specie mass-fraction.
tmp< fvMatrix< Type > > Sp(const volScalarField::Internal &, const GeometricField< Type, fvPatchField, volMesh > &)
MultiComponentPhaseModel(const phaseSystem &fluid, const word &phaseName, const bool referencePhase, const label index)
fvMesh & mesh
fluid correctSpecies()
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:58
Calculate the first temporal derivative.
virtual tmp< surfaceScalarField > alphaRhoPhi() const
Return the mass flux of the phase.
virtual const PtrList< volScalarField > & Y() const
Return the species mass fractions.
tmp< fvMatrix< Type > > ddt(const GeometricField< Type, fvPatchField, volMesh > &vf)
Definition: fvmDdt.C:46
Calculate the matrix for the first temporal derivative.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: UPtrList.H:54
virtual const UPtrList< volScalarField > & YActive() const
Return the active species mass fractions.
Calculate the divergence of the given field.
tmp< fvMatrix< Type > > div(const surfaceScalarField &flux, const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvmDiv.C:46
virtual ~MultiComponentPhaseModel()
Destructor.
Calculate the matrix for the divergence of the given field and flux.
#define R(A, B, C, D, E, F, K, M)
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:70
A class for managing temporary objects.
Definition: PtrList.H:53
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
virtual UPtrList< volScalarField > & YActiveRef()
Access the active species mass fractions.
virtual bool pure() const
Return whether the phase is pure (i.e., not multi-component)
Calculate the matrix for implicit and explicit sources.