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