FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

sequential.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "sequential.H"
00027 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00028 
00029 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00030 
00031 template<class CompType, class ThermoType>
00032 Foam::sequential<CompType, ThermoType>::sequential
00033 (
00034     ODEChemistryModel<CompType, ThermoType>& model,
00035     const word& modelName
00036 )
00037 :
00038     chemistrySolver<CompType, ThermoType>(model, modelName),
00039     coeffsDict_(model.subDict(modelName + "Coeffs")),
00040     cTauChem_(readScalar(coeffsDict_.lookup("cTauChem"))),
00041     equil_(coeffsDict_.lookup("equilibriumRateLimiter"))
00042 {}
00043 
00044 
00045 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00046 
00047 template<class CompType, class ThermoType>
00048 Foam::sequential<CompType, ThermoType>::~sequential()
00049 {}
00050 
00051 
00052 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00053 
00054 template<class CompType, class ThermoType>
00055 Foam::scalar Foam::sequential<CompType, ThermoType>::solve
00056 (
00057     scalarField &c,
00058     const scalar T,
00059     const scalar p,
00060     const scalar t0,
00061     const scalar dt
00062 ) const
00063 {
00064     scalar tChemInv = SMALL;
00065 
00066     scalar pf, cf, pb, cb;
00067     label lRef, rRef;
00068 
00069     for (label i=0; i<this->model_.reactions().size(); i++)
00070     {
00071         const Reaction<ThermoType>& R = this->model_.reactions()[i];
00072 
00073         scalar om0 = this->model_.omega
00074         (
00075             R, c, T, p, pf, cf, lRef, pb, cb, rRef
00076         );
00077 
00078         scalar omeg = 0.0;
00079         if (!equil_)
00080         {
00081             omeg = om0;
00082         }
00083         else
00084         {
00085             if (om0<0.0)
00086             {
00087                 omeg = om0/(1.0 + pb*dt);
00088             }
00089             else
00090             {
00091                 omeg = om0/(1.0 + pf*dt);
00092             }
00093         }
00094         tChemInv = max(tChemInv, mag(omeg));
00095 
00096 
00097         // update species
00098         for (label s=0; s<R.lhs().size(); s++)
00099         {
00100             label si = R.lhs()[s].index;
00101             scalar sl = R.lhs()[s].stoichCoeff;
00102             c[si] -= dt*sl*omeg;
00103             c[si] = max(0.0, c[si]);
00104         }
00105 
00106         for (label s=0; s<R.rhs().size(); s++)
00107         {
00108             label si = R.rhs()[s].index;
00109             scalar sr = R.rhs()[s].stoichCoeff;
00110             c[si] += dt*sr*omeg;
00111             c[si] = max(0.0, c[si]);
00112         }
00113 
00114     } // end for (label i...
00115 
00116     return cTauChem_/tChemInv;
00117 }
00118 
00119 
00120 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines