faBoundaryMesh.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) 2016-2017 Wikki Ltd
9  Copyright (C) 2018-2024 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::faBoundaryMesh
29 
30 Description
31  Finite area boundary mesh
32 
33 SourceFiles
34  faBoundaryMesh.C
35 
36 Author
37  Zeljko Tukovic, FMENA
38  Hrvoje Jasak, Wikki Ltd.
39 
40 \*---------------------------------------------------------------------------*/
41 
42 #ifndef Foam_faBoundaryMesh_H
43 #define Foam_faBoundaryMesh_H
44 
45 #include "regIOobject.H"
46 #include "faPatch.H"
47 #include "labelPair.H"
48 #include "lduInterfacePtrsList.H"
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace Foam
53 {
54 
55 // Forward Declarations
56 class entry;
57 class faMesh;
58 class faBoundaryMesh;
59 class wordRes;
60 
61 Ostream& operator<<(Ostream&, const faBoundaryMesh&);
62 
63 /*---------------------------------------------------------------------------*\
64  Class faBoundaryMesh Declaration
65 \*---------------------------------------------------------------------------*/
66 
67 class faBoundaryMesh
68 :
69  public faPatchList,
70  public regIOobject
71 {
72  // Private Data
73 
74  //- Reference to mesh
75  const faMesh& mesh_;
76 
77  //- Demand-driven: list of patch ids per group
78  mutable autoPtr<HashTable<labelList>> groupIDsPtr_;
79 
80 
81  // Private Member Functions
82 
83  //- Some patches have inGroup entries
84  bool hasGroupIDs() const;
85 
86  //- Calculate group name to patch ids lookup
87  void calcGroupIDs() const;
88 
89  //- Clear addressing at this level
90  void clearLocalAddressing();
91 
92  //- Populate/recreate from dictionary entries
93  void populate(PtrList<entry>&& entries);
94 
95  //- Return true if contents were read
96  //- (controlled by IOobject readOption flags).
97  bool readIOcontents(const bool allowOptionalRead);
98 
99 public:
100 
101  //- Runtime type information
102  TypeName("faBoundaryMesh");
103 
104 
105  // Generated Methods
106 
107  //- No copy construct
108  faBoundaryMesh(const faBoundaryMesh&) = delete;
109 
110  //- No copy assignment
111  void operator=(const faBoundaryMesh&) = delete;
112 
113 
114  // Constructors
115 
116  //- Read construct given IOobject and a mesh reference.
117  //- It will only read for MUST_READ variants (not READ_IF_PRESENT).
119  (
120  const IOobject& io,
121  const faMesh& fam
122  );
123 
124  //- Construct empty with IOobject properties and a mesh reference.
125  //- Does not read.
127  (
128  const IOobject& io,
129  const faMesh& fam,
130  Foam::zero
131  );
132 
133  //- Construct with specified size. Does not read.
135  (
136  const IOobject& io,
137  const faMesh& fam,
138  const label size
139  );
140 
141  //- Read construct (mandatory, optional) based on IOobject properties
142  //- or use the fallback PtrList (with cloning).
144  (
145  const IOobject& io,
146  const faMesh& fam,
147  const faPatchList& list
148  );
149 
150  //- Read construct (mandatory, optional) based on IOobject properties
151  //- or fallback to constructing from a list of dictionary entries
153  (
154  const IOobject& io,
155  const faMesh& fam,
156  PtrList<entry>&& entries
157  );
158 
159 
160  //- Destructor
161  ~faBoundaryMesh() = default;
162 
163 
164  // Member Functions
165 
166  //- Clear the patch list and all demand-driven data
167  void clear();
168 
169  //- Return the mesh reference
170  const faMesh& mesh() const noexcept
171  {
172  return mesh_;
173  }
174 
175  //- Return a list of edgeLabels for each patch
177 
178  //- Return a list of edgeFaces for each patch
180 
181  //- Return a list of pointers for each patch
182  //- with only those pointing to interfaces being set
184 
185  //- The number of patches before the first processor patch.
186  label nNonProcessor() const;
187 
188  //- The number of processorFaPatch patches
189  label nProcessorPatches() const;
190 
191  //- Return a list of patch names
192  wordList names() const;
193 
194  //- Return a list of patch types
195  wordList types() const;
196 
197  //- Return a list of patch start indices
198  labelList patchStarts() const;
199 
200  //- Return a list of patch sizes (number of edges in each patch)
202 
203  //- Return a list of patch ranges
205 
206  //- A list of the group names (if any)
207  wordList groupNames() const;
208 
209  //- The start label of the edges in the faMesh edges list
210  // Same as mesh.nInternalEdges()
211  label start() const;
212 
213  //- The number of boundary edges for the underlying mesh
214  // Same as mesh.nBoundaryEdges()
215  label nEdges() const;
216 
217  //- The edge range for all boundary edges
218  // Spans [nInternalEdges, nEdges) of the underlying mesh
219  labelRange range() const;
220 
221 
222  //- Return (sorted) patch indices for all matches.
223  // Optionally matches patch groups.
224  // A no-op (returns empty list) for an empty matcher
226  (
227  const wordRe& matcher,
228  const bool useGroups = true
229  ) const;
230 
231  //- Return (sorted) patch indices for all matches.
232  // Optionally matches patch groups.
233  // A no-op (returns empty list) for an empty matcher
235  (
236  const wordRes& matcher,
237  const bool useGroups = true
238  ) const;
239 
240  //- Return (sorted) patch indices for all selected matches that
241  //- are not ignored.
242  //- The selection logic as per Foam::wordRes::filter.
243  // Optionally matches patch groups.
244  // A no-op (returns empty list) for an empty select matcher
246  (
247  const wordRes& select,
248  const wordRes& ignore,
249  const bool useGroups = true
250  ) const;
251 
252  //- Return patch index for the first match, return -1 if not found
253  // A no-op (returns -1) for an empty key
254  label findIndex(const wordRe& key) const;
255 
256  //- Find patch index given a name, return -1 if not found
257  // A no-op (returns -1) for an empty name
258  label findPatchID
259  (
260  const word& patchName,
261  const bool allowNotFound = true
262  ) const;
263 
264  //- Return patch index for a given edge label
265  label whichPatch(const label edgeIndex) const;
266 
267  //- The patch indices per patch group
268  const HashTable<labelList>& groupPatchIDs() const;
269 
270  //- Set/add group with patches
271  void setGroup(const word& groupName, const labelUList& patchIDs);
272 
273  //- Check boundary definition
274  // \return True if in error.
275  bool checkDefinition(const bool report = false) const;
276 
277  //- Check whether all procs have all patches and in same order.
278  // \return True if in error.
279  bool checkParallelSync(const bool report = false) const;
280 
281 
282  // Edit
283 
284  //- Calculate the geometry for the patches
285  // (transformation tensors etc.)
286  void calcGeometry();
287 
288  //- Correct faBoundaryMesh after moving points
289  void movePoints(const pointField&);
290 
291  //- Correct faBoundaryMesh after topology update
292  void updateMesh();
293 
294 
295  // Write
296 
297  //- Write as a plain list of entries
298  void writeEntry(Ostream& os) const;
299 
300  //- Write as a primitive entry with given name.
301  //- If the keyword is empty, revert to a plain list.
302  void writeEntry(const word& keyword, Ostream& os) const;
303 
304  //- The writeData member function required by regIOobject
305  virtual bool writeData(Ostream& os) const;
306 
307  //- Write using stream options, but always UNCOMPRESSED
308  virtual bool writeObject
309  (
310  IOstreamOption streamOpt,
311  const bool writeOnProc = true
312  ) const;
313 
314 
315  // Ostream Operator
316 
317  friend Ostream& operator<<(Ostream&, const faBoundaryMesh&);
318 
319 
320  // Housekeeping
321 
322  //- Identical to the indices() method (AUG-2018)
323  FOAM_DEPRECATED_FOR(2018-08, "indices() method")
324  labelList findIndices(const wordRe& key, bool useGroups=true) const
325  {
326  return indices(key, useGroups);
327  }
328 };
329 
330 
331 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
332 
333 } // End namespace Foam
334 
335 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
336 
337 #endif
338 
339 // ************************************************************************* //
wordList groupNames() const
A list of the group names (if any)
label whichPatch(const label edgeIndex) const
Return patch index for a given edge label.
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition: faMesh.H:133
List< labelRange > patchRanges() const
Return a list of patch ranges.
const labelList patchIDs(pbm.indices(polyPatchNames, true))
labelList indices(const wordRe &matcher, const bool useGroups=true) const
Return (sorted) patch indices for all matches.
bool checkDefinition(const bool report=false) const
Check boundary definition.
void clear()
Clear the patch list and all demand-driven data.
virtual bool writeData(Ostream &os) const
The writeData member function required by regIOobject.
friend Ostream & operator<<(Ostream &, const faBoundaryMesh &)
lduInterfacePtrsList interfaces() const
Return a list of pointers for each patch with only those pointing to interfaces being set...
void calcGeometry()
Calculate the geometry for the patches.
labelList patchSizes() const
Return a list of patch sizes (number of edges in each patch)
labelList findIndices(const wordRe &key, bool useGroups=true) const
Identical to the indices() method (AUG-2018)
UPtrList< const labelUList > edgeFaces() const
Return a list of edgeFaces for each patch.
A range or interval of labels defined by a start and a size.
Definition: labelRange.H:52
List< bool > select(const label n, const labelUList &locations)
Construct a selection list of bools (all false) with the given pre-size, subsequently add specified l...
Definition: BitOps.C:134
void updateMesh()
Correct faBoundaryMesh after topology update.
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
A simple container for options an IOstream can normally have.
const HashTable< labelList > & groupPatchIDs() const
The patch indices per patch group.
label findIndex(const wordRe &key) const
Return patch index for the first match, return -1 if not found.
void writeEntry(Ostream &os) const
Write as a plain list of entries.
TypeName("faBoundaryMesh")
Runtime type information.
void operator=(const faBoundaryMesh &)=delete
No copy assignment.
static word groupName(StringType base, const word &group)
Create dot-delimited name.group string.
label findPatchID(const word &patchName, const bool allowNotFound=true) const
Find patch index given a name, return -1 if not found.
void movePoints(const pointField &)
Correct faBoundaryMesh after moving points.
A class for handling words, derived from Foam::string.
Definition: word.H:63
wordList names() const
Return a list of patch names.
label size() const noexcept
The number of entries in the list.
Definition: UPtrListI.H:106
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:53
A HashTable similar to std::unordered_map.
Definition: HashTable.H:108
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: HashTable.H:106
~faBoundaryMesh()=default
Destructor.
const faMesh & mesh() const noexcept
Return the mesh reference.
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings...
Definition: wordRe.H:78
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
const direction noexcept
Definition: Scalar.H:258
wordList types() const
Return a list of patch types.
OBJstream os(runTime.globalPath()/outputName)
faBoundaryMesh(const faBoundaryMesh &)=delete
No copy construct.
label start() const
The start label of the edges in the faMesh edges list.
UPtrList< const labelUList > edgeLabels() const
Return a list of edgeLabels for each patch.
label nEdges() const
The number of boundary edges for the underlying mesh.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:77
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
Definition: foamGltfBase.H:103
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: List.H:55
label nNonProcessor() const
The number of patches before the first processor patch.
void setGroup(const word &groupName, const labelUList &patchIDs)
Set/add group with patches.
Finite area boundary mesh.
bool checkParallelSync(const bool report=false) const
Check whether all procs have all patches and in same order.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:68
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:57
labelRange range() const
The edge range for all boundary edges.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
virtual bool writeObject(IOstreamOption streamOpt, const bool writeOnProc=true) const
Write using stream options, but always UNCOMPRESSED.
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:180
Calculate the matrix for the second temporal derivative.
labelList patchStarts() const
Return a list of patch start indices.
label nProcessorPatches() const
The number of processorFaPatch patches.
Namespace for OpenFOAM.