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()[mappingFieldName_];
137 
138  mapFieldMax_ = mixture_.Yprod0()[mapFieldIndex];
139 
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
thermo
psiReactionThermo & thermo
Definition: createFields.H:28
dictName
const word dictName("faMeshDefinition")
Foam::fluidThermo
Fundamental fluid thermodynamic properties.
Definition: fluidThermo.H:52
thermo
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
reaction
CombustionModel< rhoReactionThermo > & reaction
Definition: setRegionFluidFields.H:3
Foam::isA
const TargetType * isA(const Type &t)
Check if dynamic_cast to TargetType is possible.
Definition: typeInfo.H:197
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::nl
constexpr char nl
Definition: Ostream.H:404
mixtureFractionSoot.H
Foam::radiation::mixtureFractionSoot::~mixtureFractionSoot
virtual ~mixtureFractionSoot()
Destructor.
Definition: mixtureFractionSoot.C:146
singleStepReactingMixture.H
Foam::List< scalar >
Foam::radiation::sootModel
Base class for soor models.
Definition: sootModel.H:55
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::singleStepReactingMixture
Single step reacting mixture.
Definition: singleStepReactingMixture.H:55
Foam::radiation::mixtureFractionSoot::mixtureFractionSoot
mixtureFractionSoot(const dictionary &dict, const fvMesh &mesh, const word &modelType)
Construct from components.
Definition: mixtureFractionSoot.C:69
Foam::radiation::mixtureFractionSoot
This soot model is purely an state model. The amount of soot produced is determined by a single step ...
Definition: mixtureFractionSoot.H:84
Foam::GeometricField< scalar, fvPatchField, volMesh >
Foam::radiation::mixtureFractionSoot::correct
virtual void correct()
Main update/correction routine.
Definition: mixtureFractionSoot.C:153
Foam::Reaction
Simple extension of ReactionThermo to handle reaction kinetics in addition to the equilibrium thermod...
Definition: Reaction.H:59