multiComponentMixture.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) 2011-2017 OpenFOAM Foundation
9 Copyright (C) 2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32
33template<class ThermoType>
35(
36 const dictionary& thermoDict
37)
38{
39 forAll(species_, i)
40 {
41 speciesData_.set
42 (
43 i,
44 new ThermoType(thermoDict.subDict(species_[i]))
45 );
46 }
47
48 return speciesData_[0];
49}
50
51
52template<class ThermoType>
54{
55 // Multiplication by 1.0 changes Yt patches to "calculated"
56 volScalarField Yt("Yt", 1.0*Y_[0]);
57
58 for (label n=1; n<Y_.size(); n++)
59 {
60 Yt += Y_[n];
61 }
62
63 if (mag(min(Yt).value()) < ROOTVSMALL)
64 {
66 << "Sum of mass fractions is zero for species " << this->species()
67 << exit(FatalError);
68 }
69
70 if (mag(max(Yt).value()) != scalar(1))
71 {
73 << "Sum of mass fractions is different from one for species "
74 << this->species()
75 << nl;
76 }
77
78 forAll(Y_, n)
79 {
80 Y_[n] /= Yt;
81 }
82}
83
84
85// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
86
87template<class ThermoType>
89(
91 const wordList& specieNames,
92 const ReactionTable<ThermoType>& thermoData,
93 const fvMesh& mesh,
94 const word& phaseName
95)
96:
97 basicSpecieMixture(thermoDict, specieNames, mesh, phaseName),
98 speciesData_(species_.size()),
99 mixture_("mixture", *thermoData[specieNames[0]]),
100 mixtureVol_("volMixture", *thermoData[specieNames[0]])
101{
102 forAll(species_, i)
103 {
104 speciesData_.set
105 (
106 i,
107 new ThermoType(*thermoData[species_[i]])
108 );
109 }
110
111 correctMassFractions();
112}
113
114
115template<class ThermoType>
117(
118 const dictionary& thermoDict,
119 const fvMesh& mesh,
120 const word& phaseName
121)
122:
124 (
126 thermoDict.lookup("species"),
127 mesh,
128 phaseName
129 ),
130 speciesData_(species_.size()),
131 mixture_("mixture", constructSpeciesData(thermoDict)),
132 mixtureVol_("volMixture", speciesData_[0])
133{
134 correctMassFractions();
135}
136
137
138// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
139
140template<class ThermoType>
142(
143 const label celli
144) const
145{
146 mixture_ = Y_[0][celli]*speciesData_[0];
147
148 for (label n=1; n<Y_.size(); n++)
149 {
150 mixture_ += Y_[n][celli]*speciesData_[n];
151 }
152
153 return mixture_;
154}
155
156
157template<class ThermoType>
159(
160 const label patchi,
161 const label facei
162) const
163{
164 mixture_ = Y_[0].boundaryField()[patchi][facei]*speciesData_[0];
165
166 for (label n=1; n<Y_.size(); n++)
167 {
168 mixture_ += Y_[n].boundaryField()[patchi][facei]*speciesData_[n];
169 }
170
171 return mixture_;
172}
173
174
175template<class ThermoType>
177(
178 const scalar p,
179 const scalar T,
180 const label celli
181) const
182{
183 scalar rhoInv = 0.0;
184 forAll(speciesData_, i)
185 {
186 rhoInv += Y_[i][celli]/speciesData_[i].rho(p, T);
187 }
188
189 mixtureVol_ =
190 Y_[0][celli]/speciesData_[0].rho(p, T)/rhoInv*speciesData_[0];
191
192 for (label n=1; n<Y_.size(); n++)
193 {
194 mixtureVol_ +=
195 Y_[n][celli]/speciesData_[n].rho(p, T)/rhoInv*speciesData_[n];
196 }
197
198 return mixtureVol_;
199}
200
201
202template<class ThermoType>
205(
206 const scalar p,
207 const scalar T,
208 const label patchi,
209 const label facei
210) const
211{
212 scalar rhoInv = 0.0;
213 forAll(speciesData_, i)
214 {
215 rhoInv +=
216 Y_[i].boundaryField()[patchi][facei]/speciesData_[i].rho(p, T);
217 }
218
219 mixtureVol_ =
220 Y_[0].boundaryField()[patchi][facei]/speciesData_[0].rho(p, T)/rhoInv
221 * speciesData_[0];
222
223 for (label n=1; n<Y_.size(); n++)
224 {
225 mixtureVol_ +=
226 Y_[n].boundaryField()[patchi][facei]/speciesData_[n].rho(p,T)
227 / rhoInv*speciesData_[n];
228 }
229
230 return mixtureVol_;
231}
232
233
234template<class ThermoType>
236(
238)
239{
240 forAll(species_, i)
241 {
242 speciesData_[i] = ThermoType(thermoDict.subDict(species_[i]));
243 }
244}
245
246
247// ************************************************************************* //
label n
volScalarField Yt(0.0 *Y[0])
Y[inertIndex] max(0.0)
const T * set(const label i) const
Definition: PtrList.H:138
virtual bool read()
Re-read model coefficients if they have changed.
speciesTable species_
Table of specie names.
Specialization of basicMultiComponentMixture for a mixture consisting of a number for molecular speci...
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Definition: dictionary.C:460
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
Foam::multiComponentMixture.
const ThermoType & cellMixture(const label celli) const
const ThermoType & cellVolMixture(const scalar p, const scalar T, const label celli) const
const ThermoType & patchFaceMixture(const label patchi, const label facei) const
const ThermoType & patchFaceVolMixture(const scalar p, const scalar T, const label patchi, const label facei) const
Lookup type of boundary radiation properties.
Definition: lookup.H:66
A class for handling words, derived from Foam::string.
Definition: word.H:68
volScalarField & p
const volScalarField & T
const dictionary & thermoDict
Definition: EEqn.H:16
dynamicFvMesh & mesh
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
#define WarningInFunction
Report a warning using Foam::Warning.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:82
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333