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

newPolyPatch.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 "polyPatch.H"
00027 #include <OpenFOAM/dictionary.H>
00028 
00029 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00030 
00031 Foam::autoPtr<Foam::polyPatch> Foam::polyPatch::New
00032 (
00033     const word& patchType,
00034     const word& name,
00035     const label size,
00036     const label start,
00037     const label index,
00038     const polyBoundaryMesh& bm
00039 )
00040 {
00041     if (debug)
00042     {
00043         Info<< "polyPatch::New(const word&, const word&, const label, "
00044                "const label, const label, const polyBoundaryMesh&) : "
00045                "constructing polyPatch"
00046             << endl;
00047     }
00048 
00049     wordConstructorTable::iterator cstrIter =
00050         wordConstructorTablePtr_->find(patchType);
00051 
00052     if (cstrIter == wordConstructorTablePtr_->end())
00053     {
00054         FatalErrorIn
00055         (
00056             "polyPatch::New(const word&, const word&, const label, "
00057             "const label, const label, const polyBoundaryMesh&) "
00058         )   << "Unknown polyPatch type " << patchType << " for patch " << name
00059             << endl << endl
00060             << "Valid polyPatch types are :" << endl
00061             << wordConstructorTablePtr_->sortedToc()
00062             << exit(FatalError);
00063     }
00064 
00065     return autoPtr<polyPatch>(cstrIter()(name, size, start, index, bm));
00066 }
00067 
00068 
00069 Foam::autoPtr<Foam::polyPatch> Foam::polyPatch::New
00070 (
00071     const word& name,
00072     const dictionary& dict,
00073     const label index,
00074     const polyBoundaryMesh& bm
00075 )
00076 {
00077     if (debug)
00078     {
00079         Info<< "polyPatch::New(const word&, const dictionary&, const label, "
00080                "const polyBoundaryMesh&) : constructing polyPatch"
00081             << endl;
00082     }
00083 
00084     word patchType(dict.lookup("type"));
00085 
00086     dict.readIfPresent("geometricType", patchType);
00087 
00088     dictionaryConstructorTable::iterator cstrIter =
00089         dictionaryConstructorTablePtr_->find(patchType);
00090 
00091     if (cstrIter == dictionaryConstructorTablePtr_->end())
00092     {
00093         if (!disallowGenericPolyPatch)
00094         {
00095             cstrIter = dictionaryConstructorTablePtr_->find("genericPatch");
00096         }
00097 
00098         if (cstrIter == dictionaryConstructorTablePtr_->end())
00099         {
00100             FatalIOErrorIn
00101             (
00102                 "polyPatch::New(const word&, const dictionary&, "
00103                 "const label, const polyBoundaryMesh&)",
00104                 dict
00105             )   << "Unknown polyPatch type " << patchType
00106                 << " for patch " << name
00107                 << endl << endl
00108                 << "Valid polyPatch types are :" << endl
00109                 << dictionaryConstructorTablePtr_->sortedToc()
00110                 << exit(FatalIOError);
00111         }
00112     }
00113 
00114     return autoPtr<polyPatch>(cstrIter()(name, dict, index, bm));
00115 }
00116 
00117 
00118 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines