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

coordinateSystemNew.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 "coordinateSystem.H"
00027 #include <OpenFOAM/dictionary.H>
00028 
00029 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00030 
00031 Foam::autoPtr<Foam::coordinateSystem> Foam::coordinateSystem::New
00032 (
00033     const word& name,
00034     const dictionary& dict
00035 )
00036 {
00037     if (debug)
00038     {
00039         Pout<< "coordinateSystem::New(const word&, const dictionary&) : "
00040             << "constructing coordinateSystem"
00041             << endl;
00042     }
00043 
00044     // construct base class directly, also allow 'cartesian' as an alias
00045     word coordType(typeName_());
00046     if
00047     (
00048         !dict.readIfPresent("type", coordType)
00049      || coordType == typeName_()
00050      || coordType == "cartesian"
00051     )
00052     {
00053         return autoPtr<coordinateSystem>(new coordinateSystem(name, dict));
00054     }
00055 
00056     dictionaryConstructorTable::iterator cstrIter =
00057         dictionaryConstructorTablePtr_->find(coordType);
00058 
00059     if (cstrIter == dictionaryConstructorTablePtr_->end())
00060     {
00061         FatalIOErrorIn
00062         (
00063             "coordinateSystem::New(const word&, const dictionary&)",
00064             dict
00065         )   << "Unknown coordinateSystem type " << coordType << nl << nl
00066             << "Valid coordinateSystem types are :" << nl
00067             << "[default: " << typeName_() << "]"
00068             << dictionaryConstructorTablePtr_->sortedToc()
00069             << exit(FatalIOError);
00070     }
00071 
00072     return autoPtr<coordinateSystem>(cstrIter()(name, dict));
00073 }
00074 
00075 
00076 Foam::autoPtr<Foam::coordinateSystem> Foam::coordinateSystem::New
00077 (
00078     const word& coordType,
00079     const word& name,
00080     const point& origin,
00081     const coordinateRotation& cr
00082 )
00083 {
00084     if (debug)
00085     {
00086         Pout<< "coordinateSystem::New(const word&, const word&, "
00087             << "const point&, const coordinateRotation&) : "
00088                "constructing coordinateSystem"
00089             << endl;
00090     }
00091 
00092     origRotationConstructorTable::iterator cstrIter =
00093         origRotationConstructorTablePtr_->find(coordType);
00094 
00095     if (cstrIter == origRotationConstructorTablePtr_->end())
00096     {
00097         FatalErrorIn
00098         (
00099             "coordinateSystem::New(const word&, const word&, "
00100             "const point&, const coordinateRotation&) : "
00101             "constructing coordinateSystem"
00102         )   << "Unknown coordinateSystem type " << coordType << nl << nl
00103             << "Valid coordinateSystem types are :" << nl
00104             << origRotationConstructorTablePtr_->sortedToc()
00105             << exit(FatalError);
00106     }
00107 
00108     return autoPtr<coordinateSystem>(cstrIter()(name, origin, cr));
00109 }
00110 
00111 
00112 Foam::autoPtr<Foam::coordinateSystem> Foam::coordinateSystem::New
00113 (
00114     Istream& is
00115 )
00116 {
00117     word name(is);
00118     dictionary dict(is);
00119 
00120     return New(name, dict);
00121 }
00122 
00123 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines