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

newRhoChemistryModel.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) 2009-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 "rhoChemistryModel.H"
00027 
00028 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
00029 
00030 Foam::autoPtr<Foam::rhoChemistryModel> Foam::rhoChemistryModel::New
00031 (
00032     const fvMesh& mesh
00033 )
00034 {
00035     word rhoChemistryModelType;
00036     word thermoTypeName;
00037     word userModel;
00038 
00039     // Enclose the creation of the chemistrtyProperties to ensure it is
00040     // deleted before the chemistrtyProperties is created otherwise the
00041     // dictionary is entered in the database twice
00042     {
00043         IOdictionary chemistryPropertiesDict
00044         (
00045             IOobject
00046             (
00047                 "chemistryProperties",
00048                 mesh.time().constant(),
00049                 mesh,
00050                 IOobject::MUST_READ,
00051                 IOobject::NO_WRITE
00052             )
00053         );
00054 
00055         chemistryPropertiesDict.lookup("rhoChemistryModel") >> userModel;
00056 
00057         // construct chemistry model type name by inserting first template
00058         // argument
00059         label tempOpen = userModel.find('<');
00060         label tempClose = userModel.find('>');
00061 
00062         word className = userModel(0, tempOpen);
00063         thermoTypeName = userModel(tempOpen + 1, tempClose - tempOpen - 1);
00064 
00065         rhoChemistryModelType =
00066             className + '<' + typeName + ',' + thermoTypeName + '>';
00067     }
00068 
00069     if (debug)
00070     {
00071         Info<< "Selecting rhoChemistryModel " << rhoChemistryModelType << endl;
00072     }
00073     else
00074     {
00075         Info<< "Selecting rhoChemistryModel " << userModel << endl;
00076     }
00077 
00078     fvMeshConstructorTable::iterator cstrIter =
00079         fvMeshConstructorTablePtr_->find(rhoChemistryModelType);
00080 
00081     if (cstrIter == fvMeshConstructorTablePtr_->end())
00082     {
00083         if (debug)
00084         {
00085             FatalErrorIn("rhoChemistryModelBase::New(const mesh&)")
00086                 << "Unknown rhoChemistryModel type " << rhoChemistryModelType
00087                 << nl << nl << "Valid rhoChemistryModel types are:" << nl
00088                 << fvMeshConstructorTablePtr_->sortedToc() << nl << exit(FatalError);
00089         }
00090         else
00091         {
00092             wordList models = fvMeshConstructorTablePtr_->sortedToc();
00093             forAll(models, i)
00094             {
00095                 models[i] = models[i].replace(typeName + ',', "");
00096             }
00097 
00098             FatalErrorIn("rhoChemistryModelBase::New(const mesh&)")
00099                 << "Unknown rhoChemistryModel type " << userModel
00100                 << nl << nl << "Valid rhoChemistryModel types are:" << nl
00101                 << models << nl << exit(FatalError);
00102         }
00103     }
00104 
00105     return autoPtr<rhoChemistryModel>
00106         (cstrIter()(mesh, typeName, thermoTypeName));
00107 }
00108 
00109 
00110 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines