FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "hCombustionThermo.H"
00027 #include <finiteVolume/fvMesh.H>
00028 
00029 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00030 
00031 Foam::autoPtr<Foam::hCombustionThermo> Foam::hCombustionThermo::New
00032 (
00033     const fvMesh& mesh
00034 )
00035 {
00036     word hCombustionThermoTypeName;
00037 
00038     // Enclose the creation of the thermophysicalProperties to ensure it is
00039     // deleted before the turbulenceModel is created otherwise the dictionary
00040     // is entered in the database twice
00041     {
00042         IOdictionary thermoDict
00043         (
00044             IOobject
00045             (
00046                 "thermophysicalProperties",
00047                 mesh.time().constant(),
00048                 mesh,
00049                 IOobject::MUST_READ,
00050                 IOobject::NO_WRITE
00051             )
00052         );
00053 
00054         thermoDict.lookup("thermoType") >> hCombustionThermoTypeName;
00055     }
00056 
00057     Info<< "Selecting thermodynamics package " << hCombustionThermoTypeName
00058         << endl;
00059 
00060     fvMeshConstructorTable::iterator cstrIter =
00061         fvMeshConstructorTablePtr_->find(hCombustionThermoTypeName);
00062 
00063     if (cstrIter == fvMeshConstructorTablePtr_->end())
00064     {
00065         FatalErrorIn("hCombustionThermo::New(const fvMesh&)")
00066             << "Unknown hCombustionThermo type "
00067             << hCombustionThermoTypeName << nl << nl
00068             << "Valid hCombustionThermo types are:" << nl
00069             << fvMeshConstructorTablePtr_->sortedToc() << nl
00070             << exit(FatalError);
00071     }
00072 
00073     return autoPtr<hCombustionThermo>(cstrIter()(mesh));
00074 }
00075 
00076 
00077 Foam::autoPtr<Foam::hCombustionThermo> Foam::hCombustionThermo::NewType
00078 (
00079     const fvMesh& mesh,
00080     const word& thermoType
00081 )
00082 {
00083     word hCombustionThermoTypeName;
00084 
00085     // Enclose the creation of the thermophysicalProperties to ensure it is
00086     // deleted before the turbulenceModel is created otherwise the dictionary
00087     // is entered in the database twice
00088     {
00089         IOdictionary thermoDict
00090         (
00091             IOobject
00092             (
00093                 "thermophysicalProperties",
00094                 mesh.time().constant(),
00095                 mesh,
00096                 IOobject::MUST_READ,
00097                 IOobject::NO_WRITE
00098             )
00099         );
00100 
00101         thermoDict.lookup("thermoType") >> hCombustionThermoTypeName;
00102 
00103         if (hCombustionThermoTypeName.find(thermoType) == string::npos)
00104         {
00105             wordList allModels = fvMeshConstructorTablePtr_->sortedToc();
00106             DynamicList<word> validModels;
00107             forAll(allModels, i)
00108             {
00109                 if (allModels[i].find(thermoType) != string::npos)
00110                 {
00111                     validModels.append(allModels[i]);
00112                 }
00113             }
00114 
00115             FatalErrorIn
00116             (
00117                 "autoPtr<hCombustionThermo> hCombustionThermo::NewType"
00118                 "("
00119                     "const fvMesh&, "
00120                     "const word&"
00121                 ")"
00122             )   << "Inconsistent thermo package selected:" << nl << nl
00123                 << hCombustionThermoTypeName << nl << nl << "Please select a "
00124                 << "thermo package based on " << thermoType
00125                 << ". Valid options include:" << nl << validModels << nl
00126                 << exit(FatalError);
00127         }
00128     }
00129 
00130     Info<< "Selecting thermodynamics package " << hCombustionThermoTypeName
00131         << endl;
00132 
00133     fvMeshConstructorTable::iterator cstrIter =
00134         fvMeshConstructorTablePtr_->find(hCombustionThermoTypeName);
00135 
00136     if (cstrIter == fvMeshConstructorTablePtr_->end())
00137     {
00138         FatalErrorIn("hCombustionThermo::New(const fvMesh&)")
00139             << "Unknown hCombustionThermo type "
00140             << hCombustionThermoTypeName << nl << nl
00141             << "Valid hCombustionThermo types are:" << nl
00142             << fvMeshConstructorTablePtr_->sortedToc() << nl
00143             << exit(FatalError);
00144     }
00145 
00146     return autoPtr<hCombustionThermo>(cstrIter()(mesh));
00147 }
00148 
00149 
00150 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines