Newer
Older
Henry Weller
committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "specieReactionRates.H"
#include "volFields.H"
#include "fvcVolumeIntegrate.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class ChemistryModelType>
void Foam::functionObjects::specieReactionRates<ChemistryModelType>::
writeFileHeader
(
const label i
)
{
writeHeader(file(), "Specie reaction rates");
volRegion::writeFileHeader(*this, file());
Henry Weller
committed
writeHeaderValue(file(), "nSpecie", chemistryModel_.nSpecie());
writeHeaderValue(file(), "nReaction", chemistryModel_.nReaction());
writeCommented(file(), "Time");
writeTabbed(file(), "Reaction");
const wordList& speciesNames =
chemistryModel_.thermo().composition().species();
forAll (speciesNames, si)
{
writeTabbed(file(), speciesNames[si]);
}
file() << endl;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class ChemistryModelType>
Foam::functionObjects::specieReactionRates<ChemistryModelType>::
specieReactionRates
(
const word& name,
const Time& runTime,
const dictionary& dict
)
:
fvMeshFunctionObject(name, runTime, dict),
volRegion(fvMeshFunctionObject::mesh_, dict),
Henry Weller
committed
logFiles(obr_, name),
chemistryModel_
(
fvMeshFunctionObject::mesh_.lookupObject<ChemistryModelType>
(
"chemistryProperties"
)
Henry Weller
committed
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
)
{
resetName("specieReactionRates");
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class ChemistryModelType>
Foam::functionObjects::specieReactionRates<ChemistryModelType>::
~specieReactionRates()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class ChemistryModelType>
bool Foam::functionObjects::specieReactionRates<ChemistryModelType>::read
(
const dictionary& dict
)
{
regionFunctionObject::read(dict);
return true;
}
template<class ChemistryModelType>
bool Foam::functionObjects::specieReactionRates<ChemistryModelType>::execute()
{
return true;
}
template<class ChemistryModelType>
bool Foam::functionObjects::specieReactionRates<ChemistryModelType>::write()
{
logFiles::write();
const label nSpecie = chemistryModel_.nSpecie();
const label nReaction = chemistryModel_.nReaction();
// Region volume
const scalar V = this->V();
Henry Weller
committed
for (label ri=0; ri<nReaction; ri++)
{
if (Pstream::master())
{
writeTime(file());
file() << token::TAB << ri;
}
for (label si=0; si<nSpecie; si++)
{
volScalarField::Internal RR
(
chemistryModel_.calculateRR(ri, si)
);
scalar sumVRRi = 0;
if (isNull(cellIDs()))
{
sumVRRi = fvc::domainIntegrate(RR).value();
}
else
{
sumVRRi = gSum
(
scalarField(fvMeshFunctionObject::mesh_.V()*RR, cellIDs())
);
}
Henry Weller
committed
if (Pstream::master())
{
file() << token::TAB << sumVRRi/V;
Henry Weller
committed
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
}
}
if (Pstream::master())
{
file() << nl;
}
}
if (Pstream::master())
{
file() << nl << endl;
}
return true;
}
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
#include "addToRunTimeSelectionTable.H"
#include "rhoChemistryModel.H"
#include "psiChemistryModel.H"
namespace Foam
{
typedef functionObjects::specieReactionRates<psiChemistryModel>
psiSpecieReactionRates;
Henry Weller
committed
defineTemplateTypeNameAndDebugWithName
(
psiSpecieReactionRates,
"psiSpecieReactionRates",
0
);
addToRunTimeSelectionTable
(
functionObject,
psiSpecieReactionRates,
dictionary
);
typedef functionObjects::specieReactionRates<rhoChemistryModel>
rhoSpecieReactionRates;
Henry Weller
committed
defineTemplateTypeNameAndDebugWithName
(
rhoSpecieReactionRates,
"rhoSpecieReactionRates",
0
);
addToRunTimeSelectionTable
(
functionObject,
rhoSpecieReactionRates,
dictionary
);
}
// ************************************************************************* //