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-2023 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 "HashPtrTable.H"
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
31 template<class ThermoType>
33 (
34  const speciesTable& species,
35  const PtrList<ThermoType>& speciesThermo,
36  const dictionary& dict
37 )
38 {
39  // Set general temperature limits from the dictionary
41  dict.lookupOrDefault<scalar>("Tlow", 0);
42 
44  dict.lookupOrDefault<scalar>("Thigh", great);
45 
46  const dictionary& reactions(dict.subDict("reactions"));
47 
48  this->setSize(reactions.size());
49 
50  label i = 0;
51 
52  forAllConstIter(dictionary, reactions, iter)
53  {
54  this->set
55  (
56  i++,
58  (
59  species,
60  speciesThermo,
61  reactions.subDict(iter().keyword())
62  ).ptr()
63  );
64  }
65 }
66 
67 
68 template<class ThermoType>
70 (
71  const speciesTable& species,
72  const PtrList<ThermoType>& speciesThermo,
73  const objectRegistry& ob,
74  const dictionary& dict
75 )
76 {
77  // Set general temperature limits from the dictionary
79  dict.lookupOrDefault<scalar>("Tlow", 0);
80 
82  dict.lookupOrDefault<scalar>("Thigh", great);
83 
84  const dictionary& reactions(dict.subDict("reactions"));
85 
86  this->setSize(reactions.size());
87 
88  label i = 0;
89 
90  forAllConstIter(dictionary, reactions, iter)
91  {
92  this->set
93  (
94  i++,
96  (
97  species,
98  speciesThermo,
99  ob,
100  reactions.subDict(iter().keyword())
101  ).ptr()
102  );
103  }
104 }
105 
106 
107 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
108 
109 template<class ThermoType>
111 {
112  os << "reactions" << nl;
113  os << token::BEGIN_BLOCK << incrIndent << nl;
114 
115  forAll(*this, i)
116  {
117  const Reaction<ThermoType>& r = this->operator[](i);
118 
119  os << indent << r.name() << nl
120  << indent << token::BEGIN_BLOCK << incrIndent << nl;
121 
122  writeEntry(os, "type", r.type());
123 
124  r.write(os);
125 
126  os << decrIndent << indent << token::END_BLOCK << nl;
127  }
128 
129  os << decrIndent << token::END_BLOCK << nl;
130 
133 
134  os << nl;
135 }
136 
137 
138 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:477
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
void write(Ostream &os) const
Write.
Definition: ReactionList.C:110
ReactionList()
Construct empty.
Definition: ReactionList.H:61
Simple extension of ThermoType to handle reaction kinetics in addition to the equilibrium thermodynam...
Definition: Reaction.H:72
virtual void write(Ostream &) const
Write.
Definition: Reaction.C:259
const word & name() const
Return the name of the reaction.
Definition: reactionI.H:30
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
A wordList with hashed indices for faster lookup by name.
Registry of regIOobjects.
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:235
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:59
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:228
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:221
static const char nl
Definition: Ostream.H:260
points setSize(newPointi)
dictionary dict