FreeFOAM The Cross-Platform CFD Toolkit
newPolyPatch.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "polyPatch.H"
27 #include <OpenFOAM/dictionary.H>
28 
29 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
30 
32 (
33  const word& patchType,
34  const word& name,
35  const label size,
36  const label start,
37  const label index,
38  const polyBoundaryMesh& bm
39 )
40 {
41  if (debug)
42  {
43  Info<< "polyPatch::New(const word&, const word&, const label, "
44  "const label, const label, const polyBoundaryMesh&) : "
45  "constructing polyPatch"
46  << endl;
47  }
48 
49  wordConstructorTable::iterator cstrIter =
50  wordConstructorTablePtr_->find(patchType);
51 
52  if (cstrIter == wordConstructorTablePtr_->end())
53  {
55  (
56  "polyPatch::New(const word&, const word&, const label, "
57  "const label, const label, const polyBoundaryMesh&) "
58  ) << "Unknown polyPatch type " << patchType << " for patch " << name
59  << endl << endl
60  << "Valid polyPatch types are :" << endl
61  << wordConstructorTablePtr_->sortedToc()
62  << exit(FatalError);
63  }
64 
65  return autoPtr<polyPatch>(cstrIter()(name, size, start, index, bm));
66 }
67 
68 
70 (
71  const word& name,
72  const dictionary& dict,
73  const label index,
74  const polyBoundaryMesh& bm
75 )
76 {
77  if (debug)
78  {
79  Info<< "polyPatch::New(const word&, const dictionary&, const label, "
80  "const polyBoundaryMesh&) : constructing polyPatch"
81  << endl;
82  }
83 
84  word patchType(dict.lookup("type"));
85 
86  dict.readIfPresent("geometricType", patchType);
87 
88  dictionaryConstructorTable::iterator cstrIter =
89  dictionaryConstructorTablePtr_->find(patchType);
90 
91  if (cstrIter == dictionaryConstructorTablePtr_->end())
92  {
93  if (!disallowGenericPolyPatch)
94  {
95  cstrIter = dictionaryConstructorTablePtr_->find("genericPatch");
96  }
97 
98  if (cstrIter == dictionaryConstructorTablePtr_->end())
99  {
101  (
102  "polyPatch::New(const word&, const dictionary&, "
103  "const label, const polyBoundaryMesh&)",
104  dict
105  ) << "Unknown polyPatch type " << patchType
106  << " for patch " << name
107  << endl << endl
108  << "Valid polyPatch types are :" << endl
109  << dictionaryConstructorTablePtr_->sortedToc()
110  << exit(FatalIOError);
111  }
112  }
113 
114  return autoPtr<polyPatch>(cstrIter()(name, dict, index, bm));
115 }
116 
117 
118 // ************************ vim: set sw=4 sts=4 et: ************************ //