Home
Downloads
Documentation
Installation
User Guide
man-pages
API Documentation
README
Release Notes
Changes
License
Support
SourceForge Project
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
thermophysicalModels
chemistryModel
chemistrySolver
sequential
sequential.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 | Copyright (C) 1991-2010 OpenCFD Ltd.
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 "
sequential.H
"
27
#include <
OpenFOAM/addToRunTimeSelectionTable.H
>
28
29
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30
31
template
<
class
CompType,
class
ThermoType>
32
Foam::sequential<CompType, ThermoType>::sequential
33
(
34
ODEChemistryModel<CompType, ThermoType>
& model,
35
const
word
& modelName
36
)
37
:
38
chemistrySolver<CompType, ThermoType>
(model, modelName),
39
coeffsDict_(model.subDict(modelName +
"Coeffs"
)),
40
cTauChem_(
readScalar
(coeffsDict_.lookup(
"cTauChem"
))),
41
equil_(coeffsDict_.lookup(
"equilibriumRateLimiter"
))
42
{}
43
44
45
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
46
47
template
<
class
CompType,
class
ThermoType>
48
Foam::sequential<CompType, ThermoType>::~sequential
()
49
{}
50
51
52
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
53
54
template
<
class
CompType,
class
ThermoType>
55
Foam::scalar
Foam::sequential<CompType, ThermoType>::solve
56
(
57
scalarField
&c,
58
const
scalar
T
,
59
const
scalar
p
,
60
const
scalar t0,
61
const
scalar dt
62
)
const
63
{
64
scalar tChemInv = SMALL;
65
66
scalar pf, cf, pb, cb;
67
label lRef, rRef;
68
69
for
(label i=0; i<this->model_.reactions().size(); i++)
70
{
71
const
Reaction<ThermoType>
&
R
= this->model_.reactions()[i];
72
73
scalar om0 = this->model_.omega
74
(
75
R, c, T, p, pf, cf, lRef, pb, cb, rRef
76
);
77
78
scalar omeg = 0.0;
79
if
(!equil_)
80
{
81
omeg = om0;
82
}
83
else
84
{
85
if
(om0<0.0)
86
{
87
omeg = om0/(1.0 + pb*dt);
88
}
89
else
90
{
91
omeg = om0/(1.0 + pf*dt);
92
}
93
}
94
tChemInv =
max
(tChemInv,
mag
(omeg));
95
96
97
// update species
98
for
(label s=0; s<R.
lhs
().
size
(); s++)
99
{
100
label si = R.
lhs
()[s].index;
101
scalar sl = R.
lhs
()[s].stoichCoeff;
102
c[si] -= dt*sl*omeg;
103
c[si] =
max
(0.0, c[si]);
104
}
105
106
for
(label s=0; s<R.
rhs
().
size
(); s++)
107
{
108
label si = R.
rhs
()[s].index;
109
scalar sr = R.
rhs
()[s].stoichCoeff;
110
c[si] += dt*sr*omeg;
111
c[si] =
max
(0.0, c[si]);
112
}
113
114
}
// end for (label i...
115
116
return
cTauChem_/tChemInv;
117
}
118
119
120
// ************************ vim: set sw=4 sts=4 et: ************************ //