pointBoundaryMesh.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2013 OpenFOAM Foundation
9  Copyright (C) 2018-2025 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::pointBoundaryMesh
29 
30 Description
31  A pointBoundaryMesh is a pointPatch list with registered IO,
32  a reference to the associated pointMesh,
33  with additional search methods etc.
34 
35 SourceFiles
36  pointBoundaryMesh.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef Foam_pointBoundaryMesh_H
41 #define Foam_pointBoundaryMesh_H
42 
43 #include "pointPatch.H"
44 #include "regIOobject.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 // Forward Declarations
52 class pointMesh;
53 class polyBoundaryMesh;
54 class wordRes;
55 
56 /*---------------------------------------------------------------------------*\
57  Class pointBoundaryMesh Declaration
58 \*---------------------------------------------------------------------------*/
59 
61 :
62  public pointPatchList,
63  public regIOobject
64 {
65  // Private Data
66 
67  //- Reference to mesh
68  const pointMesh& mesh_;
69 
70  //- Demand-driven: list of patch ids per group
71  mutable autoPtr<HashTable<labelList>> groupIDsPtr_;
72 
73 
74  // Private Member Functions
75 
76  //- Calculate geometry for the patches (transformation tensors etc.)
77  void calcGeometry();
78 
79  //- Some patches have inGroup entries
80  bool hasGroupIDs() const;
81 
82  //- Calculate group name to patch ids lookup
83  void calcGroupIDs() const;
84 
85  //- Assign facePointPatches corresponding to the given polyBoundaryMesh
86  void addPatches(const polyBoundaryMesh& pbm);
87 
88  //- No copy construct
89  pointBoundaryMesh(const pointBoundaryMesh&) = delete;
90 
91  //- No copy assignment
92  void operator=(const pointBoundaryMesh&) = delete;
93 
94 
95 public:
96 
97  //- Declare friendship with pointMesh
98  friend class pointMesh;
99 
100 
101  //- Runtime type information
102  TypeName("pointBoundaryMesh");
103 
104 
105  // Constructors
106 
107  //- Construct from pointMesh and polyBoundaryMesh
109 
110  //- Construct from IOobject, pointMesh and polyBoundaryMesh
112  (
113  const IOobject& io,
114  const pointMesh&,
115  const polyBoundaryMesh&
116  );
117 
118 
119  //- Destructor
120  virtual ~pointBoundaryMesh() = default;
121 
122 
123  // Member Functions
124 
125  //- Return the mesh reference
126  const pointMesh& mesh() const noexcept
127  {
128  return mesh_;
129  }
130 
131  //- The number of patches before the first processor patch.
132  label nNonProcessor() const;
133 
134  //- The number of processorPointPatch patches
135  label nProcessorPatches() const;
136 
137  //- Return a list of patch names
138  wordList names() const;
139 
140  //- Return a list of patch types
141  wordList types() const;
142 
143  //- Return a list of physical types
144  wordList physicalTypes() const;
145 
146  //- The (sorted) patch indices for all matches,
147  //- optionally matching patch groups.
148  // \returns an empty list for an empty matcher
149  labelList indices(const wordRe& matcher, const bool useGroups) const;
150 
151  //- The (sorted) patch indices for all matches,
152  //- optionally matching patch groups.
153  // \returns an empty list for an empty matcher
154  labelList indices(const wordRes& matcher, const bool useGroups) const;
155 
156  //- The (sorted) patch indices: logic as per Foam::wordRes::filter,
157  //- optionally matching patch groups.
158  //
159  // An empty \em allow accepts everything not in \em deny.
160  // A literal \em allow match has higher priority than any \em deny.
161  // A regex \em allow match has lower priority than any \em deny.
162  //
163  // \returns identity list when allow/deny are both empty.
165  (
166  const wordRes& allow,
167  const wordRes& deny,
168  const bool useGroups
169  ) const;
170 
171  //- Find patch index given a name
172  // A no-op (returns -1) for an empty patchName
173  label findPatchID
174  (
175  const word& patchName,
176  const bool allowNotFound = true
177  ) const;
178 
179  //- The patch indices per patch group
180  const HashTable<labelList>& groupPatchIDs() const;
181 
182  //- Correct pointBoundaryMesh after moving points
183  void movePoints(const pointField&);
184 
185  //- Correct pointBoundaryMesh after topology update
186  void updateMesh();
187 
188  //- Reorders patches. Ordering does not have to be done in
189  // ascending or descending order. Reordering has to be unique.
190  // (is shuffle) If validBoundary calls updateMesh()
191  // after reordering to recalculate data (so call needs to be parallel
192  // sync in that case)
193  void reorder(const labelUList& oldToNew, const bool validBoundary);
194 
195  //- writeData member function required by regIOobject
196  virtual bool writeData(Ostream&) const;
197 
198 
199  // Housekeeping
200 
201  //- Identical to the indices() method (AUG-2018)
202  FOAM_DEPRECATED_FOR(2018-08, "indices() method")
203  labelList findIndices(const wordRe& key, bool useGroups) const
204  {
205  return indices(key, useGroups);
206  }
207 };
208 
209 
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211 
212 } // End namespace Foam
213 
214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 
216 #endif
217 
218 // ************************************************************************* //
const polyBoundaryMesh & pbm
label nNonProcessor() const
The number of patches before the first processor patch.
A pointBoundaryMesh is a pointPatch list with registered IO, a reference to the associated pointMesh...
wordList physicalTypes() const
Return a list of physical types.
void movePoints(const pointField &)
Correct pointBoundaryMesh after moving points.
label nProcessorPatches() const
The number of processorPointPatch patches.
FOAM_DEPRECATED_FOR(2022-09, "get(), set() or test() methods") const T *operator()(const label i) const
Deprecated(2022-09) - same as get()
Definition: UPtrList.H:492
labelList indices(const wordRe &matcher, const bool useGroups) const
The (sorted) patch indices for all matches, optionally matching patch groups.
const pointMesh & mesh() const noexcept
Return the mesh reference.
void updateMesh()
Correct pointBoundaryMesh after topology update.
Mesh representing a set of points created from polyMesh.
Definition: pointMesh.H:45
labelList findIndices(const wordRe &key, bool useGroups) const
Identical to the indices() method (AUG-2018)
A class for handling words, derived from Foam::string.
Definition: word.H:63
TypeName("pointBoundaryMesh")
Runtime type information.
void reorder(const labelUList &oldToNew, const bool validBoundary)
Reorders patches. Ordering does not have to be done in.
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:53
auto key(const Type &t) -> std::enable_if_t< std::is_enum_v< Type >, std::underlying_type_t< Type > >
Definition: foamGltfBase.H:103
A HashTable similar to std::unordered_map.
Definition: HashTable.H:108
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings...
Definition: wordRe.H:78
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh...
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
const direction noexcept
Definition: scalarImpl.H:255
label findPatchID(const word &patchName, const bool allowNotFound=true) const
Find patch index given a name.
const HashTable< labelList > & groupPatchIDs() const
The patch indices per patch group.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: List.H:54
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:68
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
wordList types() const
Return a list of patch types.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
wordList names() const
Return a list of patch names.
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:180
virtual bool writeData(Ostream &) const
writeData member function required by regIOobject
Namespace for OpenFOAM.
virtual ~pointBoundaryMesh()=default
Destructor.