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

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