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-2024 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 SourceFiles
31  chemistryReductionMethod.C
32  chemistryReductionMethods.C
33  chemistryReductionMethodNew.C
34  chemistryReductionMethodI.H
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef chemistryReductionMethod_H
39 #define chemistryReductionMethod_H
40 
41 #include "dictionary.H"
42 #include "DynamicField.H"
43 #include "Switch.H"
44 #include "cpuTime.H"
45 #include "OFstream.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 template<class ThermoType>
53 class chemistryModel;
54 
55 /*---------------------------------------------------------------------------*\
56  Class chemistryReductionMethod Declaration
57 \*---------------------------------------------------------------------------*/
58 
59 template<class ThermoType>
61 {
62 protected:
63 
64  // Protected Data
65 
66  //- Reference to the chemistry model
68 
69  //- Total number of species
70  const label nSpecie_;
71 
72  //- Number of active species
74 
75  //- List of disabled reactions (disabled = true)
77 
78  //- List of active species (active = true)
80 
81 
82  //- Protected Member Functions
83 
84  const dictionary& coeffDict(const dictionary& dict) const
85  {
86  return dict.subDict("reduction");
87  }
88 
89  //- Initialise reduction of the mechanism
90  void initReduceMechanism();
91 
92  //- End reduction of the mechanism
94 
95 
96 private:
97 
98  // Private Data
99 
100  //- Switch to select performance logging
101  Switch log_;
102 
103  //- Tolerance for the mechanism reduction algorithm
104  scalar tolerance_;
105 
106  //- CPU time for logging
107  cpuTime cpuTime_;
108 
109  //- ...
110  int64_t sumnActiveSpecies_;
111 
112  //- ...
113  int64_t sumn_;
114 
115  //- ...
116  scalar reduceMechCpuTime_;
117 
118  // Log file for the average time spent reducing the chemistry
119  autoPtr<OFstream> cpuReduceFile_;
120 
121  // Write average number of species
122  autoPtr<OFstream> nActiveSpeciesFile_;
123 
124 
125 public:
126 
127  //- Runtime type information
128  TypeName("chemistryReductionMethod");
129 
130 
131  // Declare runtime constructor selection table
133  (
134  autoPtr,
136  dictionary,
137  (
138  const dictionary& dict,
140  ),
141  (dict, chemistry)
142  );
143 
144 
145  // Constructors
146 
147  //- Construct from components
149  (
151  );
152 
153  //- Construct from components
155  (
156  const dictionary& dict,
158  );
159 
160 
161  // Selector
162 
164  (
165  const dictionary& dict,
167  );
168 
169 
170  //- Destructor
171  virtual ~chemistryReductionMethod();
172 
173 
174  // Member Functions
175 
176  //- Return mechanism reduction active
177  virtual bool active() const
178  {
179  return true;
180  }
181 
182  //- Return the number of species
183  inline label nSpecie();
184 
185  //- Return the number of active species
186  inline label nActiveSpecies() const;
187 
188  //- Return the tolerance
189  inline scalar tolerance() const;
190 
191  //- Return the active species
192  inline const List<bool>& activeSpecies() const;
193 
194  //- Return whether or not a reaction is disabled
195  inline bool reactionDisabled(const label i) const;
196 
197  //- Reduce the mechanism
198  virtual void reduceMechanism
199  (
200  const scalar p,
201  const scalar T,
202  const scalarField& c,
203  List<label>& ctos,
204  DynamicList<label>& stoc,
205  const label li
206  ) = 0;
207 
208  //- ...
209  virtual void update();
210 };
211 
212 
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 
215 } // End namespace Foam
216 
217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
218 
220 
221 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
222 
223 #ifdef NoRepository
224  #include "chemistryReductionMethod.C"
226 #endif
227 
228 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
229 
230 #endif
231 
232 // ************************************************************************* //
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
Extends base chemistry model by adding a thermo package, and ODE functions. Introduces chemistry equa...
An abstract class for methods of chemical mechanism reduction.
chemistryModel< ThermoType > & chemistry_
Reference to the chemistry model.
const List< bool > & activeSpecies() const
Return the active species.
TypeName("chemistryReductionMethod")
Runtime type information.
declareRunTimeSelectionTable(autoPtr, chemistryReductionMethod, dictionary,(const dictionary &dict, chemistryModel< ThermoType > &chemistry),(dict, chemistry))
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.
List< bool > activeSpecies_
List of active species (active = true)
Field< bool > reactionsDisabled_
List of disabled reactions (disabled = true)
bool reactionDisabled(const label i) const
Return whether or not a reaction is disabled.
scalar tolerance() const
Return the tolerance.
static autoPtr< chemistryReductionMethod< ThermoType > > New(const dictionary &dict, chemistryModel< ThermoType > &chemistry)
label nSpecie()
Return the number of species.
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.
chemistryReductionMethod(chemistryModel< ThermoType > &chemistry)
Construct from components.
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(LagrangianPatchField< Type > &f, const LagrangianPatchField< Type > &f1)
dictionary dict
volScalarField & p
basicChemistryModel & chemistry