OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

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-2009 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 the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     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, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "sequential.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 
00030 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00031 
00032 template<class CompType, class ThermoType>
00033 Foam::sequential<CompType, ThermoType>::sequential
00034 (
00035     ODEChemistryModel<CompType, ThermoType>& model,
00036     const word& modelName
00037 )
00038 :
00039     chemistrySolver<CompType, ThermoType>(model, modelName),
00040     coeffsDict_(model.subDict(modelName + "Coeffs")),
00041     cTauChem_(readScalar(coeffsDict_.lookup("cTauChem"))),
00042     equil_(coeffsDict_.lookup("equilibriumRateLimiter"))
00043 {}
00044 
00045 
00046 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00047 
00048 template<class CompType, class ThermoType>
00049 Foam::sequential<CompType, ThermoType>::~sequential()
00050 {}
00051 
00052 
00053 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00054 
00055 template<class CompType, class ThermoType>
00056 Foam::scalar Foam::sequential<CompType, ThermoType>::solve
00057 (
00058     scalarField &c,
00059     const scalar T,
00060     const scalar p,
00061     const scalar t0,
00062     const scalar dt
00063 ) const
00064 {
00065     scalar tChemInv = SMALL;
00066 
00067     scalar pf, cf, pb, cb;
00068     label lRef, rRef;
00069 
00070     for (label i=0; i<this->model_.reactions().size(); i++)
00071     {
00072         const Reaction<ThermoType>& R = this->model_.reactions()[i];
00073 
00074         scalar om0 = this->model_.omega
00075         (
00076             R, c, T, p, pf, cf, lRef, pb, cb, rRef
00077         );
00078 
00079         scalar omeg = 0.0;
00080         if (!equil_)
00081         {
00082             omeg = om0;
00083         }
00084         else
00085         {
00086             if (om0<0.0)
00087             {
00088                 omeg = om0/(1.0 + pb*dt);
00089             }
00090             else
00091             {
00092                 omeg = om0/(1.0 + pf*dt);
00093             }
00094         }
00095         tChemInv = max(tChemInv, mag(omeg));
00096 
00097 
00098         // update species
00099         for (label s=0; s<R.lhs().size(); s++)
00100         {
00101             label si = R.lhs()[s].index;
00102             scalar sl = R.lhs()[s].stoichCoeff;
00103             c[si] -= dt*sl*omeg;
00104             c[si] = max(0.0, c[si]);
00105         }
00106 
00107         for (label s=0; s<R.rhs().size(); s++)
00108         {
00109             label si = R.rhs()[s].index;
00110             scalar sr = R.rhs()[s].stoichCoeff;
00111             c[si] += dt*sr*omeg;
00112             c[si] = max(0.0, c[si]);
00113         }
00114 
00115     } // end for (label i...
00116 
00117     return cTauChem_/tChemInv;
00118 }
00119 
00120 
00121 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd