polyPatchNew.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
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 "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  InfoInFunction << "Constructing polyPatch" << endl;
44  }
45 
46  wordConstructorTable::iterator cstrIter =
47  wordConstructorTablePtr_->find(patchType);
48 
49  if (cstrIter == wordConstructorTablePtr_->end())
50  {
52  << "Unknown polyPatch type "
53  << patchType << " for patch " << name << nl << nl
54  << "Valid polyPatch types are :" << endl
55  << wordConstructorTablePtr_->sortedToc()
56  << exit(FatalError);
57  }
58 
59  return autoPtr<polyPatch>
60  (
61  cstrIter()
62  (
63  name,
64  size,
65  start,
66  index,
67  bm,
68  patchType
69  )
70  );
71 }
72 
73 
75 (
76  const word& name,
77  const dictionary& dict,
78  const label index,
79  const polyBoundaryMesh& bm
80 )
81 {
82  if (debug)
83  {
84  InfoInFunction << "Constructing polyPatch" << endl;
85  }
86 
87  word patchType(dict.lookup("type"));
88  dict.readIfPresent("geometricType", patchType);
89 
90  return polyPatch::New(patchType, name, dict, index, bm);
91 }
92 
93 
95 (
96  const word& patchType,
97  const word& name,
98  const dictionary& dict,
99  const label index,
100  const polyBoundaryMesh& bm
101 )
102 {
103  if (debug)
104  {
105  InfoInFunction << "Constructing polyPatch" << endl;
106  }
107 
108  dictionaryConstructorTable::iterator cstrIter =
109  dictionaryConstructorTablePtr_->find(patchType);
110 
111  if (cstrIter == dictionaryConstructorTablePtr_->end())
112  {
113  if (!disallowGenericPolyPatch)
114  {
115  cstrIter = dictionaryConstructorTablePtr_->find("genericPatch");
116  }
117 
118  if (cstrIter == dictionaryConstructorTablePtr_->end())
119  {
121  (
122  dict
123  ) << "Unknown polyPatch type "
124  << patchType << " for patch " << name << nl << nl
125  << "Valid polyPatch types are :" << endl
126  << dictionaryConstructorTablePtr_->sortedToc()
127  << exit(FatalIOError);
128  }
129  }
130 
131  return autoPtr<polyPatch>(cstrIter()(name, dict, index, bm, patchType));
132 }
133 
134 
135 // ************************************************************************* //
dictionary dict
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:323
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
autoPtr< BasicCompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleMomentumTransportModel::transportModel &transport)
A class for handling words, derived from string.
Definition: word.H:59
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
Foam::polyBoundaryMesh.
static const char nl
Definition: Ostream.H:260
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:335
static autoPtr< polyPatch > New(const word &patchType, const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm)
Return a pointer to a new patch created on freestore from.
Definition: polyPatchNew.C:32
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:844
IOerror FatalIOError
#define InfoInFunction
Report an information message using Foam::Info.