initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / meshes / polyMesh / polyPatches / polyPatch / newPolyPatch.C
blobf456fc840406753f71db775664f79b068224fa19
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software; you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "polyPatch.H"
28 #include "dictionary.H"
30 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
32 Foam::autoPtr<Foam::polyPatch> Foam::polyPatch::New
34     const word& patchType,
35     const word& name,
36     const label size,
37     const label start,
38     const label index,
39     const polyBoundaryMesh& bm
42     if (debug)
43     {
44         Info<< "polyPatch::New(const word&, const word&, const label, "
45                "const label, const label, const polyBoundaryMesh&) : "
46                "constructing polyPatch"
47             << endl;
48     }
50     wordConstructorTable::iterator cstrIter =
51         wordConstructorTablePtr_->find(patchType);
53     if (cstrIter == wordConstructorTablePtr_->end())
54     {
55         FatalErrorIn
56         (
57             "polyPatch::New(const word&, const word&, const label, "
58             "const label, const label, const polyBoundaryMesh&) "
59         )   << "Unknown polyPatch type " << patchType << " for patch " << name
60             << endl << endl
61             << "Valid polyPatch types are :" << endl
62             << wordConstructorTablePtr_->toc()
63             << exit(FatalError);
64     }
66     return autoPtr<polyPatch>(cstrIter()(name, size, start, index, bm));
70 Foam::autoPtr<Foam::polyPatch> Foam::polyPatch::New
72     const word& name,
73     const dictionary& dict,
74     const label index,
75     const polyBoundaryMesh& bm
78     if (debug)
79     {
80         Info<< "polyPatch::New(const word&, const dictionary&, const label, "
81                "const polyBoundaryMesh&) : constructing polyPatch"
82             << endl;
83     }
85     word patchType(dict.lookup("type"));
87     dict.readIfPresent("geometricType", patchType);
89     dictionaryConstructorTable::iterator cstrIter =
90         dictionaryConstructorTablePtr_->find(patchType);
92     if (cstrIter == dictionaryConstructorTablePtr_->end())
93     {
94         if (!disallowGenericPolyPatch)
95         {
96             cstrIter = dictionaryConstructorTablePtr_->find("genericPatch");
97         }
99         if (cstrIter == dictionaryConstructorTablePtr_->end())
100         {
101             FatalIOErrorIn
102             (
103                 "polyPatch::New(const word&, const dictionary&, "
104                 "const label, const polyBoundaryMesh&)",
105                 dict
106             )   << "Unknown polyPatch type " << patchType
107                 << " for patch " << name
108                 << endl << endl
109                 << "Valid polyPatch types are :" << endl
110                 << dictionaryConstructorTablePtr_->toc()
111                 << exit(FatalIOError);
112         }
113     }
115     return autoPtr<polyPatch>(cstrIter()(name, dict, index, bm));
119 // ************************************************************************* //