sootModelNew.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) 2013-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 \*---------------------------------------------------------------------------*/
25 
26 #include "error.H"
27 #include "sootModel.H"
28 #include "noSoot.H"
29 #include "basicThermo.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
35 (
36  const dictionary& dict,
37  const fvMesh& mesh
38 )
39 {
40  // Get the soot model type name
41  word modelType(sootModels::noSoot::typeName);
42  if (dict.found(sootModel::typeName))
43  {
44  dict.lookup(sootModel::typeName) >> modelType;
45  Info<< "Selecting soot model " << modelType << endl;
46  }
47  const wordList cmpts(basicThermo::splitThermoName(modelType, 3));
48  if (cmpts.size() == 3)
49  {
50  modelType = cmpts[0];
51 
53  << "Template parameters are no longer required when selecting a "
54  << sootModel::typeName << ". This information is now "
55  << "obtained directly from the thermodynamics. Actually selecting "
56  << "combustion model " << modelType << "." << endl;
57  }
58 
59  // Get the thermo model type names
60  word thermoType(word::null);
62  {
63  const basicThermo& thermo =
65 
66  thermoType = thermo.thermoName();
67  }
68 
69  // Construct a thermo-soot model type name
70  const word thermoModelType = modelType + '<' + thermoType + '>';
71 
72  // Lookup both possible model names
73  dictionaryConstructorTable::iterator cstrIter =
74  dictionaryConstructorTablePtr_->find(modelType);
75  dictionaryConstructorTable::iterator thermoCstrIter =
76  dictionaryConstructorTablePtr_->find(thermoModelType);
77 
78  // Construct and return
79  if (thermoCstrIter != dictionaryConstructorTablePtr_->end())
80  {
81  return autoPtr<sootModel>(thermoCstrIter()(dict, mesh, modelType));
82  }
83  else if (cstrIter != dictionaryConstructorTablePtr_->end())
84  {
85  return autoPtr<sootModel>(cstrIter()(dict, mesh, modelType));
86  }
87  else
88  {
90  << "Unknown " << sootModel::typeName << " type "
91  << modelType << nl << nl;
92 
93  const wordList names(dictionaryConstructorTablePtr_->sortedToc());
94 
95  wordList thisCmpts;
96  thisCmpts.append(word::null);
97  thisCmpts.append(basicThermo::splitThermoName(thermoType, 5));
98 
99  wordList validNames;
100  forAll(names, i)
101  {
102  wordList cmpts(basicThermo::splitThermoName(names[i], 1));
103  if (cmpts.size() != 1)
104  {
105  cmpts = basicThermo::splitThermoName(names[i], 6);
106  }
107 
108  bool isValid = true;
109  for (label i = 1; i < cmpts.size() && isValid; ++ i)
110  {
111  isValid = isValid && cmpts[i] == thisCmpts[i];
112  }
113 
114  if (isValid)
115  {
116  validNames.append(cmpts[0]);
117  }
118  }
119 
121  << "Valid " << sootModel::typeName << " types for this "
122  << "thermodynamic model are:" << endl << validNames << endl;
123 
124  List<wordList> validCmpts;
125  validCmpts.append(wordList(6, word::null));
126  validCmpts[0][0] = sootModel::typeName;
127  validCmpts[0][1] = "transport";
128  validCmpts[0][2] = "thermo";
129  validCmpts[0][3] = "equationOfState";
130  validCmpts[0][4] = "specie";
131  validCmpts[0][5] = "energy";
132  forAll(names, i)
133  {
134  const wordList cmpts1(basicThermo::splitThermoName(names[i], 1));
135  const wordList cmpts6(basicThermo::splitThermoName(names[i], 6));
136  if (cmpts1.size() == 1)
137  {
138  validCmpts.append(wordList(6, "<any>"));
139  validCmpts.last()[0] = cmpts1[0];
140  }
141  if (cmpts6.size() == 6)
142  {
143  validCmpts.append(cmpts6);
144  }
145  }
146 
148  << "All " << sootModel::typeName
149  << "/thermoPhysics combinations are:" << endl << endl;
150  printTable(validCmpts, FatalErrorInFunction);
151 
153 
154  return autoPtr<sootModel>(nullptr);
155  }
156 }
157 
158 
159 // ************************************************************************* //
dictionary dict
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:667
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
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
Abstract base-class for fluid and solid thermodynamic properties.
Definition: basicThermo.H:52
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
virtual word thermoName() const =0
Return the name of the thermo physics.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
bool foundObject(const word &name) const
Is the named Type found?
rhoReactionThermo & thermo
Definition: createFields.H:28
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type.
dynamicFvMesh & mesh
A class for handling words, derived from string.
Definition: word.H:59
void append(const T &)
Append an element at the end of the list.
Definition: ListI.H:178
const word dictName("particleTrackDict")
static const char nl
Definition: Ostream.H:260
void printTable(const List< wordList > &, List< string::size_type > &, Ostream &)
Definition: wordIOList.C:42
List< word > wordList
A List of words.
Definition: fileName.H:54
static autoPtr< sootModel > New(const dictionary &dict, const fvMesh &mesh)
Selector.
Definition: sootModelNew.C:35
#define WarningInFunction
Report a warning using Foam::Warning.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
messageStream Info
T & last()
Return the last element of the list.
Definition: UListI.H:128
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:812