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-2019 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>> neighbourEdgesPtr_;
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>& neighbourEdges() 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 keyType&,
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 keyType&) 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  //- Reorders patches. Ordering does not have to be done in
225  // ascending or descending order. Reordering has to be unique.
226  // (is shuffle) If validBoundary calls updateMesh()
227  // after reordering to recalculate data (so call needs to be parallel
228  // sync in that case)
229  void shuffle(const labelUList& newToOld, const bool validBoundary);
230 
231  //- writeData member function required by regIOobject
232  bool writeData(Ostream&) const;
233 
234  //- Write using given format, version and form uncompression
235  bool writeObject
236  (
240  const bool write = true
241  ) const;
242 
243 
244  // Member Operators
245 
246  //- Return const and non-const reference to polyPatch by index.
247  using polyPatchList::operator[];
248 
249  //- Return const reference to polyPatch by name.
250  const polyPatch& operator[](const word&) const;
251 
252  //- Return reference to polyPatch by name.
253  polyPatch& operator[](const word&);
254 
255 
256  // Ostream operator
257 
258  friend Ostream& operator<<(Ostream&, const polyBoundaryMesh&);
259 };
260 
261 
262 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
263 
264 } // End namespace Foam
265 
266 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
267 
268 #ifdef NoRepository
269  #include "polyBoundaryMeshTemplates.C"
270 #endif
271 
272 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
273 
274 #endif
275 
276 // ************************************************************************* //
A class for handling keywords in dictionaries.
Definition: keyType.H:64
const List< labelPairList > & neighbourEdges() const
Per patch the edges on the neighbouring patch. Is for every external.
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.
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
void shuffle(const labelUList &newToOld, const bool validBoundary)
Reorders patches. Ordering does not have to be done in.
const labelList & patchID() const
Per boundary face label the patch index.
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
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:53
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 &)
labelList findIndices(const keyType &, const bool usePatchGroups=true) const
Return patch indices for all matches. Optionally matches patchGroups.
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:55
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.
label findIndex(const keyType &) const
Return patch index for the first match, return -1 if not found.
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.