specieReactionRates.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) 2016-2017 OpenFOAM Foundation
9 Copyright (C) 2019-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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 "specieReactionRates.H"
30#include "volFields.H"
31#include "fvcVolumeIntegrate.H"
32
33// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
34
35template<class ChemistryModelType>
38(
39 Ostream& os
40) const
41{
42 writeHeader(os, "Specie reaction rates");
43 volRegion::writeFileHeader(*this, os);
44 writeHeaderValue(os, "nSpecie", chemistryModel_.nSpecie());
45 writeHeaderValue(os, "nReaction", chemistryModel_.nReaction());
46
47 writeCommented(os, "Time");
48 writeTabbed(os, "Reaction");
49
50 const wordList& speciesNames =
51 chemistryModel_.thermo().composition().species();
52
53 for (const word& speciesName : speciesNames)
54 {
55 writeTabbed(os, speciesName);
56 }
57
58 os << endl;
59}
60
61
62// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
63
64template<class ChemistryModelType>
67(
68 const word& name,
69 const Time& runTime,
70 const dictionary& dict
71)
72:
75 writeFile(obr_, name, typeName, dict),
76 chemistryModel_
77 (
78 fvMeshFunctionObject::mesh_.lookupObject<ChemistryModelType>
79 (
80 "chemistryProperties"
81 )
82 )
83{
84 writeFileHeader(file());
85}
86
87
88// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
89
90template<class ChemistryModelType>
92(
93 const dictionary& dict
94)
95{
97
98 return true;
99}
100
101
102template<class ChemistryModelType>
104{
105 return true;
106}
107
108
109template<class ChemistryModelType>
111{
112 const label nSpecie = chemistryModel_.nSpecie();
113 const label nReaction = chemistryModel_.nReaction();
114
115 volRegion::update(); // Ensure cached values are valid
116
117 const scalar volTotal = this->volRegion::V();
118
119 const bool useAll = this->volRegion::useAllCells();
120
121 for (label ri=0; ri<nReaction; ri++)
122 {
123 writeCurrentTime(file());
124 file() << token::TAB << ri;
125
126 for (label si=0; si<nSpecie; si++)
127 {
129 (
130 chemistryModel_.calculateRR(ri, si)
131 );
132
133 scalar sumVRRi = 0;
134
135 if (useAll)
136 {
137 sumVRRi = fvc::domainIntegrate(RR).value();
138 }
139 else
140 {
141 sumVRRi = gSum
142 (
144 );
145 }
146
147 file() << token::TAB << sumVRRi / volTotal;
148 }
149
150 file() << nl;
151 }
152
153 file() << nl << endl;
154
155 return true;
156}
157
158
159// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
160
162#include "BasicChemistryModel.H"
163#include "psiReactionThermo.H"
164#include "rhoReactionThermo.H"
165
166namespace Foam
167{
168 typedef
170 <
172 <
174 >
175 >
177
179 (
181 "psiSpecieReactionRates",
182 0
183 );
184
186 (
190 );
191
192
193 typedef
195 <
197 <
199 >
200 >
202
204 (
206 "rhoSpecieReactionRates",
207 0
208 );
209
211 (
215 );
216}
217
218
219// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
labelList cellIDs
Basic chemistry model templated on thermodynamics.
virtual bool read()
Re-read model coefficients if they have changed.
The TAB Method for Numerical Calculation of Spray Droplet Breakup.
Definition: TAB.H:69
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Abstract base-class for Time/database function objects.
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
const fvMesh & mesh_
Reference to the fvMesh.
Writes the domain averaged reaction rates for each specie for each reaction into the file <timeDir>/s...
virtual bool write()
Write the specie reaction rates.
Volume (cell) region selection class.
Definition: volRegion.H:116
bool useAllCells() const noexcept
Use all cells, not the cellIDs.
Definition: volRegionI.H:31
scalar V() const
Return total volume of the selected region.
Definition: volRegionI.H:59
bool update()
Update the cached values as required.
Definition: volRegion.C:250
Base class for writing single files from the function objects.
Definition: writeFile.H:120
virtual OFstream & file()
Return access to the file (if only 1)
Definition: writeFile.C:233
Foam::psiReactionThermo.
Foam::rhoReactionThermo.
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define defineTemplateTypeNameAndDebugWithName(Type, Name, DebugSwitch)
Define the typeName and debug information, lookup as Name.
Definition: className.H:126
engineTime & runTime
OBJstream os(runTime.globalPath()/outputName)
Volume integrate volField creating a volField.
dimensioned< Type > domainIntegrate(const GeometricField< Type, fvPatchField, volMesh > &vf)
Namespace for OpenFOAM.
List< word > wordList
A List of words.
Definition: fileName.H:63
Type gSum(const FieldField< Field, Type > &f)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
label nSpecie
dictionary dict