ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / thermophysicalModels / reactionThermo / combustionThermo / hsCombustionThermo / hsCombustionThermoNew.C
blobed9cf107a84a400fc6433c8d78e64e73cc007584
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 "hsCombustionThermo.H"
27 #include "fvMesh.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 Foam::autoPtr<Foam::hsCombustionThermo> Foam::hsCombustionThermo::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("hsCombustionThermo::New(const fvMesh&)")
62             << "Unknown hsCombustionThermo type "
63             << modelType << nl << nl
64             << "Valid hsCombustionThermo types:" << nl
65             << fvMeshConstructorTablePtr_->toc() << nl
66             << exit(FatalError);
67     }
69     return autoPtr<hsCombustionThermo>(cstrIter()(mesh));
73 Foam::autoPtr<Foam::hsCombustionThermo> Foam::hsCombustionThermo::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     );
97     if (modelType.find(thermoType) == string::npos)
98     {
99         wordList allModels = fvMeshConstructorTablePtr_->toc();
100         DynamicList<word> validModels;
101         forAll(allModels, i)
102         {
103             if (allModels[i].find(thermoType) != string::npos)
104             {
105                 validModels.append(allModels[i]);
106             }
107         }
109         FatalErrorIn
110         (
111             "autoPtr<hsCombustionThermo> hsCombustionThermo::NewType"
112             "("
113             "const fvMesh&, "
114             "const word&"
115             ")"
116         )   << "Inconsistent thermo package selected:" << nl << nl
117             << modelType << nl << nl << "Please select a "
118             << "thermo package based on " << thermoType
119             << ". Valid options include:" << nl << validModels << nl
120             << exit(FatalError);
121     }
123     Info<< "Selecting thermodynamics package " << modelType << endl;
125     fvMeshConstructorTable::iterator cstrIter =
126         fvMeshConstructorTablePtr_->find(modelType);
128     if (cstrIter == fvMeshConstructorTablePtr_->end())
129     {
130         FatalErrorIn
131         (
132             "autoPtr<hsCombustionThermo> hsCombustionThermo::NewType"
133             "("
134             "const fvMesh&, "
135             "const word&"
136             ")"
137         )   << "Unknown hsCombustionThermo type "
138             << modelType << nl << nl
139             << "Valid hsCombustionThermo types are:" << nl
140             << fvMeshConstructorTablePtr_->toc() << nl
141             << exit(FatalError);
142     }
144     return autoPtr<hsCombustionThermo>(cstrIter()(mesh));
148 // ************************************************************************* //