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

ODEChemistryModel.H

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) 2009-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 Class
00025     Foam::ODEChemistryModel
00026 
00027 Description
00028     Extends base chemistry model by adding a thermo package, and ODE functions.
00029     Introduces chemistry equation system and evaluation of chemical source
00030     terms.
00031 
00032 SourceFiles
00033     ODEChemistryModelI.H
00034     ODEChemistryModel.C
00035 
00036 \*---------------------------------------------------------------------------*/
00037 
00038 #ifndef ODEChemistryModel_H
00039 #define ODEChemistryModel_H
00040 
00041 #include <specie/Reaction.H>
00042 #include <ODE/ODE.H>
00043 #include <finiteVolume/volFieldsFwd.H>
00044 
00045 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00046 
00047 namespace Foam
00048 {
00049 
00050 // Forward declaration of classes
00051 class fvMesh;
00052 
00053 template<class CompType, class ThermoType>
00054 class chemistrySolver;
00055 
00056 /*---------------------------------------------------------------------------*\
00057                       Class ODEChemistryModel Declaration
00058 \*---------------------------------------------------------------------------*/
00059 
00060 template<class CompType, class ThermoType>
00061 class ODEChemistryModel
00062 :
00063     public CompType,
00064     public ODE
00065 {
00066     // Private Member Functions
00067 
00068         //- Disallow default bitwise assignment
00069         void operator=(const ODEChemistryModel&);
00070 
00071 
00072 protected:
00073 
00074     // Private data
00075 
00076         //- Reference to the field of specie mass fractions
00077         PtrList<volScalarField>& Y_;
00078 
00079         //- Reactions
00080         const PtrList<Reaction<ThermoType> >& reactions_;
00081 
00082         //- Thermodynamic data of the species
00083         const PtrList<ThermoType>& specieThermo_;
00084 
00085         //- Number of species
00086         label nSpecie_;
00087 
00088         //- Number of reactions
00089         label nReaction_;
00090 
00091         //- Chemistry solver
00092         autoPtr<chemistrySolver<CompType, ThermoType> > solver_;
00093 
00094         //- Chemical source term [kg/m3/s]
00095         PtrList<scalarField> RR_;
00096 
00097 
00098     // Protected Member Functions
00099 
00100         //- Write access to chemical source terms
00101         //  (e.g. for multi-chemistry model)
00102         inline PtrList<scalarField>& RR();
00103 
00104 
00105 public:
00106 
00107     //- Runtime type information
00108     TypeName("ODEChemistryModel");
00109 
00110 
00111     // Constructors
00112 
00113         //- Construct from components
00114         ODEChemistryModel
00115         (
00116             const fvMesh& mesh,
00117             const word& compTypeName,
00118             const word& thermoTypeName
00119         );
00120 
00121 
00122     //- Destructor
00123     virtual ~ODEChemistryModel();
00124 
00125 
00126     // Member Functions
00127 
00128         //- The reactions
00129         inline const PtrList<Reaction<ThermoType> >& reactions() const;
00130 
00131         //- Thermodynamic data of the species
00132         inline const PtrList<ThermoType>& specieThermo() const;
00133 
00134         //- The number of species
00135         inline label nSpecie() const;
00136 
00137         //- The number of reactions
00138         inline label nReaction() const;
00139 
00140         //- Return the chemisty solver
00141         inline const chemistrySolver<CompType, ThermoType>& solver() const;
00142 
00143         //- dc/dt = omega, rate of change in concentration, for each species
00144         virtual scalarField omega
00145         (
00146             const scalarField& c,
00147             const scalar T,
00148             const scalar p
00149         ) const;
00150 
00151         //- Return the reaction rate for reaction r and the reference
00152         //  species and charateristic times
00153         virtual scalar omega
00154         (
00155             const Reaction<ThermoType>& r,
00156             const scalarField& c,
00157             const scalar T,
00158             const scalar p,
00159             scalar& pf,
00160             scalar& cf,
00161             label& lRef,
00162             scalar& pr,
00163             scalar& cr,
00164             label& rRef
00165         ) const;
00166 
00167         //- Calculates the reaction rates
00168         virtual void calculate();
00169 
00170 
00171         // Chemistry model functions (overriding abstract functions in
00172         // basicChemistryModel.H)
00173 
00174             //- Return const access to the chemical source terms
00175             inline tmp<volScalarField> RR(const label i) const;
00176 
00177             //- Solve the reaction system for the given start time and time
00178             //  step and return the characteristic time
00179             virtual scalar solve(const scalar t0, const scalar deltaT);
00180 
00181             //- Return the chemical time scale
00182             virtual tmp<volScalarField> tc() const;
00183 
00184             //- Return source for enthalpy equation [kg/m/s3]
00185             virtual tmp<volScalarField> Sh() const;
00186 
00187             //- Return the heat release, i.e. enthalpy/sec [m2/s3]
00188             virtual tmp<volScalarField> dQ() const;
00189 
00190 
00191         // ODE functions (overriding abstract functions in ODE.H)
00192 
00193             //- Number of ODE's to solve
00194             virtual label nEqns() const;
00195 
00196             virtual void derivatives
00197             (
00198                 const scalar t,
00199                 const scalarField& c,
00200                 scalarField& dcdt
00201             ) const;
00202 
00203             virtual void jacobian
00204             (
00205                 const scalar t,
00206                 const scalarField& c,
00207                 scalarField& dcdt,
00208                 scalarSquareMatrix& dfdc
00209             ) const;
00210 };
00211 
00212 
00213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00214 
00215 } // End namespace Foam
00216 
00217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00218 
00219 #include "ODEChemistryModelI.H"
00220 
00221 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00222 
00223 #ifdef NoRepository
00224 #   include "ODEChemistryModel.C"
00225 #endif
00226 
00227 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00228 
00229 #endif
00230 
00231 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines