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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "ReactionList.H"
30 #include "IFstream.H"
31 #include "SLPtrList.H"
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
35 template<class ThermoType>
37 (
38  const speciesTable& species,
39  const HashPtrTable<ThermoType>& thermoDb
40 )
41 :
43  species_(species),
44  thermoDb_(thermoDb),
45  dict_(dictionary::null)
46 {}
47 
48 
49 template<class ThermoType>
51 (
52  const speciesTable& species,
53  const HashPtrTable<ThermoType>& thermoDb,
54  const dictionary& dict
55 )
56 :
58  species_(species),
59  thermoDb_(thermoDb),
60  dict_(dict)
61 {
62  readReactionDict();
63 }
64 
65 
66 template<class ThermoType>
68 :
69  SLPtrList<Reaction<ThermoType>>(reactions),
70  species_(reactions.species_),
71  thermoDb_(reactions.thermoDb_),
72  dict_(reactions.dict_)
73 {}
74 
75 
76 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
77 
78 template<class ThermoType>
80 {
81  for (const entry& dEntry : dict_.subDict("reactions"))
82  {
83  this->append
84  (
86  (
87  species_,
88  thermoDb_,
89  dEntry.dict()
90  ).ptr()
91  );
92  }
93 
94  return true;
95 }
96 
97 
98 template<class ThermoType>
100 {
101  os.beginBlock("reactions");
102 
103  for (const Reaction<ThermoType>& r : *this)
104  {
105  os.beginBlock(r.name());
106 
107  os.writeEntry("type", r.type());
108  r.write(os);
109 
110  os.endBlock();
111  }
112 
113  os.endBlock();
114 }
115 
116 
117 // ************************************************************************* //
Foam::entry
A keyword and a list of tokens is an 'entry'.
Definition: entry.H:67
ReactionList.H
SLPtrList.H
Non-intrusive singly-linked pointer list.
Foam::ReactionList::ReactionList
ReactionList(const speciesTable &species, const HashPtrTable< ThermoType > &thermoDatabase)
Construct null.
Definition: ReactionList.C:37
Foam::Ostream::beginBlock
virtual Ostream & beginBlock(const keyType &kw)
Write begin block group with the given name.
Definition: Ostream.C:91
append
rAUs append(new volScalarField(IOobject::groupName("rAU", phase1.name()), 1.0/(U1Eqn.A()+byDt(max(phase1.residualAlpha() - alpha1, scalar(0)) *rho1))))
Foam::LPtrList
Template class for non-intrusive linked PtrLists.
Definition: LPtrList.H:50
Foam::ReactionList
List of templated reactions.
Definition: ReactionList.H:57
Foam::hashedWordList
A wordList with hashed named lookup, which can be faster in some situations than using the normal lis...
Definition: hashedWordList.H:54
Foam::Reaction::write
virtual void write(Ostream &) const
Write.
Definition: Reaction.C:384
IFstream.H
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::Ostream::endBlock
virtual Ostream & endBlock()
Write end block group.
Definition: Ostream.C:109
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::HashPtrTable< ThermoType >
Foam::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:232
Foam::Reaction::name
const word & name() const
Definition: ReactionI.H:38
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::ReactionList::readReactionDict
bool readReactionDict()
Read reactions from dictionary.
Definition: ReactionList.C:79
Foam::Reaction
Simple extension of ReactionThermo to handle reaction kinetics in addition to the equilibrium thermod...
Definition: Reaction.H:56
Foam::ReactionList::write
void write(Ostream &os) const
Write.
Definition: ReactionList.C:99