1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 Addressing for all faces on surface of mesh. Can either be read
30 from polyMesh or from triSurface. Used for repatching existing meshes.
35 \*---------------------------------------------------------------------------*/
37 #ifndef boundaryMesh_H
38 #define boundaryMesh_H
41 #include "boundaryPatch.H"
42 #include "PrimitivePatch.H"
44 #include "polyPatchList.H"
45 #include "className.H"
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 // Forward declaration of classes
57 /*---------------------------------------------------------------------------*\
58 Class boundaryMesh Declaration
59 \*---------------------------------------------------------------------------*/
65 //- Normal along which to divide faces into categories
66 // (used in getNearest)
67 static const vector splitNormal_;
69 //- Distance to face tolerance for getNearest. Triangles are considered
70 // near if they are nearer than distanceTol_*typDim where typDim is
71 // the largest distance from face centre to one of its vertices.
72 static const scalar distanceTol_;
76 //- All boundary mesh data. Reconstructed every time faces are repatched
79 //- Patches. Reconstructed every time faces are repatched.
80 PtrList<boundaryPatch> patches_;
82 //- For every face in mesh() gives corresponding polyMesh face
83 // (not sensible if mesh read from triSurface)
91 //- points referenced by feature edges.
92 pointField featurePoints_;
94 //- feature edges. Indices into featurePoints.
95 edgeList featureEdges_;
97 //- from feature edge to mesh edge.
98 labelList featureToEdge_;
100 //- from mesh edges to featureEdges_;
101 labelList edgeToFeature_;
103 //- Feature 'segments'. Collections of connected featureEdges.
104 // Indices into featureEdges_.
105 labelListList featureSegments_;
107 //- Additional edges (indices of mesh edges)
108 labelList extraEdges_;
111 // Private Member Functions
113 //- Number of connected feature edges.
114 label nFeatureEdges(label pointI) const;
116 //- Step to next feature edge
117 label nextFeatureEdge(const label edgeI, const label vertI) const;
119 //- Return connected list of feature edges.
120 labelList collectSegment
122 const boolList& isFeaturePoint,
123 const label startEdgeI,
124 boolList& featVisited
127 //- Do point-edge walk to determine nearest (to edgeI). Stops if
128 // distance >= maxDistance. Used to determine edges close to seed
132 const label maxDistance,
134 const label distance,
135 labelList& minDistance,
136 DynamicList<label>& visited
139 //- Get index of polypatch by name
140 label findPatchID(const polyPatchList&, const word&) const;
142 //- Get index of patch for face
143 label whichPatch(const polyPatchList&, const label) const;
145 //- Gets labels of changed faces and propagates them to the edges.
146 // Returns labels of edges changed. Fills edgeRegion of visited edges
147 // with current region.
150 const boolList& regionEdge,
152 const labelList& changedFaces,
153 labelList& edgeRegion
156 //- Reverse of faceToEdge: gets edges and returns faces
160 const labelList& changedEdges,
161 labelList& faceRegion
164 //- Finds area, starting at faceI, delimited by borderEdge. Marks all
165 // faces thus visited with currentZone.
168 const boolList& borderEdge,
175 //- Disallow default bitwise copy construct
176 boundaryMesh(const boundaryMesh&);
178 //- Disallow default bitwise assignment
179 void operator=(const boundaryMesh&);
184 //- Runtime type information
185 ClassName("boundaryMesh");
205 const bMesh& mesh() const
209 FatalErrorIn("boundaryMesh::mesh()")
210 << "No mesh available. Probably mesh not yet"
211 << " read." << abort(FatalError);
216 const PtrList<boundaryPatch>& patches() const
222 //- Label of original face in polyMesh (before patchify(...))
223 const labelList& meshFace() const
229 const pointField& featurePoints() const
231 return featurePoints_;
234 //- Feature edges. Indices into featurePoints.
235 const edgeList& featureEdges() const
237 return featureEdges_;
240 //- From index into featureEdge to index into meshedges,
241 const labelList& featureToEdge() const
243 return featureToEdge_;
246 //- From edge into featureEdges
247 const labelList& edgeToFeature() const
249 return edgeToFeature_;
252 //- Lists of connected featureEdges. Indices into featureEdges.
253 const labelListList& featureSegments() const
255 return featureSegments_;
258 //- Indices into edges of additional edges.
259 const labelList& extraEdges() const
267 //- Read from boundaryMesh of polyMesh.
268 void read(const polyMesh&);
270 //- Read from triSurface
271 void readTriSurface(const fileName&);
274 void writeTriSurface(const fileName&) const;
276 //- Get bMesh index of nearest face for every boundary face in
277 // pMesh. Gets passed initial search box. If not found
278 // returns -1 for the face.
281 const primitiveMesh& pMesh,
282 const vector& searchSpan
285 //- Take over patches onto polyMesh from nearest face in *this
286 // (from call to getNearest). Insert as
287 // -new set of patches (newMesh.addPatches)
288 // -topoChanges to change faces.
289 // nearest is list of nearest face in *this for every boundary
290 // face. oldPatches is list of existing patches in mesh.
291 // newMesh is the mesh to which the new patches are added.
292 // (so has to be constructed without patches).
295 const labelList& nearest,
296 const polyBoundaryMesh& oldPatches,
302 //- Get index of patch face is in
303 label whichPatch(const label faceI) const;
305 //- Get index of patch by name
306 label findPatchID(const word& patchName) const;
308 //- Get names of patches
309 wordList patchNames() const;
311 //- Add to back of patch list.
312 void addPatch(const word& patchName);
314 //- Delete from patch list.
315 void deletePatch(const word& patchName);
318 void changePatchType(const word& patchName, const word& type);
320 //- Recalculate face ordering and patches. Return old to new
322 void changeFaces(const labelList& patchIDs, labelList& oldToNew);
327 //- Set featureEdges, edgeToFeature, featureSegments according
328 // to angle of faces across edge
329 void setFeatureEdges(const scalar minCos);
331 //- Set extraEdges to edges 'near' to edgeI. Uses point-edge walk
332 // to determine 'near'.
333 void setExtraEdges(const label edgeI);
338 //- Simple triangulation of face subset. Returns number of triangles
340 label getNTris(const label faceI) const;
342 //- Simple triangulation of face subset. TotalNTris is total number
343 // of triangles, nTris is per face number of triangles.
346 const label startFaceI,
351 //- Simple triangulation of face subset. TotalNTris is total number
352 // of triangles (from call to getNTris)
353 // triVerts is triangle vertices, three per triangle.
356 const label startFaceI,
358 const label totalNTris,
362 //- Number of points used in face subset.
363 label getNPoints(const label startFaceI, const label nFaces) const;
365 //- Same as triangulate but in local vertex numbering.
367 void triangulateLocal
369 const label startFaceI,
371 const label totalNTris,
373 labelList& localToGlobal
378 // Flood filling without crossing protected edges.
381 const labelList& protectedEdges,
388 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
390 } // End namespace Foam
392 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
396 // ************************************************************************* //