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-2016 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  const speciesTable& species,
67  const HashPtrTable<ThermoType>& thermoDb,
68  const fileName& fName
69 )
70 :
72  (
73  dictionary(IFstream(fName)()).lookup("reactions"),
74  Reaction<ThermoType>::iNew(species, thermoDb)
75  ),
76  species_(species),
77  thermoDb_(thermoDb),
78  dict_(dictionary::null)
79 {}
80 
81 
82 template<class ThermoType>
84 :
85  SLPtrList<Reaction<ThermoType>>(reactions),
86  species_(reactions.species_),
87  thermoDb_(reactions.thermoDb_),
88  dict_(reactions.dict_)
89 {}
90 
91 
92 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
93 
94 template<class ThermoType>
96 {}
97 
98 
99 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
100 
101 template<class ThermoType>
103 {
104  const dictionary& reactions(dict_.subDict("reactions"));
105 
106  forAllConstIter(dictionary, reactions, iter)
107  {
108  const word reactionName = iter().keyword();
109 
110  this->append
111  (
113  (
114  species_,
115  thermoDb_,
116  reactions.subDict(reactionName)
117  ).ptr()
118  );
119  }
120 
121  return true;
122 }
123 
124 
125 template<class ThermoType>
127 {
128  os << "reactions" << nl;
129  os << token::BEGIN_BLOCK << incrIndent << nl;
130 
131  forAllConstIter(typename SLPtrList<Reaction<ThermoType>>, *this, iter)
132  {
133  const Reaction<ThermoType>& r = iter();
134  os << indent << r.name() << nl
136  os.writeKeyword("type") << r.type() << token::END_STATEMENT << nl;
137  r.write(os);
138  os << decrIndent << indent << token::END_BLOCK << nl;
139  }
140 
141  os << decrIndent << token::END_BLOCK << nl;
142 }
143 
144 
145 // ************************************************************************* //
Non-intrusive singly-linked pointer list.
Definition: SLPtrList.H:47
ReactionList(const speciesTable &species, const HashPtrTable< ThermoType > &thermoDatabase)
Construct null.
Definition: ReactionList.C:34
void write(Ostream &os) const
Write.
Definition: ReactionList.C:126
A class for handling file names.
Definition: fileName.H:69
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:102
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:633
Class used for the read-construction of PtrLists of reaction.
Definition: Reaction.H:196
Simple extension of ReactionThermo to handle reaction kinetics in addition to the equilibrium thermod...
Definition: Reaction.H:53
A class for handling words, derived from string.
Definition: word.H:59
virtual void write(Ostream &) const
Write.
Definition: Reaction.C:435
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:29
~ReactionList()
Destructor.
Definition: ReactionList.C:95
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
Input from file stream.
Definition: IFstream.H:81
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
void append(const T *&a)
Add at tail of list.
Definition: LList.H:166
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
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:451