Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / src / thermophysicalModels / reactionThermo / combustionThermo / hCombustionThermo / newhCombustionThermo.C
blob6c22112b14f729ac6dca46c2c527b6806b440da8
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend 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 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "hCombustionThermo.H"
27 #include "fvMesh.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 Foam::autoPtr<Foam::hCombustionThermo> Foam::hCombustionThermo::New
33     const fvMesh& mesh,
34     const objectRegistry& obj
37     word hCombustionThermoTypeName;
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                 obj,
50                 IOobject::MUST_READ,
51                 IOobject::NO_WRITE
52             )
53         );
55         thermoDict.lookup("thermoType") >> hCombustionThermoTypeName;
56     }
58     Info<< "Selecting thermodynamics package " << hCombustionThermoTypeName
59         << endl;
61     fvMeshConstructorTable::iterator cstrIter =
62         fvMeshConstructorTablePtr_->find(hCombustionThermoTypeName);
64     if (cstrIter == fvMeshConstructorTablePtr_->end())
65     {
66         FatalErrorIn("hCombustionThermo::New(const fvMesh&, const objectRegistry&)")
67             << "Unknown hCombustionThermo type "
68             << hCombustionThermoTypeName << nl << nl
69             << "Valid hCombustionThermo types are:" << nl
70             << fvMeshConstructorTablePtr_->sortedToc() << nl
71             << exit(FatalError);
72     }
74     return autoPtr<hCombustionThermo>(cstrIter()(mesh, obj));
78 Foam::autoPtr<Foam::hCombustionThermo> Foam::hCombustionThermo::NewType
80     const fvMesh& mesh,
81     const objectRegistry& obj,
82     const word& thermoType
85     word hCombustionThermoTypeName;
87     // Enclose the creation of the thermophysicalProperties to ensure it is
88     // deleted before the turbulenceModel is created otherwise the dictionary
89     // is entered in the database twice
90     {
91         IOdictionary thermoDict
92         (
93             IOobject
94             (
95                 "thermophysicalProperties",
96                 mesh.time().constant(),
97                 obj,
98                 IOobject::MUST_READ,
99                 IOobject::NO_WRITE
100             )
101         );
103         thermoDict.lookup("thermoType") >> hCombustionThermoTypeName;
105         if (hCombustionThermoTypeName.find(thermoType) == string::npos)
106         {
107             wordList allModels = fvMeshConstructorTablePtr_->sortedToc();
108             DynamicList<word> validModels;
109             forAll(allModels, i)
110             {
111                 if (allModels[i].find(thermoType) != string::npos)
112                 {
113                     validModels.append(allModels[i]);
114                 }
115             }
117             FatalErrorIn
118             (
119                 "autoPtr<hCombustionThermo> hCombustionThermo::NewType"
120                 "("
121                     "const fvMesh&, "
122                     "const objectRegistry& obj, "
123                     "const word&"
124                 ")"
125             )   << "Inconsistent thermo package selected:" << nl << nl
126                 << hCombustionThermoTypeName << nl << nl << "Please select a "
127                 << "thermo package based on " << thermoType
128                 << ". Valid options include:" << nl << validModels << nl
129                 << exit(FatalError);
130         }
131     }
133     Info<< "Selecting thermodynamics package " << hCombustionThermoTypeName
134         << endl;
136     fvMeshConstructorTable::iterator cstrIter =
137         fvMeshConstructorTablePtr_->find(hCombustionThermoTypeName);
139     if (cstrIter == fvMeshConstructorTablePtr_->end())
140     {
141         FatalErrorIn("hCombustionThermo::New(const fvMesh&, const objectRegistry&)")
142             << "Unknown hCombustionThermo type "
143             << hCombustionThermoTypeName << nl << nl
144             << "Valid hCombustionThermo types are:" << nl
145             << fvMeshConstructorTablePtr_->sortedToc() << nl
146             << exit(FatalError);
147     }
149     return autoPtr<hCombustionThermo>(cstrIter()(mesh, obj));
153 // ************************************************************************* //