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

liquid.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 <OpenFOAM/error.H>
00027 
00028 #include "liquid.H"
00029 #include <OpenFOAM/HashTable.H>
00030 
00031 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00032 
00033 namespace Foam
00034 {
00035     defineTypeNameAndDebug(liquid, 0);
00036     defineRunTimeSelectionTable(liquid,);
00037     defineRunTimeSelectionTable(liquid, Istream);
00038 }
00039 
00040 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00041 
00042 Foam::autoPtr<Foam::liquid> Foam::liquid::New(Istream& is)
00043 {
00044     if (debug)
00045     {
00046         Info<< "liquid::New(Istream&) : "
00047             << "constructing liquid"
00048             << endl;
00049     }
00050 
00051     word liquidType(is);
00052 
00053     word coeffs(is);
00054 
00055     if (coeffs == "defaultCoeffs")
00056     {
00057         ConstructorTable::iterator cstrIter =
00058             ConstructorTablePtr_->find(liquidType);
00059 
00060         if (cstrIter == ConstructorTablePtr_->end())
00061         {
00062             FatalErrorIn("liquid::New(Istream&)")
00063                 << "Unknown liquid type " << liquidType
00064                 << nl << nl
00065                 << "Valid liquid types are:" << nl
00066                 << ConstructorTablePtr_->sortedToc()
00067                 << abort(FatalError);
00068         }
00069 
00070         return autoPtr<liquid>(cstrIter()());
00071     }
00072     else if (coeffs == "coeffs")
00073     {
00074         IstreamConstructorTable::iterator cstrIter =
00075             IstreamConstructorTablePtr_->find(liquidType);
00076 
00077         if (cstrIter == IstreamConstructorTablePtr_->end())
00078         {
00079             FatalErrorIn("liquid::New(Istream&)")
00080                 << "Unknown liquid type " << liquidType
00081                 << endl << endl
00082                 << "Valid liquid types are:" << nl
00083                 << IstreamConstructorTablePtr_->sortedToc()
00084                 << abort(FatalError);
00085         }
00086 
00087         return autoPtr<liquid>(cstrIter()(is));
00088     }
00089     else
00090     {
00091         FatalErrorIn("liquid::New(Istream&)")
00092             << "liquid type " << liquidType
00093             << ", option " << coeffs << " given"
00094             << ", should be coeffs or defaultCoeffs"
00095             << abort(FatalError);
00096 
00097         return autoPtr<liquid>(NULL);
00098     }
00099 }
00100 
00101 
00102 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines