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-2021 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 faBoundaryMesh_H
43 #define faBoundaryMesh_H
44 
45 #include "faPatchList.H"
46 #include "lduInterfacePtrsList.H"
47 #include "wordList.H"
48 #include "pointField.H"
49 #include "regIOobject.H"
50 
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 
53 namespace Foam
54 {
55 
56 // Forward Declarations
57 class faMesh;
58 class faBoundaryMesh;
59 class wordRes;
60 Ostream& operator<<(Ostream&, const faBoundaryMesh&);
61 
62 /*---------------------------------------------------------------------------*\
63  Class faBoundaryMesh Declaration
64 \*---------------------------------------------------------------------------*/
65 
66 class faBoundaryMesh
67 :
68  public faPatchList,
69  public regIOobject
70 {
71  // Private Data
72 
73  //- Reference to mesh
74  const faMesh& mesh_;
75 
76  //- Demand-driven: list of patch ids per group
78 
79 
80  // Private Member Functions
81 
82  //- Some patches have inGroup entries
84 
85  //- Calculate group name to patch ids lookup
87 
88  //- No copy construct
89  faBoundaryMesh(const faBoundaryMesh&) = delete;
90 
91  //- No copy assignment
92  void operator=(const faBoundaryMesh&) = delete;
93 
94 
95 public:
96 
97  //- Runtime type information
98  TypeName("faBoundaryMesh");
99 
100 
101  // Constructors
102 
103  //- Construct from faMesh
105  (
106  const IOobject& io,
107  const faMesh& fam
108  );
109 
110  //- Construct from faMesh and given size
112  (
113  const IOobject& io,
114  const faMesh& fam,
115  const label size
116  );
117 
118 
119  //- Destructor
120  ~faBoundaryMesh() = default;
121 
122 
123  // Member Functions
124 
125  //- Return the mesh reference
126  const faMesh& mesh() const noexcept
127  {
128  return mesh_;
129  }
130 
131  //- Return a list of edgeFaces for each patch
133 
134  //- Return a list of pointers for each patch
135  //- with only those pointing to interfaces being set
137 
138  //- The number of patches before the first processor patch.
139  label nNonProcessor() const;
140 
141  //- Return a list of patch names
142  wordList names() const;
143 
144  //- Return a list of patch types
145  wordList types() const;
146 
147  //- Return a list of patch start indices
148  labelList patchStarts() const;
149 
150  //- Return a list of patch sizes (number of edges in each patch)
151  labelList patchSizes() const;
152 
153  //- Return a list of patch ranges
155 
156  //- The start label of the edges in the faMesh edges list
157  // Same as mesh.nInternalEdges()
158  label start() const;
159 
160  //- The number of boundary edges for the underlying mesh
161  // Same as mesh.nBoundaryEdges()
162  label nEdges() const;
163 
164  //- The edge range for all boundary edges
165  // Spans [nInternalEdges, nEdges) of the underlying mesh
166  labelRange range() const;
167 
168 
169  //- Return (sorted) patch indices for all matches.
170  // [FUTURE] Optionally matches patch groups.
171  // A no-op (returns empty list) for an empty matcher
173  (
174  const wordRe& matcher,
175  const bool useGroups = true
176  ) const;
177 
178  //- Return (sorted) patch indices for all matches.
179  // [FUTURE] Optionally matches patch groups.
180  // A no-op (returns empty list) for an empty matcher
182  (
183  const wordRes& matcher,
184  const bool useGroups = true
185  ) const;
186 
187  //- Return patch index for the first match, return -1 if not found
188  // A no-op (returns -1) for an empty key
189  label findIndex(const wordRe& key) const;
190 
191  //- Find patch index given a name, return -1 if not found
192  // A no-op (returns -1) for an empty name
193  label findPatchID(const word& patchName) const;
194 
195  //- Return patch index for a given edge label
196  label whichPatch(const label edgeIndex) const;
197 
198  //- Check boundary definition
199  bool checkDefinition(const bool report = false) const;
200 
201 
202  // Edit
203 
204  //- Calculate the geometry for the patches
205  // (transformation tensors etc.)
206  void calcGeometry();
207 
208  //- Correct faBoundaryMesh after moving points
209  void movePoints(const pointField&);
210 
211  //- Correct faBoundaryMesh after topology update
212  void updateMesh();
213 
214  //- The writeData member function required by regIOobject
215  bool writeData(Ostream& os) const;
216 
217  //- Write using stream options
218  virtual bool writeObject
219  (
220  IOstreamOption streamOpt,
221  const bool valid
222  ) const;
223 
224 
225  // Ostream Operator
226 
227  friend Ostream& operator<<(Ostream&, const faBoundaryMesh&);
228 
229 
230  // Housekeeping
231 
232  //- Identical to the indices() method (AUG-2018)
233  FOAM_DEPRECATED_FOR(2018-08, "indices() method")
234  labelList findIndices(const wordRe& key, bool useGroups=true) const
235  {
236  return indices(key, useGroups);
237  }
238 };
239 
240 
241 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 
243 } // End namespace Foam
244 
245 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246 
247 #endif
248 
249 // ************************************************************************* //
regIOobject.H
Foam::faBoundaryMesh::whichPatch
label whichPatch(const label edgeIndex) const
Return patch index for a given edge label.
Definition: faBoundaryMesh.C:357
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::faBoundaryMesh::updateMesh
void updateMesh()
Correct faBoundaryMesh after topology update.
Definition: faBoundaryMesh.C:468
Foam::faBoundaryMesh::operator<<
friend Ostream & operator<<(Ostream &, const faBoundaryMesh &)
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::faBoundaryMesh::indices
labelList indices(const wordRe &matcher, const bool useGroups=true) const
Return (sorted) patch indices for all matches.
Definition: faBoundaryMesh.C:286
Foam::faBoundaryMesh::writeData
bool writeData(Ostream &os) const
The writeData member function required by regIOobject.
Definition: faBoundaryMesh.C:484
Foam::faBoundaryMesh::checkDefinition
bool checkDefinition(const bool report=false) const
Check boundary definition.
Definition: faBoundaryMesh.C:399
Foam::faBoundaryMesh::findIndices
labelList findIndices(const wordRe &key, bool useGroups=true) const
Identical to the indices() method (AUG-2018)
Definition: faBoundaryMesh.H:233
Foam::faBoundaryMesh::patchSizes
labelList patchSizes() const
Return a list of patch sizes (number of edges in each patch)
Definition: faBoundaryMesh.C:239
Foam::faBoundaryMesh::patchRanges
List< labelRange > patchRanges() const
Return a list of patch ranges.
Definition: faBoundaryMesh.C:250
Foam::faBoundaryMesh::calcGeometry
void calcGeometry()
Calculate the geometry for the patches.
Definition: faBoundaryMesh.C:132
Foam::glTF::key
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
Definition: foamGltfBase.H:108
Foam::faBoundaryMesh::edgeFaces
UPtrList< const labelUList > edgeFaces() const
Return a list of edgeFaces for each patch.
Definition: faBoundaryMesh.C:153
Foam::faBoundaryMesh::movePoints
void movePoints(const pointField &)
Correct faBoundaryMesh after moving points.
Definition: faBoundaryMesh.C:446
Foam::wordRe
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
Definition: wordRe.H:80
wordList.H
lduInterfacePtrsList.H
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::faBoundaryMesh::findIndex
label findIndex(const wordRe &key) const
Return patch index for the first match, return -1 if not found.
Definition: faBoundaryMesh.C:336
Foam::faBoundaryMesh
Finite area boundary mesh.
Definition: faBoundaryMesh.H:65
Foam::Field< vector >
Foam::faBoundaryMesh::names
wordList names() const
Return a list of patch names.
Definition: faBoundaryMesh.C:208
Foam::IOstreamOption
The IOstreamOption is a simple container for options an IOstream can normally have.
Definition: IOstreamOption.H:63
faPatchList.H
Foam::UPtrList
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: UPtrList.H:62
Foam::labelRange
A range or interval of labels defined by a start and a size.
Definition: labelRange.H:55
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:59
Foam::faBoundaryMesh::mesh
const faMesh & mesh() const noexcept
Return the mesh reference.
Definition: faBoundaryMesh.H:125
Foam::faBoundaryMesh::findPatchID
label findPatchID(const word &patchName) const
Find patch index given a name, return -1 if not found.
Definition: faBoundaryMesh.C:346
os
OBJstream os(runTime.globalPath()/outputName)
Foam::faBoundaryMesh::writeObject
virtual bool writeObject(IOstreamOption streamOpt, const bool valid) const
Write using stream options.
Definition: faBoundaryMesh.C:505
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::faBoundaryMesh::nEdges
label nEdges() const
The number of boundary edges for the underlying mesh.
Definition: faBoundaryMesh.C:273
Foam::faBoundaryMesh::TypeName
TypeName("faBoundaryMesh")
Runtime type information.
Foam::faBoundaryMesh::start
label start() const
The start label of the edges in the faMesh edges list.
Definition: faBoundaryMesh.C:267
pointField.H
Foam::faBoundaryMesh::types
wordList types() const
Return a list of patch types.
Definition: faBoundaryMesh.C:214
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:73
Foam::faBoundaryMesh::nNonProcessor
label nNonProcessor() const
The number of patches before the first processor patch.
Definition: faBoundaryMesh.C:188
Foam::List< word >
Foam::wordRes
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:51
Foam::faBoundaryMesh::range
labelRange range() const
The edge range for all boundary edges.
Definition: faBoundaryMesh.C:279
Foam::FOAM_DEPRECATED_FOR
class FOAM_DEPRECATED_FOR(2017-05, "Foam::Enum") NamedEnum
Definition: NamedEnum.H:69
Foam::faBoundaryMesh::~faBoundaryMesh
~faBoundaryMesh()=default
Destructor.
Foam::faMesh
Finite area mesh. Used for 2-D non-Euclidian finite area method.
Definition: faMesh.H:82
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
fam
Calculate the matrix for the second temporal derivative.
Foam::faBoundaryMesh::patchStarts
labelList patchStarts() const
Return a list of patch start indices.
Definition: faBoundaryMesh.C:220
Foam::faBoundaryMesh::interfaces
lduInterfacePtrsList interfaces() const
Definition: faBoundaryMesh.C:168