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-2022 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
32
33SourceFiles
34 faBoundaryMesh.C
35
36Author
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 "faPatch.H"
47#include "wordList.H"
48#include "pointField.H"
49#include "regIOobject.H"
50
51// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52
53namespace Foam
54{
55
56// Forward Declarations
57class faMesh;
58class faBoundaryMesh;
59class wordRes;
60
61Ostream& operator<<(Ostream&, const faBoundaryMesh&);
62
63/*---------------------------------------------------------------------------*\
64 Class faBoundaryMesh Declaration
65\*---------------------------------------------------------------------------*/
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 //- Read if IOobject flags set. Return true if read.
90 bool readContents(const bool allowReadIfPresent);
91
92 //- No copy construct
93 faBoundaryMesh(const faBoundaryMesh&) = delete;
94
95 //- No copy assignment
96 void operator=(const faBoundaryMesh&) = delete;
97
98
99public:
100
101 //- Runtime type information
102 TypeName("faBoundaryMesh");
103
104
105 // Constructors
106
107 //- Construct from faMesh
109 (
110 const IOobject& io,
111 const faMesh& fam
112 );
113
114 //- Construct from faMesh and given size
116 (
117 const IOobject& io,
118 const faMesh& fam,
119 const label size
120 );
121
122
123 //- Destructor
124 ~faBoundaryMesh() = default;
125
126
127 // Member Functions
128
129 //- Return the mesh reference
130 const faMesh& mesh() const noexcept
131 {
132 return mesh_;
133 }
134
135 //- Return a list of edgeLabels for each patch
137
138 //- Return a list of edgeFaces for each patch
140
141 //- Return a list of pointers for each patch
142 //- with only those pointing to interfaces being set
144
145 //- The number of patches before the first processor patch.
146 label nNonProcessor() const;
147
148 //- Return a list of patch names
149 wordList names() const;
150
151 //- Return a list of patch types
152 wordList types() const;
153
154 //- Return a list of patch start indices
155 labelList patchStarts() const;
156
157 //- Return a list of patch sizes (number of edges in each patch)
158 labelList patchSizes() const;
159
160 //- Return a list of patch ranges
162
163 //- The start label of the edges in the faMesh edges list
164 // Same as mesh.nInternalEdges()
165 label start() const;
166
167 //- The number of boundary edges for the underlying mesh
168 // Same as mesh.nBoundaryEdges()
169 label nEdges() const;
170
171 //- The edge range for all boundary edges
172 // Spans [nInternalEdges, nEdges) of the underlying mesh
173 labelRange range() const;
174
175
176 //- Return (sorted) patch indices for all matches.
177 // Optionally matches patch groups.
178 // A no-op (returns empty list) for an empty matcher
180 (
181 const wordRe& matcher,
182 const bool useGroups = true
183 ) const;
184
185 //- Return (sorted) patch indices for all matches.
186 // Optionally matches patch groups.
187 // A no-op (returns empty list) for an empty matcher
189 (
190 const wordRes& matcher,
191 const bool useGroups = true
192 ) const;
193
194 //- Return patch index for the first match, return -1 if not found
195 // A no-op (returns -1) for an empty key
196 label findIndex(const wordRe& key) const;
197
198 //- Find patch index given a name, return -1 if not found
199 // A no-op (returns -1) for an empty name
200 label findPatchID
201 (
202 const word& patchName,
203 const bool allowNotFound = true
204 ) const;
205
206 //- Return patch index for a given edge label
207 label whichPatch(const label edgeIndex) const;
208
209 //- The patch indices per patch group
210 const HashTable<labelList>& groupPatchIDs() const;
211
212 //- Set/add group with patches
213 void setGroup(const word& groupName, const labelUList& patchIDs);
214
215 //- Check boundary definition
216 // \return True if in error.
217 bool checkDefinition(const bool report = false) const;
218
219 //- Check whether all procs have all patches and in same order.
220 // \return True if in error.
221 bool checkParallelSync(const bool report = false) const;
222
223
224 // Edit
225
226 //- Calculate the geometry for the patches
227 // (transformation tensors etc.)
228 void calcGeometry();
229
230 //- Correct faBoundaryMesh after moving points
231 void movePoints(const pointField&);
232
233 //- Correct faBoundaryMesh after topology update
234 void updateMesh();
235
236 //- The writeData member function required by regIOobject
237 bool writeData(Ostream& os) const;
238
239 //- Write using stream options
240 virtual bool writeObject
241 (
242 IOstreamOption streamOpt,
243 const bool valid
244 ) const;
245
246
247 // Ostream Operator
249 friend Ostream& operator<<(Ostream&, const faBoundaryMesh&);
250
251
252 // Housekeeping
253
254 //- Identical to the indices() method (AUG-2018)
255 FOAM_DEPRECATED_FOR(2018-08, "indices() method")
256 labelList findIndices(const wordRe& key, bool useGroups=true) const
257 {
258 return indices(key, useGroups);
259 }
260};
261
262
263// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
264
265} // End namespace Foam
266
267// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
268
269#endif
270
271// ************************************************************************* //
A HashTable similar to std::unordered_map.
Definition: HashTable.H:123
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
static word groupName(StringType base, const word &group)
Create dot-delimited name.group string.
The IOstreamOption is a simple container for options an IOstream can normally have.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: PtrList.H:73
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: UPtrList.H:71
label size() const noexcept
The number of elements in the list.
Definition: UPtrListI.H:106
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
Finite area boundary mesh.
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 HashTable< labelList > & groupPatchIDs() const
The patch indices per patch group.
labelList patchStarts() const
Return a list of patch start indices.
lduInterfacePtrsList interfaces() const
~faBoundaryMesh()=default
Destructor.
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 &)
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.
virtual bool writeObject(IOstreamOption streamOpt, const bool valid) const
Write using stream options.
List< labelRange > patchRanges() const
Return a list of patch ranges.
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.
labelList patchSizes() const
Return a list of patch sizes (number of edges in each patch)
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.
UPtrList< const labelUList > edgeLabels() const
Return a list of edgeLabels for each patch.
labelList indices(const wordRe &matcher, const bool useGroups=true) const
Return (sorted) patch indices for all matches.
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:100
A range or interval of labels defined by a start and a size.
Definition: labelRange.H:58
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:76
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
Definition: wordRe.H:83
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:54
A class for handling words, derived from Foam::string.
Definition: word.H:68
OBJstream os(runTime.globalPath()/outputName)
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
Namespace for OpenFOAM.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
const direction noexcept
Definition: Scalar.H:223
Calculate the matrix for the second temporal derivative.
#define FOAM_DEPRECATED_FOR(since, replacement)
Definition: stdFoam.H:52
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73