All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
StandardChemistryModel.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::StandardChemistryModel
26 
27 Description
28  Extends base chemistry model by adding a thermo package, and ODE functions.
29  Introduces chemistry equation system and evaluation of chemical source
30  terms.
31 
32 SourceFiles
33  StandardChemistryModelI.H
34  StandardChemistryModel.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef StandardChemistryModel_H
39 #define StandardChemistryModel_H
40 
41 #include "BasicChemistryModel.H"
42 #include "ReactionList.H"
43 #include "ODESystem.H"
44 #include "volFields.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 // Forward declaration of classes
52 class fvMesh;
53 
54 /*---------------------------------------------------------------------------*\
55  Class StandardChemistryModel Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 template<class ReactionThermo, class ThermoType>
60 :
61  public BasicChemistryModel<ReactionThermo>,
62  public ODESystem
63 {
64  // Private Member Functions
65 
66  //- Solve the reaction system for the given time step
67  // of given type and return the characteristic time
68  template<class DeltaTType>
69  scalar solve(const DeltaTType& deltaT);
70 
71 
72 protected:
73 
74  typedef ThermoType thermoType;
75 
76 
77  // Protected data
78 
79  //- Reference to the field of specie mass fractions
81 
82  //- Thermodynamic data of the species
84 
85  //- Reactions
87 
88  //- Number of species
90 
91  //- Number of reactions
93 
94  //- Temperature below which the reaction rates are assumed 0
95  scalar Treact_;
96 
97  //- List of reaction rate per specie [kg/m^3/s]
99 
100  //- Temporary concentration field
101  mutable scalarField c_;
102 
103  //- Temporary rate-of-change of concentration field
104  mutable scalarField dcdt_;
105 
106 
107  // Protected Member Functions
108 
109  //- Write access to chemical source terms
110  // (e.g. for multi-chemistry model)
112 
113 
114 public:
115 
116  //- Runtime type information
117  TypeName("standard");
118 
119 
120  // Constructors
121 
122  //- Construct from thermo
123  StandardChemistryModel(const ReactionThermo& thermo);
124 
125  //- Disallow default bitwise copy construction
127 
128 
129  //- Destructor
130  virtual ~StandardChemistryModel();
131 
132 
133  // Member Functions
134 
135  //- The reactions
136  inline const PtrList<Reaction<ThermoType>>& reactions() const;
137 
138  //- Thermodynamic data of the species
139  inline const PtrList<ThermoType>& specieThermos() const;
140 
141  //- The number of species
142  virtual inline label nSpecie() const;
143 
144  //- The number of reactions
145  virtual inline label nReaction() const;
146 
147  //- Temperature below which the reaction rates are assumed 0
148  inline scalar Treact() const;
149 
150  //- Temperature below which the reaction rates are assumed 0
151  inline scalar& Treact();
152 
153  //- dc/dt = omega, rate of change in concentration, for each species
154  virtual void omega
155  (
156  const scalar p,
157  const scalar T,
158  const scalarField& c,
159  const label li,
160  scalarField& dcdt
161  ) const;
162 
163 
164  //- Return the reaction rate for iReaction and the reference
165  // species and characteristic times
166  virtual scalar omegaI
167  (
168  label iReaction,
169  const scalar p,
170  const scalar T,
171  const scalarField& c,
172  const label li,
173  scalar& pf,
174  scalar& cf,
175  label& lRef,
176  scalar& pr,
177  scalar& cr,
178  label& rRef
179  ) const;
180 
181  //- Calculates the reaction rates
182  virtual void calculate();
183 
184 
185  // Chemistry model functions (overriding abstract functions in
186  // basicChemistryModel.H)
187 
188  //- Return const access to the chemical source terms for specie, i
189  inline const volScalarField::Internal& RR
190  (
191  const label i
192  ) const;
193 
194  //- Return non const access to chemical source terms [kg/m^3/s]
196  (
197  const label i
198  );
199 
200  //- Return reaction rate of the speciei in reactionI
202  (
203  const label reactionI,
204  const label speciei
205  ) const;
206 
207  //- Solve the reaction system for the given time step
208  // and return the characteristic time
209  virtual scalar solve(const scalar deltaT);
210 
211  //- Solve the reaction system for the given time step
212  // and return the characteristic time
213  virtual scalar solve(const scalarField& deltaT);
214 
215  //- Return the chemical time scale
216  virtual tmp<volScalarField> tc() const;
217 
218  //- Return the heat release rate [kg/m/s^3]
219  virtual tmp<volScalarField> Qdot() const;
220 
221 
222  // ODE functions (overriding abstract functions in ODE.H)
223 
224  //- Number of ODE's to solve
225  inline virtual label nEqns() const;
226 
227  virtual void derivatives
228  (
229  const scalar t,
230  const scalarField& c,
231  const label li,
232  scalarField& dcdt
233  ) const;
234 
235  virtual void jacobian
236  (
237  const scalar t,
238  const scalarField& c,
239  const label li,
240  scalarField& dcdt,
242  ) const;
243 
244  virtual void solve
245  (
246  scalar& p,
247  scalar& T,
248  scalarField& c,
249  const label li,
250  scalar& deltaT,
251  scalar& subDeltaT
252  ) const = 0;
253 
254 
255  // Member Operators
256 
257  //- Disallow default bitwise assignment
258  void operator=(const StandardChemistryModel&) = delete;
259 };
260 
261 
262 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
263 
264 } // End namespace Foam
265 
266 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
267 
268 #include "StandardChemistryModelI.H"
269 
270 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
271 
272 #ifdef NoRepository
273  #include "StandardChemistryModel.C"
274 #endif
275 
276 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
277 
278 #endif
279 
280 // ************************************************************************* //
virtual label nSpecie() const
The number of species.
StandardChemistryModel(const ReactionThermo &thermo)
Construct from thermo.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Basic chemistry model templated on thermodynamics.
virtual tmp< volScalarField > Qdot() const
Return the heat release rate [kg/m/s^3].
Abstract base class for the systems of ordinary differential equations.
Definition: ODESystem.H:46
scalarField dcdt_
Temporary rate-of-change of concentration field.
virtual void jacobian(const scalar t, const scalarField &c, const label li, scalarField &dcdt, scalarSquareMatrix &J) const
Calculate the Jacobian of the system.
virtual void omega(const scalar p, const scalar T, const scalarField &c, const label li, scalarField &dcdt) const
dc/dt = omega, rate of change in concentration, for each species
label nSpecie_
Number of species.
PtrList< volScalarField::Internal > RR_
List of reaction rate per specie [kg/m^3/s].
const dimensionedScalar & c
Speed of light in a vacuum.
Extends base chemistry model by adding a thermo package, and ODE functions. Introduces chemistry equa...
const ReactionList< ThermoType > reactions_
Reactions.
void operator=(const StandardChemistryModel &)=delete
Disallow default bitwise assignment.
const PtrList< Reaction< ThermoType > > & reactions() const
The reactions.
virtual void calculate()
Calculates the reaction rates.
scalar Treact() const
Temperature below which the reaction rates are assumed 0.
scalar Treact_
Temperature below which the reaction rates are assumed 0.
const PtrList< ThermoType > & specieThermos_
Thermodynamic data of the species.
const PtrList< ThermoType > & specieThermos() const
Thermodynamic data of the species.
virtual scalar omegaI(label iReaction, const scalar p, const scalar T, const scalarField &c, const label li, scalar &pf, scalar &cf, label &lRef, scalar &pr, scalar &cr, label &rRef) const
Return the reaction rate for iReaction and the reference.
virtual ~StandardChemistryModel()
Destructor.
scalarField c_
Temporary concentration field.
label nReaction_
Number of reactions.
virtual void derivatives(const scalar t, const scalarField &c, const label li, scalarField &dcdt) const
Calculate the derivatives in dydx.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
PtrList< volScalarField::Internal > & RR()
Write access to chemical source terms.
virtual tmp< volScalarField::Internal > calculateRR(const label reactionI, const label speciei) const
Return reaction rate of the speciei in reactionI.
List of templated reactions.
Definition: ReactionList.H:51
virtual tmp< volScalarField > tc() const
Return the chemical time scale.
const ReactionThermo & thermo() const
Return const access to the thermo package.
virtual label nEqns() const
Number of ODE&#39;s to solve.
const PtrList< volScalarField > & Y_
Reference to the field of specie mass fractions.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:70
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
volScalarField & p
A class for managing temporary objects.
Definition: PtrList.H:53
TypeName("standard")
Runtime type information.
virtual label nReaction() const
The number of reactions.
Namespace for OpenFOAM.