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

newSolid.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 "solid.H"
00028 
00029 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00030 
00031 Foam::autoPtr<Foam::solid> Foam::solid::New(Istream& is)
00032 {
00033     if (debug)
00034     {
00035         Info<< "solid::New(Istream&): "
00036             << "constructing solid"
00037             << endl;
00038     }
00039 
00040     word solidType(is);
00041 
00042     word coeffs(is);
00043 
00044     if (coeffs == "defaultCoeffs")
00045     {
00046         ConstructorTable::iterator cstrIter =
00047             ConstructorTablePtr_->find(solidType);
00048 
00049         if (cstrIter == ConstructorTablePtr_->end())
00050         {
00051             FatalErrorIn("solid::New(Istream&)")
00052                 << "Unknown solid type " << solidType << nl << nl
00053                 << "Valid solid types are:" << endl
00054                 << ConstructorTablePtr_->toc()
00055                 << exit(FatalError);
00056         }
00057 
00058         return autoPtr<solid>(cstrIter()());
00059     }
00060     else if (coeffs == "coeffs")
00061     {
00062         IstreamConstructorTable::iterator cstrIter =
00063             IstreamConstructorTablePtr_->find(solidType);
00064 
00065         if (cstrIter == IstreamConstructorTablePtr_->end())
00066         {
00067             FatalErrorIn("solid::New(Istream&)")
00068                 << "Unknown solid type " << solidType << nl << nl
00069                 << "Valid solid types are:" << endl
00070                 << IstreamConstructorTablePtr_->toc()
00071                 << exit(FatalError);
00072         }
00073 
00074         return autoPtr<solid>(cstrIter()(is));
00075     }
00076     else
00077     {
00078         FatalErrorIn("solid::New(Istream&)")
00079             << "solid type " << solidType
00080             << ", option " << coeffs << " given"
00081             << ", should be coeffs or defaultCoeffs"
00082             << exit(FatalError);
00083 
00084         return autoPtr<solid>(NULL);
00085     }
00086 }
00087 
00088 
00089 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Copyright © 2000-2009 OpenCFD Ltd