basicSolidChemistryModelNew.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-2018 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 
28 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
29 
32 {
33  IOdictionary chemistryDict
34  (
35  IOobject
36  (
37  thermo.phasePropertyName("chemistryProperties"),
38  thermo.db().time().constant(),
39  thermo.db(),
42  false
43  )
44  );
45 
46  const dictionary& chemistryTypeDict
47  (
48  chemistryDict.subDict("chemistryType")
49  );
50 
51  Info<< "Selecting chemistry type " << chemistryTypeDict << endl;
52 
53  const int nCmpt = 13;
54  const char* cmptNames[nCmpt] =
55  {
56  "chemistrySolver",
57  "chemistryThermo",
58  "baseChemistry",
59  "transport",
60  "thermo",
61  "equationOfState",
62  "specie",
63  "energy",
64  "transport",
65  "thermo",
66  "equationOfState",
67  "specie",
68  "energy"
69  };
70 
71  IOdictionary thermoDict
72  (
73  IOobject
74  (
76  thermo.db().time().constant(),
77  thermo.db(),
80  false
81  )
82  );
83 
84  const dictionary& solidThermoTypeDict(thermoDict.subDict("thermoType"));
85  word solidThermoTypeName
86  (
87  word(solidThermoTypeDict.lookup("transport")) + '<'
88  + word(solidThermoTypeDict.lookup("thermo")) + '<'
89  + word(solidThermoTypeDict.lookup("equationOfState")) + '<'
90  + word(solidThermoTypeDict.lookup("specie")) + ">>,"
91  + word(solidThermoTypeDict.lookup("energy")) + ">"
92  );
93 
94  const dictionary& gasThermoTypeDict(thermoDict.subDict("gasThermoType"));
95  word gasThermoTypeName
96  (
97  word(gasThermoTypeDict.lookup("transport")) + '<'
98  + word(gasThermoTypeDict.lookup("thermo")) + '<'
99  + word(gasThermoTypeDict.lookup("equationOfState")) + '<'
100  + word(gasThermoTypeDict.lookup("specie")) + ">>,"
101  + word(gasThermoTypeDict.lookup("energy")) + ">"
102  );
103 
104  // Construct the name of the chemistry type from the components
105  word chemistryTypeName
106  (
107  word(chemistryTypeDict.lookup("chemistrySolver")) + '<'
108  + word(chemistryTypeDict.lookup("chemistryThermo")) + '<'
109  + typeName + ','
110  + solidThermoTypeName + ',' + gasThermoTypeName + ">>"
111  );
112 
113  Info<< "chemistryTypeName " << chemistryTypeName << endl;
114 
115  thermoConstructorTable::iterator cstrIter =
116  thermoConstructorTablePtr_->find(chemistryTypeName);
117 
118  if (cstrIter == thermoConstructorTablePtr_->end())
119  {
121  << "Unknown " << typeName << " type " << nl
122  << "chemistryType" << chemistryTypeDict << nl << nl
123  << "Valid " << typeName << " types are:"
124  << nl << nl;
125 
126  // Get the list of all the suitable chemistry packages available
127  wordList validChemistryTypeNames
128  (
129  thermoConstructorTablePtr_->sortedToc()
130  );
131  Info<< validChemistryTypeNames << endl;
132 
133  // Build a table of the thermo packages constituent parts
134  // Note: row-0 contains the names of constituent parts
135  List<wordList> validChemistryTypeNameCmpts
136  (
137  validChemistryTypeNames.size() + 1
138  );
139 
140  validChemistryTypeNameCmpts[0].setSize(nCmpt);
141  forAll(validChemistryTypeNameCmpts[0], j)
142  {
143  validChemistryTypeNameCmpts[0][j] = cmptNames[j];
144  }
145 
146  // Split the thermo package names into their constituent parts
147  forAll(validChemistryTypeNames, i)
148  {
149  validChemistryTypeNameCmpts[i+1] = basicThermo::splitThermoName
150  (
151  validChemistryTypeNames[i],
152  nCmpt
153  );
154  }
155 
156  // Print the table of available packages
157  // in terms of their constituent parts
158  printTable(validChemistryTypeNameCmpts, FatalError);
159 
161  }
162 
163  return
165 }
166 
167 
168 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
static word phasePropertyName(const word &name, const word &phaseName)
Definition: basicThermo.H:190
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
Foam::solidReactionThermo.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:256
rhoReactionThermo & thermo
Definition: createFields.H:28
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:52
const word dictName() const
Return the local dictionary name (final part of scoped name)
Definition: dictionary.H:123
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:699
static autoPtr< basicSolidChemistryModel > New(solidReactionThermo &thermo)
Selector.
static wordList splitThermoName(const word &thermoName, const int nCmpt)
Split name of thermo package into a list of the components names.
Definition: basicThermo.C:416
A class for handling words, derived from string.
Definition: word.H:59
const word & constant() const
Return constant name.
Definition: TimePaths.H:124
static const char nl
Definition: Ostream.H:265
void printTable(const List< wordList > &, List< string::size_type > &, Ostream &)
Definition: wordIOList.C:42
const Time & time() const
Return time.
void setSize(const label)
Reset size of List.
Definition: List.C:281
messageStream Info
const objectRegistry & db() const
Return the local objectRegistry.
Definition: IOobject.C:354
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92