Merge branch 'upstream/OpenFOAM' into master
[freefoam.git] / src / thermophysicalModels / chemistryModel / chemistryModel / ODEChemistryModel / ODEChemistryModel.H
blob4b8f7049937d24af2b4cb27d1a98243dc65dfdba
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2009-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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 Class
26     Foam::ODEChemistryModel
28 Description
29     Extends base chemistry model by adding a thermo package, and ODE functions.
30     Introduces chemistry equation system and evaluation of chemical source
31     terms.
33 SourceFiles
34     ODEChemistryModelI.H
35     ODEChemistryModel.C
37 \*---------------------------------------------------------------------------*/
39 #ifndef ODEChemistryModel_H
40 #define ODEChemistryModel_H
42 #include <reactionThermophysicalModels/hCombustionThermo.H>
43 #include <specie/Reaction.H>
44 #include <ODE/ODE.H>
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 namespace Foam
51 // Forward declaration of classes
52 template<class CompType, class ThermoType>
53 class chemistrySolver;
55 /*---------------------------------------------------------------------------*\
56                       Class ODEChemistryModel Declaration
57 \*---------------------------------------------------------------------------*/
59 template<class CompType, class ThermoType>
60 class ODEChemistryModel
62     public CompType,
63     public ODE
65     // Private Member Functions
67         //- Disallow default bitwise assignment
68         void operator=(const ODEChemistryModel&);
71 protected:
73     // Private data
75         //- Reference to the field of specie mass fractions
76         PtrList<volScalarField>& Y_;
78         //- Reactions
79         const PtrList<Reaction<ThermoType> >& reactions_;
81         //- Thermodynamic data of the species
82         const PtrList<ThermoType>& specieThermo_;
84         //- Number of species
85         label nSpecie_;
87         //- Number of reactions
88         label nReaction_;
90         //- Chemistry solver
91         autoPtr<chemistrySolver<CompType, ThermoType> > solver_;
93         //- Chemical source term
94         PtrList<scalarField> RR_;
97     // Protected Member Functions
99         //- Write access to chemical source terms
100         //  (e.g. for multi-chemistry model)
101         inline PtrList<scalarField>& RR();
104 public:
106     //- Runtime type information
107     TypeName("ODEChemistryModel");
110     // Constructors
112         //- Construct from components
113         ODEChemistryModel
114         (
115             const fvMesh& mesh,
116             const word& compTypeName,
117             const word& thermoTypeName
118         );
121     //- Destructor
122     virtual ~ODEChemistryModel();
125     // Member Functions
127         //- The reactions
128         inline const PtrList<Reaction<ThermoType> >& reactions() const;
130         //- Thermodynamic data of the species
131         inline const PtrList<ThermoType>& specieThermo() const;
133         //- The number of species
134         inline label nSpecie() const;
136         //- The number of reactions
137         inline label nReaction() const;
139         //- Return the chemisty solver
140         inline const chemistrySolver<CompType, ThermoType>& solver() const;
142         //- dc/dt = omega, rate of change in concentration, for each species
143         virtual scalarField omega
144         (
145             const scalarField& c,
146             const scalar T,
147             const scalar p
148         ) const;
150         //- Return the reaction rate for reaction r and the reference
151         //  species and charateristic times
152         virtual scalar omega
153         (
154             const Reaction<ThermoType>& r,
155             const scalarField& c,
156             const scalar T,
157             const scalar p,
158             scalar& pf,
159             scalar& cf,
160             label& lRef,
161             scalar& pr,
162             scalar& cr,
163             label& rRef
164         ) const;
166         //- Calculates the reaction rates
167         virtual void calculate();
170         // Chemistry model functions (overriding abstract functions in
171         // chemistryModel.H)
173             //- Return const access to the chemical source terms
174             inline tmp<volScalarField> RR(const label i) const;
176             //- Solve the reaction system for the given start time and time
177             //  step and return the characteristic time
178             virtual scalar solve(const scalar t0, const scalar deltaT);
180             //- Return the chemical time scale
181             virtual tmp<volScalarField> tc() const;
183             //- Return the heat release
184             virtual tmp<volScalarField> dQ() const;
187         // ODE functions (overriding abstract functions in ODE.H)
189             //- Number of ODE's to solve
190             virtual label nEqns() const;
192             virtual void derivatives
193             (
194                 const scalar t,
195                 const scalarField& c,
196                 scalarField& dcdt
197             ) const;
199             virtual void jacobian
200             (
201                 const scalar t,
202                 const scalarField& c,
203                 scalarField& dcdt,
204                 scalarSquareMatrix& dfdc
205             ) const;
209 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211 } // End namespace Foam
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 #include "ODEChemistryModelI.H"
217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 #ifdef NoRepository
220 #   include "ODEChemistryModel.C"
221 #endif
223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
225 #endif
227 // ************************ vim: set sw=4 sts=4 et: ************************ //