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-2026 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  DebugInFunction << "Constructing polyPatch" << endl;
42 
43  wordConstructorTable::iterator cstrIter =
44  wordConstructorTablePtr_->find(patchType);
45 
46  if (cstrIter == wordConstructorTablePtr_->end())
47  {
49  << "Unknown polyPatch type "
50  << patchType << " for patch " << name << nl << nl
51  << "Valid polyPatch types are :" << endl
52  << wordConstructorTablePtr_->sortedToc()
53  << exit(FatalError);
54  }
55 
56  autoPtr<polyPatch> ppPtr
57  (
58  cstrIter()
59  (
60  name,
61  size,
62  start,
63  index,
64  bm
65  )
66  );
67 
68  if
69  (
70  patchType != word::null
71  && ppPtr->constraint()
72  && findIndex(ppPtr->inGroups(), patchType) == -1
73  && name != patchType
74  )
75  {
76  ppPtr->inGroups().append(patchType);
77  }
78 
79  return ppPtr;
80 }
81 
82 
84 (
85  const word& name,
86  const dictionary& dict,
87  const label index,
88  const polyBoundaryMesh& bm
89 )
90 {
91  DebugInFunction << "Constructing polyPatch" << endl;
92 
93  word patchType(dict.lookup("type"));
94  dict.readIfPresent("geometricType", patchType);
95 
96  return polyPatch::New(patchType, name, dict, index, bm);
97 }
98 
99 
101 (
102  const word& patchType,
103  const word& name,
104  const dictionary& dict,
105  const label index,
106  const polyBoundaryMesh& bm
107 )
108 {
109  DebugInFunction << "Constructing polyPatch" << endl;
110 
111  dictionaryConstructorTable::iterator cstrIter =
112  dictionaryConstructorTablePtr_->find(patchType);
113 
114  if (cstrIter == dictionaryConstructorTablePtr_->end())
115  {
116  if (!disallowGenericPolyPatch)
117  {
118  cstrIter = dictionaryConstructorTablePtr_->find("genericPatch");
119  }
120 
121  if (cstrIter == dictionaryConstructorTablePtr_->end())
122  {
124  (
125  dict
126  ) << "Unknown polyPatch type "
127  << patchType << " for patch " << name << nl << nl
128  << "Valid polyPatch types are :" << endl
129  << dictionaryConstructorTablePtr_->sortedToc()
130  << exit(FatalIOError);
131  }
132  }
133 
134  autoPtr<polyPatch> ppPtr(cstrIter()(name, dict, index, bm));
135 
136  if
137  (
138  patchType != word::null
139  && ppPtr->constraint()
140  && findIndex(ppPtr->inGroups(), patchType) == -1
141  && name != patchType
142  )
143  {
144  ppPtr->inGroups().append(patchType);
145  }
146 
147  return ppPtr;
148 }
149 
150 
151 // ************************************************************************* //
label size() const
Return the number of elements in the UList.
Definition: UListI.H:311
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:669
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
label index() const
Return the index of this patch in the boundaryMesh.
const word & name() const
Return name.
Foam::polyBoundaryMesh.
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
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:277
A class for handling words, derived from string.
Definition: word.H:63
static const word null
An empty word.
Definition: word.H:78
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:346
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
#define DebugInFunction
Report an information message using Foam::Info.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
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
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:288
IOerror FatalIOError
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
error FatalError
static const char nl
Definition: Ostream.H:297
dictionary dict