1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "sequential.H"
28 #include "addToRunTimeSelectionTable.H"
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 template<class CompType, class ThermoType>
33 Foam::sequential<CompType, ThermoType>::sequential
35 ODEChemistryModel<CompType, ThermoType>& model,
39 chemistrySolver<CompType, ThermoType>(model, modelName),
40 coeffsDict_(model.subDict(modelName + "Coeffs")),
41 cTauChem_(readScalar(coeffsDict_.lookup("cTauChem"))),
42 equil_(coeffsDict_.lookup("equilibriumRateLimiter"))
46 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
48 template<class CompType, class ThermoType>
49 Foam::sequential<CompType, ThermoType>::~sequential()
53 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
55 template<class CompType, class ThermoType>
56 Foam::scalar Foam::sequential<CompType, ThermoType>::solve
65 scalar tChemInv = SMALL;
67 scalar pf, cf, pb, cb;
70 for (label i=0; i<this->model_.reactions().size(); i++)
72 const Reaction<ThermoType>& R = this->model_.reactions()[i];
74 scalar om0 = this->model_.omega
76 R, c, T, p, pf, cf, lRef, pb, cb, rRef
88 omeg = om0/(1.0 + pb*dt);
92 omeg = om0/(1.0 + pf*dt);
95 tChemInv = max(tChemInv, mag(omeg));
99 for (label s=0; s<R.lhs().size(); s++)
101 label si = R.lhs()[s].index;
102 scalar sl = R.lhs()[s].stoichCoeff;
104 c[si] = max(0.0, c[si]);
107 for (label s=0; s<R.rhs().size(); s++)
109 label si = R.rhs()[s].index;
110 scalar sr = R.rhs()[s].stoichCoeff;
112 c[si] = max(0.0, c[si]);
115 } // end for (label i...
117 return cTauChem_/tChemInv;
121 // ************************************************************************* //