reaction.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) 2020 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 "reaction.H"
27 #include "dictionary.H"
28 
29 
30 // * * * * * * * * * * * * * * * * Static Data * * * * * * * * * * * * * * * //
31 
33 
34 
35 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
36 
37 Foam::label Foam::reaction::getNewReactionID()
38 {
39  return nUnNamedReactions++;
40 }
41 
42 
43 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
44 
46 (
47  const speciesTable& species,
48  const List<specieCoeffs>& lhs,
49  const List<specieCoeffs>& rhs
50 )
51 :
52  name_("un-named-reaction-" + Foam::name(getNewReactionID())),
53  species_(species),
54  lhs_(lhs),
55  rhs_(rhs)
56 {}
57 
58 
60 (
61  const reaction& r,
62  const speciesTable& species
63 )
64 :
65  name_(r.name() + "Copy"),
66  species_(species),
67  lhs_(r.lhs_),
68  rhs_(r.rhs_)
69 {}
70 
71 
73 (
74  const speciesTable& species,
75  const dictionary& dict
76 )
77 :
78  name_(dict.dictName()),
79  species_(species)
80 {
82  (
83  IStringStream(dict.lookup("reaction"))(),
84  species_,
85  lhs_,
86  rhs_
87  );
88 }
89 
90 
91 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
92 
94 {
97  (
98  os,
99  "reaction",
100  specieCoeffs::reactionStr(reaction, species_, lhs_, rhs_)
101  );
102 }
103 
104 
105 // ************************************************************************* //
Input from memory buffer stream.
Definition: IStringStream.H:52
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:91
Output to memory buffer stream.
Definition: OStringStream.H:52
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
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.
Reaction base-class holding the specie names and coefficients.
Definition: reaction.H:57
void write(Ostream &) const
Write.
Definition: reaction.C:93
static label nUnNamedReactions
Number of un-named reactions.
Definition: reaction.H:64
reaction(const speciesTable &species, const List< specieCoeffs > &lhs, const List< specieCoeffs > &rhs)
Construct from components.
Definition: reaction.C:46
static void setLRhs(Istream &, const speciesTable &, List< specieCoeffs > &lhs, List< specieCoeffs > &rhs)
Construct the left- and right-hand-side reaction coefficients.
Definition: specieCoeffs.C:95
static void reactionStr(OStringStream &reaction, const speciesTable &, const List< specieCoeffs > &scs)
Write the string representation of the specieCoeffs list.
Definition: specieCoeffs.C:177
Namespace for OpenFOAM.
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
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
dictionary dict