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-2019 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"
28 
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 template<class ThermoType>
35 (
36  const fluidThermo& thermo
37 )
38 {
39  if (isA<singleStepReactingMixture<ThermoType>>(thermo))
40  {
41  return dynamic_cast<const singleStepReactingMixture<ThermoType>& >
42  (
43  thermo
44  );
45  }
46  else
47  {
49  << "Inconsistent thermo package for " << thermo.type()
50  << "Please select a thermo package based on "
51  << "singleStepReactingMixture" << exit(FatalError);
52 
53  return dynamic_cast<const singleStepReactingMixture<ThermoType>& >
54  (
55  thermo
56  );
57  }
58 
59 }
60 
61 
62 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
63 
64 template<class ThermoType>
66 (
67  const dictionary& dict,
68  const fvMesh& mesh,
69  const word& modelType
70 )
71 :
72  sootModel(dict, mesh, modelType),
73  soot_
74  (
75  IOobject
76  (
77  "soot",
78  mesh_.time().timeName(),
79  mesh_,
80  IOobject::MUST_READ,
81  IOobject::AUTO_WRITE
82  ),
83  mesh_
84  ),
85  coeffsDict_(dict.subOrEmptyDict(modelType + "Coeffs")),
86  nuSoot_(readScalar(coeffsDict_.lookup("nuSoot"))),
87  Wsoot_(readScalar(coeffsDict_.lookup("Wsoot"))),
88  sootMax_(-1),
89  mappingFieldName_
90  (
91  coeffsDict_.lookupOrDefault<word>("mappingField", "none")
92  ),
93  mapFieldMax_(1),
95  mixture_(checkThermo(thermo_))
96 {
97  const Reaction<ThermoType>& reaction = mixture_.operator[](0);
98 
99  const scalarList& specieStoichCoeffs(mixture_.specieStoichCoeffs());
100 
101  scalar totalMol = 0.0;
102  forAll(reaction.rhs(), i)
103  {
104  label speciei = reaction.rhs()[i].index;
105  totalMol += mag(specieStoichCoeffs[speciei]);
106  }
107 
108  totalMol += nuSoot_;
109 
110  scalarList Xi(reaction.rhs().size());
111 
112  scalar Wm = 0.0;
113  forAll(reaction.rhs(), i)
114  {
115  const label speciei = reaction.rhs()[i].index;
116  Xi[i] = mag(specieStoichCoeffs[speciei])/totalMol;
117  Wm += Xi[i]*mixture_.speciesData()[speciei].W();
118  }
119 
120  const scalar XSoot = nuSoot_/totalMol;
121  Wm += XSoot*Wsoot_;
122 
123  sootMax_ = XSoot*Wsoot_/Wm;
124 
125  Info << "Maximum soot mass concentrations: " << sootMax_ << nl;
126 
127  if (mappingFieldName_ == "none")
128  {
129  const label index = reaction.rhs()[0].index;
130  mappingFieldName_ = mixture_.Y(index).name();
131  }
132 
133  const label mapFieldIndex = mixture_.species()[mappingFieldName_];
134 
135  mapFieldMax_ = mixture_.Yprod0()[mapFieldIndex];
136 
137 }
138 
139 
140 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
141 
142 template<class ThermoType>
145 {}
146 
147 
148 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
149 
150 template<class ThermoType>
152 {
153  const volScalarField& mapField =
154  mesh_.lookupObject<volScalarField>(mappingFieldName_);
155 
156  soot_ = sootMax_*(mapField/mapFieldMax_);
157 }
158 
159 
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#define readScalar
Definition: doubleScalar.C:38
bool isA(const Type &t)
Check if a dynamic_cast to typeid is possible.
Definition: typeInfo.H:134
#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
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
Single step reacting mixture.
rhoReactionThermo & thermo
Definition: createFields.H:28
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type.
Simple extension of ReactionThermo to handle reaction kinetics in addition to the equilibrium thermod...
Definition: Reaction.H:56
A class for handling words, derived from string.
Definition: word.H:59
Fundamental fluid thermodynamic properties.
Definition: fluidThermo.H:49
CombustionModel< rhoReactionThermo > & reaction
const word dictName("particleTrackDict")
mixtureFraction(const dictionary &dict, const fvMesh &mesh, const word &modelType)
Construct from components.
static const char nl
Definition: Ostream.H:265
This soot model is purely an state model. The amount of soot produced is determined by a single step ...
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 > &)
const List< specieCoeffs > & rhs() const
Return the components of the right hand side.
Definition: ReactionI.H:64
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:734