polyBoundaryMesh.H
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-2022 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 Class
25  Foam::polyBoundaryMesh
26 
27 Description
28  Foam::polyBoundaryMesh
29 
30 SourceFiles
31  polyBoundaryMesh.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef polyBoundaryMesh_H
36 #define polyBoundaryMesh_H
37 
38 #include "polyPatchList.H"
39 #include "regIOobject.H"
40 #include "labelPair.H"
41 #include "HashSet.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 // Forward declaration of classes
49 class polyMesh;
50 class wordRe;
51 
52 // Forward declaration of friend functions and operators
53 
54 Ostream& operator<<(Ostream&, const polyBoundaryMesh&);
55 
56 
57 /*---------------------------------------------------------------------------*\
58  Class polyBoundaryMesh Declaration
59 \*---------------------------------------------------------------------------*/
60 
61 class polyBoundaryMesh
62 :
63  public polyPatchList,
64  public regIOobject
65 {
66  // private data
67 
68  //- Reference to mesh
69  const polyMesh& mesh_;
70 
71  mutable autoPtr<labelList> patchIDPtr_;
72 
73  mutable autoPtr<labelList> patchFaceIDPtr_;
74 
75  mutable autoPtr<HashTable<labelList, word>> groupPatchIDsPtr_;
76 
77  //- Edges of neighbouring patches
78  mutable autoPtr<List<labelPairList>> nbrEdgesPtr_;
79 
80 
81  // Private Member Functions
82 
83  //- Calculate the geometry for the patches (transformation tensors etc.)
84  void calcGeometry();
85 
86  //- Disallow default bitwise copy construction
88 
89  //- Disallow default bitwise assignment
90  void operator=(const polyBoundaryMesh&);
91 
92 
93 public:
94 
95  //- Declare friendship with polyMesh
96  friend class polyMesh;
97 
98 
99  //- Runtime type information
100  TypeName("polyBoundaryMesh");
101 
102 
103  // Constructors
104 
105  //- Read constructor given IOobject and a polyMesh reference
106  // Note point pointers are unset, only used in copying meshes
108  (
109  const IOobject&,
110  const polyMesh&
111  );
112 
113  //- Construct given size
115  (
116  const IOobject&,
117  const polyMesh&,
118  const label size
119  );
120 
121  //- Construct given polyPatchList
123  (
124  const IOobject&,
125  const polyMesh&,
126  const polyPatchList&
127  );
128 
129 
130  //- Destructor
132 
133  //- Clear geometry at this level and at patches
134  void clearGeom();
135 
136  //- Clear addressing at this level and at patches
137  void clearAddressing();
138 
139 
140  // Member Functions
141 
142  //- Return the mesh reference
143  const polyMesh& mesh() const
144  {
145  return mesh_;
146  }
147 
148  //- Per patch the edges on the neighbouring patch. Is for every external
149  // edge the neighbouring patch and neighbouring (external) patch edge
150  // label. Note that edge indices are offset by nInternalEdges to keep
151  // it as much as possible consistent with coupled patch addressing
152  // (where coupling is by local patch face index).
153  // Only valid for singly connected polyBoundaryMesh and not parallel
154  const List<labelPairList>& nbrEdges() const;
155 
156  //- Return a list of patch names
157  wordList names() const;
158 
159  //- Return a list of patch types
160  wordList types() const;
161 
162  //- Return a list of physical types
163  wordList physicalTypes() const;
164 
165  //- Return patch indices for all matches. Optionally matches patchGroups
167  (
168  const wordRe&,
169  const bool usePatchGroups = true
170  ) const;
171 
172  //- Return patch index for the first match, return -1 if not found
173  label findIndex(const wordRe&) const;
174 
175  //- Find patch index given a name
176  label findPatchID(const word& patchName) const;
177 
178  //- Find patch indices for a given polyPatch type
179  template<class Type>
180  labelHashSet findPatchIDs() const;
181 
182  //- Return patch index for a given face label
183  label whichPatch(const label faceIndex) const;
184 
185  //- Per boundary face label the patch index
186  const labelList& patchID() const;
187 
188  //- Per boundary face label the patch face index
189  const labelList& patchFaceID() const;
190 
191  //- Per patch group the patch indices
193 
194  //- Set/add group with patches
195  void setGroup(const word& groupName, const labelList& patchIDs);
196 
197  //- Return the set of patch IDs corresponding to the given names
198  // By default warns if given names are not found. Optionally
199  // matches to patchGroups as well as patchNames
201  (
202  const UList<wordRe>& patchNames,
203  const bool warnNotFound = true,
204  const bool usePatchGroups = true
205  ) const;
206 
207  //- Match the patches to groups. Returns all the (fully matched) groups
208  // and any remaining unmatched patches.
209  void matchGroups
210  (
211  const labelUList& patchIDs,
212  wordList& groups,
213  labelHashSet& nonGroupPatches
214  ) const;
215 
216  //- Check whether all procs have all patches and in same order. Return
217  // true if in error.
218  bool checkParallelSync(const bool report = false) const;
219 
220  //- Check boundary definition. Return true if in error.
221  bool checkDefinition(const bool report = false) const;
222 
223  //- Correct polyBoundaryMesh after moving points
224  void movePoints(const pointField&);
225 
226  //- Correct polyBoundaryMesh after topology update
227  void topoChange();
228 
229  //- Rename the patches. If validBoundary is set this calls topoChange()
230  // after reordering to recalculate data (so the call needs to be
231  // parallel synchronised).
232  void renamePatches(const wordUList& newNames, const bool validBoundary);
233 
234  //- Reorders the patches. Ordering does not have to be done in
235  // ascending or descending order. Reordering has to be unique (is a
236  // shuffle). If validBoundary is set this calls topoChange() after
237  // reordering to recalculate data (so the call needs to be parallel
238  // synchronised).
239  void reorderPatches
240  (
241  const labelUList& newToOld,
242  const bool validBoundary
243  );
244 
245  //- writeData member function required by regIOobject
246  bool writeData(Ostream&) const;
247 
248  //- Write using given format, version and form uncompression
249  bool writeObject
250  (
254  const bool write = true
255  ) const;
256 
257 
258  // Member Operators
259 
260  //- Return const and non-const reference to polyPatch by index.
261  using polyPatchList::operator[];
262 
263  //- Return const reference to polyPatch by name.
264  const polyPatch& operator[](const word&) const;
265 
266  //- Return reference to polyPatch by name.
267  polyPatch& operator[](const word&);
268 
269 
270  // Ostream operator
271 
272  friend Ostream& operator<<(Ostream&, const polyBoundaryMesh&);
273 };
274 
275 
276 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
277 
278 } // End namespace Foam
279 
280 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
281 
282 #ifdef NoRepository
283  #include "polyBoundaryMeshTemplates.C"
284 #endif
285 
286 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
287 
288 #endif
289 
290 // ************************************************************************* //
bool writeData(Ostream &) const
writeData member function required by regIOobject
bool writeObject(IOstream::streamFormat fmt, IOstream::versionNumber ver, IOstream::compressionType cmp, const bool write=true) const
Write using given format, version and form uncompression.
void renamePatches(const wordUList &newNames, const bool validBoundary)
Rename the patches. If validBoundary is set this calls topoChange()
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
const labelList & patchID() const
Per boundary face label the patch index.
void reorderPatches(const labelUList &newToOld, const bool validBoundary)
Reorders the patches. Ordering does not have to be done in.
label findPatchID(const word &patchName) const
Find patch index given a name.
void clearGeom()
Clear geometry at this level and at patches.
wordList types() const
Return a list of patch types.
labelHashSet patchSet(const UList< wordRe > &patchNames, const bool warnNotFound=true, const bool usePatchGroups=true) const
Return the set of patch IDs corresponding to the given names.
friend Ostream & operator(Ostream &, const UPtrList< T > &)
Write UPtrList to Ostream.
const polyPatch & operator[](const word &) const
Return const reference to polyPatch by name.
void matchGroups(const labelUList &patchIDs, wordList &groups, labelHashSet &nonGroupPatches) const
Match the patches to groups. Returns all the (fully matched) groups.
void topoChange()
Correct polyBoundaryMesh after topology update.
~polyBoundaryMesh()
Destructor.
void movePoints(const pointField &)
Correct polyBoundaryMesh after moving points.
A class for handling words, derived from string.
Definition: word.H:59
static word groupName(Name name, const word &group)
bool checkDefinition(const bool report=false) const
Check boundary definition. Return true if in error.
wordList names() const
Return a list of patch names.
wordList patchNames(nPatches)
streamFormat
Enumeration for the format of data in the stream.
Definition: IOstream.H:86
const polyMesh & mesh() const
Return the mesh reference.
wordList physicalTypes() const
Return a list of physical types.
An STL-conforming hash table.
Definition: HashTable.H:61
const List< labelPairList > & nbrEdges() const
Per patch the edges on the neighbouring patch. Is for every external.
A wordRe is a word, but can also have a regular expression for matching words.
Definition: wordRe.H:74
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:60
Foam::polyBoundaryMesh.
compressionType
Enumeration for the format of data in the stream.
Definition: IOstream.H:193
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
bool checkParallelSync(const bool report=false) const
Check whether all procs have all patches and in same order. Return.
TypeName("polyBoundaryMesh")
Runtime type information.
const labelList & patchFaceID() const
Per boundary face label the patch face index.
label size() const
Return the number of elements in the UPtrList.
Definition: UPtrListI.H:29
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:70
void clearAddressing()
Clear addressing at this level and at patches.
Ostream & operator<<(Ostream &, const ensightPart &)
Version number type.
Definition: IOstream.H:96
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:52
label findIndex(const wordRe &) const
Return patch index for the first match, return -1 if not found.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:76
virtual bool write(const bool write=true) const
Write using setting from DB.
friend Ostream & operator<<(Ostream &, const polyBoundaryMesh &)
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:98
label whichPatch(const label faceIndex) const
Return patch index for a given face label.
labelList findIndices(const wordRe &, const bool usePatchGroups=true) const
Return patch indices for all matches. Optionally matches patchGroups.
labelHashSet findPatchIDs() const
Find patch indices for a given polyPatch type.
void setGroup(const word &groupName, const labelList &patchIDs)
Set/add group with patches.
Namespace for OpenFOAM.
const HashTable< labelList, word > & groupPatchIDs() const
Per patch group the patch indices.