basicChemistryModelTemplates.C
Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation 00006 \\/ M anipulation | 00007 ------------------------------------------------------------------------------- 00008 License 00009 This file is part of OpenFOAM. 00010 00011 OpenFOAM is free software: you can redistribute it and/or modify it 00012 under the terms of the GNU General Public License as published by 00013 the Free Software Foundation, either version 3 of the License, or 00014 (at your option) any later version. 00015 00016 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00018 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00019 for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. 00023 00024 \*---------------------------------------------------------------------------*/ 00025 00026 #include "basicChemistryModel.H" 00027 #include "basicThermo.H" 00028 00029 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // 00030 00031 template<class ChemistryModel> 00032 Foam::autoPtr<ChemistryModel> Foam::basicChemistryModel::New 00033 ( 00034 const fvMesh& mesh 00035 ) 00036 { 00037 IOdictionary chemistryDict 00038 ( 00039 IOobject 00040 ( 00041 "chemistryProperties", 00042 mesh.time().constant(), 00043 mesh, 00044 IOobject::MUST_READ, 00045 IOobject::NO_WRITE, 00046 false 00047 ) 00048 ); 00049 00050 word chemistryTypeName; 00051 00052 if (chemistryDict.isDict("chemistryType")) 00053 { 00054 const dictionary& chemistryTypeDict 00055 ( 00056 chemistryDict.subDict("chemistryType") 00057 ); 00058 00059 Info<< "Selecting chemistry type " << chemistryTypeDict << endl; 00060 00061 const int nCmpt = 7; 00062 const char* cmptNames[nCmpt] = 00063 { 00064 "chemistrySolver", 00065 "chemistryThermo", 00066 "transport", 00067 "thermo", 00068 "equationOfState", 00069 "specie", 00070 "energy" 00071 }; 00072 00073 IOdictionary thermoDict 00074 ( 00075 IOobject 00076 ( 00077 "thermophysicalProperties", 00078 mesh.time().constant(), 00079 mesh, 00080 IOobject::MUST_READ_IF_MODIFIED, 00081 IOobject::NO_WRITE, 00082 false 00083 ) 00084 ); 00085 00086 word thermoTypeName; 00087 00088 if (thermoDict.isDict("thermoType")) 00089 { 00090 const dictionary& thermoTypeDict(thermoDict.subDict("thermoType")); 00091 thermoTypeName = 00092 word(thermoTypeDict.lookup("transport")) + '<' 00093 + word(thermoTypeDict.lookup("thermo")) + '<' 00094 + word(thermoTypeDict.lookup("equationOfState")) + '<' 00095 + word(thermoTypeDict.lookup("specie")) + ">>," 00096 + word(thermoTypeDict.lookup("energy")) + ">"; 00097 } 00098 else 00099 { 00100 FatalIOErrorIn 00101 ( 00102 (ChemistryModel::typeName + "::New(const mesh&)").c_str(), 00103 thermoDict 00104 ) << "thermoType is in the old format and must be upgraded" 00105 << exit(FatalIOError); 00106 } 00107 00108 // Construct the name of the chemistry type from the components 00109 chemistryTypeName = 00110 word(chemistryTypeDict.lookup("chemistrySolver")) + '<' 00111 + word(chemistryTypeDict.lookup("chemistryThermo")) + ',' 00112 + thermoTypeName + ">"; 00113 00114 typename ChemistryModel::fvMeshConstructorTable::iterator cstrIter = 00115 ChemistryModel::fvMeshConstructorTablePtr_->find(chemistryTypeName); 00116 00117 if (cstrIter == ChemistryModel::fvMeshConstructorTablePtr_->end()) 00118 { 00119 FatalErrorIn(ChemistryModel::typeName + "::New(const mesh&)") 00120 << "Unknown " << ChemistryModel::typeName << " type " << nl 00121 << "chemistryType" << chemistryTypeDict << nl << nl 00122 << "Valid " << ChemistryModel ::typeName << " types are:" 00123 << nl << nl; 00124 00125 // Get the list of all the suitable chemistry packages available 00126 wordList validChemistryTypeNames 00127 ( 00128 ChemistryModel::fvMeshConstructorTablePtr_->sortedToc() 00129 ); 00130 00131 // Build a table of the thermo packages constituent parts 00132 // Note: row-0 contains the names of constituent parts 00133 List<wordList> validChemistryTypeNameCmpts 00134 ( 00135 validChemistryTypeNames.size() + 1 00136 ); 00137 00138 validChemistryTypeNameCmpts[0].setSize(nCmpt); 00139 forAll(validChemistryTypeNameCmpts[0], j) 00140 { 00141 validChemistryTypeNameCmpts[0][j] = cmptNames[j]; 00142 } 00143 00144 // Split the thermo package names into their constituent parts 00145 forAll(validChemistryTypeNames, i) 00146 { 00147 validChemistryTypeNameCmpts[i+1] = basicThermo::splitThermoName 00148 ( 00149 validChemistryTypeNames[i], 00150 nCmpt 00151 ); 00152 } 00153 00154 // Print the table of available packages 00155 // in terms of their constituent parts 00156 printTable(validChemistryTypeNameCmpts, FatalError); 00157 00158 FatalError<< exit(FatalError); 00159 } 00160 00161 return autoPtr<ChemistryModel>(cstrIter()(mesh)); 00162 } 00163 else 00164 { 00165 chemistryTypeName = 00166 word(chemistryDict.lookup("chemistryType")); 00167 00168 Info<< "Selecting chemistry type " << chemistryTypeName << endl; 00169 00170 typename ChemistryModel::fvMeshConstructorTable::iterator cstrIter = 00171 ChemistryModel::fvMeshConstructorTablePtr_->find(chemistryTypeName); 00172 00173 if (cstrIter == ChemistryModel::fvMeshConstructorTablePtr_->end()) 00174 { 00175 FatalErrorIn(ChemistryModel::typeName + "::New(const mesh&)") 00176 << "Unknown " << ChemistryModel::typeName << " type " 00177 << chemistryTypeName << nl << nl 00178 << "Valid ChemistryModel types are:" << nl 00179 << ChemistryModel::fvMeshConstructorTablePtr_->sortedToc() << nl 00180 << exit(FatalError); 00181 } 00182 00183 return autoPtr<ChemistryModel>(cstrIter()(mesh)); 00184 } 00185 } 00186 00187 // ************************************************************************* //
