All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mixtureFraction.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) 2013-2020 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 
26 #include "mixtureFraction.H"
27 #include "psiReactionThermo.H"
28 #include "rhoReactionThermo.H"
29 #include "singleStepCombustion.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
33 template<class ThermoType>
35 (
36  const dictionary& dict,
37  const fvMesh& mesh,
38  const word& modelType
39 )
40 :
41  sootModel(dict, mesh, modelType),
42  soot_
43  (
44  IOobject
45  (
46  "soot",
47  mesh_.time().timeName(),
48  mesh_,
49  IOobject::MUST_READ,
50  IOobject::AUTO_WRITE
51  ),
52  mesh_
53  ),
54  coeffsDict_(dict.subOrEmptyDict(modelType + "Coeffs")),
55  nuSoot_(coeffsDict_.lookup<scalar>("nuSoot")),
56  Wsoot_(coeffsDict_.lookup<scalar>("Wsoot")),
57  sootMax_(-1),
58  mappingFieldName_
59  (
60  coeffsDict_.lookupOrDefault<word>("mappingField", "none")
61  ),
62  mapFieldMax_(1)
63 {
64  const word& combustionName = combustionModel::combustionPropertiesName;
65 
66  typedef
68  psiCombustionType;
69 
70  typedef
72  rhoCombustionType;
73 
75  mesh.foundObject<psiCombustionType>(combustionName)
76  ? mesh.lookupObject<psiCombustionType>(combustionName).mixture()
77  : mesh.lookupObject<rhoCombustionType>(combustionName).mixture();
78 
80  mesh.foundObject<psiCombustionType>(combustionName)
81  ? mesh.lookupObject<psiCombustionType>(combustionName).reaction()
82  : mesh.lookupObject<rhoCombustionType>(combustionName).reaction();
83 
84  scalar totalMol = 0;
85  forAll(reaction.rhs(), i)
86  {
87  const scalar stoichCoeff = reaction.rhs()[i].stoichCoeff;
88  totalMol += mag(stoichCoeff);
89  }
90 
91  totalMol += nuSoot_;
92 
93  scalarList Xi(reaction.rhs().size());
94 
95  scalar Wm = 0;
96  forAll(reaction.rhs(), i)
97  {
98  const label speciei = reaction.rhs()[i].index;
99  const scalar stoichCoeff = reaction.rhs()[i].stoichCoeff;
100  Xi[i] = mag(stoichCoeff)/totalMol;
101  Wm += Xi[i]*mixture.specieThermos()[speciei].W();
102  }
103 
104  scalarList Yprod0(mixture.species().size(), 0.0);
105 
106  forAll(reaction.rhs(), i)
107  {
108  const label speciei = reaction.rhs()[i].index;
109  Yprod0[speciei] = mixture.specieThermos()[speciei].W()/Wm*Xi[i];
110  }
111 
112  const scalar XSoot = nuSoot_/totalMol;
113  Wm += XSoot*Wsoot_;
114 
115  sootMax_ = XSoot*Wsoot_/Wm;
116 
117  Info << "Maximum soot mass concentrations: " << sootMax_ << nl;
118 
119  if (mappingFieldName_ == "none")
120  {
121  const label index = reaction.rhs()[0].index;
122  mappingFieldName_ = mixture.Y(index).name();
123  }
124 
125  const label mapFieldIndex = mixture.species()[mappingFieldName_];
126 
127  mapFieldMax_ = Yprod0[mapFieldIndex];
128 }
129 
130 
131 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
132 
133 template<class ThermoType>
136 {}
137 
138 
139 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
140 
141 template<class ThermoType>
143 {
144  const volScalarField& mapField =
145  mesh_.lookupObject<volScalarField>(mappingFieldName_);
146 
147  soot_ = sootMax_*(mapField/mapFieldMax_);
148 }
149 
150 
151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
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
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
bool foundObject(const word &name) const
Is the named Type found?
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type.
const PtrList< ThermoType > & specieThermos() const
Return the raw specie thermodynamic data.
A class for handling words, derived from string.
Definition: word.H:59
Foam::multiComponentMixture.
CombustionModel< rhoReactionThermo > & reaction
mixtureFraction(const dictionary &dict, const fvMesh &mesh, const word &modelType)
Construct from components.
static const char nl
Definition: Ostream.H:260
virtual void correct()
Main update/correction routine.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Base class for soot models.
Definition: sootModel.H:50
messageStream Info
dimensioned< scalar > mag(const dimensioned< Type > &)
Base class for combustion models using multiComponentMixture.
const List< specieCoeffs > & rhs() const
Return the components of the right hand side.
Definition: ReactionI.H:64
phaseChangeTwoPhaseMixture & mixture
Definition: createFields.H:38
PtrList< volScalarField > & Y()
Return the mass-fraction fields.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
dictionary subOrEmptyDict(const word &, const bool mustRead=false) const
Find and return a sub-dictionary as a copy, or.
Definition: dictionary.C:969
const speciesTable & species() const
Return the table of species.