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-2023 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 
94 public:
95 
96  //- Runtime type information
97  TypeName("faBoundaryMesh");
98 
99 
100  // Generated Methods
101 
102  //- No copy construct
103  faBoundaryMesh(const faBoundaryMesh&) = delete;
104 
105  //- No copy assignment
106  void operator=(const faBoundaryMesh&) = delete;
107 
108 
109  // Constructors
110 
111  //- Construct from faMesh
113  (
114  const IOobject& io,
115  const faMesh& fam
116  );
117 
118  //- Construct from faMesh and given size
120  (
121  const IOobject& io,
122  const faMesh& fam,
123  const label size
124  );
125 
126 
127  //- Destructor
128  ~faBoundaryMesh() = default;
129 
130 
131  // Member Functions
132 
133  //- Clear the patch list and all demand-driven data
134  void clear();
135 
136  //- Return the mesh reference
137  const faMesh& mesh() const noexcept
138  {
139  return mesh_;
140  }
141 
142  //- Return a list of edgeLabels for each patch
144 
145  //- Return a list of edgeFaces for each patch
147 
148  //- Return a list of pointers for each patch
149  //- with only those pointing to interfaces being set
151 
152  //- The number of patches before the first processor patch.
153  label nNonProcessor() const;
154 
155  //- The number of processorFaPatch patches
156  label nProcessorPatches() const;
157 
158  //- Return a list of patch names
159  wordList names() const;
160 
161  //- Return a list of patch types
162  wordList types() const;
163 
164  //- Return a list of patch start indices
165  labelList patchStarts() const;
166 
167  //- Return a list of patch sizes (number of edges in each patch)
168  labelList patchSizes() const;
169 
170  //- Return a list of patch ranges
172 
173  //- A list of the group names (if any)
174  wordList groupNames() const;
175 
176  //- The start label of the edges in the faMesh edges list
177  // Same as mesh.nInternalEdges()
178  label start() const;
179 
180  //- The number of boundary edges for the underlying mesh
181  // Same as mesh.nBoundaryEdges()
182  label nEdges() const;
183 
184  //- The edge range for all boundary edges
185  // Spans [nInternalEdges, nEdges) of the underlying mesh
186  labelRange range() const;
187 
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 wordRe& matcher,
195  const bool useGroups = true
196  ) const;
197 
198  //- Return (sorted) patch indices for all matches.
199  // Optionally matches patch groups.
200  // A no-op (returns empty list) for an empty matcher
202  (
203  const wordRes& matcher,
204  const bool useGroups = true
205  ) const;
206 
207  //- Return patch index for the first match, return -1 if not found
208  // A no-op (returns -1) for an empty key
209  label findIndex(const wordRe& key) const;
210 
211  //- Find patch index given a name, return -1 if not found
212  // A no-op (returns -1) for an empty name
213  label findPatchID
214  (
215  const word& patchName,
216  const bool allowNotFound = true
217  ) const;
218 
219  //- Return patch index for a given edge label
220  label whichPatch(const label edgeIndex) const;
221 
222  //- The patch indices per patch group
223  const HashTable<labelList>& groupPatchIDs() const;
224 
225  //- Set/add group with patches
226  void setGroup(const word& groupName, const labelUList& patchIDs);
227 
228  //- Check boundary definition
229  // \return True if in error.
230  bool checkDefinition(const bool report = false) const;
231 
232  //- Check whether all procs have all patches and in same order.
233  // \return True if in error.
234  bool checkParallelSync(const bool report = false) const;
235 
236 
237  // Edit
238 
239  //- Calculate the geometry for the patches
240  // (transformation tensors etc.)
241  void calcGeometry();
242 
243  //- Correct faBoundaryMesh after moving points
244  void movePoints(const pointField&);
245 
246  //- Correct faBoundaryMesh after topology update
247  void updateMesh();
248 
249  //- The writeData member function required by regIOobject
250  bool writeData(Ostream& os) const;
251 
252  //- Write using stream options
253  virtual bool writeObject
254  (
255  IOstreamOption streamOpt,
256  const bool writeOnProc
257  ) const;
258 
259 
260  // Ostream Operator
261 
262  friend Ostream& operator<<(Ostream&, const faBoundaryMesh&);
263 
264 
265  // Housekeeping
266 
267  //- Identical to the indices() method (AUG-2018)
268  FOAM_DEPRECATED_FOR(2018-08, "indices() method")
269  labelList findIndices(const wordRe& key, bool useGroups=true) const
270  {
271  return indices(key, useGroups);
272  }
273 };
274 
275 
276 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
277 
278 } // End namespace Foam
279 
280 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
281 
282 #endif
283 
284 // ************************************************************************* //
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.
const labelList patchIDs(pbm.patchSet(polyPatchNames, false, true).sortedToc())
bool checkDefinition(const bool report=false) const
Check boundary definition.
void clear()
Clear the patch list and all demand-driven data.
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:482
A simple container for options an IOstream can normally have.
virtual bool writeObject(IOstreamOption streamOpt, const bool writeOnProc) const
Write using stream options.
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.
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:113
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:53
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
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)
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: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:65
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)
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:171
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.