repatchMesh.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::repatchMesh
26 
27 Description
28  Addressing for all faces on surface of mesh. Can either be read
29  from polyMesh or from triSurface. Used for repatching existing meshes.
30 
31 SourceFiles
32  repatchMesh.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef repatchMesh_H
37 #define repatchMesh_H
38 
39 #include "repatchPatch.H"
40 #include "PrimitivePatch.H"
41 #include "PtrList.H"
42 #include "polyPatchList.H"
43 #include "className.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 // Forward declaration of classes
51 class polyMesh;
52 class primitiveMesh;
53 
54 /*---------------------------------------------------------------------------*\
55  Class repatchMesh Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 class repatchMesh
59 {
60 public:
61 
62  // Public Typedefs
63 
64  //- Type of the mesh
66 
67 
68 private:
69 
70  // Static data
71 
72  //- Normal along which to divide faces into categories
73  // (used in getNearest)
74  static const vector splitNormal_;
75 
76  //- Distance to face tolerance for getNearest. Triangles are considered
77  // near if they are nearer than distanceTol_*typDim where typDim is
78  // the largest distance from face centre to one of its vertices.
79  static const scalar distanceTol_;
80 
81 
82  // Private Data
83 
84  //- All boundary mesh data. Reconstructed every time faces are repatched
85  autoPtr<rMesh> meshPtr_;
86 
87  //- Patches. Reconstructed every time faces are repatched.
88  PtrList<repatchPatch> patches_;
89 
90  //- For every face in mesh() gives corresponding polyMesh face
91  // (not sensible if mesh read from triSurface)
92  labelList meshFace_;
93 
94  //- Points referenced by feature edges.
95  pointField featurePoints_;
96 
97  //- Feature edges. Indices into featurePoints.
98  edgeList featureEdges_;
99 
100  //- From feature edge to mesh edge.
101  labelList featureToEdge_;
102 
103  //- From mesh edges to featureEdges_;
104  labelList edgeToFeature_;
105 
106  //- Feature 'segments'. Collections of connected featureEdges.
107  // Indices into featureEdges_.
108  labelListList featureSegments_;
109 
110 
111  // Private Member Functions
112 
113  //- Number of connected feature edges.
114  label nFeatureEdges(label pointi) const;
115 
116  //- Step to next feature edge
117  label nextFeatureEdge(const label edgeI, const label vertI) const;
118 
119  //- Return connected list of feature edges.
120  labelList collectSegment
121  (
122  const boolList& isFeaturePoint,
123  const label startEdgeI,
124  boolList& featVisited
125  ) const;
126 
127  //- Gets labels of changed faces and propagates them to the edges.
128  // Returns labels of edges changed. Fills edgeRegion of visited edges
129  // with current region.
130  labelList faceToEdge
131  (
132  const boolList& regionEdge,
133  const label region,
134  const labelList& changedFaces,
135  labelList& edgeRegion
136  ) const;
137 
138  //- Reverse of faceToEdge: gets edges and returns faces
139  labelList edgeToFace
140  (
141  const label region,
142  const labelList& changedEdges,
143  labelList& faceRegion
144  ) const;
145 
146  //- Finds area, starting at facei, delimited by borderEdge. Marks all
147  // faces thus visited with currentZone.
148  void markZone
149  (
150  const boolList& borderEdge,
151  label facei,
152  label currentZone,
154  ) const;
155 
156 
157 public:
158 
159  //- Runtime type information
160  ClassName("repatchMesh");
161 
162 
163  // Constructors
164 
165  //- Construct null
166  repatchMesh();
167 
168  //- Disallow default bitwise copy construction
169  repatchMesh(const repatchMesh&) = delete;
170 
171 
172  //- Destructor
173  ~repatchMesh();
174 
175 
176  // Member Functions
177 
178  // Access
179 
180  //- Access the boundary mesh
181  const rMesh& mesh() const
182  {
183  if (!meshPtr_.valid())
184  {
186  << "No mesh available. Probably mesh not yet"
187  << " read." << abort(FatalError);
188  }
189  return *meshPtr_;
190  }
191 
192  //- Access the patches
193  const PtrList<repatchPatch>& patches() const
194  {
195  return patches_;
196  }
197 
198  //- Label of original face in polyMesh (before patchify(...))
199  const labelList& meshFace() const
200  {
201  return meshFace_;
202  }
203 
204  //- Feature points.
205  const pointField& featurePoints() const
206  {
207  return featurePoints_;
208  }
209 
210  //- Feature edges. Indices into featurePoints.
211  const edgeList& featureEdges() const
212  {
213  return featureEdges_;
214  }
215 
216  //- From index into featureEdge to index into meshedges,
217  const labelList& featureToEdge() const
218  {
219  return featureToEdge_;
220  }
221 
222  //- From edge into featureEdges
223  const labelList& edgeToFeature() const
224  {
225  return edgeToFeature_;
226  }
227 
228  //- Lists of connected featureEdges. Indices into featureEdges.
229  const labelListList& featureSegments() const
230  {
231  return featureSegments_;
232  }
233 
234 
235  // Edit
236 
237  //- Read from repatchMesh of polyMesh.
238  void read(const polyMesh&);
239 
240  //- Read from triSurface
241  void readTriSurface(const fileName&);
242 
243  //- Get rMesh index of nearest face for every boundary face in
244  // pMesh. Gets passed initial search box. If not found
245  // returns -1 for the face.
247  (
248  const primitiveMesh& pMesh,
249  const vector& searchSpan
250  ) const;
251 
252 
253  // Patches
254 
255  //- Get index of patch face is in
256  label whichPatch(const label facei) const;
257 
258  //- Get index of patch by name
259  label findPatchID(const word& patchName) const;
260 
261  //- Add to back of patch list.
262  void addPatch(const word& patchName);
263 
264  //- Delete from patch list.
265  void deletePatch(const word& patchName);
266 
267  //- Change patch.
268  void changePatchType(const word& patchName, const word& type);
269 
270 
271  // Edges
272 
273  //- Set featureEdges, edgeToFeature, featureSegments according
274  // to angle of faces across edge
275  void setFeatureEdges(const scalar minCos);
276 
277 
278  // Other
279 
280  // Flood filling without crossing protected edges.
281  void markFaces
282  (
283  const labelList& protectedEdges,
284  const label facei,
285  boolList& visited
286  ) const;
287 
288 
289  // Member Operators
290 
291  //- Disallow default bitwise assignment
292  void operator=(const repatchMesh&) = delete;
293 };
294 
295 
296 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
297 
298 } // End namespace Foam
299 
300 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
301 
302 #endif
303 
304 // ************************************************************************* //
void operator=(const repatchMesh &)=delete
Disallow default bitwise assignment.
const rMesh & mesh() const
Access the boundary mesh.
Definition: repatchMesh.H:180
void deletePatch(const word &patchName)
Delete from patch list.
Definition: repatchMesh.C:1178
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
A class for handling file names.
Definition: fileName.H:79
error FatalError
void setFeatureEdges(const scalar minCos)
Set featureEdges, edgeToFeature, featureSegments according.
Definition: repatchMesh.C:905
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:323
ClassName("repatchMesh")
Runtime type information.
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:74
void read(const polyMesh &)
Read from repatchMesh of polyMesh.
Definition: repatchMesh.C:348
void changePatchType(const word &patchName, const word &type)
Change patch.
Definition: repatchMesh.C:1234
const pointField & featurePoints() const
Feature points.
Definition: repatchMesh.H:204
const PtrList< repatchPatch > & patches() const
Access the patches.
Definition: repatchMesh.H:192
const labelList & meshFace() const
Label of original face in polyMesh (before patchify(...))
Definition: repatchMesh.H:198
A list of faces which address into the list of points.
A class for handling words, derived from string.
Definition: word.H:59
const edgeList & featureEdges() const
Feature edges. Indices into featurePoints.
Definition: repatchMesh.H:210
void readTriSurface(const fileName &)
Read from triSurface.
Definition: repatchMesh.C:474
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set)
Definition: autoPtrI.H:83
errorManip< error > abort(error &err)
Definition: errorManip.H:131
label findPatchID(const word &patchName) const
Get index of patch by name.
Definition: repatchMesh.C:1127
const labelListList & featureSegments() const
Lists of connected featureEdges. Indices into featureEdges.
Definition: repatchMesh.H:228
repatchMesh()
Construct null.
Definition: repatchMesh.C:327
void markFaces(const labelList &protectedEdges, const label facei, boolList &visited) const
Definition: repatchMesh.C:1285
label whichPatch(const label facei) const
Get index of patch face is in.
Definition: repatchMesh.C:1106
PrimitivePatch< faceList, const pointField > rMesh
Type of the mesh.
Definition: repatchMesh.H:64
const labelList & edgeToFeature() const
From edge into featureEdges.
Definition: repatchMesh.H:222
~repatchMesh()
Destructor.
Definition: repatchMesh.C:342
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface...
Definition: repatchMesh.H:57
void addPatch(const word &patchName)
Add to back of patch list.
Definition: repatchMesh.C:1141
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:70
Macro definitions for declaring ClassName(), NamespaceName(), etc.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
labelList getNearest(const primitiveMesh &pMesh, const vector &searchSpan) const
Get rMesh index of nearest face for every boundary face in.
Definition: repatchMesh.C:651
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
A subset of mesh faces organised as a primitive patch.
Definition: faceZone.H:64
const labelList & featureToEdge() const
From index into featureEdge to index into meshedges,.
Definition: repatchMesh.H:216
Namespace for OpenFOAM.