specieReactionRates.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) 2016-2018 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 "specieReactionRates.H"
27 #include "volFields.H"
28 #include "fvcVolumeIntegrate.H"
29 
30 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
31 
32 template<class ChemistryModelType>
35 (
36  const label i
37 )
38 {
39  writeHeader(file(), "Specie reaction rates");
40  volRegion::writeFileHeader(*this, file());
41  writeHeaderValue(file(), "nSpecie", chemistryModel_.nSpecie());
42  writeHeaderValue(file(), "nReaction", chemistryModel_.nReaction());
43 
44  writeCommented(file(), "Time");
45  writeTabbed(file(), "Reaction");
46 
47  const wordList& speciesNames =
48  chemistryModel_.thermo().composition().species();
49 
50  forAll (speciesNames, si)
51  {
52  writeTabbed(file(), speciesNames[si]);
53  }
54 
55  file() << endl;
56 }
57 
58 
59 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
60 
61 template<class ChemistryModelType>
64 (
65  const word& name,
66  const Time& runTime,
67  const dictionary& dict
68 )
69 :
70  fvMeshFunctionObject(name, runTime, dict),
71  volRegion(fvMeshFunctionObject::mesh_, dict),
72  logFiles(obr_, name),
73  chemistryModel_
74  (
75  fvMeshFunctionObject::mesh_.lookupObject<ChemistryModelType>
76  (
77  "chemistryProperties"
78  )
79  )
80 {
81  resetName("specieReactionRates");
82 }
83 
84 
85 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
86 
87 template<class ChemistryModelType>
90 {}
91 
92 
93 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
94 
95 template<class ChemistryModelType>
97 (
98  const dictionary& dict
99 )
100 {
102 
103  return true;
104 }
105 
106 
107 template<class ChemistryModelType>
109 {
110  return true;
111 }
112 
113 
114 template<class ChemistryModelType>
116 {
117  logFiles::write();
118 
119  const label nSpecie = chemistryModel_.nSpecie();
120  const label nReaction = chemistryModel_.nReaction();
121 
122  // Region volume
123  const scalar V = this->V();
124 
125  for (label ri=0; ri<nReaction; ri++)
126  {
127  if (Pstream::master())
128  {
129  writeTime(file());
130  file() << token::TAB << ri;
131  }
132 
133  for (label si=0; si<nSpecie; si++)
134  {
136  (
137  chemistryModel_.calculateRR(ri, si)
138  );
139 
140  scalar sumVRRi = 0;
141 
142  if (isNull(cellIDs()))
143  {
144  sumVRRi = fvc::domainIntegrate(RR).value();
145  }
146  else
147  {
148  sumVRRi = gSum
149  (
150  scalarField(fvMeshFunctionObject::mesh_.V()*RR, cellIDs())
151  );
152  }
153 
154  if (Pstream::master())
155  {
156  file() << token::TAB << sumVRRi/V;
157  }
158  }
159 
160  if (Pstream::master())
161  {
162  file() << nl;
163  }
164  }
165 
166  if (Pstream::master())
167  {
168  file() << nl << endl;
169  }
170 
171  return true;
172 }
173 
174 
175 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
176 
178 #include "BasicChemistryModel.H"
179 #include "psiReactionThermo.H"
180 #include "rhoReactionThermo.H"
181 
182 namespace Foam
183 {
184  typedef
186  <
188  <
190  >
191  >
193 
195  (
197  "psiSpecieReactionRates",
198  0
199  );
200 
202  (
205  dictionary
206  );
207 
208 
209  typedef
211  <
213  <
215  >
216  >
218 
220  (
222  "rhoSpecieReactionRates",
223  0
224  );
225 
227  (
230  dictionary
231  );
232 }
233 
234 
235 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
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
Basic chemistry model templated on thermodynamics.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
virtual bool write()
Write the specie reaction rates.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
dimensioned< Type > domainIntegrate(const GeometricField< Type, fvPatchField, volMesh > &vf)
void read(Istream &, label &, const dictionary &)
In-place read with dictionary lookup.
const label nSpecie
Abstract base-class for Time/database functionObjects.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
virtual bool read(const dictionary &)
Read the specieReactionRates data.
Macros for easy insertion into run-time selection tables.
bool isNull(const T &t)
Return true if t is a reference to the nullObject of type T.
Definition: nullObjectI.H:46
Type gSum(const FieldField< Field, Type > &f)
void writeHeader(std::ostream &, const bool isBinary, const std::string &title)
Write header.
A class for handling words, derived from string.
Definition: word.H:59
Foam::rhoReactionThermo.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
Volume integrate volField creating a volField.
defineTemplateTypeNameAndDebugWithName(GlobalIOField< scalar >, "scalarField", 0)
volScalarField scalarField(fieldObject, mesh)
Foam::psiReactionThermo.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
static const char nl
Definition: Ostream.H:260
Volume (cell) region selection class.
Definition: volRegion.H:102
List< word > wordList
A List of words.
Definition: fileName.H:54
Writes the domain averaged reaction rates for each specie for each reaction into the file <timeDir>/s...
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const scalar RR
Universal gas constant (default in [J/kmol/K])
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
functionObjects::specieReactionRates< BasicChemistryModel< psiReactionThermo > > psiSpecieReactionRates
functionObjects::specieReactionRates< BasicChemistryModel< rhoReactionThermo > > rhoSpecieReactionRates
specieReactionRates(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Namespace for OpenFOAM.
functionObject base class for creating, maintaining and writing log files e.g. integrated of averaged...
Definition: logFiles.H:57