ReactionList.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) 2011-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 "ReactionList.H"
27 #include "IFstream.H"
28 #include "SLPtrList.H"
29 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
32 template<class ThermoType>
34 (
35  const speciesTable& species,
36  const HashPtrTable<ThermoType>& thermoDb
37 )
38 :
40  species_(species),
41  thermoDb_(thermoDb),
42  dict_(dictionary::null)
43 {}
44 
45 
46 template<class ThermoType>
48 (
49  const speciesTable& species,
50  const HashPtrTable<ThermoType>& thermoDb,
51  const dictionary& dict
52 )
53 :
55  species_(species),
56  thermoDb_(thermoDb),
57  dict_(dict)
58 {
59  readReactionDict();
60 }
61 
62 
63 template<class ThermoType>
65 :
66  SLPtrList<Reaction<ThermoType>>(reactions),
67  species_(reactions.species_),
68  thermoDb_(reactions.thermoDb_),
69  dict_(reactions.dict_)
70 {}
71 
72 
73 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
74 
75 template<class ThermoType>
77 {}
78 
79 
80 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
81 
82 template<class ThermoType>
84 {
85  const dictionary& reactions(dict_.subDict("reactions"));
86 
87  // Set general temperature limits from the dictionary
89  dict_.lookupOrDefault<scalar>("Tlow", 0);
90 
92  dict_.lookupOrDefault<scalar>("Thigh", great);
93 
94  forAllConstIter(dictionary, reactions, iter)
95  {
96  const word reactionName = iter().keyword();
97 
98  this->append
99  (
101  (
102  species_,
103  thermoDb_,
104  reactions.subDict(reactionName)
105  ).ptr()
106  );
107  }
108 
109  return true;
110 }
111 
112 
113 template<class ThermoType>
115 {
116  os << "reactions" << nl;
117  os << token::BEGIN_BLOCK << incrIndent << nl;
118 
119  forAllConstIter(typename SLPtrList<Reaction<ThermoType>>, *this, iter)
120  {
121  const Reaction<ThermoType>& r = iter();
122  os << indent << r.name() << nl
123  << indent << token::BEGIN_BLOCK << incrIndent << nl;
124  writeEntry(os, "type", r.type());
125  r.write(os);
126  os << decrIndent << indent << token::END_BLOCK << nl;
127  }
128 
129  os << decrIndent << token::END_BLOCK << nl;
130 }
131 
132 
133 // ************************************************************************* //
ReactionList(const speciesTable &species, const HashPtrTable< ThermoType > &thermoDatabase)
Construct null.
Definition: ReactionList.C:34
void write(Ostream &os) const
Write.
Definition: ReactionList.C:114
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:226
bool readReactionDict()
Read reactions from dictionary.
Definition: ReactionList.C:83
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
const word & name() const
Return the name of the reaction.
Definition: ReactionI.H:36
virtual void write(Ostream &) const
Write.
Definition: Reaction.C:190
Simple extension of ReactionThermo to handle reaction kinetics in addition to the equilibrium thermod...
Definition: Reaction.H:56
Template class for non-intrusive linked PtrLists.
Definition: LPtrList.H:47
A class for handling words, derived from string.
Definition: word.H:59
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:29
rAUs append(new volScalarField(IOobject::groupName("rAU", phase1.name()), 1.0/(U1Eqn.A()+byDt(max(phase1.residualAlpha() - alpha1, scalar(0)) *rho1))))
~ReactionList()
Destructor.
Definition: ReactionList.C:76
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
static const char nl
Definition: Ostream.H:265
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:240
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
Non-intrusive singly-linked pointer list.
List of templated reactions.
Definition: ReactionList.H:54
A wordList with hashed indices for faster lookup by name.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:233