mixtureFractionSoot.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) 2013-2016 OpenFOAM Foundation
9  Copyright (C) 2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 
29 #include "mixtureFractionSoot.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 
35 template<class ThermoType>
38 (
39  const fluidThermo& thermo
40 )
41 {
42  if (isA<singleStepReactingMixture<ThermoType>>(thermo))
43  {
44  return dynamic_cast<const singleStepReactingMixture<ThermoType>&>
45  (
46  thermo
47  );
48  }
49  else
50  {
52  << "Inconsistent thermo package for " << thermo.type()
53  << "Please select a thermo package based on "
54  << "singleStepReactingMixture" << exit(FatalError);
55 
56  return dynamic_cast<const singleStepReactingMixture<ThermoType>&>
57  (
58  thermo
59  );
60  }
61 
62 }
63 
64 
65 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
66 
67 template<class ThermoType>
69 (
70  const dictionary& dict,
71  const fvMesh& mesh,
72  const word& modelType
73 )
74 :
75  sootModel(dict, mesh, modelType),
76  soot_
77  (
78  IOobject
79  (
80  "soot",
81  mesh_.time().timeName(),
82  mesh_,
83  IOobject::MUST_READ,
84  IOobject::AUTO_WRITE
85  ),
86  mesh_
87  ),
88  coeffsDict_(dict.subOrEmptyDict(modelType + "Coeffs")),
89  nuSoot_(coeffsDict_.get<scalar>("nuSoot")),
90  Wsoot_(coeffsDict_.get<scalar>("Wsoot")),
91  sootMax_(-1),
92  mappingFieldName_
93  (
94  coeffsDict_.getOrDefault<word>("mappingField", "none")
95  ),
96  mapFieldMax_(1),
97  thermo_(mesh.lookupObject<fluidThermo>(basicThermo::dictName)),
98  mixture_(checkThermo(thermo_))
99 {
100  const Reaction<ThermoType>& reaction = mixture_.operator[](0);
101 
102  const scalarList& specieStoichCoeffs(mixture_.specieStoichCoeffs());
103 
104  scalar totalMol = 0.0;
105  forAll(reaction.rhs(), i)
106  {
107  label speciei = reaction.rhs()[i].index;
108  totalMol += mag(specieStoichCoeffs[speciei]);
109  }
110 
111  totalMol += nuSoot_;
112 
113  scalarList Xi(reaction.rhs().size());
114 
115  scalar Wm = 0.0;
116  forAll(reaction.rhs(), i)
117  {
118  const label speciei = reaction.rhs()[i].index;
119  Xi[i] = mag(specieStoichCoeffs[speciei])/totalMol;
120  Wm += Xi[i]*mixture_.speciesData()[speciei].W();
121  }
122 
123  const scalar XSoot = nuSoot_/totalMol;
124  Wm += XSoot*Wsoot_;
125 
126  sootMax_ = XSoot*Wsoot_/Wm;
127 
128  Info << "Maximum soot mass concentrations: " << sootMax_ << nl;
129 
130  if (mappingFieldName_ == "none")
131  {
132  const label index = reaction.rhs()[0].index;
133  mappingFieldName_ = mixture_.Y(index).name();
134  }
135 
136  const label mapFieldIndex = mixture_.species().find(mappingFieldName_);
137 
138  mapFieldMax_ = mixture_.Yprod0()[mapFieldIndex];
140 }
141 
142 
143 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
144 
145 template<class ThermoType>
147 {}
148 
149 
150 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
151 
152 template<class ThermoType>
154 {
155  const volScalarField& mapField =
156  mesh_.lookupObject<volScalarField>(mappingFieldName_);
157 
158  soot_ = sootMax_*(mapField/mapFieldMax_);
159 }
160 
161 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
dictionary dict
Abstract base-class for fluid and solid thermodynamic properties.
Definition: basicThermo.H:59
mixtureFractionSoot(const dictionary &dict, const fvMesh &mesh, const word &modelType)
Construct from components.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:598
Single step reacting mixture.
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
virtual void correct()
Main update/correction routine.
const word dictName("faMeshDefinition")
Simple extension of ReactionThermo to handle reaction kinetics in addition to the equilibrium thermod...
Definition: Reaction.H:55
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
psiReactionThermo & thermo
Definition: createFields.H:28
word timeName
Definition: getTimeIndex.H:3
dynamicFvMesh & mesh
Base class for soor models.
Definition: sootModel.H:49
A class for handling words, derived from Foam::string.
Definition: word.H:63
Fundamental fluid thermodynamic properties.
Definition: fluidThermo.H:48
This soot model is purely an state model. The amount of soot produced is determined by a single step ...
CombustionModel< rhoReactionThermo > & reaction
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
messageStream Info
Information stream (stdout output on master, null elsewhere)
const Type * isA(const U &obj)
Check if dynamic_cast to Type is possible.
Definition: typeInfo.H:88
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172