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 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "mixtureFractionSoot.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 
34 template<class ThermoType>
37 (
38  const fluidThermo& thermo
39 )
40 {
41  if (isA<singleStepReactingMixture<ThermoType>>(thermo))
42  {
43  return dynamic_cast<const singleStepReactingMixture<ThermoType>&>
44  (
45  thermo
46  );
47  }
48  else
49  {
51  << "Inconsistent thermo package for " << thermo.type()
52  << "Please select a thermo package based on "
53  << "singleStepReactingMixture" << exit(FatalError);
54 
55  return dynamic_cast<const singleStepReactingMixture<ThermoType>&>
56  (
57  thermo
58  );
59  }
60 
61 }
62 
63 
64 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
65 
66 template<class ThermoType>
68 (
69  const dictionary& dict,
70  const fvMesh& mesh,
71  const word& modelType
72 )
73 :
74  sootModel(dict, mesh, modelType),
75  soot_
76  (
77  IOobject
78  (
79  "soot",
80  mesh_.time().timeName(),
81  mesh_,
82  IOobject::MUST_READ,
83  IOobject::AUTO_WRITE
84  ),
85  mesh_
86  ),
87  coeffsDict_(dict.subOrEmptyDict(modelType + "Coeffs")),
88  nuSoot_(coeffsDict_.get<scalar>("nuSoot")),
89  Wsoot_(coeffsDict_.get<scalar>("Wsoot")),
90  sootMax_(-1),
91  mappingFieldName_
92  (
93  coeffsDict_.lookupOrDefault<word>("mappingField", "none")
94  ),
95  mapFieldMax_(1),
96  thermo_(mesh.lookupObject<fluidThermo>(basicThermo::dictName)),
97  mixture_(checkThermo(thermo_))
98 {
99  const Reaction<ThermoType>& reaction = mixture_.operator[](0);
100 
101  const scalarList& specieStoichCoeffs(mixture_.specieStoichCoeffs());
102 
103  scalar totalMol = 0.0;
104  forAll(reaction.rhs(), i)
105  {
106  label speciei = reaction.rhs()[i].index;
107  totalMol += mag(specieStoichCoeffs[speciei]);
108  }
109 
110  totalMol += nuSoot_;
111 
112  scalarList Xi(reaction.rhs().size());
113 
114  scalar Wm = 0.0;
115  forAll(reaction.rhs(), i)
116  {
117  const label speciei = reaction.rhs()[i].index;
118  Xi[i] = mag(specieStoichCoeffs[speciei])/totalMol;
119  Wm += Xi[i]*mixture_.speciesData()[speciei].W();
120  }
121 
122  const scalar XSoot = nuSoot_/totalMol;
123  Wm += XSoot*Wsoot_;
124 
125  sootMax_ = XSoot*Wsoot_/Wm;
126 
127  Info << "Maximum soot mass concentrations: " << sootMax_ << nl;
128 
129  if (mappingFieldName_ == "none")
130  {
131  const label index = reaction.rhs()[0].index;
132  mappingFieldName_ = mixture_.Y(index).name();
133  }
134 
135  const label mapFieldIndex = mixture_.species()[mappingFieldName_];
136 
137  mapFieldMax_ = mixture_.Yprod0()[mapFieldIndex];
138 
139 }
140 
141 
142 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
143 
144 template<class ThermoType>
146 {}
147 
148 
149 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
150 
151 template<class ThermoType>
153 {
154  const volScalarField& mapField =
155  mesh_.lookupObject<volScalarField>(mappingFieldName_);
156 
157  soot_ = sootMax_*(mapField/mapFieldMax_);
158 }
159 
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
thermo
psiReactionThermo & thermo
Definition: createFields.H:28
Foam::fluidThermo
Fundamental fluid thermodynamic properties.
Definition: fluidThermo.H:52
dictName
const word dictName("blockMeshDict")
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:290
Foam::label
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:62
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
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:121
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:84
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:355
Foam::nl
constexpr char nl
Definition: Ostream.H:372
mixtureFractionSoot.H
Foam::radiation::mixtureFractionSoot::~mixtureFractionSoot
virtual ~mixtureFractionSoot()
Destructor.
Definition: mixtureFractionSoot.C:145
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:68
Foam::radiation::mixtureFractionSoot
This soot model is purely an state model. The ammount 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:152
Foam::Reaction
Simple extension of ReactionThermo to handle reaction kinetics in addition to the equilibrium thermod...
Definition: Reaction.H:56