chemistryReductionMethodNew.C
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) 2016-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 \*---------------------------------------------------------------------------*/
25 
27 #include "noChemistryReduction.H"
28 #include "Time.H"
29 
30 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
31 
32 template<class ThermoType>
35 (
36  const dictionary& dict,
38 )
39 {
40  if (dict.found("reduction"))
41  {
42  const dictionary& reductionDict(dict.subDict("reduction"));
43 
44  const word methodName(reductionDict.lookup("method"));
45 
47  << "Selecting chemistry reduction method " << methodName << endl;
48 
49  const word methodTypeName =
50  methodName + '<' + ThermoType::typeName() + '>';
51 
52  typename dictionaryConstructorTable::iterator cstrIter =
53  dictionaryConstructorTablePtr_->find(methodTypeName);
54 
55  if (cstrIter == dictionaryConstructorTablePtr_->end())
56  {
58  << "Unknown " << typeName_() << " type " << methodName << endl
59  << endl;
60 
61  const wordList names(dictionaryConstructorTablePtr_->sortedToc());
62 
63  wordList thisCmpts;
64  thisCmpts.append(word::null);
65  thisCmpts.append
66  (
67  basicThermo::splitThermoName(ThermoType::typeName(), 5)
68  );
69 
70  wordList validNames;
71  forAll(names, i)
72  {
73  const wordList cmpts(basicThermo::splitThermoName(names[i], 6));
74 
75  if
76  (
77  SubList<word>(cmpts, 5, 1) == SubList<word>(thisCmpts, 5, 1)
78  )
79  {
80  validNames.append(cmpts[0]);
81  }
82  }
83 
85  << "Valid " << typeName_()
86  << " types are:" << validNames << endl
87  << exit(FatalIOError);
88  }
89 
91  (
92  cstrIter()(dict, chemistry)
93  );
94 
95  chemistry.reduction_ = crmPtr->active();
96 
97  return crmPtr;
98  }
99  else
100  {
102  (
104  );
105  }
106 }
107 
108 
109 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
void append(const T &)
Append an element at the end of the list.
Definition: ListI.H:178
A List obtained as a section of another List.
Definition: SubList.H:56
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...
static autoPtr< chemistryReductionMethod< ThermoType > > New(const dictionary &dict, chemistryModels::Standard< ThermoType > &chemistry)
A chemistryReductionMethod which does nothing to allow reduction to be switched-off.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:669
A class for handling words, derived from string.
Definition: word.H:63
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:346
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:288
String typeName(const std::type_info &info)
Return the un-mangled name given the standard type info.
messageStream Info
IOerror FatalIOError
Ostream & indentOrNl(Ostream &os)
Indent stream or add newline if indent level == 0.
Definition: Ostream.H:250
dictionary dict
chemistryModel & chemistry