initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / thermophysicalModels / reactionThermo / reactionThermo / hReactionThermo / newhReactionThermo.C
blob688b37b6d2a726a82771119fd896c3649bcf59df
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 "hReactionThermo.H"
28 #include "fvMesh.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 Foam::autoPtr<Foam::hReactionThermo> Foam::hReactionThermo::New
34     const fvMesh& mesh
37     word hReactionThermoTypeName;
39     // Enclose the creation of the thermophysicalProperties to ensure it is
40     // deleted before the turbulenceModel is created otherwise the dictionary
41     // is entered in the database twice
42     {
43         IOdictionary thermoDict
44         (
45             IOobject
46             (
47                 "thermophysicalProperties",
48                 mesh.time().constant(),
49                 mesh,
50                 IOobject::MUST_READ,
51                 IOobject::NO_WRITE
52             )
53         );
55         thermoDict.lookup("thermoType") >> hReactionThermoTypeName;
56     }
58     Info<< "Selecting thermodynamics package " << hReactionThermoTypeName
59         << endl;
61     fvMeshConstructorTable::iterator cstrIter =
62         fvMeshConstructorTablePtr_->find(hReactionThermoTypeName);
64     if (cstrIter == fvMeshConstructorTablePtr_->end())
65     {
66         FatalErrorIn("hReactionThermo::New(const fvMesh&)")
67             << "Unknown hReactionThermo type "
68             << hReactionThermoTypeName << nl << nl
69             << "Valid hReactionThermo types are:" << nl
70             << fvMeshConstructorTablePtr_->toc() << nl
71             << exit(FatalError);
72     }
74     return autoPtr<hReactionThermo>(cstrIter()(mesh));
78 Foam::autoPtr<Foam::hReactionThermo> Foam::hReactionThermo::NewType
80     const fvMesh& mesh,
81     const word& thermoType
84     word hReactionThermoTypeName;
86     // Enclose the creation of the thermophysicalProperties to ensure it is
87     // deleted before the turbulenceModel is created otherwise the dictionary
88     // is entered in the database twice
89     {
90         IOdictionary thermoDict
91         (
92             IOobject
93             (
94                 "thermophysicalProperties",
95                 mesh.time().constant(),
96                 mesh,
97                 IOobject::MUST_READ,
98                 IOobject::NO_WRITE
99             )
100         );
102         thermoDict.lookup("thermoType") >> hReactionThermoTypeName;
104         if (hReactionThermoTypeName.find(thermoType) == string::npos)
105         {
106             wordList allModels = fvMeshConstructorTablePtr_->toc();
107             DynamicList<word> validModels;
108             forAll(allModels, i)
109             {
110                 if (allModels[i].find(thermoType) != string::npos)
111                 {
112                     validModels.append(allModels[i]);
113                 }
114             }
116             FatalErrorIn
117             (
118                 "autoPtr<hReactionThermo> hReactionThermo::NewType"
119                 "("
120                     "const fvMesh&, "
121                     "const word&"
122                 ")"
123             )   << "Inconsistent thermo package selected:" << nl << nl
124                 << hReactionThermoTypeName << nl << nl << "Please select a "
125                 << "thermo package based on " << thermoType
126                 << ". Valid options include:" << nl << validModels << nl
127                 << exit(FatalError);
128         }
129     }
131     Info<< "Selecting thermodynamics package " << hReactionThermoTypeName
132         << endl;
134     fvMeshConstructorTable::iterator cstrIter =
135         fvMeshConstructorTablePtr_->find(hReactionThermoTypeName);
137     if (cstrIter == fvMeshConstructorTablePtr_->end())
138     {
139         FatalErrorIn("hReactionThermo::New(const fvMesh&)")
140             << "Unknown hReactionThermo type "
141             << hReactionThermoTypeName << nl << nl
142             << "Valid hReactionThermo types are:" << nl
143             << fvMeshConstructorTablePtr_->toc() << nl
144             << exit(FatalError);
145     }
147     return autoPtr<hReactionThermo>(cstrIter()(mesh));
151 // ************************************************************************* //