uMulticomponentbInhomogeneous.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) 2026 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 #include "uMulticomponentMixture.H"
28 #include "bInhomogeneousMixture.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 namespace ubMixtureMaps
36 {
39  (
42  thermo
43  );
44 }
45 }
46 
47 
48 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
49 
52 (
53  const uRhoMulticomponentThermo& uThermo,
54  const bRhoMulticomponentThermo& bThermo
55 )
56 :
57  ubMixtureMap(uThermo, bThermo),
58  fu_(uMixtureCast<uMulticomponentMixture>().fu())
59 {
60  const dictionary& uDict = uThermo.properties();
61  const speciesTable& uSpecies = uThermo.species();
62 
63  if (uDict.found("oxidantSpecies"))
64  {
65  const dictionary& oxidantSpecies(uDict.subDict("oxidantSpecies"));
66  ox_.setSize(oxidantSpecies.size());
67 
68  label i = 0;
69  forAllConstIter(dictionary, oxidantSpecies, iter)
70  {
71  const word specieName(iter().keyword());
72  const scalar massFraction(iter().stream()[0].scalarToken());
73 
74  ox_[i++] = {uSpecies[specieName], massFraction};
75  }
76  }
77 
78  if (uDict.found("productSpecies"))
79  {
80  const dictionary& productSpecies(uDict.subDict("productSpecies"));
81  pr_.setSize(productSpecies.size());
82 
83  label i = 0;
84  forAllConstIter(dictionary, productSpecies, iter)
85  {
86  const word specieName(iter().keyword());
87  const scalar massFraction(iter().stream()[0].scalarToken());
88 
89  pr_[i++] = {uSpecies[specieName], massFraction};
90  }
91  }
92 }
93 
94 
95 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
96 
99 {}
100 
101 
102 
103 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
104 
107 (
108  const PtrList<volScalarField>& Yu
109 ) const
110 {
112  Yp.set(bInhomogeneousMixture::FT, Yu[fu_]());
113 
114  return Yp;
115 }
116 
117 
119 (
120  const volScalarField& b,
122  const volScalarField& c,
124 ) const
125 {
126  if (!ox_.size() || !pr_.size())
127  {
129  << "oxidantSpecies or productSpecies not specified"
130  << exit(FatalError);
131  }
132 
133  const uMulticomponentMixture& um = uMixtureCast<uMulticomponentMixture>();
134 
135  volScalarField& fuu = Yu[fu_];
136 
137  const volScalarField& ftb = Yb[bInhomogeneousMixture::FT];
138 
139  const volScalarField fub
140  (
141  max
142  (
143  ftb - (scalar(1) - ftb)/um.stoicRatio(),
144  scalar(0)
145  )
146  );
147 
148  fuu = b*fuu + c*fub;
149 
150  const volScalarField oxb(1 - ftb - (ftb - fub)*um.stoicRatio());
151 
152  forAll(ox_, i)
153  {
154  Yu[ox_[i].first()] = b*Yu[ox_[i].first()] + c*ox_[i].second()*oxb;
155  }
156 
157  const volScalarField prb(1 - fub - oxb);
158 
159  forAll(pr_, i)
160  {
161  Yu[pr_[i].first()] = b*Yu[pr_[i].first()] + c*pr_[i].second()*prb;
162  }
163 }
164 
165 
166 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:492
Macros for easy insertion into run-time selection tables.
Generic GeometricField class.
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
bool set(const label) const
Is element set.
Definition: PtrListI.H:62
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
Base-class for combustion fluid thermodynamic properties based on compressibility.
virtual const IOdictionary & properties() const =0
Properties dictionary.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:778
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:468
A wordList with hashed indices for faster lookup by name.
virtual const speciesTable & species() const =0
Return the table of species.
Unburnt gas combustion multicomponent mixture for a single fuel specie.
scalar stoicRatio() const
Return the stoichiometric air/fuel ratio.
Base-class for combustion fluid thermodynamic properties based on compressibility.
Base class for unburnt/burnt gas composition mapping.
Definition: ubMixtureMap.H:51
virtual void reset(const volScalarField &b, UPtrList< volScalarField > &Yu, const volScalarField &c, const UPtrList< const volScalarField > &Yb) const
Reset the mixture to an unburnt state.
uMulticomponentbInhomogeneous(const uRhoMulticomponentThermo &uThermo, const bRhoMulticomponentThermo &bThermo)
Construct from components.
virtual PtrList< volScalarField::Internal > prompt(const PtrList< volScalarField > &Yu) const
Return the burnt gas prompt specie mass fractions.
A class for handling words, derived from string.
Definition: word.H:63
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
volScalarField & b
Definition: createFields.H:27
const dimensionedScalar c
Speed of light in a vacuum.
defineTypeNameAndDebug(uHomogeneousbHomogeneous, 0)
addToRunTimeSelectionTable(ubMixtureMap, uHomogeneousbHomogeneous, thermo)
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
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
error FatalError
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
fluidMulticomponentThermo & thermo
Definition: createFields.H:15