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 "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  HashPtrTable<ThermoType> thermoDatabase;
49  forAll(speciesThermo, i)
50  {
51  thermoDatabase.insert
52  (
53  speciesThermo[i].name(),
54  speciesThermo[i].clone().ptr()
55  );
56  }
57 
58  this->setSize(reactions.size());
59  label i = 0;
60 
61  forAllConstIter(dictionary, reactions, iter)
62  {
63  this->set
64  (
65  i++,
67  (
68  species,
69  thermoDatabase,
70  reactions.subDict(iter().keyword())
71  ).ptr()
72  );
73  }
74 }
75 
76 
77 template<class ThermoType>
79 (
80  const speciesTable& species,
81  const PtrList<ThermoType>& speciesThermo,
82  const objectRegistry& ob,
83  const dictionary& dict
84 )
85 {
86  // Set general temperature limits from the dictionary
88  dict.lookupOrDefault<scalar>("Tlow", 0);
89 
91  dict.lookupOrDefault<scalar>("Thigh", great);
92 
93  const dictionary& reactions(dict.subDict("reactions"));
94 
95  HashPtrTable<ThermoType> thermoDatabase;
96  forAll(speciesThermo, i)
97  {
98  thermoDatabase.insert
99  (
100  speciesThermo[i].name(),
101  speciesThermo[i].clone().ptr()
102  );
103  }
104 
105  this->setSize(reactions.size());
106  label i = 0;
107 
108  forAllConstIter(dictionary, reactions, iter)
109  {
110  this->set
111  (
112  i++,
114  (
115  species,
116  thermoDatabase,
117  ob,
118  reactions.subDict(iter().keyword())
119  ).ptr()
120  );
121  }
122 }
123 
124 
125 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
126 
127 template<class ThermoType>
129 {
130  os << "reactions" << nl;
131  os << token::BEGIN_BLOCK << incrIndent << nl;
132 
133  forAll(*this, i)
134  {
135  const Reaction<ThermoType>& r = this->operator[](i);
136 
137  os << indent << r.name() << nl
138  << indent << token::BEGIN_BLOCK << incrIndent << nl;
139 
140  writeEntry(os, "type", r.type());
141 
142  r.write(os);
143 
144  os << decrIndent << indent << token::END_BLOCK << nl;
145  }
146 
147  os << decrIndent << token::END_BLOCK << nl;
148 
151 
152  os << nl;
153 }
154 
155 
156 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
void write(Ostream &os) const
Write.
Definition: ReactionList.C:128
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 & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:221
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
virtual void write(Ostream &) const
Write.
Definition: Reaction.C:282
A HashTable specialisation for hashing pointers.
Definition: HashPtrTable.H:50
ReactionList()
Construct empty.
Definition: ReactionList.H:61
Simple extension of ReactionThermo to handle reaction kinetics in addition to the equilibrium thermod...
Definition: Reaction.H:55
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:982
points setSize(newPointi)
T clone(const T &t)
Definition: List.H:54
autoPtr< BasicCompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleMomentumTransportModel::transportModel &transport)
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:29
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
static const char nl
Definition: Ostream.H:260
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:235
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
A wordList with hashed indices for faster lookup by name.
const word & name() const
Return the name of the reaction.
Definition: reactionI.H:30
Registry of regIOobjects.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:228