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-2020 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<HashTable<labelList, word>> groupPatchIDsPtr_;
74 
75  //- Edges of neighbouring patches
76  mutable autoPtr<List<labelPairList>> nbrEdgesPtr_;
77 
78 
79  // Private Member Functions
80 
81  //- Calculate the geometry for the patches (transformation tensors etc.)
82  void calcGeometry();
83 
84  //- Disallow default bitwise copy construction
86 
87  //- Disallow default bitwise assignment
88  void operator=(const polyBoundaryMesh&);
89 
90 
91 public:
92 
93  //- Declare friendship with polyMesh
94  friend class polyMesh;
95 
96 
97  //- Runtime type information
98  TypeName("polyBoundaryMesh");
99 
100 
101  // Constructors
102 
103  //- Read constructor given IOobject and a polyMesh reference
104  // Note point pointers are unset, only used in copying meshes
106  (
107  const IOobject&,
108  const polyMesh&
109  );
110 
111  //- Construct given size
113  (
114  const IOobject&,
115  const polyMesh&,
116  const label size
117  );
118 
119  //- Construct given polyPatchList
121  (
122  const IOobject&,
123  const polyMesh&,
124  const polyPatchList&
125  );
126 
127 
128  //- Destructor
130 
131  //- Clear geometry at this level and at patches
132  void clearGeom();
133 
134  //- Clear addressing at this level and at patches
135  void clearAddressing();
136 
137 
138  // Member Functions
139 
140  //- Return the mesh reference
141  const polyMesh& mesh() const
142  {
143  return mesh_;
144  }
145 
146  //- Per patch the edges on the neighbouring patch. Is for every external
147  // edge the neighbouring patch and neighbouring (external) patch edge
148  // label. Note that edge indices are offset by nInternalEdges to keep
149  // it as much as possible consistent with coupled patch addressing
150  // (where coupling is by local patch face index).
151  // Only valid for singly connected polyBoundaryMesh and not parallel
152  const List<labelPairList>& nbrEdges() const;
153 
154  //- Return a list of patch names
155  wordList names() const;
156 
157  //- Return a list of patch types
158  wordList types() const;
159 
160  //- Return a list of physical types
161  wordList physicalTypes() const;
162 
163  //- Return patch indices for all matches. Optionally matches patchGroups
165  (
166  const wordRe&,
167  const bool usePatchGroups = true
168  ) const;
169 
170  //- Return patch index for the first match, return -1 if not found
171  label findIndex(const wordRe&) const;
172 
173  //- Find patch index given a name
174  label findPatchID(const word& patchName) const;
175 
176  //- Find patch indices for a given polyPatch type
177  template<class Type>
178  labelHashSet findPatchIDs() const;
179 
180  //- Return patch index for a given face label
181  label whichPatch(const label faceIndex) const;
182 
183  //- Per boundary face label the patch index
184  const labelList& patchID() const;
185 
186  //- Per patch group the patch indices
188 
189  //- Set/add group with patches
190  void setGroup(const word& groupName, const labelList& patchIDs);
191 
192  //- Return the set of patch IDs corresponding to the given names
193  // By default warns if given names are not found. Optionally
194  // matches to patchGroups as well as patchNames
196  (
197  const UList<wordRe>& patchNames,
198  const bool warnNotFound = true,
199  const bool usePatchGroups = true
200  ) const;
201 
202  //- Match the patches to groups. Returns all the (fully matched) groups
203  // and any remaining unmatched patches.
204  void matchGroups
205  (
206  const labelUList& patchIDs,
207  wordList& groups,
208  labelHashSet& nonGroupPatches
209  ) const;
210 
211  //- Check whether all procs have all patches and in same order. Return
212  // true if in error.
213  bool checkParallelSync(const bool report = false) const;
214 
215  //- Check boundary definition. Return true if in error.
216  bool checkDefinition(const bool report = false) const;
217 
218  //- Correct polyBoundaryMesh after moving points
219  void movePoints(const pointField&);
220 
221  //- Correct polyBoundaryMesh after topology update
222  void updateMesh();
223 
224  //- Rename the patches. If validBoundary is set this calls updateMesh()
225  // after reordering to recalculate data (so the call needs to be
226  // parallel synchronised).
227  void renamePatches(const wordUList& newNames, const bool validBoundary);
228 
229  //- Reorders the patches. Ordering does not have to be done in
230  // ascending or descending order. Reordering has to be unique (is a
231  // shuffle). If validBoundary is set this calls updateMesh() after
232  // reordering to recalculate data (so the call needs to be parallel
233  // synchronised).
234  void reorderPatches
235  (
236  const labelUList& newToOld,
237  const bool validBoundary
238  );
239 
240  //- writeData member function required by regIOobject
241  bool writeData(Ostream&) const;
242 
243  //- Write using given format, version and form uncompression
244  bool writeObject
245  (
249  const bool write = true
250  ) const;
251 
252 
253  // Member Operators
254 
255  //- Return const and non-const reference to polyPatch by index.
256  using polyPatchList::operator[];
257 
258  //- Return const reference to polyPatch by name.
259  const polyPatch& operator[](const word&) const;
260 
261  //- Return reference to polyPatch by name.
262  polyPatch& operator[](const word&);
263 
264 
265  // Ostream operator
266 
267  friend Ostream& operator<<(Ostream&, const polyBoundaryMesh&);
268 };
269 
270 
271 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
272 
273 } // End namespace Foam
274 
275 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
276 
277 #ifdef NoRepository
278  #include "polyBoundaryMeshTemplates.C"
279 #endif
280 
281 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
282 
283 #endif
284 
285 // ************************************************************************* //
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
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 updateMesh()
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.
~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.
void updateMesh()
Correct polyBoundaryMesh after topology update.
TypeName("polyBoundaryMesh")
Runtime type information.
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:74
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:92
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.