ReactionList.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 | Copyright (C) 2011-2017 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  forAllConstIter(dictionary, reactions, iter)
88  {
89  const word reactionName = iter().keyword();
90 
91  this->append
92  (
94  (
95  species_,
96  thermoDb_,
97  reactions.subDict(reactionName)
98  ).ptr()
99  );
100  }
101 
102  return true;
103 }
104 
105 
106 template<class ThermoType>
108 {
109  os << "reactions" << nl;
110  os << token::BEGIN_BLOCK << incrIndent << nl;
111 
112  forAllConstIter(typename SLPtrList<Reaction<ThermoType>>, *this, iter)
113  {
114  const Reaction<ThermoType>& r = iter();
115  os << indent << r.name() << nl
116  << indent << token::BEGIN_BLOCK << incrIndent << nl;
117  os.writeKeyword("type") << r.type() << token::END_STATEMENT << nl;
118  r.write(os);
119  os << decrIndent << indent << token::END_BLOCK << nl;
120  }
121 
122  os << decrIndent << token::END_BLOCK << nl;
123 }
124 
125 
126 // ************************************************************************* //
ReactionList(const speciesTable &species, const HashPtrTable< ThermoType > &thermoDatabase)
Construct null.
Definition: ReactionList.C:34
void write(Ostream &os) const
Write.
Definition: ReactionList.C:107
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:223
word & name()
Definition: ReactionI.H:36
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:137
virtual void write(Ostream &) const
Write.
Definition: Reaction.C:382
Simple extension of ReactionThermo to handle reaction kinetics in addition to the equilibrium thermod...
Definition: Reaction.H:53
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
~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:262
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:237
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:54
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:230