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

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