chemistryReductionMethod.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) 2021-2026 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::chemistryReductionMethod
26 
27 Description
28  An abstract class for methods of chemical mechanism reduction
29 
30  References:
31  \verbatim
32  Contino, F., Jeanmart, H., Lucchini, T., & D’Errico, G. (2011).
33  Coupling of in situ adaptive tabulation and dynamic adaptive chemistry:
34  An effective method for solving combustion in engine simulations.
35  Proceedings of the Combustion Institute, 33(2), 3057-3064.
36 
37  Contino, F., Lucchini, T., D'Errico, G., Duynslaegher, C.,
38  Dias, V., & Jeanmart, H. (2012).
39  Simulations of advanced combustion modes using detailed chemistry
40  combined with tabulation and mechanism reduction techniques.
41  SAE International Journal of Engines,
42  5(2012-01-0145), 185-196.
43 
44  Contino, F., Foucher, F., Dagaut, P., Lucchini, T., D’Errico, G., &
45  Mounaïm-Rousselle, C. (2013).
46  Experimental and numerical analysis of nitric oxide effect on the
47  ignition of iso-octane in a single cylinder HCCI engine.
48  Combustion and Flame, 160(8), 1476-1483.
49 
50  Contino, F., Masurier, J. B., Foucher, F., Lucchini, T., D’Errico, G., &
51  Dagaut, P. (2014).
52  CFD simulations using the TDAC method to model iso-octane combustion
53  for a large range of ozone seeding and temperature conditions
54  in a single cylinder HCCI engine.
55  Fuel, 137, 179-184.
56  \endverbatim
57 
58 SourceFiles
59  chemistryReductionMethod.C
60  chemistryReductionMethods.C
61  chemistryReductionMethodNew.C
62  chemistryReductionMethodI.H
63 
64 \*---------------------------------------------------------------------------*/
65 
66 #ifndef chemistryReductionMethod_H
67 #define chemistryReductionMethod_H
68 
69 #include "dictionary.H"
70 #include "DynamicField.H"
71 #include "boolList.H"
72 #include "Switch.H"
73 #include "cpuTime.H"
74 #include "OFstream.H"
75 
76 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
77 
78 namespace Foam
79 {
80 
81 namespace chemistryModels
82 {
83  template<class ThermoType>
84  class Standard;
85 }
86 
87 /*---------------------------------------------------------------------------*\
88  Class chemistryReductionMethod Declaration
89 \*---------------------------------------------------------------------------*/
90 
91 template<class ThermoType>
93 {
94 protected:
95 
96  // Protected Data
97 
98  //- Reference to the chemistry model
100 
101  //- Total number of species
102  const label nSpecie_;
103 
104  //- Number of active species
106 
107  //- List of disabled reactions (disabled = true)
109 
110  //- List of active species (active = true)
112 
113 
114  //- Protected Member Functions
115 
116  const dictionary& coeffDict(const dictionary& dict) const
117  {
118  return dict.subDict("reduction");
119  }
120 
121  //- Initialise reduction of the mechanism
122  void initReduceMechanism();
123 
124  //- End reduction of the mechanism
126 
127 
128 private:
129 
130  // Private Data
131 
132  //- Switch to select performance logging
133  Switch log_;
134 
135  //- Tolerance for the mechanism reduction algorithm
136  scalar tolerance_;
137 
138  //- CPU time for logging
139  cpuTime cpuTime_;
140 
141  //- ...
142  int64_t sumnActiveSpecies_;
143 
144  //- ...
145  int64_t sumn_;
146 
147  //- ...
148  scalar reduceMechCpuTime_;
149 
150  // Log file for the average time spent reducing the chemistry
151  autoPtr<OFstream> cpuReduceFile_;
152 
153  // Write average number of species
154  autoPtr<OFstream> nActiveSpeciesFile_;
155 
156 
157 public:
158 
159  //- Runtime type information
160  TypeName("chemistryReductionMethod");
161 
162 
163  // Declare runtime constructor selection table
165  (
166  autoPtr,
168  dictionary,
169  (
170  const dictionary& dict,
172  ),
173  (dict, chemistry)
174  );
175 
176 
177  // Constructors
178 
179  //- Construct from components
181  (
183  );
184 
185  //- Construct from components
187  (
188  const dictionary& dict,
190  );
191 
192 
193  // Selector
194 
196  (
197  const dictionary& dict,
199  );
200 
201 
202  //- Destructor
203  virtual ~chemistryReductionMethod();
204 
205 
206  // Member Functions
207 
208  //- Return mechanism reduction active
209  virtual bool active() const
210  {
211  return true;
212  }
213 
214  //- Return the number of species
215  inline label nSpecie();
216 
217  //- Return the number of active species
218  inline label nActiveSpecies() const;
219 
220  //- Return the tolerance
221  inline scalar tolerance() const;
222 
223  //- Return the active species
224  inline const boolList& activeSpecies() const;
225 
226  //- Return whether or not a reaction is disabled
227  inline bool reactionDisabled(const label i) const;
228 
229  //- Reduce the mechanism
230  virtual void reduceMechanism
231  (
232  const scalar p,
233  const scalar T,
234  const scalarField& c,
235  List<label>& ctos,
236  DynamicList<label>& stoc,
237  const label li
238  ) = 0;
239 
240  //- ...
241  virtual void update();
242 };
243 
244 
245 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246 
247 } // End namespace Foam
248 
249 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
250 
252 
253 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
254 
255 #ifdef NoRepository
256  #include "chemistryReductionMethod.C"
258 #endif
259 
260 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
261 
262 #endif
263 
264 // ************************************************************************* //
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:61
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
Extension to Foam::chemistryModels::standard templated on thermo and provides stiff ODE integration f...
An abstract class for methods of chemical mechanism reduction.
TypeName("chemistryReductionMethod")
Runtime type information.
chemistryReductionMethod(chemistryModels::Standard< ThermoType > &chemistry)
Construct from components.
virtual ~chemistryReductionMethod()
Destructor.
const dictionary & coeffDict(const dictionary &dict) const
Protected Member Functions.
void initReduceMechanism()
Initialise reduction of the mechanism.
const label nSpecie_
Total number of species.
Field< bool > reactionsDisabled_
List of disabled reactions (disabled = true)
bool reactionDisabled(const label i) const
Return whether or not a reaction is disabled.
chemistryModels::Standard< ThermoType > & chemistry_
Reference to the chemistry model.
scalar tolerance() const
Return the tolerance.
static autoPtr< chemistryReductionMethod< ThermoType > > New(const dictionary &dict, chemistryModels::Standard< ThermoType > &chemistry)
declareRunTimeSelectionTable(autoPtr, chemistryReductionMethod, dictionary,(const dictionary &dict, chemistryModels::Standard< ThermoType > &chemistry),(dict, chemistry))
label nSpecie()
Return the number of species.
const boolList & activeSpecies() const
Return the active species.
boolList activeSpecies_
List of active species (active = true)
void endReduceMechanism(List< label > &ctos, DynamicList< label > &stoc)
End reduction of the mechanism.
label nActiveSpecies() const
Return the number of active species.
label nActiveSpecies_
Number of active species.
virtual bool active() const
Return mechanism reduction active.
virtual void reduceMechanism(const scalar p, const scalar T, const scalarField &c, List< label > &ctos, DynamicList< label > &stoc, const label li)=0
Reduce the mechanism.
Starts timing CPU usage and return elapsed time from start.
Definition: cpuTime.H:55
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
const dimensionedScalar c
Speed of light in a vacuum.
Namespace for OpenFOAM.
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
void T(GeometricField< Type, GeoMesh, PrimitiveField1 > &gf, const GeometricField< Type, GeoMesh, PrimitiveField2 > &gf1)
dictionary dict
volScalarField & p
chemistryModel & chemistry