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

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