OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

newhCombustionThermo.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "hCombustionThermo.H"
00028 #include "fvMesh.H"
00029 
00030 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00031 
00032 Foam::autoPtr<Foam::hCombustionThermo> Foam::hCombustionThermo::New
00033 (
00034     const fvMesh& mesh
00035 )
00036 {
00037     word hCombustionThermoTypeName;
00038 
00039     // Enclose the creation of the thermophysicalProperties to ensure it is
00040     // deleted before the turbulenceModel is created otherwise the dictionary
00041     // is entered in the database twice
00042     {
00043         IOdictionary thermoDict
00044         (
00045             IOobject
00046             (
00047                 "thermophysicalProperties",
00048                 mesh.time().constant(),
00049                 mesh,
00050                 IOobject::MUST_READ,
00051                 IOobject::NO_WRITE
00052             )
00053         );
00054 
00055         thermoDict.lookup("thermoType") >> hCombustionThermoTypeName;
00056     }
00057 
00058     Info<< "Selecting thermodynamics package " << hCombustionThermoTypeName
00059         << endl;
00060 
00061     fvMeshConstructorTable::iterator cstrIter =
00062         fvMeshConstructorTablePtr_->find(hCombustionThermoTypeName);
00063 
00064     if (cstrIter == fvMeshConstructorTablePtr_->end())
00065     {
00066         FatalErrorIn("hCombustionThermo::New(const fvMesh&)")
00067             << "Unknown hCombustionThermo type "
00068             << hCombustionThermoTypeName << nl << nl
00069             << "Valid hCombustionThermo types are:" << nl
00070             << fvMeshConstructorTablePtr_->toc() << nl
00071             << exit(FatalError);
00072     }
00073 
00074     return autoPtr<hCombustionThermo>(cstrIter()(mesh));
00075 }
00076 
00077 
00078 Foam::autoPtr<Foam::hCombustionThermo> Foam::hCombustionThermo::NewType
00079 (
00080     const fvMesh& mesh,
00081     const word& thermoType
00082 )
00083 {
00084     word hCombustionThermoTypeName;
00085 
00086     // Enclose the creation of the thermophysicalProperties to ensure it is
00087     // deleted before the turbulenceModel is created otherwise the dictionary
00088     // is entered in the database twice
00089     {
00090         IOdictionary thermoDict
00091         (
00092             IOobject
00093             (
00094                 "thermophysicalProperties",
00095                 mesh.time().constant(),
00096                 mesh,
00097                 IOobject::MUST_READ,
00098                 IOobject::NO_WRITE
00099             )
00100         );
00101 
00102         thermoDict.lookup("thermoType") >> hCombustionThermoTypeName;
00103 
00104         if (hCombustionThermoTypeName.find(thermoType) == string::npos)
00105         {
00106             wordList allModels = fvMeshConstructorTablePtr_->toc();
00107             DynamicList<word> validModels;
00108             forAll(allModels, i)
00109             {
00110                 if (allModels[i].find(thermoType) != string::npos)
00111                 {
00112                     validModels.append(allModels[i]);
00113                 }
00114             }
00115 
00116             FatalErrorIn
00117             (
00118                 "autoPtr<hCombustionThermo> hCombustionThermo::NewType"
00119                 "("
00120                     "const fvMesh&, "
00121                     "const word&"
00122                 ")"
00123             )   << "Inconsistent thermo package selected:" << nl << nl
00124                 << hCombustionThermoTypeName << nl << nl << "Please select a "
00125                 << "thermo package based on " << thermoType
00126                 << ". Valid options include:" << nl << validModels << nl
00127                 << exit(FatalError);
00128         }
00129     }
00130 
00131     Info<< "Selecting thermodynamics package " << hCombustionThermoTypeName
00132         << endl;
00133 
00134     fvMeshConstructorTable::iterator cstrIter =
00135         fvMeshConstructorTablePtr_->find(hCombustionThermoTypeName);
00136 
00137     if (cstrIter == fvMeshConstructorTablePtr_->end())
00138     {
00139         FatalErrorIn("hCombustionThermo::New(const fvMesh&)")
00140             << "Unknown hCombustionThermo type "
00141             << hCombustionThermoTypeName << nl << nl
00142             << "Valid hCombustionThermo types are:" << nl
00143             << fvMeshConstructorTablePtr_->toc() << nl
00144             << exit(FatalError);
00145     }
00146 
00147     return autoPtr<hCombustionThermo>(cstrIter()(mesh));
00148 }
00149 
00150 
00151 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd