BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / thermophysicalModels / reactionThermo / combustionThermo / hCombustionThermo / hCombustionThermoNew.C
blobb3934076f54025e2e6517dbb1eab3a606ca176bb
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
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
13     the Free Software Foundation, either version 3 of the License, or
14     (at your 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, 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
36     // get model name, but do not register the dictionary
37     // otherwise it is registered in the database twice
38     const word modelType
39     (
40         IOdictionary
41         (
42             IOobject
43             (
44                 "thermophysicalProperties",
45                 mesh.time().constant(),
46                 mesh,
47                 IOobject::MUST_READ_IF_MODIFIED,
48                 IOobject::NO_WRITE,
49                 false
50             )
51         ).lookup("thermoType")
52     );
54     Info<< "Selecting thermodynamics package " << modelType << endl;
56     fvMeshConstructorTable::iterator cstrIter =
57         fvMeshConstructorTablePtr_->find(modelType);
59     if (cstrIter == fvMeshConstructorTablePtr_->end())
60     {
61         FatalErrorIn("hCombustionThermo::New(const fvMesh&)")
62             << "Unknown hCombustionThermo type "
63             << modelType << nl << nl
64             << "Valid hCombustionThermo types are:" << nl
65             << fvMeshConstructorTablePtr_->sortedToc() << nl
66             << exit(FatalError);
67     }
69     return autoPtr<hCombustionThermo>(cstrIter()(mesh));
73 Foam::autoPtr<Foam::hCombustionThermo> Foam::hCombustionThermo::NewType
75     const fvMesh& mesh,
76     const word& thermoType
79     // get model name, but do not register the dictionary
80     // otherwise it is registered in the database twice
81     const word modelType
82     (
83         IOdictionary
84         (
85             IOobject
86             (
87                 "thermophysicalProperties",
88                 mesh.time().constant(),
89                 mesh,
90                 IOobject::MUST_READ_IF_MODIFIED,
91                 IOobject::NO_WRITE,
92                 false
93             )
94         ).lookup("thermoType")
95     );
98     if (modelType.find(thermoType) == string::npos)
99     {
100         wordList allModels = fvMeshConstructorTablePtr_->sortedToc();
101         DynamicList<word> validModels;
102         forAll(allModels, i)
103         {
104             if (allModels[i].find(thermoType) != string::npos)
105             {
106                 validModels.append(allModels[i]);
107             }
108         }
110         FatalErrorIn
111         (
112             "autoPtr<hCombustionThermo> hCombustionThermo::NewType"
113             "("
114                 "const fvMesh&, "
115                 "const word&"
116             ")"
117         )   << "Inconsistent thermo package selected:" << nl << nl
118             << modelType << nl << nl << "Please select a "
119             << "thermo package based on " << thermoType
120             << ". Valid options include:" << nl << validModels << nl
121             << exit(FatalError);
122     }
124     Info<< "Selecting thermodynamics package " << modelType << endl;
126     fvMeshConstructorTable::iterator cstrIter =
127         fvMeshConstructorTablePtr_->find(modelType);
129     if (cstrIter == fvMeshConstructorTablePtr_->end())
130     {
131         FatalErrorIn
132         (
133             "autoPtr<hCombustionThermo> hCombustionThermo::NewType"
134             "("
135                 "const fvMesh&, "
136                 "const word&"
137             ")"
138         )   << "Unknown hCombustionThermo type "
139             << modelType << nl << nl
140             << "Valid hCombustionThermo types are:" << nl
141             << fvMeshConstructorTablePtr_->sortedToc() << nl
142             << exit(FatalError);
143     }
145     return autoPtr<hCombustionThermo>(cstrIter()(mesh));
149 // ************************************************************************* //