basicSolidChemistryModelNew.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) 2013-2017 OpenFOAM Foundation
9  Copyright (C) 2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 
30 
31 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
32 
35 {
36  const IOdictionary chemistryDict
37  (
38  IOobject
39  (
40  thermo.phasePropertyName("chemistryProperties"),
41  thermo.db().time().constant(),
42  thermo.db(),
45  false
46  )
47  );
48 
49  const dictionary& chemistryTypeDict =
50  chemistryDict.subDict("chemistryType");
51 
52  Info<< "Selecting chemistry type " << chemistryTypeDict << endl;
53 
54  std::initializer_list<const char*> cmptNames
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 
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  const word solidThermoTypeName
86  (
87  solidThermoTypeDict.get<word>("transport") + '<'
88  + solidThermoTypeDict.get<word>("thermo") + '<'
89  + solidThermoTypeDict.get<word>("equationOfState") + '<'
90  + solidThermoTypeDict.get<word>("specie") + ">>,"
91  + solidThermoTypeDict.get<word>("energy") + ">"
92  );
93 
94  const dictionary& gasThermoTypeDict = thermoDict.subDict("gasThermoType");
95  const word gasThermoTypeName
96  (
97  gasThermoTypeDict.get<word>("transport") + '<'
98  + gasThermoTypeDict.get<word>("thermo") + '<'
99  + gasThermoTypeDict.get<word>("equationOfState") + '<'
100  + gasThermoTypeDict.get<word>("specie") + ">>,"
101  + gasThermoTypeDict.get<word>("energy") + ">"
102  );
103 
104  // Construct the name of the chemistry type from the components
105  const word chemistryTypeName
106  (
107  chemistryTypeDict.get<word>("chemistrySolver") + '<'
108  + chemistryTypeDict.get<word>("chemistryThermo") + '<'
109  + typeName + ','
110  + solidThermoTypeName + ',' + gasThermoTypeName + ">>"
111  );
112 
113  Info<< "chemistryTypeName " << chemistryTypeName << endl;
114 
115  auto cstrIter = thermoConstructorTablePtr_->cfind(chemistryTypeName);
116 
117  if (!cstrIter.found())
118  {
119  const int nCmpt = cmptNames.size();
120 
121  // Build a table of the thermo packages constituent parts
122  // Note: row-0 contains the names of constituent parts
123  List<wordList> validCmpts(thermoConstructorTablePtr_->size()+1);
124 
125  // Header (row 0)
126  validCmpts[0].resize(nCmpt);
127  std::copy(cmptNames.begin(), cmptNames.end(), validCmpts[0].begin());
128 
129  label rowi = 1;
130  for (const word& validName : thermoConstructorTablePtr_->sortedToc())
131  {
132  validCmpts[rowi] = basicThermo::splitThermoName(validName, nCmpt);
133 
134  if (validCmpts[rowi].size())
135  {
136  ++rowi;
137  }
138  }
139  validCmpts.resize(rowi);
140 
141 
143  (
144  chemistryTypeDict,
145  typeName,
146  word::null, // Suppress long name? Just output dictionary (above)
147  *thermoConstructorTablePtr_
148  );
149 
150  // Table of available packages (as constituent parts)
151  printTable(validCmpts, FatalIOError)
152  << exit(FatalIOError);
153  }
154 
155  return
157 }
158 
159 
160 // ************************************************************************* //
Foam::IOobject::NO_WRITE
Definition: IOobject.H:130
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:54
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
Foam::solidReactionThermo
Foam::solidReactionThermo.
Definition: solidReactionThermo.H:55
basicSolidChemistryModel.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
thermo
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
Foam::FatalIOError
IOerror FatalIOError
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
Foam::dictionary::get
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:81
FatalIOErrorInLookup
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:406
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
Foam::dictionary::subDict
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Definition: dictionary.C:528
Foam::printTable
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:47
Foam::basicThermo::splitThermoName
static wordList splitThermoName(const word &thermoName, const int nCmpt)
Split name of thermo package into a list of the components names.
Definition: basicThermo.C:451
Foam::List::resize
void resize(const label newSize)
Adjust allocated size of list.
Definition: ListI.H:139
Foam::dictionary::dictName
word dictName() const
The local dictionary name (final part of scoped name)
Definition: dictionary.H:458
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::basicSolidChemistryModel::New
static autoPtr< basicSolidChemistryModel > New(solidReactionThermo &thermo)
Selector.
Definition: basicSolidChemistryModelNew.C:34
Foam::autoPtr< Foam::basicSolidChemistryModel >
thermoDict
const dictionary & thermoDict
Definition: EEqn.H:16
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::word::null
static const word null
An empty word.
Definition: word.H:77
Foam::IOobject::MUST_READ_IF_MODIFIED
Definition: IOobject.H:121
Foam::IOobject::MUST_READ
Definition: IOobject.H:120