Loading...
Searching...
No Matches
combustionModelTemplates.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2017 OpenFOAM Foundation
9 Copyright (C) 2019-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
30
31template<class CombustionModel>
33(
36 const word& combustionProperties
37)
38{
39 IOobject combIO
40 (
41 thermo.phasePropertyName(combustionProperties),
42 thermo.db().time().constant(),
43 thermo.db(),
47 );
48
49 word combModelName("none");
50 if (combIO.typeHeaderOk<IOdictionary>(false))
51 {
52 IOdictionary(combIO).readEntry("combustionModel", combModelName);
53 }
54 else
55 {
56 Info<< "Combustion model not active: "
57 << thermo.phasePropertyName(combustionProperties)
58 << " not found" << endl;
59 }
60
61 Info<< "Selecting combustion model " << combModelName << endl;
62
63 const wordList cmpts2(basicThermo::splitThermoName(combModelName, 2));
64 const wordList cmpts3(basicThermo::splitThermoName(combModelName, 3));
65 if (cmpts2.size() == 2 || cmpts3.size() == 3)
66 {
67 combModelName = cmpts2.size() ? cmpts2[0] : cmpts3[0];
68
70 << "Template parameters are no longer required when selecting a "
71 << combustionModel::typeName << ". This information is now "
72 << "obtained directly from the thermodynamics. Actually selecting "
73 << "combustion model " << combModelName << "." << endl;
74 }
75
76
77 const word compCombModelName
78 (
79 combModelName + '<' + CombustionModel::reactionThermo::typeName + '>'
80 );
81
82 const word thermoCombModelName
83 (
84 combModelName + '<' + CombustionModel::reactionThermo::typeName + ','
85 + thermo.thermoName() + '>'
86 );
87
88
89 const auto& cnstrTable = *(CombustionModel::dictionaryConstructorTablePtr_);
90
91 auto ctorIter = cnstrTable.cfind(thermoCombModelName);
92
93 if (!ctorIter.good())
94 {
95 ctorIter = cnstrTable.cfind(compCombModelName);
96 }
97
98 if (!ctorIter.good())
99 {
100 const wordList names(cnstrTable.sortedToc());
101
110
111 DynamicList<wordList> validCmpts2;
112 validCmpts2.append
113 (
114 // Header
116 ({
118 combustionModel::typeName,
119 "reactionThermo"
120 })
121 );
122
123 DynamicList<wordList> validCmpts7;
124 validCmpts7.append
125 (
126 // Header
128 ({
130 combustionModel::typeName,
131 "reactionThermo",
132 "transport",
133 "thermo",
134 "equationOfState",
135 "specie",
136 "energy"
137 })
138 );
139
140 for (const word& validName : names)
141 {
142 wordList cmpts(basicThermo::splitThermoName(validName, 0));
143
144 if (cmpts.size() == 2)
145 {
146 validCmpts2.append(std::move(cmpts));
147 }
148 else if (cmpts.size() == 7)
149 {
154 validCmpts7.append(std::move(cmpts));
155 }
156 }
157
159 (
160 combustionModel::typeName,
161 combModelName,
162 cnstrTable
163 );
164
165 if (validCmpts2.size() > 1)
166 {
168 << "All " << validCmpts2[0][0] << '/' << validCmpts2[0][1]
169 << " combinations are:" << nl << nl;
170
171 printTable(validCmpts2, FatalError) << nl;
172 }
173
174 if (validCmpts7.size() > 1)
175 {
177 << "All " << validCmpts7[0][0] << '/' << validCmpts7[0][1]
178 << "/thermoPhysics combinations are:" << nl << nl;
179
180 printTable(validCmpts7, FatalError) << nl;
181 }
182
184 << exit(FatalError);
185 }
186
188 (
189 ctorIter.val()(combModelName, thermo, turb, combustionProperties)
190 );
191}
192
193
194// ************************************************************************* //
compressible::turbulenceModel & turb
ReactionThermo reactionThermo
Thermo type.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition DynamicList.H:68
void append(const T &val)
Copy append an element to the end of this list.
IOdictionary(const IOobject &io, const dictionary *fallback=nullptr)
Construct given an IOobject and optional fallback dictionary content.
@ NO_REGISTER
Do not request registration (bool: false).
@ MUST_READ
Reading required.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
bool typeHeaderOk(const bool checkType=true, const bool search=true, const bool verbose=true)
Read header (respects is_globalIOobject trait) and check its info. A void type suppresses trait and t...
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
static wordList splitThermoName(const std::string &thermoName, const int nExpectedCmpts)
Split thermo package name into a list of components names.
static autoPtr< CombustionModel > New(typename CombustionModel::reactionThermo &thermo, const compressibleTurbulenceModel &turb, const word &combustionProperties)
Generic New for each of the related chemistry model.
Abstract base class for turbulence models (RAS, LES and laminar).
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
A class for handling words, derived from Foam::string.
Definition word.H:66
static const word null
An empty word.
Definition word.H:84
#define FatalErrorInLookup(lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalError.
Definition error.H:607
auto & names
#define WarningInFunction
Report a warning using Foam::Warning.
List< word > wordList
List of word.
Definition fileName.H:60
messageStream Info
Information stream (stdout output on master, null elsewhere).
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
Ostream & printTable(const UList< wordList > &tbl, List< std::string::size_type > &columnWidths, Ostream &os, bool headerSeparator=true)
Print a List of wordList as a table.
Definition wordIOList.C:40
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50