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 -------------------------------------------------------------------------------
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 #include "wordList.H"
50 #include "pointField.H"
51 
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 
54 namespace Foam
55 {
56 
57 // Forward Declarations
58 class faMesh;
59 class faBoundaryMesh;
60 class wordRes;
61 
62 Ostream& operator<<(Ostream&, const faBoundaryMesh&);
63 
64 /*---------------------------------------------------------------------------*\
65  Class faBoundaryMesh Declaration
66 \*---------------------------------------------------------------------------*/
67 
68 class faBoundaryMesh
69 :
70  public faPatchList,
71  public regIOobject
72 {
73  // Private Data
74 
75  //- Reference to mesh
76  const faMesh& mesh_;
77 
78  //- Demand-driven: list of patch ids per group
79  mutable autoPtr<HashTable<labelList>> groupIDsPtr_;
80 
81 
82  // Private Member Functions
83 
84  //- Some patches have inGroup entries
85  bool hasGroupIDs() const;
86 
87  //- Calculate group name to patch ids lookup
88  void calcGroupIDs() const;
89 
90  //- Read if IOobject flags set. Return true if read.
91  bool readContents(const bool allowReadIfPresent);
92 
93  //- No copy construct
94  faBoundaryMesh(const faBoundaryMesh&) = delete;
95 
96  //- No copy assignment
97  void operator=(const faBoundaryMesh&) = delete;
98 
99 
100 public:
101 
102  //- Runtime type information
103  TypeName("faBoundaryMesh");
104 
105 
106  // Constructors
107 
108  //- Construct from faMesh
110  (
111  const IOobject& io,
112  const faMesh& fam
113  );
114 
115  //- Construct from faMesh and given size
117  (
118  const IOobject& io,
119  const faMesh& fam,
120  const label size
121  );
122 
123 
124  //- Destructor
125  ~faBoundaryMesh() = default;
126 
127 
128  // Member Functions
129 
130  //- Return the mesh reference
131  const faMesh& mesh() const noexcept
132  {
133  return mesh_;
134  }
135 
136  //- Return a list of edgeLabels for each patch
138 
139  //- Return a list of edgeFaces for each patch
141 
142  //- Return a list of pointers for each patch
143  //- with only those pointing to interfaces being set
145 
146  //- The number of patches before the first processor patch.
147  label nNonProcessor() const;
148 
149  //- Return a list of patch names
150  wordList names() const;
151 
152  //- Return a list of patch types
153  wordList types() const;
154 
155  //- Return a list of patch start indices
156  labelList patchStarts() const;
157 
158  //- Return a list of patch sizes (number of edges in each patch)
159  labelList patchSizes() const;
160 
161  //- Return a list of patch ranges
163 
164  //- A list of the group names (if any)
165  wordList groupNames() const;
166 
167  //- The start label of the edges in the faMesh edges list
168  // Same as mesh.nInternalEdges()
169  label start() const;
170 
171  //- The number of boundary edges for the underlying mesh
172  // Same as mesh.nBoundaryEdges()
173  label nEdges() const;
174 
175  //- The edge range for all boundary edges
176  // Spans [nInternalEdges, nEdges) of the underlying mesh
177  labelRange range() const;
178 
179 
180  //- Return (sorted) patch indices for all matches.
181  // Optionally matches patch groups.
182  // A no-op (returns empty list) for an empty matcher
184  (
185  const wordRe& matcher,
186  const bool useGroups = true
187  ) const;
188 
189  //- Return (sorted) patch indices for all matches.
190  // Optionally matches patch groups.
191  // A no-op (returns empty list) for an empty matcher
193  (
194  const wordRes& matcher,
195  const bool useGroups = true
196  ) const;
197 
198  //- Return patch index for the first match, return -1 if not found
199  // A no-op (returns -1) for an empty key
200  label findIndex(const wordRe& key) const;
201 
202  //- Find patch index given a name, return -1 if not found
203  // A no-op (returns -1) for an empty name
204  label findPatchID
205  (
206  const word& patchName,
207  const bool allowNotFound = true
208  ) const;
209 
210  //- Return patch index for a given edge label
211  label whichPatch(const label edgeIndex) const;
212 
213  //- The patch indices per patch group
214  const HashTable<labelList>& groupPatchIDs() const;
215 
216  //- Set/add group with patches
217  void setGroup(const word& groupName, const labelUList& patchIDs);
218 
219  //- Check boundary definition
220  // \return True if in error.
221  bool checkDefinition(const bool report = false) const;
222 
223  //- Check whether all procs have all patches and in same order.
224  // \return True if in error.
225  bool checkParallelSync(const bool report = false) const;
226 
227 
228  // Edit
229 
230  //- Calculate the geometry for the patches
231  // (transformation tensors etc.)
232  void calcGeometry();
233 
234  //- Correct faBoundaryMesh after moving points
235  void movePoints(const pointField&);
236 
237  //- Correct faBoundaryMesh after topology update
238  void updateMesh();
239 
240  //- The writeData member function required by regIOobject
241  bool writeData(Ostream& os) const;
242 
243  //- Write using stream options
244  virtual bool writeObject
245  (
246  IOstreamOption streamOpt,
247  const bool valid
248  ) const;
249 
250 
251  // Ostream Operator
252 
253  friend Ostream& operator<<(Ostream&, const faBoundaryMesh&);
254 
255 
256  // Housekeeping
257 
258  //- Identical to the indices() method (AUG-2018)
259  FOAM_DEPRECATED_FOR(2018-08, "indices() method")
260  labelList findIndices(const wordRe& key, bool useGroups=true) const
261  {
262  return indices(key, useGroups);
263  }
264 };
265 
266 
267 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
268 
269 } // End namespace Foam
270 
271 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
272 
273 #endif
274 
275 // ************************************************************************* //
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:88
List< labelRange > patchRanges() const
Return a list of patch ranges.
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.
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:51
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:416
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.
TypeName("faBoundaryMesh")
Runtime type information.
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.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
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 elements in the list.
Definition: UPtrListI.H:99
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:47
A HashTable similar to std::unordered_map.
Definition: HashTable.H:102
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: HashTable.H:100
~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
virtual bool writeObject(IOstreamOption streamOpt, const bool valid) const
Write using stream options.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:55
const direction noexcept
Definition: Scalar.H:258
wordList types() const
Return a list of patch types.
OBJstream os(runTime.globalPath()/outputName)
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:76
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:69
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
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:166
Calculate the matrix for the second temporal derivative.
labelList patchStarts() const
Return a list of patch start indices.
Namespace for OpenFOAM.