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 | Copyright (C) 2013-2015 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 
31 New
32 (
33  const fvMesh& mesh,
34  const word& phaseName
35 )
36 {
37  IOdictionary chemistryDict
38  (
39  IOobject
40  (
41  IOobject::groupName("chemistryProperties", phaseName),
42  mesh.time().constant(),
43  mesh,
44  IOobject::MUST_READ,
45  IOobject::NO_WRITE,
46  false
47  )
48  );
49 
50  const dictionary& chemistryTypeDict
51  (
52  chemistryDict.subDict("chemistryType")
53  );
54 
55  Info<< "Selecting chemistry type " << chemistryTypeDict << endl;
56 
57  const int nCmpt = 13;
58  const char* cmptNames[nCmpt] =
59  {
60  "chemistrySolver",
61  "chemistryThermo",
62  "baseChemistry",
63  "transport",
64  "thermo",
65  "equationOfState",
66  "specie",
67  "energy",
68  "transport",
69  "thermo",
70  "equationOfState",
71  "specie",
72  "energy"
73  };
74 
75  IOdictionary thermoDict
76  (
77  IOobject
78  (
80  mesh.time().constant(),
81  mesh,
82  IOobject::MUST_READ_IF_MODIFIED,
83  IOobject::NO_WRITE,
84  false
85  )
86  );
87 
88  const dictionary& solidThermoTypeDict(thermoDict.subDict("thermoType"));
89  word solidThermoTypeName
90  (
91  word(solidThermoTypeDict.lookup("transport")) + '<'
92  + word(solidThermoTypeDict.lookup("thermo")) + '<'
93  + word(solidThermoTypeDict.lookup("equationOfState")) + '<'
94  + word(solidThermoTypeDict.lookup("specie")) + ">>,"
95  + word(solidThermoTypeDict.lookup("energy")) + ">"
96  );
97 
98  const dictionary& gasThermoTypeDict(thermoDict.subDict("gasThermoType"));
99  word gasThermoTypeName
100  (
101  word(gasThermoTypeDict.lookup("transport")) + '<'
102  + word(gasThermoTypeDict.lookup("thermo")) + '<'
103  + word(gasThermoTypeDict.lookup("equationOfState")) + '<'
104  + word(gasThermoTypeDict.lookup("specie")) + ">>,"
105  + word(gasThermoTypeDict.lookup("energy")) + ">"
106  );
107 
108  // Construct the name of the chemistry type from the components
109  word chemistryTypeName
110  (
111  word(chemistryTypeDict.lookup("chemistrySolver")) + '<'
112  + word(chemistryTypeDict.lookup("chemistryThermo")) + '<'
113  + typeName + ','
114  + solidThermoTypeName + ',' + gasThermoTypeName + ">>"
115  );
116 
117  Info<< "chemistryTypeName " << chemistryTypeName << endl;
118 
119  fvMeshConstructorTable::iterator cstrIter =
120  fvMeshConstructorTablePtr_->find(chemistryTypeName);
121 
122  if (cstrIter == fvMeshConstructorTablePtr_->end())
123  {
125  << "Unknown " << typeName << " type " << nl
126  << "chemistryType" << chemistryTypeDict << nl << nl
127  << "Valid " << typeName << " types are:"
128  << nl << nl;
129 
130  // Get the list of all the suitable chemistry packages available
131  wordList validChemistryTypeNames
132  (
133  fvMeshConstructorTablePtr_->sortedToc()
134  );
135  Info<< validChemistryTypeNames << endl;
136 
137  // Build a table of the thermo packages constituent parts
138  // Note: row-0 contains the names of constituent parts
139  List<wordList> validChemistryTypeNameCmpts
140  (
141  validChemistryTypeNames.size() + 1
142  );
143 
144  validChemistryTypeNameCmpts[0].setSize(nCmpt);
145  forAll(validChemistryTypeNameCmpts[0], j)
146  {
147  validChemistryTypeNameCmpts[0][j] = cmptNames[j];
148  }
149 
150  // Split the thermo package names into their constituent parts
151  forAll(validChemistryTypeNames, i)
152  {
153  validChemistryTypeNameCmpts[i+1] = basicThermo::splitThermoName
154  (
155  validChemistryTypeNames[i],
156  nCmpt
157  );
158  }
159 
160  // Print the table of available packages
161  // in terms of their constituent parts
162  printTable(validChemistryTypeNameCmpts, FatalError);
163 
165  }
166 
167  return autoPtr<basicSolidChemistryModel>(cstrIter()(mesh, phaseName));
168 }
169 
170 
171 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
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:137
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:633
static autoPtr< basicSolidChemistryModel > New(const fvMesh &mesh, const word &phaseName=word::null)
Selector.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:53
dynamicFvMesh & mesh
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:262
void printTable(const List< wordList > &, List< string::size_type > &, Ostream &)
Definition: wordIOList.C:42
void setSize(const label)
Reset size of List.
Definition: List.C:295
word dictName("noiseDict")
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
messageStream Info
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:243