initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / thermophysicalModels / chemistryModel / chemistryModel / psiChemistryModel / newPsiChemistryModel.C
blob6a5606d0e73f13bdc636512e8e5217d95a5f5f8e
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2009-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "psiChemistryModel.H"
29 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
31 Foam::autoPtr<Foam::psiChemistryModel> Foam::psiChemistryModel::New
33     const fvMesh& mesh
36     word psiChemistryModelType;
37     word thermoTypeName;
38     word userModel;
40     // Enclose the creation of the chemistrtyProperties to ensure it is
41     // deleted before the chemistrtyProperties is created otherwise the
42     // dictionary is entered in the database twice
43     {
44         IOdictionary chemistryPropertiesDict
45         (
46             IOobject
47             (
48                 "chemistryProperties",
49                 mesh.time().constant(),
50                 mesh,
51                 IOobject::MUST_READ,
52                 IOobject::NO_WRITE
53             )
54         );
56         chemistryPropertiesDict.lookup("psiChemistryModel") >> userModel;
58         // construct chemistry model type name by inserting first template
59         // argument
60         label tempOpen = userModel.find('<');
61         label tempClose = userModel.find('>');
63         word className = userModel(0, tempOpen);
64         thermoTypeName = userModel(tempOpen + 1, tempClose - tempOpen - 1);
66         psiChemistryModelType =
67             className + '<' + typeName + ',' + thermoTypeName + '>';
68     }
70     if (debug)
71     {
72         Info<< "Selecting psiChemistryModel " << psiChemistryModelType << endl;
73     }
74     else
75     {
76         Info<< "Selecting psiChemistryModel " << userModel << endl;
77     }
79     fvMeshConstructorTable::iterator cstrIter =
80         fvMeshConstructorTablePtr_->find(psiChemistryModelType);
82     if (cstrIter == fvMeshConstructorTablePtr_->end())
83     {
84         if (debug)
85         {
86             FatalErrorIn("psiChemistryModelBase::New(const mesh&)")
87                 << "Unknown psiChemistryModel type " << psiChemistryModelType
88                 << nl << nl << "Valid psiChemistryModel types are:" << nl
89                 << fvMeshConstructorTablePtr_->toc() << nl << exit(FatalError);
90         }
91         else
92         {
93             wordList models = fvMeshConstructorTablePtr_->toc();
94             forAll(models, i)
95             {
96                 models[i] = models[i].replace(typeName + ',', "");
97             }
99             FatalErrorIn("psiChemistryModelBase::New(const mesh&)")
100                 << "Unknown psiChemistryModel type " << userModel
101                 << nl << nl << "Valid psiChemistryModel types are:" << nl
102                 << models << nl << exit(FatalError);
103         }
104     }
106     return autoPtr<psiChemistryModel>
107         (cstrIter()(mesh, typeName, thermoTypeName));
111 // ************************************************************************* //